Add TriggerActionFactory and related resources for button and logic sequence components
This commit is contained in:
21
Code/Factories/TriggerActionFactory.cs
Normal file
21
Code/Factories/TriggerActionFactory.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using CryptonymThunder.Code.Resources;
|
||||
using GameCore.Logic;
|
||||
using GameCore.Logic.Interfaces;
|
||||
|
||||
namespace CryptonymThunder.Code.Factories;
|
||||
|
||||
public class TriggerActionFactory
|
||||
{
|
||||
public ITriggerAction Create(TriggerActionResource resource)
|
||||
{
|
||||
return resource switch
|
||||
{
|
||||
UnlockDoorActionResource unlock => new UnlockDoorAction(unlock.TargetWorldId),
|
||||
SpawnEntityActionResource spawn => new SpawnEntityAction(spawn.ArchetypeId, spawn.SpawnerWorldId),
|
||||
DebugMessageActionResource debug => new DebugMessageAction(debug.Message),
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(resource),
|
||||
$"TriggerAction type {resource.GetType().Name} not recognized")
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user