diff options
| author | alex <[email protected]> | 2026-11-09 11:46:51 +0100 |
|---|---|---|
| committer | alex <[email protected]> | 2026-11-09 11:46:51 +0100 |
| commit | 26972abbe2dd670d2afac067c548cfaf1da73b2d (patch) | |
| tree | 8d286077301ed39646c8ebaf9589a33c2f19c7ea /DungeonSystem/scripts/Door.cs | |
| parent | 5bc1a8224bb73dcac910e1f05f5e036b4f89ceb8 (diff) | |
| download | godot-testing-26972abbe2dd670d2afac067c548cfaf1da73b2d.tar.xz godot-testing-26972abbe2dd670d2afac067c548cfaf1da73b2d.zip | |
boos room
Diffstat (limited to 'DungeonSystem/scripts/Door.cs')
| -rw-r--r-- | DungeonSystem/scripts/Door.cs | 90 |
1 files changed, 45 insertions, 45 deletions
diff --git a/DungeonSystem/scripts/Door.cs b/DungeonSystem/scripts/Door.cs index c30c462..e3ec5d6 100644 --- a/DungeonSystem/scripts/Door.cs +++ b/DungeonSystem/scripts/Door.cs @@ -5,61 +5,61 @@ namespace DungeonSystem; [GlobalClass] public partial class Door : Node2D { - [Signal] - public delegate void PlayerEnteredDoorwayEventHandler(Door door); + [Signal] + public delegate void PlayerEnteredDoorwayEventHandler(Door door); - public enum DoorState { Open, Locked } - public DoorState CurrentState { get; private set; } = DoorState.Open; + public enum DoorState { Open, Locked } + public DoorState CurrentState { get; private set; } = DoorState.Open; - private CollisionShape2D? _barrierCollision; - private Area2D? _triggerArea; - private AnimationPlayer? _animPlayer; + private CollisionShape2D? _barrierCollision; + private Area2D? _triggerArea; + private AnimationPlayer? _animPlayer; - public override void _Ready() - { - _barrierCollision = GetNodeOrNull<CollisionShape2D>("Barrier/CollisionShape2D") - ?? GetNodeOrNull<CollisionShape2D>("StaticBody2D/CollisionShape2D"); - _triggerArea = GetNodeOrNull<Area2D>("TriggerArea") - ?? GetNodeOrNull<Area2D>("Area2D"); - _animPlayer = GetNodeOrNull<AnimationPlayer>("AnimationPlayer"); + public override void _Ready() + { + _barrierCollision = GetNodeOrNull<CollisionShape2D>("Barrier/CollisionShape2D") + ?? GetNodeOrNull<CollisionShape2D>("StaticBody2D/CollisionShape2D"); + _triggerArea = GetNodeOrNull<Area2D>("TriggerArea") + ?? GetNodeOrNull<Area2D>("Area2D"); + _animPlayer = GetNodeOrNull<AnimationPlayer>("AnimationPlayer"); - if (_triggerArea != null) - { - _triggerArea.CollisionMask |= 1u << 1; - _triggerArea.Monitoring = true; - } + if (_triggerArea != null) + { + _triggerArea.CollisionMask |= 1u << 1; + _triggerArea.Monitoring = true; + } - if (_triggerArea != null) - _triggerArea.BodyEntered += OnBodyEntered; + if (_triggerArea != null) + _triggerArea.BodyEntered += OnBodyEntered; - UnlockDoor(); - } + UnlockDoor(); + } - public void LockDoor() - { - if (CurrentState == DoorState.Locked) return; + public void LockDoor() + { + if (CurrentState == DoorState.Locked) return; - CurrentState = DoorState.Locked; - _barrierCollision?.SetDeferred(CollisionShape2D.PropertyName.Disabled, false); + CurrentState = DoorState.Locked; + _barrierCollision?.SetDeferred(CollisionShape2D.PropertyName.Disabled, false); - if (_animPlayer != null && _animPlayer.HasAnimation("lock")) - _animPlayer.Play("lock"); - } + if (_animPlayer != null && _animPlayer.HasAnimation("lock")) + _animPlayer.Play("lock"); + } - public void UnlockDoor() - { - CurrentState = DoorState.Open; - _barrierCollision?.SetDeferred(CollisionShape2D.PropertyName.Disabled, true); + public void UnlockDoor() + { + CurrentState = DoorState.Open; + _barrierCollision?.SetDeferred(CollisionShape2D.PropertyName.Disabled, true); - if (_animPlayer != null && _animPlayer.HasAnimation("unlock")) - _animPlayer.Play("unlock"); - } + if (_animPlayer != null && _animPlayer.HasAnimation("unlock")) + _animPlayer.Play("unlock"); + } - private void OnBodyEntered(Node2D body) - { - if (CurrentState == DoorState.Open && body.IsInGroup("player")) - { - EmitSignal(SignalName.PlayerEnteredDoorway, this); - } - } + private void OnBodyEntered(Node2D body) + { + if (CurrentState == DoorState.Open && body.IsInGroup("player")) + { + EmitSignal(SignalName.PlayerEnteredDoorway, this); + } + } } |
