Add CloseDoorActionResource and update LogicSequenceComponentResource for activation and deactivation actions

This commit is contained in:
2025-10-30 02:46:16 +01:00
parent 214d541c2b
commit c373ed4953
7 changed files with 36 additions and 6 deletions

View File

@@ -167,12 +167,21 @@ public class ComponentFactory
IsOneTimeTrigger = resource.IsOneTimeTrigger,
};
foreach (var actionResource in resource.OnCompleteActions)
foreach (var actionResource in resource.OnActivateActions)
{
var action = _triggerActionFactory.Create(actionResource);
if (action != null)
{
component.OnCompleteActions.Add(action);
component.OnActivateActions.Add(action);
}
}
foreach (var actionResource in resource.OnDeactivateActions)
{
var action = _triggerActionFactory.Create(actionResource);
if (action != null)
{
component.OnDeactivateActions.Add(action);
}
}

View File

@@ -15,6 +15,7 @@ public class TriggerActionFactory
SpawnEntityActionResource spawn => new SpawnEntityAction(spawn.ArchetypeId, spawn.SpawnerWorldId),
DebugMessageActionResource debug => new DebugMessageAction(debug.Message),
OpenDoorActionResource open => new OpenDoorAction(open.TargetWorldId),
CloseDoorActionResource close => new CloseDoorAction(close.TargetWorldId),
_ => throw new ArgumentOutOfRangeException(nameof(resource),
$"TriggerAction type {resource.GetType().Name} not recognized")
};

View File

@@ -0,0 +1,9 @@
using Godot;
namespace CryptonymThunder.Code.Resources;
[GlobalClass]
public partial class CloseDoorActionResource : TriggerActionResource
{
[Export] public string TargetWorldId { get; set; } = "door_to_close";
}

View File

@@ -0,0 +1 @@
uid://d3u3q5yhenegb

View File

@@ -7,6 +7,7 @@ namespace CryptonymThunder.Code.Resources;
public partial class LogicSequenceComponentResource : Resource
{
[Export] public Array<string> RequiredChannels { get; set; } = [];
[Export] public Array<TriggerActionResource> OnCompleteActions { get; set; } = [];
[Export] public Array<TriggerActionResource> OnActivateActions { get; set; } = [];
[Export] public Array<TriggerActionResource> OnDeactivateActions { get; set; } = [];
[Export] public bool IsOneTimeTrigger { get; set; } = true;
}