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

            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.Scientist.Facts.NearbyExplosives, true, true, true, true);
                        npcContext.IncrementFact(Rust.Ai.HTN.Scientist.Facts.Alertness, 2, true, true, true);
                        return;
                    }
                }
            }
            npcContext.SetFact(Rust.Ai.HTN.Scientist.Facts.NearbyExplosives, false, true, true, true);
        }
Esempio n. 2
0
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            ScientistJunkpileContext npcContext = npc.AiDomain.NpcContext as ScientistJunkpileContext;

            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);
        }