コード例 #1
0
        private void TryLand()
        {
            //move ship there
            Map oldMap = parent.Map;
            Map newMap = Find.Maps.FirstOrDefault(x => x.Tile == oldMap.Tile && x != oldMap);

            if (newMap == null)
            {
                ///OH NOES!
                throw new Exception("WTF");
            }

            var def = oldMap
                      .GetSpaceAtmosphereMapComponent()
                      .DefinitionAt(parent.Position);

            IntVec3?landingSpot = null;

            LongEventHandler.QueueLongEvent(() =>
            {
                landingSpot = def.DetermineLandingSpot(newMap);
                if (landingSpot == null)
                {
                    Find.LetterStack.ReceiveLetter("No Landing Spot", "No suitable landing spot found.", LetterDefOf.NeutralEvent);
                    LongEventHandler.ClearQueuedEvents();
                }
            }, "Landing_Spot", true, Handler);

            def
            .Move(oldMap, () => newMap, "Landing", true, Handler, null, () => landingSpot.Value)
            .Then(() =>
            {
                Current.Game.CurrentMap = newMap;
            }, "Landing_Swap", Handler)
            .Then(() => {
                foreach (var pawn in Find.CurrentMap.mapPawns.AllPawns.Where(p => p.Faction == Faction.OfPlayer))
                {
                    pawn.playerSettings.AreaRestriction = Find.CurrentMap.areaManager.Home;
                }
            }, "Landing_Swap", Handler)
            .Then(() =>
            {
                Find.World.worldObjects.Remove(oldMap.Parent);
                Find.Maps.Remove(oldMap);
            }, "Landing_DestroyOldMap", Handler);


            //do cool graphic?
        }
コード例 #2
0
ファイル: World_Patch.cs プロジェクト: SwimUp/worldedit
        public static void Postfix()
        {
            if (!WorldEditor.isEdit && !WorldEditor.isInit)
            {
                return;
            }

            if (Input.GetKeyDown(KeyCode.Escape))
            {
                if (Find.WindowStack.IsOpen(typeof(CustomStartingSite)))
                {
                    return;
                }

                Dialog_MessageBox.CreateConfirmation("Back to menu?", delegate
                {
                    LongEventHandler.ClearQueuedEvents();
                    LongEventHandler.QueueLongEvent(delegate
                    {
                        MemoryUtility.ClearAllMapsAndWorld();
                        Current.Game = null;
                    }, "Entry", "LoadingLongEvent", doAsynchronously: false, null);
                });
            }

            if (Input.GetKeyDown(Settings.EditorHotKey))
            {
                WorldEditor.Editor.Reset();
                Find.WindowStack.Add(WorldEditor.Editor);
            }

            if (Input.GetKeyDown(Settings.FactionHotKey))
            {
                Find.WindowStack.Add(WorldEditor.Editor.factionEditor);
            }

            if (Input.GetKeyDown(Settings.RiversAndRoadsHotKey))
            {
                Find.WindowStack.Add(new RoadAndRiversEditor());
            }

            if (Input.GetKeyDown(Settings.WorldObjectHotKey))
            {
                Find.WindowStack.Add(WorldEditor.Editor.worldObjectsEditor);
            }
        }