ported from perforce

This commit is contained in:
2026-04-19 00:43:27 +02:00
commit 6c0c33f5d4
700 changed files with 19735 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
using RobotAndDonkey.Game.Intents;
namespace RobotAndDonkey.Game.Modifiers;
public record Entity()
{
protected Entity(Entity clone)
{
m_Modifiers = [];
foreach (var modifier in clone.Modifiers)
AddModifier(modifier.DeepClone(), []);
}
public void InsertModifier(Modifier modifier, List<Intent> newIntents)
{
if (m_Modifiers.Any(m => m.Id == modifier.Id))
throw new InvalidOperationException();
m_Modifiers.Insert(0, modifier);
modifier.OnAdded(this, newIntents);
}
public void AddModifier(Modifier modifier, List<Intent> newIntents)
{
if (m_Modifiers.Any(m => m.Id == modifier.Id))
throw new InvalidOperationException();
m_Modifiers.Add(modifier);
modifier.OnAdded(this, newIntents);
}
public void RemoveModifier(Modifier modifier, List<Intent> newIntents)
{
if (!m_Modifiers.Remove(modifier))
throw new InvalidOperationException();
modifier.OnRemoved(this, newIntents);
}
public override string ToString()
{
return "[" + string.Join(", ", m_Modifiers) + "]";
}
public IReadOnlyList<Modifier> Modifiers => m_Modifiers;
private readonly List<Modifier> m_Modifiers = [];
}