21 lines
758 B
C#
21 lines
758 B
C#
namespace Beam {
|
|
public class NumberedStateChanger(NumberedStateChanger.MoveState moveState) : IStateChangeBehaviour {
|
|
public delegate void MoveState(State state, int amount);
|
|
public MoveState MoveStateDlgte { get; set; } = moveState;
|
|
|
|
public virtual void Apply(State state, object stimulus) {
|
|
if (stimulus is not int amount)
|
|
throw new ArgumentException(S.M.StimulusMustBeInt, nameof(stimulus));
|
|
Apply(state, amount);
|
|
}
|
|
|
|
public virtual void Apply(State state, int amount) {
|
|
MoveStateDlgte(state, amount);
|
|
}
|
|
|
|
public NumberedStateChanger(IStateChangeBehaviour behavior) : this((x, i) => {
|
|
behavior.Apply(x, i);
|
|
}) {}
|
|
}
|
|
}
|