Exemplo n.º 1
0
        public AnimalPen GetClosestPen(Creature agent)
        {
            if (LastPen != null && LastPen.CanHold(Animal.Stats.SpeciesName) && agent.World.EnumerateZones().Contains(LastPen) && LastPen.IsBuilt)
            {
                return(LastPen);
            }

            var       pens        = agent.World.EnumerateZones().Where(room => room is AnimalPen && room.IsBuilt).Cast <AnimalPen>().Where(pen => pen.CanHold(Animal.Stats.SpeciesName));
            AnimalPen closestPen  = null;
            float     closestDist = float.MaxValue;

            foreach (var pen in pens)
            {
                var dist = (pen.GetBoundingBox().Center() - agent.Physics.Position).LengthSquared();
                if (dist < closestDist)
                {
                    closestDist = dist;
                    closestPen  = pen;
                }
            }

            if (closestPen == null)
            {
                agent.World.UserInterface.MakeWorldPopup("Can't wrangle " + Animal.Stats.CurrentClass.Name + "s. Need more animal pens.", Animal.Physics, -10, 10);
            }

            LastPen = closestPen;
            return(closestPen);
        }
Exemplo n.º 2
0
        public AnimalPen GetClosestPen(Creature agent)
        {
            if (LastPen != null && (LastPen.Species == "" || LastPen.Species == Animal.Species) && agent.Faction.GetRooms().Contains(LastPen) && LastPen.IsBuilt)
            {
                return(LastPen);
            }

            var       pens        = agent.Faction.GetRooms().Where(room => room is AnimalPen && room.IsBuilt).Cast <AnimalPen>().Where(pen => pen.Species == "" || pen.Species == Animal.Species);
            AnimalPen closestPen  = null;
            float     closestDist = float.MaxValue;

            foreach (var pen in pens)
            {
                var dist = (pen.GetBoundingBox().Center() - agent.Physics.Position).LengthSquared();
                if (dist < closestDist)
                {
                    closestDist = dist;
                    closestPen  = pen;
                }
            }

            if (closestPen == null)
            {
                agent.World.MakeWorldPopup("Can't wrangle " + Animal.Species + "s. Need more animal pens.", Animal.Physics, -10, 10);
            }

            LastPen = closestPen;
            return(closestPen);
        }
Exemplo n.º 3
0
 public static void InitializeStatics()
 {
     RegisterType(Stockpile.InitializeData());
     RegisterType(BalloonPort.InitializeData());
     //RegisterType(BedRoom.InitializeData());
     //RegisterType(CommonRoom.InitializeData());
     //RegisterType(LibraryRoom.InitializeData());
     //RegisterType(TrainingRoom.InitializeData());
     //RegisterType(WorkshopRoom.InitializeData());
     //RegisterType(Kitchen.InitializeData());
     RegisterType(Graveyard.InitializeData());
     RegisterType(AnimalPen.InitializeData());
     RegisterType(Treasury.InitializeData());
     staticIntialized = true;
 }
Exemplo n.º 4
0
        public IEnumerable <Act.Status> PenAnimal(CreatureAI agent, CreatureAI creature, AnimalPen animalPen)
        {
            foreach (var status in animalPen.AddAnimal(Animal.Physics, agent.Faction))
            {
                if (status == Act.Status.Fail)
                {
                    creature.ResetPositionConstraint();
                    agent.SetMessage("Failed to pen animal.");
                    yield return(Act.Status.Fail);

                    yield break;
                }
            }
            yield return(Act.Status.Success);
        }