Exemple #1
0
        public static Ray AimAtHead(HTNAnimal npc, ref NpcPlayerInfo info)
        {
            Vector3 vector3 = npc.CenterPoint();
            Vector3 player  = info.Player.eyes.position - npc.CenterPoint();

            return(new Ray(vector3, player.normalized));
        }
Exemple #2
0
        public override BaseCorpse OnCreateCorpse(HTNAnimal target)
        {
            BaseCorpse baseCorpse;

            if (this.DeathEffect.isValid)
            {
                Effect.server.Run(this.DeathEffect.resourcePath, target, 0, Vector3.zero, Vector3.zero, null, false);
            }
            using (TimeWarning timeWarning = TimeWarning.New("Create corpse", 0.1f))
            {
                BaseCorpse navAgent = target.DropCorpse(this.CorpsePrefab.resourcePath);
                if (navAgent)
                {
                    if (target.AiDomain != null && target.AiDomain.NavAgent != null && target.AiDomain.NavAgent.isOnNavMesh)
                    {
                        navAgent.transform.position = navAgent.transform.position + (Vector3.down * target.AiDomain.NavAgent.baseOffset);
                    }
                    navAgent.InitCorpse(target);
                    navAgent.Spawn();
                    navAgent.TakeChildren(target);
                }
                baseCorpse = navAgent;
            }
            return(baseCorpse);
        }
        public BearContext(HTNAnimal body, BearDomain domain)
        {
            int length = Enum.GetValues(typeof(Facts)).Length;

            if (this._worldState == null || (int)this._worldState.Length != length)
            {
                this._worldState         = new byte[length];
                this._previousWorldState = new byte[length];
                if (BearContext._worldStateChanges == null)
                {
                    BearContext._worldStateChanges = new Stack <WorldStateInfo> [length];
                    for (int i = 0; i < length; i++)
                    {
                        BearContext._worldStateChanges[i] = new Stack <WorldStateInfo>(5);
                    }
                }
            }
            this._decompositionScore = 2147483647;
            this.Body      = body;
            this.Domain    = domain;
            this.PlanState = PlanStateType.NoPlan;
            if (this.Memory == null || this.Memory.BearContext != this)
            {
                this.Memory = new BearMemory(this);
            }
        }
Exemple #4
0
        public static Ray AimAtBody(HTNAnimal npc, ref NpcPlayerInfo info)
        {
            Vector3 vector3  = npc.CenterPoint();
            Vector3 vector31 = info.Player.CenterPoint() - npc.CenterPoint();

            return(new Ray(vector3, vector31.normalized));
        }
        public BearContext(HTNAnimal body, BearDomain domain)
        {
            int length = System.Enum.GetValues(typeof(Facts)).Length;

            if (this._worldState == null || this._worldState.Length != length)
            {
                this._worldState         = new byte[length];
                this._previousWorldState = new byte[length];
                if (BearContext._worldStateChanges == null)
                {
                    BearContext._worldStateChanges = new Stack <WorldStateInfo> [length];
                    for (int index = 0; index < length; ++index)
                    {
                        BearContext._worldStateChanges[index] = new Stack <WorldStateInfo>(5);
                    }
                }
            }
            this._decompositionScore = int.MaxValue;
            this.Body      = body;
            this.Domain    = domain;
            this.PlanState = (PlanStateType)0;
            if (this.Memory != null && this.Memory.BearContext == this)
            {
                return;
            }
            this.Memory = new BearMemory(this);
        }
Exemple #6
0
        public static Ray AimAtHead(HTNAnimal npc, ref NpcPlayerInfo info)
        {
            Vector3 vector3_1  = npc.CenterPoint();
            Vector3 vector3_2  = Vector3.op_Subtraction(info.Player.eyes.position, npc.CenterPoint());
            Vector3 normalized = ((Vector3) ref vector3_2).get_normalized();

            return(new Ray(vector3_1, normalized));
        }
 public override void StopVoices(HTNAnimal target)
 {
     if (!this._isEffectRunning)
     {
         return;
     }
     this._isEffectRunning = false;
 }
 public override void StartVoices(HTNAnimal target)
 {
     if (this._isEffectRunning)
     {
         return;
     }
     this._isEffectRunning = true;
     ((MonoBehaviour)target).StartCoroutine(this.PlayEffects(target));
 }
 private IEnumerator PlayEffects(HTNAnimal target)
 {
     while (this._isEffectRunning && Object.op_Inequality((Object)target, (Object)null) && (Object.op_Inequality((Object)((Component)target).get_transform(), (Object)null) && !target.IsDestroyed) && !target.IsDead())
     {
         if (this.IdleEffect.isValid)
         {
             Effect.server.Run(this.IdleEffect.resourcePath, (BaseEntity)target, StringPool.Get("head"), Vector3.get_zero(), Vector3.get_zero(), (Connection)null, false);
         }
         yield return((object)CoroutineEx.waitForSeconds(Random.Range((float)this.IdleEffectRepeatRange.x, (float)(this.IdleEffectRepeatRange.y + 1.0))));
     }
 }
Exemple #10
0
        private IEnumerator PlayEffects(HTNAnimal target)
        {
            BearDefinition bearDefinition = null;

            while (bearDefinition._isEffectRunning && target != null && target.transform != null && !target.IsDestroyed && !target.IsDead())
            {
                if (bearDefinition.IdleEffect.isValid)
                {
                    Effect.server.Run(bearDefinition.IdleEffect.resourcePath, target, StringPool.Get("head"), Vector3.zero, Vector3.zero, null, false);
                }
                float single = UnityEngine.Random.Range(bearDefinition.IdleEffectRepeatRange.x, bearDefinition.IdleEffectRepeatRange.y + 1f);
                yield return(CoroutineEx.waitForSeconds(single));
            }
        }
Exemple #11
0
        public static Ray AimAtBody(IHTNAgent npc, ref NpcPlayerInfo info)
        {
            HTNPlayer npc1 = npc as HTNPlayer;

            if (Object.op_Inequality((Object)npc1, (Object)null))
            {
                return(BearEnemyPlayersLineOfSightSensor.AimAtBody(npc1, ref info));
            }
            HTNAnimal npc2 = npc as HTNAnimal;

            if (Object.op_Inequality((Object)npc2, (Object)null))
            {
                return(BearEnemyPlayersLineOfSightSensor.AimAtBody(npc2, ref info));
            }
            return((Ray)null);
        }
Exemple #12
0
        public static Ray AimAtHead(IHTNAgent npc, ref NpcPlayerInfo info)
        {
            HTNPlayer hTNPlayer = npc as HTNPlayer;

            if (hTNPlayer != null)
            {
                return(BearEnemyPlayersLineOfSightSensor.AimAtHead(hTNPlayer, ref info));
            }
            HTNAnimal hTNAnimal = npc as HTNAnimal;

            if (hTNAnimal != null)
            {
                return(BearEnemyPlayersLineOfSightSensor.AimAtHead(hTNAnimal, ref info));
            }
            return(new Ray());
        }
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            BearContext npcContext = npc.AiDomain.NpcContext as BearContext;

            if (npcContext == null)
            {
                return;
            }
            HTNAnimal htnAnimal = npc as HTNAnimal;

            if (Object.op_Equality((Object)htnAnimal, (Object)null) || (double)time - (double)htnAnimal.lastAttackedTime <= 3.0 || (!npcContext.IsFact(Rust.Ai.HTN.Bear.Facts.Vulnerability) || (double)time - (double)this._lastVulnerabilityDecrementTime <= 2.0))
            {
                return;
            }
            this._lastVulnerabilityDecrementTime = time;
            npcContext.IncrementFact(Rust.Ai.HTN.Bear.Facts.Vulnerability, -1, true, true, true);
        }
Exemple #14
0
 private void AgencyAddPending()
 {
     if (AiManager.ai_dormant)
     {
         foreach (IHTNAgent hTNAgent in this.pendingAddToDormant)
         {
             if (hTNAgent == null || hTNAgent.IsDestroyed)
             {
                 continue;
             }
             this.dormantAgents.Add(hTNAgent);
             hTNAgent.IsDormant = true;
         }
         this.pendingAddToDormant.Clear();
     }
     foreach (IHTNAgent hTNAgent1 in this.pendingAddToActive)
     {
         if (hTNAgent1 == null || hTNAgent1.IsDestroyed || !this.activeAgents.Add(hTNAgent1))
         {
             continue;
         }
         hTNAgent1.IsDormant = false;
         HTNPlayer hTNPlayer = hTNAgent1 as HTNPlayer;
         if (!hTNPlayer)
         {
             HTNAnimal hTNAnimal = hTNAgent1 as HTNAnimal;
             if (!hTNAnimal)
             {
                 continue;
             }
             this.tickingAnimals.Add(hTNAnimal);
         }
         else if (!(hTNPlayer.AiDomain is ScientistJunkpileDomain))
         {
             this.tickingPlayers.Add(hTNPlayer);
         }
         else
         {
             this.tickingJunkpilePlayers.Add(hTNPlayer);
         }
     }
     this.pendingAddToActive.Clear();
 }
Exemple #15
0
 private void AgencyAddPending()
 {
     if (AiManager.ai_dormant)
     {
         foreach (IHTNAgent htnAgent in this.pendingAddToDormant)
         {
             if (htnAgent != null && !htnAgent.IsDestroyed)
             {
                 this.dormantAgents.Add(htnAgent);
                 htnAgent.IsDormant = true;
             }
         }
         this.pendingAddToDormant.Clear();
     }
     foreach (IHTNAgent htnAgent in this.pendingAddToActive)
     {
         if (htnAgent != null && !htnAgent.IsDestroyed && this.activeAgents.Add(htnAgent))
         {
             htnAgent.IsDormant = false;
             HTNPlayer htnPlayer = htnAgent as HTNPlayer;
             if (Object.op_Implicit((Object)htnPlayer))
             {
                 if (htnPlayer.AiDomain is ScientistJunkpileDomain)
                 {
                     this.tickingJunkpilePlayers.Add(htnPlayer);
                 }
                 else
                 {
                     this.tickingPlayers.Add(htnPlayer);
                 }
             }
             else
             {
                 HTNAnimal htnAnimal = htnAgent as HTNAnimal;
                 if (Object.op_Implicit((Object)htnAnimal))
                 {
                     this.tickingAnimals.Add(htnAnimal);
                 }
             }
         }
     }
     this.pendingAddToActive.Clear();
 }
Exemple #16
0
 private void AgencyCleanup()
 {
     if (AiManager.ai_dormant)
     {
         foreach (IHTNAgent htnAgent in this.pendingRemoveFromDormant)
         {
             if (htnAgent != null)
             {
                 this.dormantAgents.Remove(htnAgent);
             }
         }
         this.pendingRemoveFromDormant.Clear();
     }
     foreach (IHTNAgent htnAgent in this.pendingRemoveFromActive)
     {
         if (htnAgent != null)
         {
             this.activeAgents.Remove(htnAgent);
             HTNPlayer htnPlayer = htnAgent as HTNPlayer;
             if (Object.op_Implicit((Object)htnPlayer))
             {
                 if (htnPlayer.AiDomain is ScientistJunkpileDomain)
                 {
                     this.tickingJunkpilePlayers.Remove(htnPlayer);
                 }
                 else
                 {
                     this.tickingPlayers.Remove(htnPlayer);
                 }
             }
             else
             {
                 HTNAnimal htnAnimal = htnAgent as HTNAnimal;
                 if (Object.op_Implicit((Object)htnAnimal))
                 {
                     this.tickingAnimals.Remove(htnAnimal);
                 }
             }
         }
     }
     this.pendingRemoveFromActive.Clear();
 }
Exemple #17
0
 private void AgencyCleanup()
 {
     if (AiManager.ai_dormant)
     {
         foreach (IHTNAgent hTNAgent in this.pendingRemoveFromDormant)
         {
             if (hTNAgent == null)
             {
                 continue;
             }
             this.dormantAgents.Remove(hTNAgent);
         }
         this.pendingRemoveFromDormant.Clear();
     }
     foreach (IHTNAgent hTNAgent1 in this.pendingRemoveFromActive)
     {
         if (hTNAgent1 == null)
         {
             continue;
         }
         this.activeAgents.Remove(hTNAgent1);
         HTNPlayer hTNPlayer = hTNAgent1 as HTNPlayer;
         if (!hTNPlayer)
         {
             HTNAnimal hTNAnimal = hTNAgent1 as HTNAnimal;
             if (!hTNAnimal)
             {
                 continue;
             }
             this.tickingAnimals.Remove(hTNAnimal);
         }
         else if (!(hTNPlayer.AiDomain is ScientistJunkpileDomain))
         {
             this.tickingPlayers.Remove(hTNPlayer);
         }
         else
         {
             this.tickingJunkpilePlayers.Remove(hTNPlayer);
         }
     }
     this.pendingRemoveFromActive.Clear();
 }
Exemple #18
0
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            BearContext npcContext = npc.AiDomain.NpcContext as BearContext;

            if (npcContext == null)
            {
                return;
            }
            HTNAnimal htnAnimal = npc as HTNAnimal;

            if (Object.op_Equality((Object)htnAnimal, (Object)null))
            {
                return;
            }
            NpcOrientation npcOrientation = NpcOrientation.Heading;

            if (npc.IsDestroyed || htnAnimal.IsDead())
            {
                npcOrientation = NpcOrientation.None;
            }
            else if (Object.op_Inequality((Object)npcContext.Memory.PrimaryKnownAnimal.Animal, (Object)null))
            {
                npcOrientation = !Object.op_Inequality((Object)npcContext.PrimaryEnemyPlayerInLineOfSight.Player, (Object)null) ? NpcOrientation.LookAtAnimal : ((double)npcContext.Memory.PrimaryKnownAnimal.SqrDistance >= (double)npcContext.PrimaryEnemyPlayerInLineOfSight.SqrDistance ? (npcContext.PrimaryEnemyPlayerInLineOfSight.BodyVisible ? NpcOrientation.PrimaryTargetBody : (npcContext.PrimaryEnemyPlayerInLineOfSight.HeadVisible ? NpcOrientation.PrimaryTargetHead : NpcOrientation.LastKnownPrimaryTargetLocation)) : NpcOrientation.LookAtAnimal);
            }
            else if (Object.op_Inequality((Object)npcContext.PrimaryEnemyPlayerInLineOfSight.Player, (Object)null))
            {
                npcOrientation = npcContext.PrimaryEnemyPlayerInLineOfSight.BodyVisible ? NpcOrientation.PrimaryTargetBody : (npcContext.PrimaryEnemyPlayerInLineOfSight.HeadVisible ? NpcOrientation.PrimaryTargetHead : NpcOrientation.LastKnownPrimaryTargetLocation);
            }
            else if (Object.op_Inequality((Object)htnAnimal.lastAttacker, (Object)null) && (double)htnAnimal.lastAttackedTime > 0.0 && (double)time - (double)htnAnimal.lastAttackedTime < 2.0)
            {
                npcOrientation = NpcOrientation.LastAttackedDirection;
            }
            else if (Object.op_Inequality((Object)npcContext.Memory.PrimaryKnownEnemyPlayer.PlayerInfo.Player, (Object)null))
            {
                npcOrientation = npcContext.GetFact(Rust.Ai.HTN.Bear.Facts.IsSearching) <= (byte)0 || npcContext.GetFact(Rust.Ai.HTN.Bear.Facts.IsNavigating) != (byte)0 ? (npcContext.GetFact(Rust.Ai.HTN.Bear.Facts.IsIdle) <= (byte)0 ? NpcOrientation.LastKnownPrimaryTargetLocation : (!npcContext.IsFact(Rust.Ai.HTN.Bear.Facts.CanHearEnemy) ? NpcOrientation.Heading : NpcOrientation.AudibleTargetDirection)) : NpcOrientation.LookAround;
            }
            else if (npcContext.IsFact(Rust.Ai.HTN.Bear.Facts.CanHearEnemy))
            {
                npcOrientation = NpcOrientation.AudibleTargetDirection;
            }
            npcContext.OrientationType = npcOrientation;
        }
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            BearContext npcContext = npc.AiDomain.NpcContext as BearContext;

            if (npcContext == null)
            {
                return;
            }
            HTNAnimal hTNAnimal = npc as HTNAnimal;

            if (hTNAnimal == null)
            {
                return;
            }
            if (time - hTNAnimal.lastAttackedTime > 3f && npcContext.IsFact(Facts.Vulnerability) && time - this._lastVulnerabilityDecrementTime > 2f)
            {
                this._lastVulnerabilityDecrementTime = time;
                npcContext.IncrementFact(Facts.Vulnerability, -1, true, true, true);
            }
        }
 public override BaseCorpse OnCreateCorpse(HTNAnimal target)
 {
     if (this.DeathEffect.isValid)
     {
         Effect.server.Run(this.DeathEffect.resourcePath, (BaseEntity)target, 0U, Vector3.get_zero(), Vector3.get_zero(), (Connection)null, false);
     }
     using (TimeWarning.New("Create corpse", 0.1f))
     {
         BaseCorpse baseCorpse = target.DropCorpse(this.CorpsePrefab.resourcePath);
         if (Object.op_Implicit((Object)baseCorpse))
         {
             if (Object.op_Inequality((Object)target.AiDomain, (Object)null) && Object.op_Inequality((Object)target.AiDomain.NavAgent, (Object)null) && target.AiDomain.NavAgent.get_isOnNavMesh())
             {
                 ((Component)baseCorpse).get_transform().set_position(Vector3.op_Addition(((Component)baseCorpse).get_transform().get_position(), Vector3.op_Multiply(Vector3.get_down(), target.AiDomain.NavAgent.get_baseOffset())));
             }
             baseCorpse.InitCorpse((BaseEntity)target);
             baseCorpse.Spawn();
             baseCorpse.TakeChildren((BaseEntity)target);
         }
         return(baseCorpse);
     }
 }
Exemple #21
0
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            NpcOrientation npcOrientation;
            NpcOrientation npcOrientation1;
            BearContext    npcContext = npc.AiDomain.NpcContext as BearContext;

            if (npcContext == null)
            {
                return;
            }
            HTNAnimal hTNAnimal = npc as HTNAnimal;

            if (hTNAnimal == null)
            {
                return;
            }
            NpcOrientation npcOrientation2 = NpcOrientation.Heading;

            if (npc.IsDestroyed || hTNAnimal.IsDead())
            {
                npcOrientation2 = NpcOrientation.None;
            }
            else if (npcContext.Memory.PrimaryKnownAnimal.Animal != null)
            {
                if (npcContext.PrimaryEnemyPlayerInLineOfSight.Player == null)
                {
                    npcOrientation2 = NpcOrientation.LookAtAnimal;
                }
                else if (npcContext.Memory.PrimaryKnownAnimal.SqrDistance >= npcContext.PrimaryEnemyPlayerInLineOfSight.SqrDistance)
                {
                    if (npcContext.PrimaryEnemyPlayerInLineOfSight.BodyVisible)
                    {
                        npcOrientation1 = NpcOrientation.PrimaryTargetBody;
                    }
                    else
                    {
                        npcOrientation1 = (npcContext.PrimaryEnemyPlayerInLineOfSight.HeadVisible ? NpcOrientation.PrimaryTargetHead : NpcOrientation.LastKnownPrimaryTargetLocation);
                    }
                    npcOrientation2 = npcOrientation1;
                }
                else
                {
                    npcOrientation2 = NpcOrientation.LookAtAnimal;
                }
            }
            else if (npcContext.PrimaryEnemyPlayerInLineOfSight.Player != null)
            {
                if (npcContext.PrimaryEnemyPlayerInLineOfSight.BodyVisible)
                {
                    npcOrientation = NpcOrientation.PrimaryTargetBody;
                }
                else
                {
                    npcOrientation = (npcContext.PrimaryEnemyPlayerInLineOfSight.HeadVisible ? NpcOrientation.PrimaryTargetHead : NpcOrientation.LastKnownPrimaryTargetLocation);
                }
                npcOrientation2 = npcOrientation;
            }
            else if (hTNAnimal.lastAttacker != null && hTNAnimal.lastAttackedTime > 0f && time - hTNAnimal.lastAttackedTime < 2f)
            {
                npcOrientation2 = NpcOrientation.LastAttackedDirection;
            }
            else if (npcContext.Memory.PrimaryKnownEnemyPlayer.PlayerInfo.Player == null)
            {
                if (npcContext.IsFact(Facts.CanHearEnemy))
                {
                    npcOrientation2 = NpcOrientation.AudibleTargetDirection;
                }
            }
            else if (npcContext.GetFact(Facts.IsSearching) > 0 && npcContext.GetFact(Facts.IsNavigating) == 0)
            {
                npcOrientation2 = NpcOrientation.LookAround;
            }
            else if (npcContext.GetFact(Facts.IsIdle) <= 0)
            {
                npcOrientation2 = NpcOrientation.LastKnownPrimaryTargetLocation;
            }
            else
            {
                npcOrientation2 = (!npcContext.IsFact(Facts.CanHearEnemy) ? NpcOrientation.Heading : NpcOrientation.AudibleTargetDirection);
            }
            npcContext.OrientationType = npcOrientation2;
        }
Exemple #22
0
            public void InvokedTick()
            {
                this.watch.Reset();
                this.watch.Start();
                int num = this.playerTickIndex;

                do
                {
                    if (this.tickingPlayers.Count <= 0)
                    {
                        break;
                    }
                    if (this.playerTickIndex >= this.tickingPlayers.Count)
                    {
                        this.playerTickIndex = 0;
                    }
                    HTNPlayer item = this.tickingPlayers[this.playerTickIndex];
                    if (item != null && item.transform != null && !item.IsDestroyed)
                    {
                        item.Tick();
                    }
                    this.playerTickIndex++;
                    if (this.playerTickIndex < this.tickingPlayers.Count)
                    {
                        continue;
                    }
                    this.playerTickIndex = 0;
                }while (this.playerTickIndex != num && this.watch.Elapsed.TotalMilliseconds <= (double)AiManager.ai_htn_player_tick_budget);
                this.watch.Reset();
                this.watch.Start();
                num = this.junkpilePlayerTickIndex;
                do
                {
                    if (this.tickingJunkpilePlayers.Count <= 0)
                    {
                        break;
                    }
                    if (this.junkpilePlayerTickIndex >= this.tickingJunkpilePlayers.Count)
                    {
                        this.junkpilePlayerTickIndex = 0;
                    }
                    HTNPlayer hTNPlayer = this.tickingJunkpilePlayers[this.junkpilePlayerTickIndex];
                    if (hTNPlayer != null && hTNPlayer.transform != null && !hTNPlayer.IsDestroyed)
                    {
                        hTNPlayer.Tick();
                    }
                    this.junkpilePlayerTickIndex++;
                    if (this.junkpilePlayerTickIndex < this.tickingJunkpilePlayers.Count)
                    {
                        continue;
                    }
                    this.junkpilePlayerTickIndex = 0;
                }while (this.junkpilePlayerTickIndex != num && this.watch.Elapsed.TotalMilliseconds <= (double)AiManager.ai_htn_player_junkpile_tick_budget);
                this.watch.Reset();
                this.watch.Start();
                num = this.animalTickIndex;
                do
                {
                    if (this.tickingAnimals.Count <= 0)
                    {
                        break;
                    }
                    if (this.animalTickIndex >= this.tickingAnimals.Count)
                    {
                        this.animalTickIndex = 0;
                    }
                    HTNAnimal hTNAnimal = this.tickingAnimals[this.animalTickIndex];
                    if (hTNAnimal != null && hTNAnimal.transform != null && !hTNAnimal.IsDestroyed)
                    {
                        hTNAnimal.Tick();
                    }
                    this.animalTickIndex++;
                    if (this.animalTickIndex < this.tickingAnimals.Count)
                    {
                        continue;
                    }
                    this.animalTickIndex = 0;
                }while (this.animalTickIndex != num && this.watch.Elapsed.TotalMilliseconds <= (double)AiManager.ai_htn_animal_tick_budget);
            }
Exemple #23
0
 public virtual BaseCorpse OnCreateCorpse(HTNAnimal target)
 {
     return((BaseCorpse)null);
 }
Exemple #24
0
 public virtual void StopVoices(HTNAnimal target)
 {
 }
Exemple #25
0
 public virtual void Loadout(HTNAnimal target)
 {
 }
Exemple #26
0
            public void InvokedTick()
            {
                this.watch.Reset();
                this.watch.Start();
                int playerTickIndex = this.playerTickIndex;

                while (this.tickingPlayers.Count > 0)
                {
                    if (this.playerTickIndex >= this.tickingPlayers.Count)
                    {
                        this.playerTickIndex = 0;
                    }
                    HTNPlayer tickingPlayer = this.tickingPlayers[this.playerTickIndex];
                    if (Object.op_Inequality((Object)tickingPlayer, (Object)null) && Object.op_Inequality((Object)((Component)tickingPlayer).get_transform(), (Object)null) && !tickingPlayer.IsDestroyed)
                    {
                        tickingPlayer.Tick();
                    }
                    ++this.playerTickIndex;
                    if (this.playerTickIndex >= this.tickingPlayers.Count)
                    {
                        this.playerTickIndex = 0;
                    }
                    if (this.playerTickIndex == playerTickIndex || this.watch.Elapsed.TotalMilliseconds > (double)AiManager.ai_htn_player_tick_budget)
                    {
                        break;
                    }
                }
                this.watch.Reset();
                this.watch.Start();
                int junkpilePlayerTickIndex = this.junkpilePlayerTickIndex;

                while (this.tickingJunkpilePlayers.Count > 0)
                {
                    if (this.junkpilePlayerTickIndex >= this.tickingJunkpilePlayers.Count)
                    {
                        this.junkpilePlayerTickIndex = 0;
                    }
                    HTNPlayer tickingJunkpilePlayer = this.tickingJunkpilePlayers[this.junkpilePlayerTickIndex];
                    if (Object.op_Inequality((Object)tickingJunkpilePlayer, (Object)null) && Object.op_Inequality((Object)((Component)tickingJunkpilePlayer).get_transform(), (Object)null) && !tickingJunkpilePlayer.IsDestroyed)
                    {
                        tickingJunkpilePlayer.Tick();
                    }
                    ++this.junkpilePlayerTickIndex;
                    if (this.junkpilePlayerTickIndex >= this.tickingJunkpilePlayers.Count)
                    {
                        this.junkpilePlayerTickIndex = 0;
                    }
                    if (this.junkpilePlayerTickIndex == junkpilePlayerTickIndex || this.watch.Elapsed.TotalMilliseconds > (double)AiManager.ai_htn_player_junkpile_tick_budget)
                    {
                        break;
                    }
                }
                this.watch.Reset();
                this.watch.Start();
                int animalTickIndex = this.animalTickIndex;

                while (this.tickingAnimals.Count > 0)
                {
                    if (this.animalTickIndex >= this.tickingAnimals.Count)
                    {
                        this.animalTickIndex = 0;
                    }
                    HTNAnimal tickingAnimal = this.tickingAnimals[this.animalTickIndex];
                    if (Object.op_Inequality((Object)tickingAnimal, (Object)null) && Object.op_Inequality((Object)((Component)tickingAnimal).get_transform(), (Object)null) && !tickingAnimal.IsDestroyed)
                    {
                        tickingAnimal.Tick();
                    }
                    ++this.animalTickIndex;
                    if (this.animalTickIndex >= this.tickingAnimals.Count)
                    {
                        this.animalTickIndex = 0;
                    }
                    if (this.animalTickIndex == animalTickIndex || this.watch.Elapsed.TotalMilliseconds > (double)AiManager.ai_htn_animal_tick_budget)
                    {
                        break;
                    }
                }
            }