Exemplo n.º 1
0
        public BuildRoomAct(CreatureAI agent, BuildRoomOrder buildRoom) :
            base(agent)
        {
            Name      = "Build BuildRoom " + buildRoom.ToString();
            Resources = buildRoom.ListRequiredResources();
            BuildRoom = buildRoom;
            if (BuildRoom.ResourcesReservedFor != null && BuildRoom.ResourcesReservedFor.IsDead)
            {
                BuildRoom.ResourcesReservedFor = null;
            }

            Tree = new Sequence(new Select(new Domain(buildRoom.HasResources || buildRoom.ResourcesReservedFor != null, true),
                                           new Domain(!buildRoom.HasResources && (buildRoom.ResourcesReservedFor == null || buildRoom.ResourcesReservedFor == Agent), new Sequence(new Wrap(Reserve), new GetResourcesAct(Agent, Resources))),
                                           new Domain(buildRoom.HasResources || buildRoom.ResourcesReservedFor != null, true)),
                                new Domain(() => IsRoomBuildOrder(buildRoom) && !buildRoom.IsBuilt && !buildRoom.IsDestroyed && ValidResourceState(),
                                           new Sequence(
                                               SetTargetVoxelFromRoomAct(buildRoom, "ActionVoxel"),
                                               new GoToNamedVoxelAct("ActionVoxel", PlanAct.PlanType.Adjacent, Agent),
                                               new Wrap(PutResources),
                                               new Wrap(WaitForResources)
            {
                Name = "Wait for resources..."
            },
                                               new Wrap(() => Creature.HitAndWait(true, () => 1.0f, () => buildRoom.BuildProgress,
                                                                                  () => buildRoom.BuildProgress += agent.Stats.BuildSpeed / buildRoom.VoxelOrders.Count * 0.5f,
                                                                                  () => MathFunctions.RandVector3Box(buildRoom.GetBoundingBox()), ContentPaths.Audio.Oscar.sfx_ic_dwarf_craft, () => !buildRoom.IsBuilt && !buildRoom.IsDestroyed))
            {
                Name = "Build room.."
            },
                                               new CreateRoomAct(Agent, buildRoom)
                                               , new Wrap(OnFailOrCancel))) | new Wrap(OnFailOrCancel)
                                );
        }