示例#1
0
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            BearContext npcContext = npc.AiDomain.NpcContext as BearContext;

            if (npcContext == null)
            {
                return;
            }
            if (npcContext.Memory.PrimaryKnownEnemyPlayer.PlayerInfo.Player == null)
            {
                npcContext.SetFact(Facts.EnemyRange, EnemyRange.OutOfRange, true, true, true);
            }
            Vector3 lastKnownPosition = npcContext.Memory.PrimaryKnownEnemyPlayer.LastKnownPosition - npcContext.BodyPosition;
            float   single            = lastKnownPosition.sqrMagnitude;

            if (single <= npcContext.Body.AiDefinition.Engagement.SqrCloseRange)
            {
                npcContext.SetFact(Facts.EnemyRange, EnemyRange.CloseRange, true, true, true);
                return;
            }
            if (single <= npcContext.Body.AiDefinition.Engagement.SqrMediumRange)
            {
                npcContext.SetFact(Facts.EnemyRange, EnemyRange.MediumRange, true, true, true);
                return;
            }
            if (single <= npcContext.Body.AiDefinition.Engagement.SqrLongRange)
            {
                npcContext.SetFact(Facts.EnemyRange, EnemyRange.LongRange, true, true, true);
                return;
            }
            npcContext.SetFact(Facts.EnemyRange, EnemyRange.OutOfRange, true, true, true);
        }
示例#2
0
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            NavMeshHit  navMeshHit;
            BearContext npcContext = npc.AiDomain.NpcContext as BearContext;

            if (npcContext == null)
            {
                return;
            }
            if (!npcContext.IsFact(Facts.IsReturningHome))
            {
                if (npcContext.Memory.PrimaryKnownEnemyPlayer.PlayerInfo.Player == null || time - npcContext.Memory.PrimaryKnownEnemyPlayer.Time > npcContext.Body.AiDefinition.Memory.NoSeeReturnToSpawnTime)
                {
                    npcContext.SetFact(Facts.IsReturningHome, true, true, true, true);
                    if (NavMesh.SamplePosition(npcContext.Domain.SpawnPosition, out navMeshHit, 1f, npcContext.Domain.NavAgent.areaMask))
                    {
                        npcContext.Domain.SetDestination(navMeshHit.position);
                        return;
                    }
                }
            }
            else if (npcContext.IsFact(Facts.CanSeeEnemy) || time - npcContext.Body.lastAttackedTime < 2f || npcContext.IsFact(Facts.AtLocationHome))
            {
                npcContext.SetFact(Facts.IsReturningHome, false, true, true, true);
            }
        }
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            BearContext npcContext = npc.AiDomain.NpcContext as BearContext;

            if (npcContext == null)
            {
                return;
            }
            float healthFraction = npc.healthFraction;

            if ((double)healthFraction > 0.899999976158142)
            {
                npcContext.SetFact(Facts.HealthState, HealthState.FullHealth, true, true, true);
            }
            else if ((double)healthFraction > 0.600000023841858)
            {
                npcContext.SetFact(Facts.HealthState, HealthState.HighHealth, true, true, true);
            }
            else if ((double)healthFraction > 0.300000011920929)
            {
                npcContext.SetFact(Facts.HealthState, HealthState.MediumHealth, true, true, true);
            }
            else if ((double)healthFraction > 0.0)
            {
                npcContext.SetFact(Facts.HealthState, HealthState.LowHealth, true, true, true);
            }
            else
            {
                npcContext.SetFact(Facts.HealthState, HealthState.Dead, true, true, true);
            }
        }
示例#4
0
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            BearContext npcContext = npc.AiDomain.NpcContext as BearContext;

            if (npcContext == null)
            {
                return;
            }
            float single = npc.healthFraction;

            if (single > 0.9f)
            {
                npcContext.SetFact(Facts.HealthState, HealthState.FullHealth, true, true, true);
                return;
            }
            if (single > 0.6f)
            {
                npcContext.SetFact(Facts.HealthState, HealthState.HighHealth, true, true, true);
                return;
            }
            if (single > 0.3f)
            {
                npcContext.SetFact(Facts.HealthState, HealthState.MediumHealth, true, true, true);
                return;
            }
            if (single > 0f)
            {
                npcContext.SetFact(Facts.HealthState, HealthState.LowHealth, true, true, true);
                return;
            }
            npcContext.SetFact(Facts.HealthState, HealthState.Dead, true, true, true);
        }
示例#5
0
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            BearContext npcContext = npc.AiDomain.NpcContext as BearContext;

            if (npcContext == null)
            {
                return;
            }
            BaseNpc animal      = null;
            float   sqrDistance = Single.MaxValue;

            for (int i = 0; i < npcContext.AnimalsInRange.Count; i++)
            {
                AnimalInfo item = npcContext.AnimalsInRange[i];
                if (item.Animal != null && item.SqrDistance < sqrDistance)
                {
                    sqrDistance = item.SqrDistance;
                    animal      = item.Animal;
                }
            }
            if (!(animal != null) || sqrDistance >= npc.AiDefinition.Engagement.SqrMediumRange)
            {
                npcContext.SetFact(Facts.NearbyAnimal, false, true, true, true);
                return;
            }
            npcContext.Memory.RememberPrimaryAnimal(animal);
            npcContext.SetFact(Facts.NearbyAnimal, true, true, true, true);
        }
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            BearContext npcContext = npc.AiDomain.NpcContext as BearContext;

            if (npcContext == null)
            {
                return;
            }
            BaseNpc animal = (BaseNpc)null;
            float   num    = float.MaxValue;

            for (int index = 0; index < npcContext.AnimalsInRange.Count; ++index)
            {
                AnimalInfo animalInfo = npcContext.AnimalsInRange[index];
                if (Object.op_Inequality((Object)animalInfo.Animal, (Object)null) && (double)animalInfo.SqrDistance < (double)num)
                {
                    num    = animalInfo.SqrDistance;
                    animal = animalInfo.Animal;
                }
            }
            if (Object.op_Inequality((Object)animal, (Object)null) && (double)num < (double)npc.AiDefinition.Engagement.SqrMediumRange)
            {
                npcContext.Memory.RememberPrimaryAnimal(animal);
                npcContext.SetFact(Rust.Ai.HTN.Bear.Facts.NearbyAnimal, true, true, true, true);
            }
            else
            {
                npcContext.SetFact(Rust.Ai.HTN.Bear.Facts.NearbyAnimal, false, true, true, true);
            }
        }
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            BearContext npcContext = npc.AiDomain.NpcContext as BearContext;

            if (npcContext == null)
            {
                return;
            }
            npcContext.SetFact(Facts.HasEnemyTarget, npcContext.Memory.PrimaryKnownEnemyPlayer.PlayerInfo.Player != null, true, true, true);
        }
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            BearContext npcContext = npc.AiDomain.NpcContext as BearContext;

            if (npcContext == null)
            {
                return;
            }
            npcContext.SetFact(Facts.HasPlayersInRange, npcContext.PlayersInRange.Count > 0, true, true, true);
        }
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            BearContext npcContext = npc.AiDomain.NpcContext as BearContext;

            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)
        {
            BearContext npcContext = npc.AiDomain.NpcContext as BearContext;

            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)
        {
            BearContext npcContext = npc.AiDomain.NpcContext as BearContext;

            if (npcContext == null)
            {
                return;
            }
            Vector3 vector3 = Vector3.op_Subtraction(npcContext.BodyPosition, npcContext.Domain.SpawnPosition);

            if ((double)((Vector3) ref vector3).get_sqrMagnitude() < 3.0)
            {
                npcContext.SetFact(Facts.AtLocationHome, true, true, true, true);
            }
示例#12
0
		public void Tick(IHTNAgent npc, float deltaTime, float time)
		{
			BearContext npcContext = npc.AiDomain.NpcContext as BearContext;
			if (npcContext == null)
			{
				return;
			}
			if ((npcContext.BodyPosition - npcContext.Domain.SpawnPosition).sqrMagnitude < 3f)
			{
				npcContext.SetFact(Facts.AtLocationHome, true, true, true, true);
				return;
			}
			npcContext.SetFact(Facts.AtLocationHome, false, true, true, true);
		}
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            BearContext npcContext = npc.AiDomain.NpcContext as BearContext;

            if (npcContext == null)
            {
                return;
            }
            if (npcContext.Memory.PrimaryKnownEnemyPlayer.PlayerInfo.Player != null && (BearDomain.BearNavigateToLastKnownLocationOfPrimaryEnemyPlayer.GetDestination(npcContext) - npcContext.Body.transform.position).sqrMagnitude < 1f)
            {
                npcContext.SetFact(Facts.AtLocationLastKnownLocationOfPrimaryEnemyPlayer, 1, true, true, true);
                return;
            }
            npcContext.SetFact(Facts.AtLocationLastKnownLocationOfPrimaryEnemyPlayer, 0, true, true, true);
        }
        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);
        }
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            BearContext npcContext = npc.AiDomain.NpcContext as BearContext;

            if (npcContext == null)
            {
                return;
            }
            if (Object.op_Inequality((Object)npcContext.Memory.PrimaryKnownEnemyPlayer.PlayerInfo.Player, (Object)null))
            {
                Vector3 vector3 = Vector3.op_Subtraction(BearDomain.BearNavigateToLastKnownLocationOfPrimaryEnemyPlayer.GetDestination(npcContext), ((Component)npcContext.Body).get_transform().get_position());
                if ((double)((Vector3) ref vector3).get_sqrMagnitude() < 1.0)
                {
                    npcContext.SetFact(Facts.AtLocationLastKnownLocationOfPrimaryEnemyPlayer, 1, true, true, true);
                    return;
                }
            }
            npcContext.SetFact(Facts.AtLocationLastKnownLocationOfPrimaryEnemyPlayer, 0, true, true, true);
        }
示例#16
0
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            BearContext npcContext = npc.AiDomain.NpcContext as BearContext;

            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);
        }
示例#17
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;
            }
            NpcPlayerInfo primaryEnemyPlayerTarget = npcContext.GetPrimaryEnemyPlayerTarget();

            if (primaryEnemyPlayerTarget.Player != null)
            {
                if (PreferredFightingRangeReasoner.IsAtPreferredRange(npcContext, ref primaryEnemyPlayerTarget))
                {
                    npcContext.SetFact(Facts.AtLocationPreferredFightingRange, 1, true, true, true);
                    return;
                }
                npcContext.SetFact(Facts.AtLocationPreferredFightingRange, 0, true, true, true);
            }
        }
        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);
            }
        }
示例#20
0
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            BearContext npcContext = npc.AiDomain.NpcContext as BearContext;

            if (npcContext == null)
            {
                return;
            }
            if (Object.op_Equality((Object)npcContext.Memory.PrimaryKnownEnemyPlayer.PlayerInfo.Player, (Object)null))
            {
                npcContext.SetFact(Facts.EnemyRange, EnemyRange.OutOfRange, true, true, true);
            }
            Vector3 vector3       = Vector3.op_Subtraction(npcContext.Memory.PrimaryKnownEnemyPlayer.LastKnownPosition, npcContext.BodyPosition);
            float   sqrMagnitude  = ((Vector3) ref vector3).get_sqrMagnitude();
            float   sqrCloseRange = npcContext.Body.AiDefinition.Engagement.SqrCloseRange;

            if ((double)sqrMagnitude <= (double)sqrCloseRange)
            {
                npcContext.SetFact(Facts.EnemyRange, EnemyRange.CloseRange, true, true, true);
            }
            else
            {
                float sqrMediumRange = npcContext.Body.AiDefinition.Engagement.SqrMediumRange;
                if ((double)sqrMagnitude <= (double)sqrMediumRange)
                {
                    npcContext.SetFact(Facts.EnemyRange, EnemyRange.MediumRange, true, true, true);
                }
                else
                {
                    float sqrLongRange = npcContext.Body.AiDefinition.Engagement.SqrLongRange;
                    if ((double)sqrMagnitude <= (double)sqrLongRange)
                    {
                        npcContext.SetFact(Facts.EnemyRange, EnemyRange.LongRange, true, true, true);
                    }
                    else
                    {
                        npcContext.SetFact(Facts.EnemyRange, EnemyRange.OutOfRange, true, true, true);
                    }
                }
            }
        }
示例#21
0
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            BearContext npcContext = npc.AiDomain.NpcContext as BearContext;

            if (npcContext == null)
            {
                return;
            }
            if (npcContext.IsFact(Facts.Alertness))
            {
                if (npcContext.GetFact(Facts.Alertness) > 10)
                {
                    npcContext.SetFact(Facts.Alertness, 10, true, false, true);
                }
                if (time - this._lastFrustrationDecrementTime > 1f)
                {
                    this._lastFrustrationDecrementTime = time;
                    npcContext.IncrementFact(Facts.Alertness, -1, true, true, true);
                }
            }
        }
示例#22
0
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            BearContext npcContext = npc.AiDomain.NpcContext as BearContext;

            if (npcContext == null)
            {
                return;
            }
            BearDomain aiDomain = npc.AiDomain as BearDomain;

            if (Object.op_Equality((Object)aiDomain, (Object)null))
            {
                return;
            }
            npcContext.SetFact(Facts.CanSeeEnemy, npcContext.EnemyPlayersInLineOfSight.Count > 0, true, true, true);
            bool          isStanding     = aiDomain.BearContext.IsFact(Facts.IsStandingUp);
            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)aiDomain.BearDefinition.SqrAggroRange(isStanding)) * 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)
        {
            BearContext npcContext = npc.AiDomain.NpcContext as BearContext;

            if (npcContext == null)
            {
                return;
            }
            BearDomain aiDomain = npc.AiDomain as BearDomain;

            if (aiDomain == null)
            {
                return;
            }
            npcContext.SetFact(Facts.CanSeeEnemy, npcContext.EnemyPlayersInLineOfSight.Count > 0, true, true, true);
            bool          flag          = aiDomain.BearContext.IsFact(Facts.IsStandingUp);
            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 / aiDomain.BearDefinition.SqrAggroRange(flag)) * 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)
        {
            BearContext npcContext = npc.AiDomain.NpcContext as BearContext;

            if (npcContext == null)
            {
                return;
            }
            NpcPlayerInfo enemyPlayerTarget = npcContext.GetPrimaryEnemyPlayerTarget();

            if (!Object.op_Inequality((Object)enemyPlayerTarget.Player, (Object)null))
            {
                return;
            }
            if (PreferredFightingRangeReasoner.IsAtPreferredRange(npcContext, ref enemyPlayerTarget))
            {
                npcContext.SetFact(Facts.AtLocationPreferredFightingRange, 1, true, true, true);
            }
            else
            {
                npcContext.SetFact(Facts.AtLocationPreferredFightingRange, 0, true, true, true);
            }
        }
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            BearContext npcContext = npc.AiDomain.NpcContext as BearContext;

            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)
        {
            BearContext npcContext = npc.AiDomain.NpcContext as BearContext;

            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);
        }
示例#27
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;
        }
 public static bool IsAtPreferredRange(BearContext context, ref NpcPlayerInfo target)
 {
     return(target.SqrDistance <= context.Body.AiDefinition.Engagement.SqrCloseRange);
 }
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            BearContext npcContext = npc.AiDomain.NpcContext as BearContext;

            npcContext?.SetFact(Facts.HasEnemyTarget, Object.op_Inequality((Object)npcContext.Memory.PrimaryKnownEnemyPlayer.PlayerInfo.Player, (Object)null), true, true, true);
        }