[Add] GameLoop base

This commit is contained in:
2026-03-18 09:13:48 +07:00
parent c819c0d045
commit 537ae1ce5c
28 changed files with 997 additions and 40 deletions
+39
View File
@@ -0,0 +1,39 @@
using System;
namespace YachtDice.Run
{
public sealed class StoredRollBank
{
public int Value { get; private set; }
public event Action<int> OnChanged;
public void Reset()
{
SetValue(0);
}
public void Add(int amount)
{
if (amount <= 0)
return;
SetValue(Value + amount);
}
public bool TrySpend(int amount)
{
if (amount <= 0 || Value < amount)
return false;
SetValue(Value - amount);
return true;
}
private void SetValue(int value)
{
Value = Math.Max(0, value);
OnChanged?.Invoke(Value);
}
}
}