예제 #1
0
        public override void Initialize()
        {
            Body closestItem = Agent.Faction.FindNearestItemWithTags("Bed", Agent.Position, true, Agent);


            if (closestItem != null && !Creature.Status.Health.IsCritical())
            {
                closestItem.ReservedFor = Agent;
                Creature.AI.Blackboard.SetData("Bed", closestItem);
                Act unreserveAct = new Wrap(() => Creature.Unreserve("Bed"));
                Tree =
                    new Sequence
                    (
                        new GoToEntityAct(closestItem, Creature.AI),
                        new TeleportAct(Creature.AI)
                {
                    Location = closestItem.GetRotatedBoundingBox().Center() + new Vector3(-0.0f, 0.75f, -0.0f)
                },
                        new SleepAct(Creature.AI)
                {
                    HealRate = 1.0f, RechargeRate = 1.0f, Teleport = true, TeleportLocation = closestItem.GetRotatedBoundingBox().Center() + new Vector3(-0.0f, 0.75f, -0.0f), Type = SleepAct.SleepType.Heal
                },
                        unreserveAct
                    ) | unreserveAct;
            }
            else
            {
                if (Agent.Faction == Agent.World.PlayerFaction)
                {
                    Agent.World.MakeWorldPopup(String.Format("{0} passed out.", Agent.Stats.FullName), Agent.Physics, -10, 10);
                    Agent.World.Master.TaskManager.AddTask(new HealAllyTask(Agent)
                    {
                        Priority = Task.PriorityType.High
                    });
                }
                Tree = new SleepAct(Creature.AI)
                {
                    HealRate = 0.1f, RechargeRate = 1.0f, Teleport = false, Type = SleepAct.SleepType.Heal
                };
            }
            base.Initialize();
        }
예제 #2
0
        public override void Initialize()
        {
            Body closestItem = Agent.Faction.FindNearestItemWithTags("Bed", Agent.Position, true);


            if (Agent.Status.Energy.IsDissatisfied() && closestItem != null)
            {
                closestItem.ReservedFor = Agent;
                Creature.AI.Blackboard.SetData("Bed", closestItem);
                closestItem.IsReserved  = true;
                closestItem.ReservedFor = Agent;
                Act unreserveAct = new Wrap(() => Creature.Unreserve("Bed"));
                Tree =
                    new Sequence
                    (
                        new GoToEntityAct(closestItem, Creature.AI),
                        new TeleportAct(Creature.AI)
                {
                    Location = closestItem.GetRotatedBoundingBox().Center() + new Vector3(-0.0f, 0.75f, -0.0f)
                },
                        new SleepAct(Creature.AI)
                {
                    RechargeRate = 1.0f, Teleport = true, TeleportLocation = closestItem.GetRotatedBoundingBox().Center() + new Vector3(-0.0f, 0.75f, -0.0f)
                },
                        unreserveAct
                    ) | unreserveAct;
            }
            else if (Agent.Status.Energy.IsDissatisfied() && closestItem == null)
            {
                Creature.AI.AddThought(Thought.ThoughtType.SleptOnGround);

                Tree = new SleepAct(Creature.AI)
                {
                    RechargeRate = 1.0f
                };
            }
            else
            {
                Tree = null;
            }
            base.Initialize();
        }
예제 #3
0
        public override void Initialize()
        {
            Act unreserveAct = new Wrap(() => Creature.Unreserve("Train"));

            Tree = new Sequence(
                new Wrap(() => Creature.FindAndReserve("Train", "Train")),
                new Sequence
                (
                    new GoToTaggedObjectAct(Agent)
            {
                Tag = "Train", Teleport = false, TeleportOffset = new Vector3(1, 0, 0), ObjectName = "Train"
            },
                    new MeleeAct(Agent, "Train")
            {
                Training = true, Timeout = new Timer(10.0f, false)
            },
                    unreserveAct
                ) | new Sequence(unreserveAct, false)
                ) | new Sequence(unreserveAct, false);
            base.Initialize();
        }
예제 #4
0
        public IEnumerable <Status> UnReserve()
        {
            if (Des.ResourcesReservedFor != null && Des.ResourcesReservedFor.IsDead)
            {
                Des.ResourcesReservedFor = null;
            }

            foreach (var status in Creature.Unreserve("craft-location"))
            {
                ;
            }

            if (Des.ResourcesReservedFor == Agent)
            {
                Des.ResourcesReservedFor = null;
            }

            Agent.Physics.Active     = true;
            Agent.Physics.IsSleeping = false;

            yield return(Act.Status.Success);
        }
예제 #5
0
        public override void Initialize()
        {
            Body closestItem = Agent.Faction.FindNearestItemWithTags("Bed", Agent.Position, true);


            if (closestItem != null)
            {
                closestItem.ReservedFor = Agent;
                Creature.AI.Blackboard.SetData("Bed", closestItem);
                Act unreserveAct = new Wrap(() => Creature.Unreserve("Bed"));
                Tree =
                    new Sequence
                    (
                        new GoToEntityAct(closestItem, Creature.AI),
                        new TeleportAct(Creature.AI)
                {
                    Location = closestItem.GetRotatedBoundingBox().Center() + new Vector3(-0.0f, 0.75f, -0.0f)
                },
                        new SleepAct(Creature.AI)
                {
                    HealRate = 1.0f, RechargeRate = 1.0f, Teleport = true, TeleportLocation = closestItem.GetRotatedBoundingBox().Center() + new Vector3(-0.0f, 0.75f, -0.0f), Type = SleepAct.SleepType.Heal
                },
                        unreserveAct
                    ) | unreserveAct;
            }
            else
            {
                if (Agent.Faction == Agent.World.PlayerFaction)
                {
                    Agent.World.MakeAnnouncement(String.Format("{0} passed out.", Agent.Stats.FullName));
                }
                Tree = new SleepAct(Creature.AI)
                {
                    HealRate = 0.1f, RechargeRate = 1.0f, Teleport = false, Type = SleepAct.SleepType.Heal
                };
            }
            base.Initialize();
        }
예제 #6
0
        public override void Initialize()
        {
            Act   unreserveAct = new Wrap(() => Creature.Unreserve("Anvil"));
            float time         = CraftLibrary.CraftItems[ItemType].BaseCraftTime / Creature.AI.Stats.BuffedInt;

            Tree = new Sequence(
                new Wrap(() => Creature.FindAndReserve("Anvil", "Anvil")),
                new GetResourcesAct(Agent, CraftLibrary.CraftItems[ItemType].RequiredResources),
                new Sequence
                (
                    new GoToTaggedObjectAct(Agent)
            {
                Tag = "Anvil", Teleport = false, TeleportOffset = new Vector3(1, 0, 0), ObjectName = "Anvil"
            },
                    new Wrap(() => WaitAndHit(time)),
                    new Wrap(DestroyResources),
                    unreserveAct,
                    new GoToVoxelAct(Voxel, PlanAct.PlanType.Adjacent, Agent),
                    new CreateCraftItemAct(Voxel, Creature.AI, ItemType)
                ) | new Sequence(unreserveAct, new Wrap(Creature.RestockAll), false)
                ) | new Sequence(unreserveAct, false);
            base.Initialize();
        }
예제 #7
0
        public override void Initialize()
        {
            Creature.OverrideCharacterMode = false;

            Tree = new Select(
                new Domain(() => !Agent.IsDead && !Agent.Creature.Stats.IsAsleep,
                           new Sequence(
                               new ClearBlackboardData(Creature.AI, "reserved-chair"),
                               new Wrap(() => Creature.FindAndReserve("Chair", "reserved-chair")),
                               new Domain(ValidateSit,
                                          new Sequence(
                                              new GoToTaggedObjectAct(Creature.AI)
            {
                Teleport             = true,
                TeleportOffset       = new Vector3(0, 0.1f, 0),
                ObjectBlackboardName = "reserved-chair",
                CheckForOcclusion    = false
            },
                                              new Wrap(WaitUntilBored))),
                               new Wrap(() => Creature.Unreserve("reserved-chair")))),
                new Wrap(() => Creature.Unreserve("reserved-chair")));

            base.Initialize();
        }
예제 #8
0
        public override void Initialize()
        {
            Creature.OverrideCharacterMode = false;

            Tree = new Sequence(new ClearBlackboardData(Creature.AI, "Grave"),
                                new Wrap(() => Creature.FindAndReserve("Grave", "Grave")),
                                new GoToTaggedObjectAct(Creature.AI)
            {
                Tag = "Grave", Teleport = false, TeleportOffset = new Vector3(1.0f, 0.0f, 0), ObjectName = "Grave"
            },
                                new Wrap(WaitUntilBored),
                                new Wrap(() => Creature.Unreserve("Grave"))) | new Wrap(() => Creature.Unreserve("Grave"));
            base.Initialize();
        }
예제 #9
0
        public override void Initialize()
        {
            Act   unreserveAct = new Wrap(() => Creature.Unreserve(ItemType.CraftLocation));
            float time         = ItemType.BaseCraftTime / Creature.AI.Stats.BuffedInt;
            Act   getResources = null;

            if (ItemType.SelectedResources == null || ItemType.SelectedResources.Count == 0)
            {
                getResources = new GetResourcesAct(Agent, ItemType.RequiredResources);
            }
            else
            {
                getResources = new GetResourcesAct(Agent, ItemType.SelectedResources);
            }

            if (ItemType.Type == CraftItem.CraftType.Object)
            {
                Tree = new Sequence(
                    new Wrap(() => Creature.FindAndReserve(ItemType.CraftLocation, ItemType.CraftLocation)),
                    getResources,
                    new Sequence
                    (
                        new GoToTaggedObjectAct(Agent)
                {
                    Tag            = ItemType.CraftLocation,
                    Teleport       = false,
                    TeleportOffset = new Vector3(1, 0, 0),
                    ObjectName     = ItemType.CraftLocation
                },
                        new Wrap(() => WaitAndHit(time)),
                        new Wrap(DestroyResources),
                        unreserveAct,
                        new GoToVoxelAct(Voxel, PlanAct.PlanType.Adjacent, Agent),
                        new CreateCraftItemAct(Voxel, Creature.AI, ItemType.Name)
                    ) | new Sequence(unreserveAct, new Wrap(Creature.RestockAll), false)
                    ) | new Sequence(unreserveAct, false);
            }
            else
            {
                Tree = new Sequence(
                    new Wrap(() => Creature.FindAndReserve(ItemType.CraftLocation, ItemType.CraftLocation)),
                    getResources,
                    new Sequence
                    (
                        new GoToTaggedObjectAct(Agent)
                {
                    Tag            = ItemType.CraftLocation,
                    Teleport       = false,
                    TeleportOffset = new Vector3(1, 0, 0),
                    ObjectName     = ItemType.CraftLocation
                },
                        new Wrap(() => WaitAndHit(time)),
                        new Wrap(DestroyResources),
                        unreserveAct,
                        new Wrap(CreateResources),
                        new Wrap(Creature.RestockAll)
                    ) | new Sequence(unreserveAct, new Wrap(Creature.RestockAll), false)
                    ) | new Sequence(unreserveAct, false);
            }
            base.Initialize();
        }
예제 #10
0
        public override void Initialize()
        {
            Creature.OverrideCharacterMode = false;

            Tree = new Sequence(new ClearBlackboardData(Creature.AI, "Chair"),
                                new Wrap(() => Creature.FindAndReserve("Chair", "Chair")),
                                new GoToTaggedObjectAct(Creature.AI)
            {
                Tag = "Chair", Teleport = true, TeleportOffset = new Vector3(0, 0.1f, 0), ObjectName = "Chair", CheckForOcclusion = false
            },
                                new Wrap(WaitUntilBored),
                                new Wrap(() => Creature.Unreserve("Chair"))) | new Wrap(() => Creature.Unreserve("Chair"));
            base.Initialize();
        }