Skip to content

Commit b88b3ac

Browse files
using enum values to init AI state type array
1 parent 3edcdf6 commit b88b3ac

File tree

1 file changed

+4
-5
lines changed
  • Assets/BossRoom/Scripts/Server/Game/Character

1 file changed

+4
-5
lines changed

Assets/BossRoom/Scripts/Server/Game/Character/AIBrain.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ private enum AIStateType
1717
IDLE,
1818
}
1919

20-
static readonly AIStateType[] k_AIStates = { AIStateType.ATTACK , AIStateType.IDLE};
20+
static readonly AIStateType[] k_AIStates = (AIStateType[])Enum.GetValues(typeof(AIStateType));
2121

2222
private ServerCharacter m_ServerCharacter;
2323
private ActionPlayer m_ActionPlayer;
@@ -71,12 +71,11 @@ private AIStateType FindBestEligibleAIState()
7171
{
7272
// for now we assume the AI states are in order of appropriateness,
7373
// which may be nonsensical when there are more states
74-
for (int i = 0; i < k_AIStates.Length; i++)
74+
foreach (AIStateType aiStateType in k_AIStates)
7575
{
76-
var aiState = k_AIStates[i];
77-
if (m_Logics[aiState].IsEligible())
76+
if (m_Logics[aiStateType].IsEligible())
7877
{
79-
return aiState;
78+
return aiStateType;
8079
}
8180
}
8281

0 commit comments

Comments
 (0)