add: Item Manager
This commit is contained in:
60
src/Agents/AgentAction.cs
Normal file
60
src/Agents/AgentAction.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using Godot;
|
||||
|
||||
namespace Polonium.Agents;
|
||||
|
||||
public abstract partial class AgentAction : Node
|
||||
{
|
||||
public abstract class Parameter
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void SetParameter(Parameter p)
|
||||
{
|
||||
}
|
||||
|
||||
public abstract void Execute();
|
||||
|
||||
public abstract void Finish();
|
||||
|
||||
public abstract void Reset();
|
||||
|
||||
public abstract class Template : PoloniumTemplate<AgentAction>
|
||||
{
|
||||
public abstract string ActionName { get; }
|
||||
public abstract Template Copy { get; }
|
||||
}
|
||||
|
||||
public class Template<TAction> : Template
|
||||
where TAction : AgentAction
|
||||
{
|
||||
public override string ActionName => PoloniumRegistry.Action<TAction>.Name;
|
||||
|
||||
public override TAction Get
|
||||
{
|
||||
get
|
||||
{
|
||||
TAction res = PoloniumRegistry.Asset<TAction>.Get();
|
||||
res.Reset();
|
||||
Modify(res);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Modify(AgentAction obj)
|
||||
{
|
||||
if (obj is not TAction act)
|
||||
return;
|
||||
Modify(act);
|
||||
}
|
||||
|
||||
public void Return(TAction res) => PoloniumRegistry.Asset<TAction>.Return(res);
|
||||
|
||||
public override Template Copy => new Template<TAction> { };
|
||||
|
||||
public virtual void Modify(TAction action)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user