public bool UpdateTargetFromList(List <PatrolHelicopterAI.targetinfo> newTargetList) { int num = UnityEngine.Random.Range(0, newTargetList.Count); int num2 = newTargetList.Count; while (num2 >= 0) { num2--; PatrolHelicopterAI.targetinfo targetinfo = newTargetList[num]; if (targetinfo != null && targetinfo.ent != null && targetinfo.IsVisible() && InFiringArc(targetinfo.ply)) { SetTarget(targetinfo.ply); return(true); } num++; if (num >= newTargetList.Count) { num = 0; } } return(false); }
public bool UpdateTargetFromList(List <PatrolHelicopterAI.targetinfo> newTargetList) { int index = Random.Range(0, newTargetList.Count); int count = newTargetList.Count; while (count >= 0) { --count; PatrolHelicopterAI.targetinfo newTarget = newTargetList[index]; if (newTarget != null && Object.op_Inequality((Object)newTarget.ent, (Object)null) && (newTarget.IsVisible() && this.InFiringArc((BaseCombatEntity)newTarget.ply))) { this.SetTarget((BaseCombatEntity)newTarget.ply); return(true); } ++index; if (index >= newTargetList.Count) { index = 0; } } return(false); }
public bool UpdateTargetFromList(List <PatrolHelicopterAI.targetinfo> newTargetList) { int num = UnityEngine.Random.Range(0, newTargetList.Count); int count = newTargetList.Count; while (count >= 0) { count--; PatrolHelicopterAI.targetinfo item = newTargetList[num]; if (item != null && item.ent != null && item.IsVisible() && this.InFiringArc(item.ply)) { this.SetTarget(item.ply); return(true); } num++; if (num < newTargetList.Count) { continue; } num = 0; } return(false); }
public void UpdateTargetList() { bool flag; Vector3 vector3 = Vector3.zero; bool flag1 = false; bool flag2 = false; for (int i = this._targetList.Count - 1; i >= 0; i--) { PatrolHelicopterAI.targetinfo item = this._targetList[i]; if (item == null || item.ent == null) { this._targetList.Remove(item); } else { if (UnityEngine.Time.realtimeSinceStartup > item.nextLOSCheck) { item.nextLOSCheck = UnityEngine.Time.realtimeSinceStartup + 1f; if (!this.PlayerVisible(item.ply)) { item.visibleFor = 0f; } else { item.lastSeenTime = UnityEngine.Time.realtimeSinceStartup; item.visibleFor += 1f; } } bool flag3 = (item.ply ? item.ply.IsDead() : item.ent.Health() <= 0f); if (item.TimeSinceSeen() >= 6f | flag3) { bool flag4 = UnityEngine.Random.Range(0f, 1f) >= 0f; if ((this.CanStrafe() || this.CanUseNapalm()) && this.IsAlive() && !flag1 && !flag3) { flag = (item.ply == this.leftGun._target ? true : item.ply == this.rightGun._target); } else { flag = false; } if (flag & flag4) { flag2 = (!this.ValidStrafeTarget(item.ply) ? true : UnityEngine.Random.Range(0f, 1f) > 0.75f); flag1 = true; vector3 = item.ply.transform.position; } this._targetList.Remove(item); } } } foreach (BasePlayer basePlayer in BasePlayer.activePlayerList) { if (basePlayer.HasPlayerFlag(BasePlayer.PlayerFlags.SafeZone) || Vector3Ex.Distance2D(base.transform.position, basePlayer.transform.position) > 150f) { continue; } bool flag5 = false; foreach (PatrolHelicopterAI.targetinfo _targetinfo in this._targetList) { if (_targetinfo.ply != basePlayer) { continue; } flag5 = true; goto Label0; } Label0: if (flag5 || basePlayer.GetThreatLevel() <= 0.5f || !this.PlayerVisible(basePlayer)) { continue; } this._targetList.Add(new PatrolHelicopterAI.targetinfo(basePlayer, basePlayer)); } if (flag1) { this.ExitCurrentState(); this.State_Strafe_Enter(vector3, flag2); } }
private void UpdateTargetList() { Vector3 strafePos = Vector3.zero; bool isStrafing = false; bool shouldUseNapalm = false; for (int i = _targets.Count - 1; i >= 0; i--) { PatrolHelicopterAI.targetinfo targetinfo = _targets[i]; if (targetinfo == null || targetinfo.ent == null) { _targets.Remove(targetinfo); } else { if (Time.realtimeSinceStartup > targetinfo.nextLOSCheck) { targetinfo.nextLOSCheck = Time.realtimeSinceStartup + 1f; if (PlayerVisible(targetinfo.ply)) { targetinfo.lastSeenTime = Time.realtimeSinceStartup; targetinfo.visibleFor += 1f; } else { targetinfo.visibleFor = 0f; } } bool isDead = targetinfo.ply ? targetinfo.ply.IsDead() : (targetinfo.ent.Health() <= 0f); if (targetinfo.TimeSinceSeen() >= 6f || isDead) { if ((CanStrafe() || CanUseNapalm()) && AI.IsAlive() && !isStrafing && !isDead && (targetinfo.ply == AI.leftGun._target || targetinfo.ply == AI.rightGun._target)) { shouldUseNapalm = (!ValidStrafeTarget(targetinfo.ply) || UnityEngine.Random.Range(0f, 1f) > 0.75f); strafePos = targetinfo.ply.transform.position; isStrafing = true; } _targets.Remove(targetinfo); } } } foreach (EventManager.BaseEventPlayer eventPlayer in Event.eventPlayers) { BasePlayer player = eventPlayer.Player; if (Vector3Ex.Distance2D(tr.position, player.transform.position) <= 150f) { bool isCurrentTarget = false; for (int i = 0; i < _targets.Count; i++) { PatrolHelicopterAI.targetinfo targetInfo = _targets[i]; if (targetInfo.ply == player) { isCurrentTarget = true; break; } } if (!isCurrentTarget && PlayerVisible(player)) { _targets.Add(new PatrolHelicopterAI.targetinfo(player, player)); } } } if (isStrafing) { AI.ExitCurrentState(); AI.State_Strafe_Enter(strafePos, shouldUseNapalm); } AI._targetList.Clear(); AI._targetList.AddRange(_targets); }