public static void NavigateToLastEnemy(NPCHumanContext c)
 {
     if (Object.op_Inequality((Object)c.AIAgent.AttackTarget, (Object)null) && c.AIAgent.IsNavRunning())
     {
         Memory.SeenInfo info = c.Memory.GetInfo(c.AIAgent.AttackTarget);
         if (Object.op_Inequality((Object)info.Entity, (Object)null) && (double)((Vector3) ref info.Position).get_sqrMagnitude() > 0.0)
         {
             BasePlayer player = c.AIAgent.AttackTarget.ToPlayer();
             if (Object.op_Inequality((Object)player, (Object)null) && (player.IsAdmin || player.IsDeveloper) && player.IsFlying)
             {
                 SetHumanSpeed.Set((BaseContext)c, NPCPlayerApex.SpeedEnum.StandStill);
                 return;
             }
             NavMeshHit navMeshHit;
             if (!NavMesh.SamplePosition(info.Position, ref navMeshHit, 1f, c.AIAgent.GetNavAgent.get_areaMask()))
             {
                 SetHumanSpeed.Set((BaseContext)c, NPCPlayerApex.SpeedEnum.StandStill);
                 return;
             }
             HumanNavigateToOperator.MakeUnstuck(c);
             c.Human.StoppingDistance = 1f;
             c.Human.Destination      = ((NavMeshHit) ref navMeshHit).get_position();
             c.Human.SetTargetPathStatus(0.05f);
         }
     }
     HumanNavigateToOperator.UpdateRoamTime(c);
 }
        public static void NavigateToLastEnemy(NPCHumanContext c)
        {
            NavMeshHit navMeshHit;

            if (c.AIAgent.AttackTarget != null && c.AIAgent.IsNavRunning())
            {
                Memory.SeenInfo info = c.Memory.GetInfo(c.AIAgent.AttackTarget);
                if (info.Entity != null && info.Position.sqrMagnitude > 0f)
                {
                    BasePlayer player = c.AIAgent.AttackTarget.ToPlayer();
                    if (player != null && (player.IsAdmin || player.IsDeveloper) && player.IsFlying)
                    {
                        SetHumanSpeed.Set(c, NPCPlayerApex.SpeedEnum.StandStill);
                        return;
                    }
                    if (!NavMesh.SamplePosition(info.Position, out navMeshHit, 1f, c.AIAgent.GetNavAgent.areaMask))
                    {
                        SetHumanSpeed.Set(c, NPCPlayerApex.SpeedEnum.StandStill);
                        return;
                    }
                    HumanNavigateToOperator.MakeUnstuck(c);
                    c.Human.StoppingDistance = 1f;
                    c.Human.Destination      = navMeshHit.position;
                    c.Human.SetTargetPathStatus(0.05f);
                }
            }
            HumanNavigateToOperator.UpdateRoamTime(c);
        }
        public static void NavigateToEnemy(NPCHumanContext c)
        {
            if (c.GetFact(NPCPlayerApex.Facts.HasEnemy) <= (byte)0 || !c.AIAgent.IsNavRunning())
            {
                return;
            }
            if (c.GetFact(NPCPlayerApex.Facts.HasLineOfSight) > (byte)0)
            {
                Vector3 enemyPosition = c.EnemyPosition;
                if ((double)((Vector3) ref enemyPosition).get_sqrMagnitude() > 0.0)
                {
                    HumanNavigateToOperator.MakeUnstuck(c);
                    c.Human.StoppingDistance = 1.5f;
                    c.Human.Destination      = c.EnemyPosition;
                    goto label_6;
                }
            }
            Memory.SeenInfo info = c.Memory.GetInfo(c.AIAgent.AttackTarget);
            if (Object.op_Inequality((Object)info.Entity, (Object)null) && (double)((Vector3) ref info.Position).get_sqrMagnitude() > 0.0)
            {
                HumanNavigateToOperator.MakeUnstuck(c);
                c.Human.StoppingDistance = 1.5f;
                c.Human.Destination      = info.Position;
            }
label_6:
            c.Human.SetTargetPathStatus(0.05f);
        }
        public override void Execute(PlayerTargetContext context)
        {
            BaseContext baseContext = context.Self.GetContext(Guid.Empty) as BaseContext;

            if (baseContext != null)
            {
                float      danger          = 0f;
                BasePlayer basePlayer      = null;
                Vector3    position        = Vector3.zero;
                float      aggressionRange = baseContext.AIAgent.GetStats.AggressionRange * baseContext.AIAgent.GetStats.AggressionRange;
                float      deaggroRange    = baseContext.AIAgent.GetStats.DeaggroRange * baseContext.AIAgent.GetStats.DeaggroRange;
                for (int i = 0; i < baseContext.Memory.All.Count; i++)
                {
                    Memory.SeenInfo item   = baseContext.Memory.All[i];
                    BasePlayer      entity = item.Entity as BasePlayer;
                    if (entity != null)
                    {
                        float single = (item.Position - baseContext.Position).sqrMagnitude;
                        if (item.Danger > danger && (single <= aggressionRange || baseContext.Entity.lastAttacker == entity && single <= deaggroRange))
                        {
                            danger     = item.Danger;
                            basePlayer = entity;
                            position   = item.Position;
                        }
                    }
                }
                if (basePlayer != null)
                {
                    context.Target            = basePlayer;
                    context.Score             = danger;
                    context.LastKnownPosition = position;
                }
            }
        }
예제 #5
0
 public Memory.SeenInfo Update(BaseEntity ent, Vector3 position, float danger = 0.0f)
 {
     for (int index = 0; index < this.All.Count; ++index)
     {
         if (Object.op_Equality((Object)this.All[index].Entity, (Object)ent))
         {
             Memory.SeenInfo seenInfo = this.All[index];
             seenInfo.Position  = position;
             seenInfo.Timestamp = Time.get_realtimeSinceStartup();
             seenInfo.Danger   += danger;
             this.All[index]    = seenInfo;
             return(seenInfo);
         }
     }
     Memory.SeenInfo seenInfo1 = new Memory.SeenInfo()
     {
         Entity    = ent,
         Position  = position,
         Timestamp = Time.get_realtimeSinceStartup(),
         Danger    = danger
     };
     this.All.Add(seenInfo1);
     this.Visible.Add(ent);
     return(seenInfo1);
 }
예제 #6
0
 public void AddDanger(Vector3 position, float amount)
 {
     for (int index = 0; index < this.All.Count; ++index)
     {
         if (Mathf.Approximately((float)this.All[index].Position.x, (float)position.x) && Mathf.Approximately((float)this.All[index].Position.y, (float)position.y) && Mathf.Approximately((float)this.All[index].Position.z, (float)position.z))
         {
             Memory.SeenInfo seenInfo = this.All[index];
             seenInfo.Danger = amount;
             this.All[index] = seenInfo;
             return;
         }
     }
     this.All.Add(new Memory.SeenInfo()
     {
         Position  = position,
         Timestamp = Time.get_realtimeSinceStartup(),
         Danger    = amount
     });
 }
예제 #7
0
        public void AddDanger(Vector3 position, float amount)
        {
            for (int i = 0; i < this.All.Count; i++)
            {
                if (Mathf.Approximately(this.All[i].Position.x, position.x) && Mathf.Approximately(this.All[i].Position.y, position.y) && Mathf.Approximately(this.All[i].Position.z, position.z))
                {
                    Memory.SeenInfo item = this.All[i];
                    item.Danger = amount;
                    this.All[i] = item;
                    return;
                }
            }
            List <Memory.SeenInfo> all = this.All;

            Memory.SeenInfo seenInfo = new Memory.SeenInfo()
            {
                Position  = position,
                Timestamp = Time.realtimeSinceStartup,
                Danger    = amount
            };
            all.Add(seenInfo);
        }
 public static void NavigateToEnemy(NPCHumanContext c)
 {
     if (c.GetFact(NPCPlayerApex.Facts.HasEnemy) > 0 && c.AIAgent.IsNavRunning())
     {
         if (c.GetFact(NPCPlayerApex.Facts.HasLineOfSight) <= 0 || c.EnemyPosition.sqrMagnitude <= 0f)
         {
             Memory.SeenInfo info = c.Memory.GetInfo(c.AIAgent.AttackTarget);
             if (info.Entity != null && info.Position.sqrMagnitude > 0f)
             {
                 HumanNavigateToOperator.MakeUnstuck(c);
                 c.Human.StoppingDistance = 1.5f;
                 c.Human.Destination      = info.Position;
             }
         }
         else
         {
             HumanNavigateToOperator.MakeUnstuck(c);
             c.Human.StoppingDistance = 1.5f;
             c.Human.Destination      = c.EnemyPosition;
         }
         c.Human.SetTargetPathStatus(0.05f);
     }
 }
예제 #9
0
 public Memory.SeenInfo GetInfo(Vector3 position)
 {
     Memory.SeenInfo seenInfo;
     List <Memory.SeenInfo> .Enumerator enumerator = this.All.GetEnumerator();
     try
     {
         while (enumerator.MoveNext())
         {
             Memory.SeenInfo current = enumerator.Current;
             if ((current.Position - position).sqrMagnitude >= 1f)
             {
                 continue;
             }
             seenInfo = current;
             return(seenInfo);
         }
         return(new Memory.SeenInfo());
     }
     finally
     {
         ((IDisposable)enumerator).Dispose();
     }
     return(seenInfo);
 }
예제 #10
0
 public Memory.SeenInfo GetInfo(BaseEntity entity)
 {
     Memory.SeenInfo seenInfo;
     List <Memory.SeenInfo> .Enumerator enumerator = this.All.GetEnumerator();
     try
     {
         while (enumerator.MoveNext())
         {
             Memory.SeenInfo current = enumerator.Current;
             if (current.Entity != entity)
             {
                 continue;
             }
             seenInfo = current;
             return(seenInfo);
         }
         return(new Memory.SeenInfo());
     }
     finally
     {
         ((IDisposable)enumerator).Dispose();
     }
     return(seenInfo);
 }
예제 #11
0
        public virtual void Execute(PlayerTargetContext context)
        {
            BaseContext context1 = context.Self.GetContext(Guid.Empty) as BaseContext;

            if (context1 == null)
            {
                return;
            }
            float      num1       = 0.0f;
            BasePlayer basePlayer = (BasePlayer)null;
            Vector3    vector3_1  = Vector3.get_zero();
            float      num2       = context1.AIAgent.GetStats.AggressionRange * context1.AIAgent.GetStats.AggressionRange;

            for (int index = 0; index < context1.Memory.All.Count; ++index)
            {
                Memory.SeenInfo seenInfo = context1.Memory.All[index];
                BasePlayer      entity   = seenInfo.Entity as BasePlayer;
                if (Object.op_Inequality((Object)entity, (Object)null) && (double)Time.get_time() < (double)context1.Memory.GetExtendedInfo(seenInfo.Entity).LastHurtUsTime + (double)this.HostilityTimeout && (double)seenInfo.Danger > (double)num1)
                {
                    Vector3 vector3_2 = Vector3.op_Subtraction(seenInfo.Position, context1.Position);
                    if ((double)((Vector3) ref vector3_2).get_sqrMagnitude() <= (double)num2)
                    {
                        num1       = seenInfo.Danger;
                        basePlayer = entity;
                        vector3_1  = seenInfo.Position;
                    }
                }
            }
            if (!Object.op_Inequality((Object)basePlayer, (Object)null))
            {
                return;
            }
            context.Target            = basePlayer;
            context.Score             = num1;
            context.LastKnownPosition = vector3_1;
        }
예제 #12
0
 internal void Forget(float maxSecondsOld)
 {
     for (int index1 = 0; index1 < this.All.Count; ++index1)
     {
         float num1 = Time.get_realtimeSinceStartup() - this.All[index1].Timestamp;
         if ((double)num1 > (double)maxSecondsOld)
         {
             if (Object.op_Inequality((Object)this.All[index1].Entity, (Object)null))
             {
                 this.Visible.Remove(this.All[index1].Entity);
                 for (int index2 = 0; index2 < this.AllExtended.Count; ++index2)
                 {
                     if (Object.op_Equality((Object)this.AllExtended[index2].Entity, (Object)this.All[index1].Entity))
                     {
                         this.AllExtended.RemoveAt(index2);
                         break;
                     }
                 }
             }
             this.All.RemoveAt(index1);
             --index1;
         }
         else if ((double)num1 > 0.0)
         {
             float num2 = num1 / maxSecondsOld;
             if ((double)this.All[index1].Danger > 0.0)
             {
                 Memory.SeenInfo seenInfo = this.All[index1];
                 seenInfo.Danger -= num2;
                 this.All[index1] = seenInfo;
             }
             if ((double)num1 >= 1.0)
             {
                 for (int index2 = 0; index2 < this.AllExtended.Count; ++index2)
                 {
                     if (Object.op_Equality((Object)this.AllExtended[index2].Entity, (Object)this.All[index1].Entity))
                     {
                         Memory.ExtendedInfo extendedInfo = this.AllExtended[index2];
                         extendedInfo.LineOfSight = (byte)0;
                         this.AllExtended[index2] = extendedInfo;
                         break;
                     }
                 }
             }
         }
     }
     for (int index = 0; index < this.Visible.Count; ++index)
     {
         if (Object.op_Equality((Object)this.Visible[index], (Object)null))
         {
             this.Visible.RemoveAt(index);
             --index;
         }
     }
     for (int index = 0; index < this.AllExtended.Count; ++index)
     {
         if (Object.op_Equality((Object)this.AllExtended[index].Entity, (Object)null))
         {
             this.AllExtended.RemoveAt(index);
             --index;
         }
     }
 }