Class ActiveUnitsTrigger

java.lang.Object
megamek.server.trigger.ActiveUnitsTrigger
All Implemented Interfaces:
Trigger

public class ActiveUnitsTrigger extends Object implements Trigger
This Trigger reacts when the count of active units is equal to the given count. When the playerName is blank, units of all players are counted, otherwise only those of the given player. When a list of unit IDs is given, only those units will be considered. Note that immobile units or those with stunned crews or the like are still active. Only units that have fled or are destroyed are no longer active. Note that destroyed units can spawn pilots and some other objects are counted as in-game, so providing an ID list can make sense. Note that this trigger will react multiple times. Use OnceTrigger to limit it to one-time-only.
  • Constructor Details

    • ActiveUnitsTrigger

      public ActiveUnitsTrigger(@Nullable String playerName, List<Integer> unitIds, int minUnitCount, int maxUnitCount)
    • ActiveUnitsTrigger

      public ActiveUnitsTrigger(@Nullable String playerName, List<Integer> unitIds, int fledUnitCount)
    • ActiveUnitsTrigger

      @Deprecated(since="0.51.0", forRemoval=true) public ActiveUnitsTrigger(@Nullable String playerName, int fledUnitCount)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • ActiveUnitsTrigger

      @Deprecated(since="0.51.0", forRemoval=true) public ActiveUnitsTrigger(@Nullable String playerName, int minUnitCount, int maxUnitCount)
      Deprecated, for removal: This API element is subject to removal in a future version.
  • Method Details

    • isTriggered

      public boolean isTriggered(IGame game, TriggerSituation event)
      Description copied from interface: Trigger
      Returns true when this Trigger is triggered, i.e. if the prerequisites for its associated event are deemed to be satisfied. Note that the event is itself responsible for making sure that it only returns true once, if it should only trigger once. If it returns true on multiple occasions, the triggered event may happen multiple times. The given TriggerEvent specifies when at what moment of the game this method is called.
      Specified by:
      isTriggered in interface Trigger
      Parameters:
      game - The game
      event - The type of event that caused the trigger to be called
      Returns:
      True when this Trigger considers itself triggered, false otherwise
    • toString

      public String toString()
      Overrides:
      toString in class Object