public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            ScientistAStarContext npcContext = npc.AiDomain.NpcContext as ScientistAStarContext;

            if (npcContext == null)
            {
                return;
            }
            npcContext.SetFact(Facts.CanSeeEnemy, npcContext.EnemyPlayersInLineOfSight.Count > 0, true, true, true);
            float         num1           = 0.0f;
            NpcPlayerInfo npcPlayerInfo1 = new NpcPlayerInfo();

            foreach (NpcPlayerInfo npcPlayerInfo2 in npc.AiDomain.NpcContext.EnemyPlayersInLineOfSight)
            {
                float num2 = (float)((1.0 - (double)npcPlayerInfo2.SqrDistance / (double)npc.AiDefinition.Engagement.SqrAggroRange) * 2.0) + (float)(((double)npcPlayerInfo2.ForwardDotDir + 1.0) * 0.5);
                if ((double)num2 > (double)num1)
                {
                    num1           = num2;
                    npcPlayerInfo1 = npcPlayerInfo2;
                }
                NpcPlayerInfo info = npcPlayerInfo2;
                info.VisibilityScore = num2;
                npcContext.Memory.RememberEnemyPlayer(npc, ref info, time, 0.0f, "SEE!");
            }
            npcContext.PrimaryEnemyPlayerInLineOfSight = npcPlayerInfo1;
            if (!Object.op_Inequality((Object)npcPlayerInfo1.Player, (Object)null) || !Object.op_Equality((Object)npcContext.Memory.PrimaryKnownEnemyPlayer.PlayerInfo.Player, (Object)null) && (double)npcContext.Memory.PrimaryKnownEnemyPlayer.PlayerInfo.AudibleScore >= (double)num1)
            {
                return;
            }
            npcContext.Memory.RememberPrimaryEnemyPlayer(npcPlayerInfo1.Player);
            npcContext.IncrementFact(Facts.Alertness, 2, true, true, true);
        }
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            ScientistAStarContext npcContext = npc.AiDomain.NpcContext as ScientistAStarContext;

            if (npcContext == null)
            {
                return;
            }
            for (int index = 0; index < npcContext.Memory.KnownTimedExplosives.Count; ++index)
            {
                BaseNpcMemory.EntityOfInterestInfo knownTimedExplosive = npcContext.Memory.KnownTimedExplosives[index];
                if (Object.op_Inequality((Object)knownTimedExplosive.Entity, (Object)null))
                {
                    AttackEntity firearm = npcContext.Domain.GetFirearm();
                    Vector3      vector3 = Vector3.op_Subtraction(((Component)knownTimedExplosive.Entity).get_transform().get_position(), npcContext.BodyPosition);
                    if ((double)((Vector3) ref vector3).get_sqrMagnitude() < (double)npcContext.Body.AiDefinition.Engagement.SqrCloseRangeFirearm(firearm))
                    {
                        npcContext.SetFact(Rust.Ai.HTN.ScientistAStar.Facts.NearbyExplosives, true, true, true, true);
                        npcContext.IncrementFact(Rust.Ai.HTN.ScientistAStar.Facts.Alertness, 2, true, true, true);
                        return;
                    }
                }
            }
            npcContext.SetFact(Rust.Ai.HTN.ScientistAStar.Facts.NearbyExplosives, false, true, true, true);
        }
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            ScientistAStarContext npcContext = npc.AiDomain.NpcContext as ScientistAStarContext;

            if (npcContext == null)
            {
                return;
            }
            npcContext.SetFact(Facts.CanSeeEnemy, npcContext.EnemyPlayersInLineOfSight.Count > 0, true, true, true);
            float         single        = 0f;
            NpcPlayerInfo npcPlayerInfo = new NpcPlayerInfo();

            foreach (NpcPlayerInfo enemyPlayersInLineOfSight in npc.AiDomain.NpcContext.EnemyPlayersInLineOfSight)
            {
                float forwardDotDir = (enemyPlayersInLineOfSight.ForwardDotDir + 1f) * 0.5f;
                float sqrDistance   = (1f - enemyPlayersInLineOfSight.SqrDistance / npc.AiDefinition.Engagement.SqrAggroRange) * 2f + forwardDotDir;
                if (sqrDistance > single)
                {
                    single        = sqrDistance;
                    npcPlayerInfo = enemyPlayersInLineOfSight;
                }
                NpcPlayerInfo npcPlayerInfo1 = enemyPlayersInLineOfSight;
                npcPlayerInfo1.VisibilityScore = sqrDistance;
                npcContext.Memory.RememberEnemyPlayer(npc, ref npcPlayerInfo1, time, 0f, "SEE!");
            }
            npcContext.PrimaryEnemyPlayerInLineOfSight = npcPlayerInfo;
            if (npcPlayerInfo.Player != null && (npcContext.Memory.PrimaryKnownEnemyPlayer.PlayerInfo.Player == null || npcContext.Memory.PrimaryKnownEnemyPlayer.PlayerInfo.AudibleScore < single))
            {
                npcContext.Memory.RememberPrimaryEnemyPlayer(npcPlayerInfo.Player);
                npcContext.IncrementFact(Facts.Alertness, 2, true, true, true);
            }
        }
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            ScientistAStarContext npcContext = npc.AiDomain.NpcContext as ScientistAStarContext;

            if (npcContext == null || !npcContext.IsFact(Facts.Frustration) || (double)time - (double)this._lastFrustrationDecrementTime <= 5.0)
            {
                return;
            }
            this._lastFrustrationDecrementTime = time;
            npcContext.IncrementFact(Facts.Frustration, -1, true, true, true);
        }
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            ScientistAStarContext npcContext = npc.AiDomain.NpcContext as ScientistAStarContext;

            if (npcContext == null)
            {
                return;
            }
            if (npcContext.IsFact(Facts.Frustration) && time - this._lastFrustrationDecrementTime > 5f)
            {
                this._lastFrustrationDecrementTime = time;
                npcContext.IncrementFact(Facts.Frustration, -1, true, true, true);
            }
        }
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            ScientistAStarContext npcContext = npc.AiDomain.NpcContext as ScientistAStarContext;

            if (npcContext == null)
            {
                return;
            }
            HTNPlayer htnPlayer = npc as HTNPlayer;

            if (Object.op_Equality((Object)htnPlayer, (Object)null) || (double)time - (double)htnPlayer.lastAttackedTime <= 3.0 || (!npcContext.IsFact(Rust.Ai.HTN.ScientistAStar.Facts.Vulnerability) || (double)time - (double)this._lastVulnerabilityDecrementTime <= 2.0))
            {
                return;
            }
            this._lastVulnerabilityDecrementTime = time;
            npcContext.IncrementFact(Rust.Ai.HTN.ScientistAStar.Facts.Vulnerability, -1, true, true, true);
        }
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            ScientistAStarContext npcContext = npc.AiDomain.NpcContext as ScientistAStarContext;

            if (npcContext == null || !npcContext.IsFact(Facts.Alertness))
            {
                return;
            }
            if (npcContext.GetFact(Facts.Alertness) > (byte)10)
            {
                npcContext.SetFact(Facts.Alertness, 10, true, false, true);
            }
            if ((double)time - (double)this._lastFrustrationDecrementTime <= 1.0)
            {
                return;
            }
            this._lastFrustrationDecrementTime = time;
            npcContext.IncrementFact(Facts.Alertness, -1, true, true, true);
        }
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            ScientistAStarContext npcContext = npc.AiDomain.NpcContext as ScientistAStarContext;

            if (npcContext == null)
            {
                return;
            }
            HTNPlayer hTNPlayer = npc as HTNPlayer;

            if (hTNPlayer == null)
            {
                return;
            }
            if (time - hTNPlayer.lastAttackedTime > 3f && npcContext.IsFact(Facts.Vulnerability) && time - this._lastVulnerabilityDecrementTime > 2f)
            {
                this._lastVulnerabilityDecrementTime = time;
                npcContext.IncrementFact(Facts.Vulnerability, -1, true, true, true);
            }
        }
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            ScientistAStarContext npcContext = npc.AiDomain.NpcContext as ScientistAStarContext;

            if (npcContext == null)
            {
                return;
            }
            npcContext.SetFact(Facts.CanHearEnemy, npcContext.EnemyPlayersAudible.Count > 0, true, true, true);
            float         single        = 0f;
            NpcPlayerInfo npcPlayerInfo = new NpcPlayerInfo();

            foreach (NpcPlayerInfo enemyPlayersAudible in npc.AiDomain.NpcContext.EnemyPlayersAudible)
            {
                if (enemyPlayersAudible.SqrDistance > npc.AiDefinition.Sensory.SqrHearingRange)
                {
                    continue;
                }
                float single1 = 1f - Mathf.Min(1f, enemyPlayersAudible.SqrDistance / npc.AiDefinition.Sensory.SqrHearingRange);
                float single2 = single1 * 2f;
                if (single2 > single)
                {
                    single        = single2;
                    npcPlayerInfo = enemyPlayersAudible;
                }
                NpcPlayerInfo npcPlayerInfo1 = enemyPlayersAudible;
                npcPlayerInfo1.AudibleScore = single2;
                npcContext.Memory.RememberEnemyPlayer(npc, ref npcPlayerInfo1, time, (1f - single1) * 20f, "SOUND!");
            }
            npcContext.PrimaryEnemyPlayerAudible = npcPlayerInfo;
            if (npcPlayerInfo.Player != null && (npcContext.Memory.PrimaryKnownEnemyPlayer.PlayerInfo.Player == null || npcContext.Memory.PrimaryKnownEnemyPlayer.PlayerInfo.VisibilityScore < single))
            {
                npcContext.Memory.RememberPrimaryEnemyPlayer(npcPlayerInfo.Player);
                npcContext.IncrementFact(Facts.Alertness, 1, true, true, true);
            }
        }
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            ScientistAStarContext npcContext = npc.AiDomain.NpcContext as ScientistAStarContext;

            if (npcContext == null)
            {
                return;
            }
            npcContext.SetFact(Facts.CanHearEnemy, npcContext.EnemyPlayersAudible.Count > 0, true, true, true);
            float         num1           = 0.0f;
            NpcPlayerInfo npcPlayerInfo1 = new NpcPlayerInfo();

            foreach (NpcPlayerInfo npcPlayerInfo2 in npc.AiDomain.NpcContext.EnemyPlayersAudible)
            {
                if ((double)npcPlayerInfo2.SqrDistance <= (double)npc.AiDefinition.Sensory.SqrHearingRange)
                {
                    float num2 = 1f - Mathf.Min(1f, npcPlayerInfo2.SqrDistance / npc.AiDefinition.Sensory.SqrHearingRange);
                    float num3 = num2 * 2f;
                    if ((double)num3 > (double)num1)
                    {
                        num1           = num3;
                        npcPlayerInfo1 = npcPlayerInfo2;
                    }
                    NpcPlayerInfo info = npcPlayerInfo2;
                    info.AudibleScore = num3;
                    npcContext.Memory.RememberEnemyPlayer(npc, ref info, time, (float)((1.0 - (double)num2) * 20.0), "SOUND!");
                }
            }
            npcContext.PrimaryEnemyPlayerAudible = npcPlayerInfo1;
            if (!Object.op_Inequality((Object)npcPlayerInfo1.Player, (Object)null) || !Object.op_Equality((Object)npcContext.Memory.PrimaryKnownEnemyPlayer.PlayerInfo.Player, (Object)null) && (double)npcContext.Memory.PrimaryKnownEnemyPlayer.PlayerInfo.VisibilityScore >= (double)num1)
            {
                return;
            }
            npcContext.Memory.RememberPrimaryEnemyPlayer(npcPlayerInfo1.Player);
            npcContext.IncrementFact(Facts.Alertness, 1, true, true, true);
        }
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            ScientistAStarContext npcContext = npc.AiDomain.NpcContext as ScientistAStarContext;

            if (npcContext == null)
            {
                return;
            }
            for (int i = 0; i < npcContext.Memory.KnownTimedExplosives.Count; i++)
            {
                BaseNpcMemory.EntityOfInterestInfo item = npcContext.Memory.KnownTimedExplosives[i];
                if (item.Entity != null)
                {
                    AttackEntity firearm = npcContext.Domain.GetFirearm();
                    if ((item.Entity.transform.position - npcContext.BodyPosition).sqrMagnitude < npcContext.Body.AiDefinition.Engagement.SqrCloseRangeFirearm(firearm))
                    {
                        npcContext.SetFact(Facts.NearbyExplosives, true, true, true, true);
                        npcContext.IncrementFact(Facts.Alertness, 2, true, true, true);
                        return;
                    }
                }
            }
            npcContext.SetFact(Facts.NearbyExplosives, false, true, true, true);
        }