33 lines
1.0 KiB
C#
33 lines
1.0 KiB
C#
using System;
|
|
using Sirenix.OdinInspector;
|
|
using VOID.Generic.Dict;
|
|
|
|
namespace VOID.Generic.Objects.Unit.Data
|
|
{
|
|
[Serializable]
|
|
public record UnitResources
|
|
{
|
|
[MinValue(0f)] public float actionPoints = 2f;
|
|
[MinValue(0f)] public float movePoints = 0f;
|
|
|
|
public float Get(UnitResourceType type)
|
|
{
|
|
return type switch
|
|
{
|
|
UnitResourceType.ActionPoints => actionPoints,
|
|
UnitResourceType.MovePoints => movePoints,
|
|
_ => throw new ArgumentOutOfRangeException(nameof(type), type, null)
|
|
};
|
|
}
|
|
|
|
public void Set(UnitResourceType type, float value)
|
|
{
|
|
switch(type)
|
|
{
|
|
case UnitResourceType.ActionPoints: actionPoints = value; return;
|
|
case UnitResourceType.MovePoints: movePoints = value; return;
|
|
default: throw new ArgumentOutOfRangeException(nameof(type), type, null);
|
|
};
|
|
}
|
|
}
|
|
} |