public bool SetToMainAgent(Agent agent) { if (agent != null) { if (Mission.MainAgent == agent || agent.Team != Mission.PlayerTeam) { return(false); } if (!Utility.IsPlayerDead()) { MissionEvent.OnMainAgentWillBeChangedToAnotherOne(agent); MissionLibrary.Event.MissionEvent.OnMainAgentWillBeChangedToAnotherOne(agent); Utility.AIControlMainAgent(false); } GameTexts.SetVariable("ControlledTroopName", agent.Name); Utility.DisplayLocalizedText("str_rts_camera_control_troop"); bool shouldSmoothMoveToAgent = Utility.BeforeSetMainAgent(); if (_switchFreeCameraLogic.IsSpectatorCamera) { Mission.MainAgent = agent; Utility.AfterSetMainAgent(shouldSmoothMoveToAgent, _flyCameraMissionView.MissionScreen, false); } else { Utility.PlayerControlAgent(agent); Utility.AfterSetMainAgent(shouldSmoothMoveToAgent, _flyCameraMissionView.MissionScreen, true); } return(true); } Utility.DisplayLocalizedText("str_rts_camera_no_troop_to_control"); return(false); }
public bool ForceControlAgent(Agent agent) { try { if (agent != null) { if (agent.Controller == Agent.ControllerType.Player || agent.Team != Mission.PlayerTeam) { return(false); } if (!Utility.IsPlayerDead() && Mission.MainAgent != agent) { MissionEvent.OnMainAgentWillBeChangedToAnotherOne(agent); MissionLibrary.Event.MissionEvent.OnMainAgentWillBeChangedToAnotherOne(agent); Utility.AIControlMainAgent(false); } bool shouldSmoothMoveToAgent = Utility.BeforeSetMainAgent(); if (_switchFreeCameraLogic.IsSpectatorCamera) { Mission.MainAgent = agent; _switchFreeCameraLogic.SwitchCamera(); } else { Utility.PlayerControlAgent(agent); } Utility.AfterSetMainAgent(shouldSmoothMoveToAgent, _flyCameraMissionView.MissionScreen); return(true); } else { Utility.DisplayLocalizedText("str_rts_camera_no_troop_to_control"); return(false); } } catch (Exception e) { Utility.DisplayMessage(e.ToString()); } return(false); }