Class DoorComponent
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.components.obstacles.DoorComponent
Door that can be unlocked with a key and (optionally) trigger an area transition.
Usage:
- Locked until the player collides and has
keyIdinInventoryComponent.Bag.INVENTORY. - On unlock: collider becomes sensor, plays
door_opening, then switches todoor_open. - After opening finishes, emits GameArea event
"doorEntered"(player, door)if non-static and has target.
Requires: AnimationRenderComponent with animations:
door_closed (loop), door_opening (non-loop), door_open (loop);
ColliderComponent, HitboxComponent on the door entity.
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionDoorComponent(String keyId, GameArea area, boolean isStaticDoor, String targetArea) -
Method Summary
Modifier and TypeMethodDescriptionvoidcreate()Wire listeners and set initial animation todoor_closed.Accessory for door target areabooleanisLocked()Accessor for isLockedvoidopenDoor()Open the door (non-blocking + play opening animation).voidTry to unlock the door using the player's inventory.voidupdate()Advance the animation; emit transition when it finishes (if eligible).Methods inherited from class com.csse3200.game.components.Component
dispose, earlyUpdate, getEntity, getPrio, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate
-
Constructor Details
-
DoorComponent
- Parameters:
keyId- inventory key id that unlocks the doorarea- owning game area (used to emitdoorEntered)isStaticDoor- if true, acts as barrier only (no transition)targetArea- target area id (used only when non-static)
-
-
Method Details
-
create
public void create()Wire listeners and set initial animation todoor_closed. -
update
public void update()Advance the animation; emit transition when it finishes (if eligible). -
tryUnlock
Try to unlock the door using the player's inventory. -
openDoor
public void openDoor()Open the door (non-blocking + play opening animation). -
isLocked
public boolean isLocked()Accessor for isLocked- Returns:
- true if door is locked, false otherwise.
-
getTargetArea
Accessory for door target area- Returns:
- the area (if any) on the other side of the door
-