Im writing in c# for XNA MonoGame, and have written up an enemy state enumeration to allow me to determine what logic to use for my enemy at each update function.
Here is the enumeration:
public enum EnemyState {
/// <summary>Non-active state, ideally should not process logic.</summary>
WaitOrder,
/// <summary>Enemy is moving towards a directed position.</summary>
MoveOrder,
/// <summary>Enemy is chasing a directed target.</summary>
ChaseOrder,
/// <summary>Enemy is launching an attack towards directed target.</summary>
AttackOrder,
/// <summary>Enemy is dieing, and should be moving towards being deleted.</summary>
Dieing
}
And I simply use EnemyState state
as a deceleration in my enemy class, with the constructor adding state = EnemyState.MoveOrder
.
The problem is, XNA is appearing very clingy to the MoveOrder state. Even though I check that state == EnemyState.MoveOrder
before entering the movement update function, and this clearly returns false
, it still enters.
With a break-point inside the movement function, marking the line where I change the value of state, I proceed to step through the code, line by line.
Visual Studio is telling me that state == EnemyState.WaitOrder
before and after the if statement, and that state == EnemyState.MoveOrder
returns false
.
What could otherwise cause it to ignore the requirement, and jump into the statement, even when the requirements are not met?
update
If I place the check into a boolean, first, the boolean shows the check to be true. That said, If I change state == EnemyState.WaitOrder
to state == 0
, I do not have a problem.