private void SetControl() { // Check for disabled controlling ally if (Commanding != null) { if (Commanding.CannotAct || Commanding.Confusion) { ClearControl(); } } // Check turn timers and enqueue if up for (int i = 0; i < Party.PARTY_SIZE; i++) { Ally ally = Allies[i]; bool isReady = ally != null && // they're not null ally.TurnTimer.IsUp && // they're ready !ally.WaitingToResolve && // they're not already acting !ally.CannotAct; // they can actually act if (isReady) { if (ally.Confusion) { ally.RunAIConfu(); } else if (ally.Berserk) { ally.RunAIBerserk(); } else { if (!_turnQueue.Contains(ally) && ally != Commanding) { _turnQueue.Enqueue(ally); } } } } // Check turn queue and set control if none set if (Commanding == null) { if (_turnQueue.Count > 0) { Commanding = _turnQueue.Dequeue(); Screen.PushControl(Commanding.BattleMenu); } } }