Пример #1
0
        public override void Initialize()
        {
            var closestItem = Agent.Faction.FindNearestItemWithTags("Bed", Agent.Position, true, Agent);
            var closestZone = Agent.World.FindNearestZone(Agent.Position);

            if (!Agent.Stats.Energy.IsSatisfied() && closestItem != null)
            {
                closestItem.ReservedFor = Agent;
                Creature.AI.Blackboard.SetData("Bed", closestItem);

                var unreserveAct = new Wrap(() => Creature.Unreserve("Bed"));

                Tree =
                    new Select(
                        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.Stats.Energy.IsSatisfied() && closestItem == null && closestZone != null)
            {
                Creature.AddThought("I slept on the ground.", new TimeSpan(0, 8, 0, 0), -6.0f);

                Tree = new Sequence(
                    new GoToZoneAct(Creature.AI, closestZone),
                    new SleepAct(Creature.AI)
                {
                    RechargeRate = 1.0f
                });
            }
            else if (!Agent.Stats.Energy.IsSatisfied() && closestItem == null && closestZone == null)
            {
                Creature.AddThought("I slept on the ground.", new TimeSpan(0, 8, 0, 0), -6.0f);

                Tree = new SleepAct(Creature.AI)
                {
                    RechargeRate = 1.0f
                };
            }
            else
            {
                Tree = null;
            }
            base.Initialize();
        }
Пример #2
0
        public override void Initialize()
        {
            Body closestItem = Agent.Faction.FindNearestItemWithTags("Bed", Agent.Position, true, Agent);
            Zone closestZone = Agent.Faction.GetNearestRoom(Agent.Position);

            if (!Agent.Status.Energy.IsSatisfied() && closestItem != null)
            {
                closestItem.ReservedFor = Agent;
                Creature.AI.Blackboard.SetData("Bed", closestItem);
                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.IsSatisfied() && closestItem == null && closestZone != null)
            {
                Creature.AddThought(Thought.ThoughtType.SleptOnGround);

                Tree = new Sequence(new GoToZoneAct(Creature.AI, closestZone),
                                    new SleepAct(Creature.AI)
                {
                    RechargeRate = 1.0f
                });
            }
            else if (!Agent.Status.Energy.IsSatisfied() && closestItem == null && closestZone == null)
            {
                Creature.AddThought(Thought.ThoughtType.SleptOnGround);

                Tree = new SleepAct(Creature.AI)
                {
                    RechargeRate = 1.0f
                };
            }
            else
            {
                Tree = null;
            }
            base.Initialize();
        }
Пример #3
0
        public override void Initialize()
        {
            GameComponent closestItem = Agent.Faction.FindNearestItemWithTags("Bed", Agent.Position, true, Agent);


            if (closestItem != null && !Creature.Stats.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.UserInterface.MakeWorldPopup(String.Format("{0} passed out.", Agent.Stats.FullName), Agent.Physics, -10, 10);
                    Agent.World.TaskManager.AddTask(new HealAllyTask(Agent)
                    {
                        Priority = TaskPriority.High
                    });
                }
                Tree = new SleepAct(Creature.AI)
                {
                    HealRate = 0.4f, RechargeRate = 1.0f, Teleport = false, Type = SleepAct.SleepType.Heal
                };
            }
            base.Initialize();
        }
Пример #4
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();
        }