コード例 #1
0
        public override void Initialize()
        {
            if (Agent.Status.Hunger.IsUnhappy())
            {
                Room commonRoom = Creature.Faction.GetNearestRoomOfType("CommonRoom", Agent.Position);

                if (commonRoom != null && commonRoom.IsBuilt)
                {
                    Tree = (new GoToZoneAct(Agent, commonRoom) & new GoToChairAndSitAct(Agent) & new Wrap(Creature.EatStockedFood));
                }
                else
                {
                    Stockpile stockRoom = Creature.Faction.GetNearestStockpile(Agent.Position);

                    if (stockRoom != null && stockRoom.IsBuilt)
                    {
                        Tree = new GoToZoneAct(Agent, stockRoom) & new Wrap(Creature.EatStockedFood);
                    }
                }
            }
            else
            {
                Tree = null;
            }

            base.Initialize();
        }
コード例 #2
0
ファイル: FindAndEatFoodAct.cs プロジェクト: scorvi/dwarfcorp
        public override void Initialize()
        {
            if(Agent.Status.Hunger.IsUnhappy())
            {
                Room commonRoom = Creature.Faction.GetNearestRoomOfType("CommonRoom", Agent.Position);

                if (commonRoom != null && commonRoom.IsBuilt)
                {
                    Tree =  (new GoToZoneAct(Agent, commonRoom) & new GoToChairAndSitAct(Agent) & new Wrap(Creature.EatStockedFood));
                }
                else
                {
                    Stockpile stockRoom = Creature.Faction.GetNearestStockpile(Agent.Position);

                    if (stockRoom != null && stockRoom.IsBuilt)
                    {
                        Tree = new GoToZoneAct(Agent, stockRoom) & new Wrap(Creature.EatStockedFood);
                    }
                }
            }
            else
            {
                Tree = null;
            }

            base.Initialize();
        }
コード例 #3
0
        public override MaybeNull <Act> CreateScript(Creature creature)
        {
            var above = VoxelHelpers.GetVoxelAbove(creature.Physics.CurrentVoxel);

            if ((above.IsValid && above.LiquidLevel > 0) || creature.AI.Movement.CanFly)
            {
                return(new Wrap(() => SwimUp(creature))
                {
                    Name = "Swim up"
                });
            }

            Act fallback = null;

            if (creature.World.EnumerateZones().Count() == 0)
            {
                fallback = new LongWanderAct(creature.AI)
                {
                    PathLength = 20, Radius = 30, Is2D = true, Name = "Randomly wander."
                }
            }
            ;
            else
            {
                fallback = new GoToZoneAct(creature.AI, Datastructures.SelectRandom(creature.World.EnumerateZones()));
            }

            return(new Select(new Sequence(new Wrap(() => FindLandEnum(creature))
            {
                Name = "Search for land."
            },
                                           new GoToNamedVoxelAct("Land", PlanAct.PlanType.Into, creature.AI)),
                              fallback)
            {
                Name = "Find Land"
            });
        }