Class GateCollider
java.lang.Object
com.deco2800.game.components.Component
com.deco2800.game.components.building.GateCollider
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
create()
On create, listen for the events "collisionStart" and "collisionEnd" initiated by the PhysicsContactListener, which will execute the functions "onCollisionStart" and "onCollisionEnd"Returns a copy of the collided allies list - used for unit testingboolean
Returns the status of the gatevoid
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.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 itMethods inherited from class com.deco2800.game.components.Component
dispose, earlyUpdate, getEntity, isAnimationRenderComponent, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate, update
-
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" -
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 entityother
- 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 entityother
- the fixture related to the ColliderComponent of an entity that has come into contact with the Gate's fixture
-
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
-