示例#1
0
        public void Callback_NewJob_SleepBed(int sleepTypeInt)
        {
            bool chooseBed = (sleepTypeInt == (int)BedSleepTypes.Specific ||
                              sleepTypeInt == (int)BedSleepTypes.SpecificEmergency),
                 isEmergency = (sleepTypeInt == (int)BedSleepTypes.GeneralEmergency ||
                                sleepTypeInt == (int)BedSleepTypes.SpecificEmergency);

            //If the player wants to choose a specific bed, let him.
            if (chooseBed)
            {
                var playerGroup = Game.Map.FindGroup <GameLogic.Groups.PlayerGroup>();
                var data        = new Window_SelectTile.TileSelectionData(
                    (tilePos) =>
                    (Job_SleepBed.FirstFriendlyBedAtPos(tilePos, Target) != null &&
                     !playerGroup.JobQueries.AnyJobsAffecting(tilePos)),
                    "WINDOW_SLEEPAT_TITLE", "WINDOW_SLEEPAT_MESSAGE");
                data.OnFinished += (tilePos) =>
                {
                    if (tilePos.HasValue)
                    {
                        var bed = Job_SleepBed.FirstFriendlyBedAtPos(tilePos.Value, Target);
                        Target.AddJob(new Job_SleepBed(isEmergency, Game.Map, bed));
                    }
                };
                ContentUI.Instance.CreateWindow(ContentUI.Instance.Window_SelectTile, data);
            }
            //Otherwise, just sleep at the closest bed.
            else
            {
                Target.AddJob(new Job_SleepBed(isEmergency, Game.Map));
            }
        }
示例#2
0
        public void Callback_NewJob_MoveToPos(bool makeEmergency)
        {
            //Ask the player to select a tile to move to.
            var playerGroup = Game.Map.FindGroup <GameLogic.Groups.PlayerGroup>();
            var data        = new Window_SelectTile.TileSelectionData(
                (tilePos) =>
                (!Game.Map.Tiles[tilePos].BlocksMovement() &&
                 !playerGroup.JobQueries.AnyJobsAffecting(tilePos)),
                "WINDOW_MOVETOPOS_TITLE", "WINDOW_MOVETOPOS_MESSAGE");

            data.OnFinished += (tilePos) =>
            {
                if (tilePos.HasValue)
                {
                    Target.AddJob(new Job_MoveToPos(tilePos.Value, makeEmergency, Game.Map));
                }
            };
            ContentUI.Instance.CreateWindow(ContentUI.Instance.Window_SelectTile, data);
        }
示例#3
0
        public void Callback_NewJob_BuildBed(bool makeEmergency)
        {
            //Ask the player where the bed should be built.
            var playerGroup = Game.Map.FindGroup <GameLogic.Groups.PlayerGroup>();
            var data        = new Window_SelectTile.TileSelectionData(
                (tilePos) =>
                (Game.Map.Tiles[tilePos].IsBuildableOn() &&
                 !playerGroup.JobQueries.AnyJobsAffecting(tilePos)),
                "WINDOW_BUILDBED_TITLE", "WINDOW_BUILDBED_MESSAGE");

            data.OnFinished += (tilePos) =>
            {
                if (tilePos.HasValue)
                {
                    Target.AddJob(new Job_BuildBed(tilePos.Value, Target.MyGroupID,
                                                   makeEmergency, Game.Map));
                }
            };
            ContentUI.Instance.CreateWindow(ContentUI.Instance.Window_SelectTile, data);
        }