public override bool Check(Agent agent) { agent = agent == null || !agent.IsMount ? agent : agent.RiderAgent; if (agent == null) { return(false); } MissionMultiplayerFlagDomination gameModeInstance = this.GameModeInstance; ClosestFlagCondition.FlagOwner flagOwner = ClosestFlagCondition.FlagOwner.None; float num1 = float.MaxValue; foreach (FlagCapturePoint allCapturePoint in gameModeInstance.AllCapturePoints) { if (!allCapturePoint.IsDeactivated) { float num2 = agent.Position.DistanceSquared(allCapturePoint.Position); if ((double)num2 < (double)num1) { num1 = num2; Team flagOwnerTeam = gameModeInstance.GetFlagOwnerTeam(allCapturePoint); flagOwner = flagOwnerTeam != null ? (flagOwnerTeam != agent.Team ? ClosestFlagCondition.FlagOwner.Enemy : ClosestFlagCondition.FlagOwner.Ally) : ClosestFlagCondition.FlagOwner.None; } } } return(this._owner == ClosestFlagCondition.FlagOwner.Any || this._owner == flagOwner); }
protected override void Deserialize(XmlNode node) { string str = node?.Attributes?["owner"]?.Value; this._owner = ClosestFlagCondition.FlagOwner.Any; if (str == null || Enum.TryParse <ClosestFlagCondition.FlagOwner>(str, true, out this._owner)) { return; } this._owner = ClosestFlagCondition.FlagOwner.Any; }