コード例 #1
0
  private void signalButtonActivated(EntityRef block, SignalProducerComponent producerComponent) {
    if (block.hasComponent(SignalDelayedActionComponent.class)) {
      block.removeComponent(SignalDelayedActionComponent.class);
    }

    SignalDelayedActionComponent actionComponent = new SignalDelayedActionComponent();
    actionComponent.executeTime = time.getGameTimeInMs() + BUTTON_PRESS_TIME;
    block.addComponent(actionComponent);

    startProducingSignal(block, -1);
  }
コード例 #2
0
 private void signalChangedForDelayOnGate(
     EntityRef entity, SignalConsumerStatusComponent consumerStatusComponent) {
   SignalTimeDelayComponent delay = entity.getComponent(SignalTimeDelayComponent.class);
   if (consumerStatusComponent.hasSignal) {
     // Schedule for the gate to be looked at when the time passes
     SignalDelayedActionComponent delayedAction = new SignalDelayedActionComponent();
     delayedAction.executeTime = time.getGameTimeInMs() + delay.delaySetting;
     entity.addComponent(delayedAction);
   } else {
     // Remove any signal-delayed actions on the entity and turn off signal from it, if it has any
     if (entity.hasComponent(SignalDelayedActionComponent.class)) {
       entity.removeComponent(SignalDelayedActionComponent.class);
     }
     stopProducingSignal(entity);
   }
 }
コード例 #3
0
 private void delayGateSignalChangeIfNeeded(EntityRef entity) {
   if (!entity.hasComponent(SignalDelayedActionComponent.class)) {
     // Schedule for the gate to be looked either immediately (during "update" method) or at least
     // GATE_MINIMUM_SIGNAL_CHANGE_INTERVAL from the time it has last changed, whichever is later
     SignalDelayedActionComponent delayedAction = new SignalDelayedActionComponent();
     long whenToLookAt;
     final ImmutableBlockLocation location =
         new ImmutableBlockLocation(entity.getComponent(BlockComponent.class).getPosition());
     if (gateLastSignalChangeTime.containsKey(location)) {
       whenToLookAt = gateLastSignalChangeTime.get(location) + GATE_MINIMUM_SIGNAL_CHANGE_INTERVAL;
     } else {
       whenToLookAt = time.getGameTimeInMs();
     }
     delayedAction.executeTime = whenToLookAt;
     entity.addComponent(delayedAction);
   }
 }