Door
namespace Griff.Scenes;
public sealed class Door : ComponentTakes whoever uses it somewhere else, with no code: a level’s exit to the next Scene, or a door or teleporter to the Target entity in this one. It’s used on touch, or with the Interact action while touching it when NeedsInteract is on. Needs a collider, usually a trigger. Going to another scene, the players arrive at the entity its ArriveAt names there (the door back), so doors join rooms both ways.
This is a component: its saved properties are on its component page.
Properties
Section titled “Properties”ArriveAt
Section titled “ArriveAt”public string? ArriveAt { get; set; }Where whoever goes through arrives in the Scene: the name of an entity there, e.g. “West Door” (the door back, which they don’t go straight back through), standing where it is; the players’ other characters arrive there too. Empty starts them where the scene has them.
public float Fade { get; set; }Seconds to fade the screen out (and as long back in) around the trip. 0 cuts straight there.
public string? Key { get; set; }An item it needs, e.g. “Key”: it’s locked to anyone without one in their Inventory. The first trip through uses one up and clears this, so it stays open after that.
Layers
Section titled “Layers”public string? Layers { get; set; }The collision layers that can use it, e.g. “Player”. Empty lets anything with a Body use it.
Locked
Section titled “Locked”public bool Locked { get; set; }Nobody can use it while it’s locked. Switches lock and unlock it.
NeedsFlag
Section titled “NeedsFlag”public string? NeedsFlag { get; set; }A flag that has to be set before anyone can use it, e.g. “MetKing” (set by a trigger’s Set Flag, a dialogue’s “[set MetKing]” or a script’s Game.SetFlag), or “not MetKing” for while it isn’t: it stays shut until then, and its prompt hidden.
NeedsInteract
Section titled “NeedsInteract”public bool NeedsInteract { get; set; }Only go through when the player presses Interact (E, Enter, the gamepad’s Y) while touching it.
Prompt
Section titled “Prompt”public string? Prompt { get; set; }The name of an entity to show only while something is touching it, e.g. a “Press E” hint above the door. It’s hidden the rest of the time.
public string? Scene { get; set; }The scene to go to, e.g. “Level2”. Empty stays in this scene and goes to Target.
public string? Sound { get; set; }A sound played when it’s used, e.g. “Sounds/door.wav”.
Target
Section titled “Target”public string? Target { get; set; }The name of an entity in this scene to go to, e.g. “CaveExit”, when there’s no Scene.
Methods
Section titled “Methods”AcceptsLayer
Section titled “AcceptsLayer”public bool AcceptsLayer(string? layer)True if something on collision layer layer can use it.
public void Lock()Locks it: nobody can use it until it’s opened (or a switch unlocks it).
public void Open()Unlocks it for good, key or not.
Events
Section titled “Events”public event Action<Entity>? UsedRaised when it’s used, with whatever used it.