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

            if (npcContext == null)
            {
                return;
            }
            BaseNpc animal      = (BaseNpc)null;
            float   sqrDistance = 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)sqrDistance)
                {
                    sqrDistance = animalInfo.SqrDistance;
                    animal      = animalInfo.Animal;
                }
            }
            if (Object.op_Inequality((Object)animal, (Object)null) && AnimalReasoner.IsNearby(npcContext.Domain, sqrDistance))
            {
                npcContext.Memory.RememberPrimaryAnimal(animal);
                npcContext.SetFact(Rust.Ai.HTN.ScientistJunkpile.Facts.NearbyAnimal, true, true, true, true);
            }
            else
            {
                npcContext.SetFact(Rust.Ai.HTN.ScientistJunkpile.Facts.NearbyAnimal, false, true, true, true);
            }
        }
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            ScientistJunkpileContext npcContext = npc.AiDomain.NpcContext as ScientistJunkpileContext;

            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) || !AnimalReasoner.IsNearby(npcContext.Domain, sqrDistance))
            {
                npcContext.SetFact(Facts.NearbyAnimal, false, true, true, true);
                return;
            }
            npcContext.Memory.RememberPrimaryAnimal(animal);
            npcContext.SetFact(Facts.NearbyAnimal, true, true, true, true);
        }