public void UpdateTargetList() { List <BaseEntity> list = Facepunch.Pool.GetList <BaseEntity>(); Vis.Entities <BaseEntity>(base.transform.position, this.searchRange, list, 133120, QueryTriggerInteraction.Collide); foreach (BaseEntity baseEntity in list) { if (!(baseEntity is BasePlayer)) { continue; } BasePlayer basePlayer = baseEntity as BasePlayer; if (basePlayer.IsDead() || basePlayer is Scientist || !this.VisibilityTest(baseEntity)) { continue; } bool flag = false; foreach (BradleyAPC.TargetInfo targetInfo in this.targetList) { if (targetInfo.entity != baseEntity) { continue; } targetInfo.lastSeenTime = UnityEngine.Time.time; flag = true; goto Label0; } Label0: if (flag) { continue; } BradleyAPC.TargetInfo targetInfo1 = Facepunch.Pool.Get <BradleyAPC.TargetInfo>(); targetInfo1.Setup(baseEntity, UnityEngine.Time.time); this.targetList.Add(targetInfo1); } for (int i = this.targetList.Count - 1; i >= 0; i--) { BradleyAPC.TargetInfo item = this.targetList[i]; BasePlayer basePlayer1 = item.entity as BasePlayer; if (item.entity == null || UnityEngine.Time.time - item.lastSeenTime > this.memoryDuration || basePlayer1.IsDead()) { this.targetList.Remove(item); Facepunch.Pool.Free <BradleyAPC.TargetInfo>(ref item); } } Facepunch.Pool.FreeList <BaseEntity>(ref list); this.targetList.Sort(new Comparison <BradleyAPC.TargetInfo>(this.SortTargets)); }
public void AddOrUpdateTarget(BaseEntity ent, Vector3 pos, float damageFrom = 0f) { BradleyAPC.TargetInfo targetInfo; if (!(ent is BasePlayer)) { return; } BradleyAPC.TargetInfo targetInfo1 = null; foreach (BradleyAPC.TargetInfo targetInfo2 in this.targetList) { if (targetInfo2.entity != ent) { continue; } targetInfo1 = targetInfo2; if (targetInfo1 == null) { targetInfo1 = Facepunch.Pool.Get <BradleyAPC.TargetInfo>(); targetInfo1.Setup(ent, UnityEngine.Time.time - 1f); this.targetList.Add(targetInfo1); } targetInfo1.lastSeenPosition = pos; targetInfo = targetInfo1; targetInfo.damageReceivedFrom += damageFrom; return; } if (targetInfo1 == null) { targetInfo1 = Facepunch.Pool.Get <BradleyAPC.TargetInfo>(); targetInfo1.Setup(ent, UnityEngine.Time.time - 1f); this.targetList.Add(targetInfo1); } targetInfo1.lastSeenPosition = pos; targetInfo = targetInfo1; targetInfo.damageReceivedFrom += damageFrom; }