Class GateCollider

java.lang.Object
com.deco2800.game.components.Component
com.deco2800.game.components.building.GateCollider

public class GateCollider extends Component
  • Field Details

    • gateOpen

      public boolean gateOpen
  • Constructor Details

    • GateCollider

      public GateCollider()
  • Method Details

    • create

      public void create()
      On create, listen for the events "collisionStart" and "collisionEnd" initiated by the PhysicsContactListener, which will execute the functions "onCollisionStart" and "onCollisionEnd"
      Overrides:
      create in class Component
    • onCollisionStart

      public void onCollisionStart(com.badlogic.gdx.physics.box2d.Fixture gate, com.badlogic.gdx.physics.box2d.Fixture other)
      Handles the collision of two physics Fixtures: if an allied unit collides with the gate, open it
      Parameters:
      gate - the fixture related to the ColliderComponent attached to the Gate entity
      other - the fixture related to the ColliderComponent of an entity that has come into contact with the Gate's fixture
    • onCollisionEnd

      public void onCollisionEnd(com.badlogic.gdx.physics.box2d.Fixture gate, com.badlogic.gdx.physics.box2d.Fixture other)
      Handles the end of collision of two physics Fixtures: if an allied unit has left the gate, reduce the number of allies in contact with the gate, if no allies are in contact, close it.
      Parameters:
      gate - the fixture related to the ColliderComponent attached to the Gate entity
      other - the fixture related to the ColliderComponent of an entity that has come into contact with the Gate's fixture
    • getCollidedIds

      public List<Integer> getCollidedIds()
      Returns a copy of the collided allies list - used for unit testing
      Returns:
      copy of allies collided list
    • isGateOpen

      public boolean isGateOpen()
      Returns the status of the gate
      Returns:
      true if it is open, else false