redesign: Agents

This commit is contained in:
h z
2025-02-27 15:39:28 +00:00
parent 8df4ebb6d5
commit e90f701bd5
15 changed files with 166 additions and 144 deletions

View File

@@ -1,60 +0,0 @@
using Polonium.Interfaces;
namespace Polonium.Agents;
public abstract class AgentAction
{
}
public abstract class AgentAction<TAgent, TAgentDecisionMaker, TAgentKnowledge, TAgentAction> : AgentAction, ITimeConsumer
where TAgent : Agent<TAgent, TAgentDecisionMaker, TAgentKnowledge, TAgentAction>, new()
where TAgentDecisionMaker : AgentDecisionMaker<TAgent, TAgentDecisionMaker, TAgentKnowledge, TAgentAction>, new()
where TAgentKnowledge : AgentKnowledge<TAgent, TAgentDecisionMaker, TAgentKnowledge, TAgentAction>, new()
where TAgentAction : AgentAction<TAgent, TAgentDecisionMaker, TAgentKnowledge, TAgentAction>, new()
{
public int Level { get; private set; }
public abstract int MaxLevel { get; }
public virtual void LevelUp()
{
if(Level < MaxLevel)
Level++;
}
public AgentAction(double coolDown)
{
CoolDown = coolDown;
PoloniumRegistry.Instance.TimeConsumers.Add(this);
}
public abstract class ActionParameter
{
}
public virtual bool Execute(ActionParameter parameter)
{
if (Disabled || CoolDown > 0)
return false;
CoolDownTime = CoolDown;
return true;
}
private double CoolDownTime { get; set; }
public bool Disabled { get; set; }
private double CoolDown { get; }
public void Process(double delta)
{
if (Disabled || CoolDownTime <= 0)
return;
CoolDownTime -= delta;
if (CoolDownTime <= 0)
CoolDownTime = 0;
}
}