} // end of ResetIgnoreList() /// <summary> /// Resolves conflicts in the follow lists used by the camera. /// An entry in the NeverFollowList overrides one in the FollowList. /// Also removes any dead bots. /// This should be called after the brain updates but before the /// camera is used. /// </summary> public static void ResolveFollowLists() { // An explicit ignore in the bot's programming trumps // an explicit follow or a user controlled follow. for (int i = 0; i < brainIgnoreMeList.Count; i++) { brainFollowMeList.Remove(brainIgnoreMeList[i]); brainUserControlledList.Remove(brainIgnoreMeList[i]); } // // Remove any dead bots. // for (int i = brainFollowMeList.Count - 1; i >= 0; i--) { GameActor actor = brainFollowMeList[i]; if (!actor.IsAlive()) { brainFollowMeList.RemoveAt(i); } } for (int i = brainUserControlledList.Count - 1; i >= 0; i--) { GameActor actor = brainUserControlledList[i]; if (!actor.IsAlive()) { brainUserControlledList.RemoveAt(i); } } if (FirstPersonActive) { /// We want to clear out anyone that has requested first person /// but lost out. They can continue to request, but if they requested /// at some point in the past but stopped requesting, and the current /// first person stops being first person, we want their request to /// have expired. So achieving firstperson-ness is sticky, but requesting /// firstperson-ness is not. GameActor winner = null; for (int i = brainFirstPersonStack.Count - 1; i >= 0; i--) { GameActor actor = brainFirstPersonStack[i]; if (actor.IsAlive()) { winner = actor; break; } } brainFirstPersonStack.Clear(); if (winner != null) { brainFirstPersonStack.Add(winner); } } // Create the merged follow list. mergedFollowList.Clear(); for (int i = 0; i < brainFollowMeList.Count; i++) { GameActor actor = brainFollowMeList[i]; if (!mergedFollowList.Contains(actor)) { mergedFollowList.Add(actor); } } for (int i = 0; i < brainUserControlledList.Count; i++) { GameActor actor = brainUserControlledList[i]; if (!mergedFollowList.Contains(actor)) { mergedFollowList.Add(actor); } } // Flag whether camera is following any actors. wasFollowingActors = amFollowingActors; amFollowingActors = mergedFollowList.Count > 0 || brainFirstPersonStack.Count > 0; // Clear the user controlled list since it gets updated every frame. brainUserControlledList.Clear(); } // end of ResolveFollowLists()