public void UpdateTargets(float delta) { UpdateMemory(); int num = -1; float num2 = -1f; Vector3 position = base.transform.position; for (int i = 0; i < myMemory.All.Count; i++) { SimpleAIMemory.SeenInfo seenInfo = myMemory.All[i]; if (seenInfo.Entity == null) { continue; } float num3 = 0f; float value = Vector3.Distance(seenInfo.Entity.transform.position, position); if (!seenInfo.Entity.IsNpc && !(seenInfo.Entity.Health() <= 0f)) { num3 += 1f - Mathf.InverseLerp(10f, sightRange, value); float value2 = Vector3.Dot((seenInfo.Entity.transform.position - eyes.position).normalized, eyes.BodyForward()); num3 += Mathf.InverseLerp(visionCone, 1f, value2); float value3 = seenInfo.Timestamp - UnityEngine.Time.realtimeSinceStartup; num3 += 1f - Mathf.InverseLerp(0f, 3f, value3); if (num3 > num2) { num = i; num2 = num3; } } } if (num != -1) { SimpleAIMemory.SeenInfo seenInfo2 = myMemory.All[num]; if (seenInfo2.Entity != null && seenInfo2.Entity is BasePlayer) { BasePlayer component = seenInfo2.Entity.GetComponent <BasePlayer>(); if (Interface.CallHook("OnNpcTarget", this, component) == null) { currentTarget = component; currentTargetLOS = IsPlayerVisibleToUs(component); } } } else { currentTarget = null; currentTargetLOS = false; } }
public void UpdateTargets(float delta) { this.UpdateMemory(); int num = -1; float single = -1f; Vector3 serverPosition = this.ServerPosition; for (int i = 0; i < this.myMemory.All.Count; i++) { SimpleAIMemory.SeenInfo item = this.myMemory.All[i]; if (item.Entity != null) { float single1 = 0f; float single2 = Vector3.Distance(item.Entity.ServerPosition, serverPosition); if (!item.Entity.IsNpc && item.Entity.Health() > 0f) { single1 = single1 + (1f - Mathf.InverseLerp(10f, this.sightRange, single2)); Vector3 vector3 = item.Entity.ServerPosition - this.eyes.position; float single3 = Vector3.Dot(vector3.normalized, this.eyes.BodyForward()); single1 += Mathf.InverseLerp(this.visionCone, 1f, single3); float timestamp = item.Timestamp - UnityEngine.Time.realtimeSinceStartup; single1 = single1 + (1f - Mathf.InverseLerp(0f, 3f, timestamp)); if (single1 > single) { num = i; single = single1; } } } } if (num == -1) { this.currentTarget = null; this.currentTargetLOS = false; } else { SimpleAIMemory.SeenInfo seenInfo = this.myMemory.All[num]; if (seenInfo.Entity != null && seenInfo.Entity is BasePlayer) { BasePlayer component = seenInfo.Entity.GetComponent <BasePlayer>(); this.currentTarget = component; this.currentTargetLOS = this.IsVisibleToUs(component); return; } } }
public void UpdateTargets(float delta) { this.UpdateMemory(); int index1 = -1; float num1 = -1f; Vector3 serverPosition = this.ServerPosition; for (int index2 = 0; index2 < this.myMemory.All.Count; ++index2) { SimpleAIMemory.SeenInfo seenInfo = this.myMemory.All[index2]; if (!Object.op_Equality((Object)seenInfo.Entity, (Object)null)) { float num2 = 0.0f; float num3 = Vector3.Distance(seenInfo.Entity.ServerPosition, serverPosition); if (!seenInfo.Entity.IsNpc && (double)seenInfo.Entity.Health() > 0.0) { float num4 = num2 + (1f - Mathf.InverseLerp(10f, this.sightRange, num3)); Vector3 vector3 = Vector3.op_Subtraction(seenInfo.Entity.ServerPosition, this.eyes.position); float num5 = Vector3.Dot(((Vector3) ref vector3).get_normalized(), this.eyes.BodyForward()); float num6 = num4 + Mathf.InverseLerp(this.visionCone, 1f, num5) + (1f - Mathf.InverseLerp(0.0f, 3f, seenInfo.Timestamp - Time.get_realtimeSinceStartup())); if ((double)num6 > (double)num1) { index1 = index2; num1 = num6; } } } } if (index1 != -1) { SimpleAIMemory.SeenInfo seenInfo = this.myMemory.All[index1]; if (!Object.op_Inequality((Object)seenInfo.Entity, (Object)null) || !(seenInfo.Entity is BasePlayer)) { return; } BasePlayer component = (BasePlayer)((Component)seenInfo.Entity).GetComponent <BasePlayer>(); this.currentTarget = (BaseCombatEntity)component; this.currentTargetLOS = this.IsVisibleToUs(component); } else { this.currentTarget = (BaseCombatEntity)null; this.currentTargetLOS = false; } }