private boolean processOutputForSetResetGate(EntityRef blockEntity) { SignalConsumerAdvancedStatusComponent consumerAdvancedStatusComponent = blockEntity.getComponent(SignalConsumerAdvancedStatusComponent.class); EnumSet<Side> signals = SideBitFlag.getSides(consumerAdvancedStatusComponent.sidesWithSignals); SignalProducerComponent producerComponent = blockEntity.getComponent(SignalProducerComponent.class); int resultSignal = producerComponent.signalStrength; if (signals.contains(Side.TOP) || signals.contains(Side.BOTTOM)) { resultSignal = 0; } else if (signals.size() > 0) { resultSignal = -1; } if (producerComponent.signalStrength != resultSignal) { producerComponent.signalStrength = resultSignal; blockEntity.saveComponent(producerComponent); if (resultSignal != 0) { if (!blockEntity.hasComponent(SignalProducerModifiedComponent.class)) { blockEntity.addComponent(new SignalProducerModifiedComponent()); } } else if (blockEntity.hasComponent(SignalProducerModifiedComponent.class)) { blockEntity.removeComponent(SignalProducerModifiedComponent.class); } return true; } return false; }
private boolean stopProducingSignal(EntityRef entity) { SignalProducerComponent producer = entity.getComponent(SignalProducerComponent.class); if (producer.signalStrength != 0) { producer.signalStrength = 0; entity.saveComponent(producer); entity.removeComponent(SignalProducerModifiedComponent.class); return true; } return false; }
private boolean startProducingSignal(EntityRef entity, int signalStrength) { final SignalProducerComponent producer = entity.getComponent(SignalProducerComponent.class); if (producer.signalStrength != signalStrength) { producer.signalStrength = signalStrength; entity.saveComponent(producer); entity.addComponent(new SignalProducerModifiedComponent()); return true; } return false; }