Locked Doors

This commit is contained in:
Marco 2025-04-24 16:40:51 +02:00
commit e25da0fe16
20 changed files with 318 additions and 61 deletions

View file

@ -0,0 +1,24 @@
using Cirno.Scripts.Controllers;
namespace Cirno.Scripts.Interactables;
public partial class RogueliteDoorLock : Switch
{
public RoomConnection Connection { get; set; }
public override bool Activate(ActivationType activationType = ActivationType.Toggle)
{
base.Activate(activationType);
if (!MeetsRequirements()) return false;
Connection.FromDoor.Activate(activationType);
Connection.ToDoor.Activate(activationType);
InventoryManager.Instance.RemoveItem("GRAY_KEY", 1);
this.QueueFree();
return true;
}
}

View file

@ -0,0 +1 @@
uid://6n7duf35c52l

View file

@ -25,15 +25,25 @@ public partial class Switch : Interactable
public override bool Activate(ActivationType activationType = ActivationType.Toggle)
{
ActivationType activationTypeToUse;
if (activationType is ActivationType.Use)
{
activationTypeToUse = ActivationType;
}
else
{
activationTypeToUse = activationType;
}
if (!MeetsRequirements()) return false;
_activationSound?.Play();
EmitSignal(SignalName.OnActivated, (int)activationType);
EmitSignal(SignalName.OnActivated, (int)activationTypeToUse);
// Compatibility for old single system
bool success = ActivateTarget(Target, activationType);
bool success = ActivateTarget(Target, activationTypeToUse);
return Targets.Aggregate(success, (current, target) => ActivateTarget(target, activationType) | success);
return Targets.Aggregate(success, (current, target) => ActivateTarget(target, activationTypeToUse) | success);
}
private bool ActivateTarget(Node2D target, ActivationType activationType = ActivationType.Toggle)