// called during static constructor initialization
 internal void LateInitialize()
 {
     try {
         if (!earlyInitializationCompleted)
         {
             Logger.Error("Attempted late initialization before early initialization: " + Environment.StackTrace);
             return;
         }
         if (lateInitializationCompleted)
         {
             Logger.Warning("Attempted repeated late initialization of controller: " + Environment.StackTrace);
             return;
         }
         lateInitializationCompleted = true;
         RegisterOwnSettings();
         QuickstartController.Initialize();
         LongEventHandler.QueueLongEvent(LoadReloadInitialize, "Initializing", true, null);
     } catch (Exception e) {
         Logger.Error("An exception occurred during late initialization: " + e);
     }
 }
        public MultiplayerMod(ModContentPack pack) : base(pack)
        {
            if (GenCommandLine.CommandLineArgPassed("arbiter"))
            {
                arbiterInstance = true;
            }

            EarlyMarkNoInline(typeof(Multiplayer).Assembly);
            EarlyPatches();

            CheckInterfaceVersions();

            settings = GetSettings <MpSettings>();

            if (MpVersion.IsDebug)
            {
                LongEventHandler.ExecuteWhenFinished(() => {
                    Log.Message("== Structure == \n" + Sync.syncWorkers.PrintStructure());
                });
            }
        }
Beispiel #3
0
        public void SaveWorld(bool delete = false)
        {
            LongEventHandler.QueueLongEvent(delegate
            {
                this.SaveColony();

                this.ConvertCurrentGameWorldObjects();

                this.LoadSaver.SaveWorldData();

                this.ConvertToCurrentGameWorldObjects();

                if (!delete)
                {
                    return;
                }

                SaveFileUtils.DeleteFile(this.Colony.FileInfo.FullName);
                GenScene.GoToMainMenu();
            }, "FilUnderscore.PersistentRimWorlds.Saving.World", false, null);
        }
        public SRTSExpanded(ModContentPack mod)
        {
            LongEventHandler.ExecuteWhenFinished(DelayedPatch);

            // Refuel shuttle
            MP.RegisterSyncDelegate(AccessTools.TypeByName("SRTS.StartUp"), "<>c__DisplayClass24_1", "<LaunchAndBombGizmosPassthrough>b__3");

            // Bombing
            MP.RegisterSyncWorker <Pair <IntVec3, IntVec3> >(SyncIntVec3Pair, typeof(Pair <IntVec3, IntVec3>));
            var type = AccessTools.TypeByName("SRTS.CompBombFlyer");

            MP.RegisterSyncMethod(type, "TryLaunchBombRun");
            bombTypeSync = MP.RegisterSyncField(type, "bombType");

            foreach (MethodInfo method in MpCompat.MethodsByIndex(type, "<CompGetGizmosExtra>", 1, 2))
            {
                MpCompat.harmony.Patch(method,
                                       prefix: new HarmonyMethod(typeof(SRTSExpanded), nameof(PreSyncBombType)),
                                       postfix: new HarmonyMethod(typeof(SRTSExpanded), nameof(PostSyncBombType)));
            }
        }
Beispiel #5
0
        public virtual void Effect()
        {
            LocalTargetInfo t    = this.TargetsAoE[0];
            bool            flag = t.Cell != default(IntVec3);

            if (flag)
            {
                Pawn casterPawn = base.CasterPawn;
                //this.Ability.PostAbilityAttempt();
                if (ModCheck.Validate.GiddyUp.Core_IsInitialized())
                {
                    ModCheck.GiddyUp.ForceDismount(base.CasterPawn);
                }

                LongEventHandler.QueueLongEvent(delegate
                {
                    FlyingObject_ValiantCharge flyingObject = (FlyingObject_ValiantCharge)GenSpawn.Spawn(ThingDef.Named("FlyingObject_ValiantCharge"), this.CasterPawn.Position, this.CasterPawn.Map);
                    flyingObject.Launch(this.CasterPawn, t.Cell, this.CasterPawn);
                }, "LaunchingFlyer", false, null);
            }
        }
        public static void Named(string s)
        {
            Faction.OfPlayer.Name = s;
            if (!Find.GameInfo.permadeathMode)
            {
                return;
            }
            string oldSavefileName = Find.GameInfo.permadeathModeUniqueName;
            string newSavefileName = PermadeathModeUtility.GeneratePermadeathSaveNameBasedOnPlayerInput(s, oldSavefileName);

            if (!(oldSavefileName != newSavefileName))
            {
                return;
            }
            LongEventHandler.QueueLongEvent(delegate
            {
                Find.GameInfo.permadeathModeUniqueName = newSavefileName;
                Find.Autosaver.DoAutosave();
                GenFilePaths.AllSavedGameFiles.FirstOrDefault((FileInfo x) => Path.GetFileNameWithoutExtension(x.Name) == oldSavefileName)?.Delete();
            }, "Autosaving", doAsynchronously: false, null);
        }
Beispiel #7
0
 public override void ExposeData()
 {
     base.ExposeData();
     if (Scribe.mode == LoadSaveMode.PostLoadInit)
     {
         LongEventHandler.ExecuteWhenFinished(delegate
         {
             if (shieldGraphic == null)
             {
                 if (def.defName == "RK_WoodenShield")
                 {
                     shieldGraphic = GraphicDatabase.Get <Graphic_Multi>(path + def.defName, ShaderDatabase.Cutout, def.graphicData.drawSize, Color.white);
                 }
                 else
                 {
                     shieldGraphic = GraphicDatabase.Get <Graphic_Multi>(path + def.defName, ShaderDatabase.Cutout, def.graphicData.drawSize, Stuff.stuffProps.color);
                 }
             }
         });
     }
 }
Beispiel #8
0
        public MultiplayerMod(ModContentPack pack) : base(pack)
        {
            if (GenCommandLine.CommandLineArgPassed("arbiter"))
            {
                ArbiterWindowFix.Run();

                arbiterInstance = true;
            }

            //EarlyMarkNoInline(typeof(Multiplayer).Assembly);
            EarlyPatches();

            CheckInterfaceVersions();

            settings = GetSettings <MpSettings>();

            LongEventHandler.ExecuteWhenFinished(() => {
                // Double Execute ensures it'll run last.
                LongEventHandler.ExecuteWhenFinished(LatePatches);
            });
        }
Beispiel #9
0
        public override void ExposeData()
        {
            Scribe_Values.Look(ref hideOverwallCoolers, "hideOverwallCoolers", false);
            Scribe_Values.Look(ref hideNormalCoolers, "hideNormalCoolers", false);

            if (Scribe.mode == LoadSaveMode.Saving)
            {
                Scribe_Collections.Look(ref BridgelikeTerrain.allBridgeTerrains, "bridgePrefNames");
            }
            else if (Scribe.mode == LoadSaveMode.LoadingVars)
            {
                List <string> defNames = null;
                Scribe_Collections.Look(ref defNames, "bridgePrefNames");

                //Gotta wait for DefOfs to load to use DefDatabase
                if (defNames != null)
                {
                    LongEventHandler.ExecuteWhenFinished(() =>
                    {
                        List <TerrainDef> loadedBridgeOrder = defNames.Select(n => DefDatabase <TerrainDef> .GetNamed(n, false)).ToList();
                        loadedBridgeOrder.RemoveAll(d => d == null);                        //Any removed mods, forget about em.

                        //To merge with maybe new modded bridges:
                        //Take all from known loadedBridgeOrder and push to front:
                        //Any new modded terrains will be in back - which is normal for modded terrain anyway.
                        //TODO: order default list by cost or something. Meh.
                        loadedBridgeOrder.Reverse();
                        foreach (TerrainDef terDef in loadedBridgeOrder)
                        {
                            //Sanity check if terDef is still counted as a bridge in case we eliminated it in a patch and settings still saved it
                            if (BridgelikeTerrain.allBridgeTerrains.Contains(terDef))
                            {
                                BridgelikeTerrain.allBridgeTerrains.Remove(terDef);
                                BridgelikeTerrain.allBridgeTerrains.Insert(0, terDef);
                            }
                        }
                    });
                }
            }
        }
Beispiel #10
0
        static bool Prefix()
        {
            if (gameToLoad == null)
            {
                return(true);
            }

            SaveCompression.doSaveCompression = true;

            ScribeUtil.StartLoading(gameToLoad);
            ScribeMetaHeaderUtility.LoadGameDataHeader(ScribeMetaHeaderUtility.ScribeHeaderMode.Map, false);
            Scribe.EnterNode("game");
            Current.Game = new Game();
            Current.Game.LoadGame(); // calls Scribe.loader.FinalizeLoading()

            SaveCompression.doSaveCompression = false;
            gameToLoad = null;

            Log.Message("Game loaded");

            if (Multiplayer.Client != null)
            {
                LongEventHandler.ExecuteWhenFinished(() =>
                {
                    // Inits all caches
                    foreach (ITickable tickable in TickPatch.AllTickables.Where(t => !(t is ConstantTicker)))
                    {
                        tickable.Tick();
                    }

                    if (!Current.Game.Maps.Any())
                    {
                        MemoryUtility.UnloadUnusedUnityAssets();
                        Find.World.renderer.RegenerateAllLayersNow();
                    }
                });
            }

            return(false);
        }
Beispiel #11
0
        public static void Open(TabWindow window, bool clearForward = false)
        {
            if (openWindow != window)
            {
                if (openWindow != null)
                {
                    TabWindow cur = openWindow;
                    backStack.Push(delegate() { openWindow = cur; openWindow.PreActive(); });
                    curCommand = delegate() { openWindow = window; openWindow.PreActive(); };
                }
                if (clearForward)
                {
                    forwardStack.Clear();
                }

                if (window is ResearchWindow)
                {
                    if (!ResearchWindow.initialized)
                    {
                        Find.WindowStack.TryRemove(instance);
                        LongEventHandler.QueueLongEvent(DRimEditor.Research.Tree.Initialize, "DRimEditor.Research.BuildingResearchTree", false, null);
                        LongEventHandler.QueueLongEvent(() => openWindow = researchWindow, "", false, null);
                        return;
                    }
                }
                if (window is DefExplorerWindow)
                {
                    if (!DefExplorerWindow.initialized)
                    {
                        Find.WindowStack.TryRemove(instance);
                        LongEventHandler.QueueLongEvent(DefDatabaseBuilder.ResolveImpliedDefs, "BuildingRimEditDatabase", false, null);
                        LongEventHandler.QueueLongEvent(() => openWindow = defExplorerWindow, "", false, null);
                        return;
                    }
                }

                openWindow = window;
                openWindow.PreActive();
            }
        }
Beispiel #12
0
    public static void WaitForConnection(string host)
    {
        tc = new TcpClient();
        tc.Client.NoDelay = true;
        tc.Connect(host, 12345);
        ns               = tc.GetStream();
        hasClientID      = false;
        forcedDisconnect = false;
        try
        {
            LongEventHandler.QueueLongEvent(() =>
            {
                PirateRPC.PirateRPC.SendInvocation(ns, u =>
                {
                    int cid = SyncTickData.cliendID;
                    Interlocked.Increment(ref SyncTickData.cliendID);
                    NetDemo.ServerHandlePlayerJoined(cid, u);
                });

                for (; !hasClientID && !forcedDisconnect;)
                {
                }
            }, "Waiting for server".Translate(), true, e => { RimLog.Error(e.ToString()); });
        }
        catch (Exception ee)
        {
            log(ee.ToString());
        }

        Thread t = new Thread(() =>
        {
            for (;  ;)
            {
                PirateRPC.PirateRPC.ReceiveInvocation(ns);
            }
        });

        t.Start();
    }
        public virtual void Effect()
        {
            var targetCell = base.CasterPawn.Position;

            targetCell.z += 3;
            LocalTargetInfo t = targetCell;

            if (targetCell.InBounds(base.CasterPawn.Map) && targetCell.IsValid)
            {
                //base.CasterPawn.rotationTracker.Face(targetCell.ToVector3());
                LongEventHandler.QueueLongEvent(delegate
                {
                    var flyingObject = (Ulmo_FlyingObject_RainDance)GenSpawn.Spawn(
                        ThingDef.Named("FlyingObject_RainDance"), CasterPawn.Position, CasterPawn.Map);
                    flyingObject.Launch(CasterPawn, t.Cell, base.CasterPawn);
                }, "LaunchingFlyer", false, null);
            }
            else
            {
                Log.Message("not enough height to use this ability");
            }
        }
        public MapComponent_ColonistSelections(Map map) : base(map)
        {
            kbDef_Help = DefDatabase <KeyBindingDef> .GetNamed("ColonistSelectionKeys_Help");

            kbDef_Release = DefDatabase <KeyBindingDef> .GetNamed("ColonistSelectionKeys_Release");

            kbDef_Group1 = DefDatabase <KeyBindingDef> .GetNamed("ColonistSelectionKeys_Group1");

            kbDef_Group2 = DefDatabase <KeyBindingDef> .GetNamed("ColonistSelectionKeys_Group2");

            kbDef_Group3 = DefDatabase <KeyBindingDef> .GetNamed("ColonistSelectionKeys_Group3");

            kbDef_Group4 = DefDatabase <KeyBindingDef> .GetNamed("ColonistSelectionKeys_Group4");

            kbDef_Group5 = DefDatabase <KeyBindingDef> .GetNamed("ColonistSelectionKeys_Group5");

            kbDef_Group6 = DefDatabase <KeyBindingDef> .GetNamed("ColonistSelectionKeys_Group6");

            kbDef_Colony = DefDatabase <KeyBindingDef> .GetNamed("ColonistSelectionKeys_CenterOnColony");

            PawnsKey_Group1 = new List <Pawn>();
            CellsKey_Group1 = new List <IntVec3>();
            PawnsKey_Group2 = new List <Pawn>();
            CellsKey_Group2 = new List <IntVec3>();
            PawnsKey_Group3 = new List <Pawn>();
            CellsKey_Group3 = new List <IntVec3>();
            PawnsKey_Group4 = new List <Pawn>();
            CellsKey_Group4 = new List <IntVec3>();

            ThingsKey_Group5 = new List <Thing>();
            ThingsKey_Group6 = new List <Thing>();

            //if (kbDef_Eat == null || kbDef_Sleep == null || kbDef_Help == null || kbDef_Release == null || kbDef_Group1 == null || kbDef_Group2 == null || kbDef_Group3 == null || kbDef_Group4 == null)
            //    Log.Error("Somethings null!!!");
            //else
            //    Log.Error("KeyBinding done.");

            LongEventHandler.ExecuteWhenFinished(InitGraphics);
        }
Beispiel #15
0
        public void StartWar(bool notify = true)
        {
            if (Started)
            {
                return;
            }

            if (WarGoalDef == null)
            {
                return;
            }

            if (AssaultFactions == null || DefendingFactions == null)
            {
                return;
            }

            LongEventHandler.QueueLongEvent(delegate
            {
                StartWarNow(notify);
            }, "War_LongEventStarting", doAsynchronously: true, null);
        }
 public SubSustainer(Sustainer parent, SubSoundDef subSoundDef)
 {
     this.parent = parent;
     this.subDef = subSoundDef;
     LongEventHandler.ExecuteWhenFinished(delegate
     {
         this.creationFrame    = Time.frameCount;
         this.creationRealTime = Time.realtimeSinceStartup;
         if (Current.ProgramState == ProgramState.Playing)
         {
             this.creationTick = Find.TickManager.TicksGame;
         }
         if (this.subDef.startDelayRange.TrueMax < 0.001f)
         {
             this.StartSample();
         }
         else
         {
             this.nextSampleStartTime = Time.realtimeSinceStartup + this.subDef.startDelayRange.RandomInRange;
         }
     });
 }
 public void ResolveReferencesSpecial()
 {
     if (soundDoorOpenPowered == null)
     {
         soundDoorOpenPowered = SoundDefOf.Door_OpenPowered;
     }
     if (soundDoorClosePowered == null)
     {
         soundDoorClosePowered = SoundDefOf.Door_ClosePowered;
     }
     if (soundDoorOpenManual == null)
     {
         soundDoorOpenManual = SoundDefOf.Door_OpenManual;
     }
     if (soundDoorCloseManual == null)
     {
         soundDoorCloseManual = SoundDefOf.Door_CloseManual;
     }
     if (turretGunDef != null)
     {
         LongEventHandler.ExecuteWhenFinished(delegate
         {
             turretTopMat = MaterialPool.MatFrom(turretGunDef.graphicData.texPath);
         });
     }
     if (fixedStorageSettings != null)
     {
         fixedStorageSettings.filter.ResolveReferences();
     }
     if (defaultStorageSettings == null && fixedStorageSettings != null)
     {
         defaultStorageSettings = new StorageSettings();
         defaultStorageSettings.CopyFrom(fixedStorageSettings);
     }
     if (defaultStorageSettings != null)
     {
         defaultStorageSettings.filter.ResolveReferences();
     }
 }
Beispiel #18
0
        public EccentricTechFusionPower(ModContentPack mod)
        {
            // RNG
            {
                var type = AccessTools.TypeByName("EccentricPower.CompFusionGenerator");
                PatchingUtilities.PatchSystemRand(AccessTools.Method(type, "generateNewFailurePoints"), false);
                PatchingUtilities.PatchSystemRand(AccessTools.Method(type, "doEmergencyVentFireDamage"), true);
            }

            // Gizmos
            {
                var type = AccessTools.TypeByName("EccentricPower.CompFusionGenerator");
                MP.RegisterSyncMethod(type, "SetDesiredOutputLevel");
                MP.RegisterSyncMethod(type, "setPowerMode");
                MP.RegisterSyncMethod(type, "StartIgnitionCycle");
                MP.RegisterSyncMethod(type, "StartShutdownCycle");
                MP.RegisterSyncMethod(type, "StartEmergencyVent");
                MpCompat.RegisterLambdaMethod(type, "CompGetGizmosExtra", Enumerable.Range(3, 5).ToArray()).SetDebugOnly(); // 3 to 7
            }

            LongEventHandler.ExecuteWhenFinished(LatePatch);
        }
Beispiel #19
0
 public void ResolveReferencesSpecial()
 {
     if (this.soundDoorOpenPowered == null)
     {
         this.soundDoorOpenPowered = SoundDefOf.Door_OpenPowered;
     }
     if (this.soundDoorClosePowered == null)
     {
         this.soundDoorClosePowered = SoundDefOf.Door_ClosePowered;
     }
     if (this.soundDoorOpenManual == null)
     {
         this.soundDoorOpenManual = SoundDefOf.Door_OpenManual;
     }
     if (this.soundDoorCloseManual == null)
     {
         this.soundDoorCloseManual = SoundDefOf.Door_CloseManual;
     }
     if (!this.turretTopGraphicPath.NullOrEmpty())
     {
         LongEventHandler.ExecuteWhenFinished(delegate
         {
             this.turretTopMat = MaterialPool.MatFrom(this.turretTopGraphicPath);
         });
     }
     if (this.fixedStorageSettings != null)
     {
         this.fixedStorageSettings.filter.ResolveReferences();
     }
     if (this.defaultStorageSettings == null && this.fixedStorageSettings != null)
     {
         this.defaultStorageSettings = new StorageSettings();
         this.defaultStorageSettings.CopyFrom(this.fixedStorageSettings);
     }
     if (this.defaultStorageSettings != null)
     {
         this.defaultStorageSettings.filter.ResolveReferences();
     }
 }
 public Sustainer(SoundDef def, SoundInfo info)
 {
     this.def  = def;
     this.info = info;
     if (def.subSounds.Count > 0)
     {
         foreach (KeyValuePair <string, float> keyValuePair in info.DefinedParameters)
         {
             this.externalParams[keyValuePair.Key] = keyValuePair.Value;
         }
         if (def.HasSubSoundsInWorld)
         {
             if (info.IsOnCamera)
             {
                 Log.Error("Playing sound " + def.ToString() + " on camera, but it has sub-sounds in the world.", false);
             }
             this.worldRootObject = new GameObject("SustainerRootObject_" + def.defName);
             this.UpdateRootObjectPosition();
         }
         else if (!info.IsOnCamera)
         {
             info = SoundInfo.OnCamera(info.Maintenance);
         }
         Find.SoundRoot.sustainerManager.RegisterSustainer(this);
         if (!info.IsOnCamera)
         {
             Find.SoundRoot.sustainerManager.UpdateAllSustainerScopes();
         }
         for (int i = 0; i < def.subSounds.Count; i++)
         {
             this.subSustainers.Add(new SubSustainer(this, def.subSounds[i]));
         }
     }
     LongEventHandler.ExecuteWhenFinished(delegate
     {
         this.lastMaintainTick  = Find.TickManager.TicksGame;
         this.lastMaintainFrame = Time.frameCount;
     });
 }
Beispiel #21
0
 public VerbProperties_Custom()
 {
     LongEventHandler.ExecuteWhenFinished(delegate
     {
         if (!texPath.NullOrEmpty())
         {
             texture = ContentFinder <Texture2D> .Get(texPath);
         }
         if (!texPathSelected.NullOrEmpty())
         {
             textureSelected = ContentFinder <Texture2D> .Get(texPathSelected);
         }
         if (!texPathCooldown.NullOrEmpty())
         {
             textureCooldown = ContentFinder <Texture2D> .Get(texPathCooldown);
         }
         if (verbClass == typeof(Verb_Shoot_Cooldown) && cooldownTick <= 0)
         {
             Log.Warning($"[Explorite]Detected cooldownTick {cooldownTick}, which is not more than 0.");
         }
     });
 }
        public VFESecurity(ModContentPack mod)
        {
            // Artillery fix
            {
                var type = AccessTools.TypeByName("RimWorld.Building_TurretGun");
                resetCurrentTargetMethod = AccessTools.Method(type, "ResetCurrentTarget");
                resetForcedTargetMethod  = AccessTools.Method(type, "ResetForcedTarget");
            }

            // RNG fix
            {
                var methodNames = new[]
                {
                    "VFESecurity.ArtilleryStrikeArrivalAction_AIBase:Arrived",
                    "VFESecurity.ArtilleryStrikeArrivalAction_Insectoid:StrikeAction",
                    "VFESecurity.ArtilleryStrikeArrivalAction_Map:Arrived",
                    "VFESecurity.ArtilleryStrikeArrivalAction_Outpost:StrikeAction",
                    "VFESecurity.ArtilleryStrikeArrivalAction_PeaceTalks:Arrived",
                    "VFESecurity.ArtilleryStrikeArrivalAction_Settlement:StrikeAction",
                    "VFESecurity.WorldObjectCompProperties_Artillery:ArtilleryCountFor",
                    // ArtilleryStrikeUtility:GetRandomShellFor and ArtilleryStrikeUtility:PotentialStrikeCells are only called by methods that are patched already
                    "VFESecurity.Building_BarbedWire:SpringSub",
                    "VFESecurity.Building_TrapBear:SpringSub",
                    // This one seems like it should have no random calls at all in its hierarchy, but desync traces show that there are actually some.
                    "VFESecurity.Verb_Dazzle:TryCastShot",
                    "NoCamShakeExplosions.DamageWorker_FlameNoCamShake:Apply",
                    "NoCamShakeExplosions.DamageWorker_FlameNoCamShake:ExplosionAffectCell",
                    // Motes
                    "VFESecurity.ExtendedMoteMaker:SearchlightEffect",
                    "ExplosiveTrailsEffect.ExhaustFlames:ThrowRocketExhaustFlame",
                    "ExplosiveTrailsEffect.SmokeThrowher:ThrowSmokeTrail",
                };

                PatchingUtilities.PatchPushPopRand(AccessTools.Method(AccessTools.Inner(AccessTools.TypeByName("VFESecurity.Patch_Building_Trap"), "Spring"), "ShouldDestroy"));
                PatchingUtilities.PatchPushPopRand(methodNames);
                LongEventHandler.ExecuteWhenFinished(LateSyncMethods);
            }
        }
Beispiel #23
0
        public static void Initialize()
        {
            // make sure we only have one initializer running
            if (_initializing)
            {
                return;
            }
            _initializing = true;

            // setup
            LongEventHandler.QueueLongEvent(CheckPrerequisites, "Fluffy.ResearchTree.PreparingTree.Setup", false, null);
            LongEventHandler.QueueLongEvent(CreateEdges, "Fluffy.ResearchTree.PreparingTree.Setup", false, null);
            LongEventHandler.QueueLongEvent(HorizontalPositions, "Fluffy.ResearchTree.PreparingTree.Setup", false, null);
            LongEventHandler.QueueLongEvent(NormalizeEdges, "Fluffy.ResearchTree.PreparingTree.Setup", false, null);
#if DEBUG
            LongEventHandler.QueueLongEvent(DebugStatus, "Fluffy.ResearchTree.PreparingTree.Setup", false, null);
#endif

            // crossing reduction
            LongEventHandler.QueueLongEvent(Collapse, "Fluffy.ResearchTree.PreparingTree.CrossingReduction", false, null);
            LongEventHandler.QueueLongEvent(MinimizeCrossings, "Fluffy.ResearchTree.PreparingTree.CrossingReduction", false, null);
#if DEBUG
            LongEventHandler.QueueLongEvent(DebugStatus, "Fluffy.ResearchTree.PreparingTree.CrossingReduction", false, null);
#endif

            // layout
            LongEventHandler.QueueLongEvent(MinimizeEdgeLength, "Fluffy.ResearchTree.PreparingTree.Layout", false, null);
            LongEventHandler.QueueLongEvent(RemoveEmptyRows, "Fluffy.ResearchTree.PreparingTree.Layout", false, null);
#if DEBUG
            LongEventHandler.QueueLongEvent(DebugStatus, "Fluffy.ResearchTree.PreparingTree.Layout", false, null);
#endif

            // done!
            LongEventHandler.QueueLongEvent(() => { Initialized = true; }, "Fluffy.ResearchTree.PreparingTree.Layout", false, null);

            // tell researh tab we're ready
            LongEventHandler.QueueLongEvent(MainTabWindow_ResearchTree.Instance.Notify_TreeInitialized, "Fluffy.ResearchTree.RestoreQueue", false, null);
        }
        private void SyncModsAndConfigs(bool syncConfigs)
        {
            Log.Message("MP remote host's modIds: " + string.Join(", ", mods.remoteModIds));
            Log.Message("MP remote host's workshopIds: " + string.Join(", ", mods.remoteWorkshopModIds));

            LongEventHandler.QueueLongEvent(() => {
                try {
                    ModManagement.DownloadWorkshopMods(mods.remoteWorkshopModIds);
                }
                catch (InvalidOperationException e) {
                    Log.Warning($"MP Workshop mod download error: {e.Message}");
                    var missingMods = ModManagement.GetNotInstalledMods(mods.remoteModIds).ToList();
                    if (missingMods.Any())
                    {
                        Find.WindowStack.Add(new DebugTextWindow(
                                                 $"Failed to connect to Workshop.\nThe following mods are missing, please install them:\n"
                                                 + missingMods.Join(s => $"- {s}", "\n")
                                                 ));
                        return;
                    }
                }

                try {
                    ModManagement.RebuildModsList();
                    ModsConfig.SetActiveToList(mods.remoteModIds.ToList());
                    ModsConfig.Save();
                    if (syncConfigs)
                    {
                        ModManagement.ApplyHostModConfigFiles(mods.remoteModConfigs);
                    }
                    ModManagement.PromptRestartAndReconnect(mods.remoteAddress, mods.remotePort);
                }
                catch (Exception e) {
                    Log.Error($"MP mod sync error: {e.GetType()} {e.Message}");
                    Find.WindowStack.Add(new DebugTextWindow($"Failed to sync mods: {e.GetType()} {e.Message}"));
                }
            }, "MpDownloadingWorkshopMods", true, null);
        }
        public static void Settle(Caravan caravan)
        {
            Faction faction = caravan.Faction;

            if (faction != Faction.OfPlayer)
            {
                Log.Error("Cannot settle with non-player faction.", false);
            }
            else
            {
                Settlement newHome = SettleUtility.AddNewHome(caravan.Tile, faction);
                Action     action  = delegate()
                {
                    GetOrGenerateMapUtility.GetOrGenerateMap(caravan.Tile, Find.World.info.initialMapSize, null);
                };
                string textKey          = "GeneratingMap";
                bool   doAsynchronously = true;
                if (SettleInEmptyTileUtility.< > f__mg$cache0 == null)
                {
                    SettleInEmptyTileUtility.< > f__mg$cache0 = new Action <Exception>(GameAndMapInitExceptionHandlers.ErrorWhileGeneratingMap);
                }
                LongEventHandler.QueueLongEvent(action, textKey, doAsynchronously, SettleInEmptyTileUtility.< > f__mg$cache0);
                Action action2 = delegate()
                {
                    Map  map = newHome.Map;
                    Pawn t   = caravan.PawnsListForReading[0];
                    CaravanEnterMapUtility.Enter(caravan, map, CaravanEnterMode.Center, CaravanDropInventoryMode.DropInstantly, false, (IntVec3 x) => x.GetRoom(map, RegionType.Set_Passable).CellCount >= 600);
                    CameraJumper.TryJump(t);
                };
                string textKey2          = "SpawningColonists";
                bool   doAsynchronously2 = true;
                if (SettleInEmptyTileUtility.< > f__mg$cache1 == null)
                {
                    SettleInEmptyTileUtility.< > f__mg$cache1 = new Action <Exception>(GameAndMapInitExceptionHandlers.ErrorWhileGeneratingMap);
                }
                LongEventHandler.QueueLongEvent(action2, textKey2, doAsynchronously2, SettleInEmptyTileUtility.< > f__mg$cache1);
            }
        }
        public override void SpawnSetup()
        {
            base.SpawnSetup();

            ToolsForHaulUtility.CartTurret.Add(this);

            if (mountableComp.Driver != null && IsCurrentlyMotorized())
            {
                LongEventHandler.ExecuteWhenFinished(delegate
                {
                    SoundInfo info = SoundInfo.InWorld(this);
                    mountableComp.sustainerAmbient = vehicleComp.compProps.soundAmbient.TrySpawnSustainer(info);
                });
            }

            if (mountableComp.Driver != null)
            {
                mountableComp.Driver.RaceProps.makesFootprints = false;

                if (mountableComp.Driver.RaceProps.Humanlike)
                {
                    mountableComp.driverComp = new CompDriver {
                        vehicle = this
                    };
                    mountableComp.Driver.AllComps?.Add(mountableComp.driverComp);
                    mountableComp.driverComp.parent = mountableComp.Driver;
                }
            }

            //if (allowances == null)
            //{
            //    allowances = new ThingFilter();
            //    allowances.SetFromPreset(StorageSettingsPreset.DefaultStockpile);
            //    allowances.SetFromPreset(StorageSettingsPreset.DumpingStockpile);
            //}

            LongEventHandler.ExecuteWhenFinished(UpdateGraphics);
        }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            map         = parms.target as Map;
            pos         = altar(map).Position;
            exSacrifice = corpse(map).InnerPawn;
            deadBody    = corpse(map);

            LongEventHandler.QueueLongEvent(delegate
            {
                //Throw some smoke
                MoteMaker.ThrowDustPuff(SpellWorker_Reincarnation.pos, SpellWorker_Reincarnation.map, 2f);

                //Make the body strip and despawn around the altar
                SpellWorker_Reincarnation.deadBody.Strip();
                SpellWorker_Reincarnation.deadBody.DeSpawn();

                //Trigger the nightmare event on the altar
                altar(SpellWorker_Reincarnation.map).NightmareEvent();

                Cthulhu.Utility.ApplyTaleDef("Cults_SpellReincarnation", deadBody.InnerPawn);
            }, "Cults_SpellReincarnation", false, null);
            return(true);
        }
        public static void Settle(Caravan caravan)
        {
            Faction faction = caravan.Faction;

            if (faction != Faction.OfPlayer)
            {
                Log.Error("Cannot settle with non-player faction.", false);
                return;
            }
            Settlement newHome = SettleUtility.AddNewHome(caravan.Tile, faction);

            LongEventHandler.QueueLongEvent(delegate
            {
                GetOrGenerateMapUtility.GetOrGenerateMap(caravan.Tile, Find.World.info.initialMapSize, null);
            }, "GeneratingMap", true, new Action <Exception>(GameAndMapInitExceptionHandlers.ErrorWhileGeneratingMap));
            LongEventHandler.QueueLongEvent(delegate
            {
                Map map = newHome.Map;
                Pawn t  = caravan.PawnsListForReading[0];
                CaravanEnterMapUtility.Enter(caravan, map, CaravanEnterMode.Center, CaravanDropInventoryMode.DropInstantly, false, (IntVec3 x) => x.GetRoom(map, RegionType.Set_Passable).CellCount >= 600);
                CameraJumper.TryJump(t);
            }, "SpawningColonists", true, new Action <Exception>(GameAndMapInitExceptionHandlers.ErrorWhileGeneratingMap));
        }
        public static void ReplaceEdgeWalls(ResolveParams rp, ThingDef wall, ThingDef door = null)
        {
            Map map = BaseGen.globalSettings.map;

            rp.rect = rp.rect.ExpandedBy(1);
            LongEventHandler.QueueLongEvent(delegate
            {
                foreach (IntVec3 current in rp.rect.EdgeCells)
                {
                    //Thing regBar = ThingMaker.MakeThing(ThingDefOf.TemporaryRegionBarrier);
                    //GenSpawn.Spawn(regBar, current, map);
                    if (current.GetFirstThing(map, ThingDefOf.Wall) != null)
                    {
                        GenSpawn.Spawn(ThingMaker.MakeThing(ThingDefOf.Wall, wall), current, map);
                    }
                    else if (current.GetFirstThing(map, ThingDefOf.Door) != null)
                    {
                        GenSpawn.Spawn(ThingMaker.MakeThing(ThingDefOf.Door, door ?? wall), current, map);
                    }
                    //regBar.Destroy(DestroyMode.Vanish);
                }
            }, "wall" + DateTime.Now.GetHashCode(), false, null);
        }
Beispiel #30
0
 protected override bool CanDoNext()
 {
     if (!base.CanDoNext())
     {
         return(false);
     }
     LongEventHandler.QueueLongEvent(delegate
     {
         Find.GameInitData.ResetWorldRelatedMapInitData();
         Current.Game.World = WorldGenerator.GenerateWorld(this.planetCoverage, this.seedString, this.rainfall, this.temperature);
         LongEventHandler.ExecuteWhenFinished(delegate
         {
             if (this.next != null)
             {
                 Find.WindowStack.Add(this.next);
             }
             MemoryUtility.UnloadUnusedUnityAssets();
             Find.World.renderer.RegenerateAllLayersNow();
             this.Close(true);
         });
     }, "GeneratingWorld", true, null);
     return(false);
 }