private static void CorrectLoadOrderBeforeRestart()
        {
            var allMods = LoadedModManager.RunningMods.ToList();

            // Deactivate all mods
            foreach (var mod in allMods)
            {
                ModsConfig.SetActive(mod.Name, false);
            }
            // Activate core first
            ModsConfig.SetActive(ModContentPack.CoreModIdentifier, true);
            if (cclModIndex != -1)
            { // Activate CCL second
                ModsConfig.SetActive(Controller.Data.cclModIdentifier, true);
            }
            // Activate everything else in the same order
            foreach (var mod in allMods)
            {
                if (
                    (mod.Name != ModContentPack.CoreModIdentifier) &&
                    (mod.Name != Controller.Data.cclModIdentifier)
                    )
                {
                    ModsConfig.SetActive(mod.Name, true);
                }
            }
            // Now save the config
            ModsConfig.Save();
        }
        // Handle the reloading of mods when the Mods screen is closed.
        public override void PostClose()
        {
            base.PostClose();

            // Only reloads mods if the user actually made changes to the mod configuration.
            if (HasConfigurationChanged)
            {
                // Deactivate all of the mods...
                foreach (InstalledMod mod in InstalledModLister.AllInstalledMods)
                {
                    mod.Active = false;
                }
                // ...and then activate them in the selected order
                foreach (InstalledMod mod in activeMods)
                {
                    mod.Active = true;
                }

                ModsConfig.Save();
                PlayDataLoader.ClearAllPlayData();
                PlayDataLoader.LoadAllPlayData(false);
            }
            else
            {
                Log.Message("Mod selection did not change.  Skipping mod reload.");
            }

            // TODO: Alpha 12
            //Find.WindowStack.Add(new Page_MainMenu());
        }
        private static void ExposeData(string filepath, bool useUndoAction = false)
        {
            try {
                if (CurrentMode == Mode.Saving)
                {
                    Data = new ModsConfigData {
                        buildNumber = RimWorld.VersionControl.CurrentBuild,
                        activeMods  = ModsConfigHandler.GetActiveMods()
                    };
                    DirectXmlSaver.SaveDataObject((object)Data, filepath);
                }
                else if (CurrentMode == Mode.Loading)
                {
                    List <string> current = new List <string>();

                    Data = ReadModList(filepath);

                    ModsConfigHandler.ClearLoadedMods(true);
                    foreach (string modID in Data.activeMods)
                    {
                        ModsConfig.SetActive(modID, true);
                    }
                }
            }
            catch (Exception e) {
                Main.Log.ReportException(e);
                ModsConfigHandler.ClearLoadedMods();
            }
        }
Example #4
0
        private static void CorrectLoadOrderBeforeRestart()
        {
            var allMods = LoadedModManager.LoadedMods.ToList();

            // Deactivate all mods
            foreach (var mod in allMods)
            {
                ModsConfig.SetActive(mod.name, false);
            }
            // Activate core first
            ModsConfig.SetActive("Core", true);
            if (cclModIndex != -1)
            { // Activate CCL second
                ModsConfig.SetActive(Controller.Data.UnityObjectName, true);
            }
            // Activate everything else in the same order
            foreach (var mod in allMods)
            {
                if (
                    (mod.name != "Core") &&
                    (mod.name != Controller.Data.UnityObjectName)
                    )
                {
                    ModsConfig.SetActive(mod.name, true);
                }
            }
            // Now save the config
            ModsConfig.Save();
        }
Example #5
0
        public static void InjectCustomUI()
        {
            Rect editButtonRect = new Rect(620f, 0.0f, 50f, 30f);

            if (ModsConfig.IsActive("hahkethomemah.simplepersonalities"))
            {
                editButtonRect.x -= 130;
            }

            if (Widgets.ButtonText(editButtonRect, "RandomPlus.FilterButton".Translate(), true, false, true))
            {
                var page = new Page_RandomEditor();
                Find.WindowStack.Add(page);
            }

            Rect rerollLabelRect = new Rect(620f, 40f, 200f, 30f);

            if (ModsConfig.IdeologyActive)
            {
                rerollLabelRect.y += 40;
            }

            string labelText = "RandomPlus.RerollLabel".Translate() + RandomSettings.RandomRerollCounter() + "/" + RandomSettings.PawnFilter.RerollLimit;

            var tmpSave = GUI.color;

            if (RandomSettings.RandomRerollCounter() >= RandomSettings.PawnFilter.RerollLimit)
            {
                GUI.color = Color.red;
            }
            Widgets.Label(rerollLabelRect, labelText);
            GUI.color = tmpSave;
        }
Example #6
0
        public static void GenerateLaserFence(ZoneProperties[,] zoneMap, ref OG_OutpostData outpostData)
        {
            if (ModsConfig.IsActive("M&Co. LaserFence") == false)
            {
                Log.Warning("M&Co. OutpostGenerator: M&Co. LaserFence mod is not active. Cannot generate laser fences.");
                return;
            }

            int horizontalZonesNumber = 0;
            int verticalZonesNumber   = 0;

            if (outpostData.size == OG_OutpostSize.SmallOutpost)
            {
                horizontalZonesNumber = OG_SmallOutpost.horizontalZonesNumber;
                verticalZonesNumber   = OG_SmallOutpost.verticalZonesNumber;

                GenerateLaseFenceForSmallOutpost(zoneMap, horizontalZonesNumber, verticalZonesNumber, ref outpostData);
            }
            else
            {
                horizontalZonesNumber = OG_BigOutpost.horizontalZonesNumber;
                verticalZonesNumber   = OG_BigOutpost.verticalZonesNumber;
                GenerateLaseFenceForBigOutpost(zoneMap, horizontalZonesNumber, verticalZonesNumber, ref outpostData);
            }
        }
        public void SaveMods()
        {
            var config = new INI();

            this.SaveModsTo(             // Save as RWMV xml
                Path.Combine(
                    config.Read("ConfigurationDir", "Directories"),
                    "Config",
                    "Default.rwmv.xml"
                    )
                );

            // Save as RimWorld xml
            ModsConfig.SaveAsRimWorldModsConfig(
                Path.Combine(
                    config.Read("ConfigurationDir", "Directories"),
                    "Config",
                    "ModsConfig.xml"
                    ),
                this.ModList.ToArray()
                );
            ModColor.SaveModsColor(
                Path.Combine(
                    config.Read("ConfigurationDir", "Directories")
                    ),
                this.ModList.ToArray()
                );
            MessageBox.Show("Save done.", "RimWorldModVisualizer", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Example #8
0
 private static void BindDefsFor(Type type)
 {
     FieldInfo[] fields = type.GetFields(BindingFlags.Static | BindingFlags.Public);
     foreach (FieldInfo fieldInfo in fields)
     {
         Type fieldType = fieldInfo.FieldType;
         if (!typeof(Def).IsAssignableFrom(fieldType))
         {
             Log.Error(fieldType + " is not a Def.");
             continue;
         }
         MayRequireAttribute mayRequireAttribute = fieldInfo.TryGetAttribute <MayRequireAttribute>();
         bool              flag = (mayRequireAttribute == null || ModsConfig.IsActive(mayRequireAttribute.modId)) && !earlyTry;
         string            text = fieldInfo.Name;
         DefAliasAttribute defAliasAttribute = fieldInfo.TryGetAttribute <DefAliasAttribute>();
         if (defAliasAttribute != null)
         {
             text = defAliasAttribute.defName;
         }
         if (fieldType == typeof(SoundDef))
         {
             SoundDef soundDef = SoundDef.Named(text);
             if (soundDef.isUndefined && flag)
             {
                 Log.Error("Could not find SoundDef named " + text);
             }
             fieldInfo.SetValue(null, soundDef);
         }
         else
         {
             Def def = GenDefDatabase.GetDef(fieldType, text, flag);
             fieldInfo.SetValue(null, def);
         }
     }
 }
        private static void PostCloseDetour(this Page_ModsConfig self)
        {
            if (SettingsHandler.LastRestartOnClose.Value != RestartOnClose)
            {
                SettingsHandler.LastRestartOnClose.Value = RestartOnClose;
                HugsLibController.Instance.Settings.SaveChanges();
            }

            ModsConfig.Save();
            int activeModsWhenOpenedHash = (int)typeof(Page_ModsConfig).GetField("activeModsWhenOpenedHash", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(self);

            if (activeModsWhenOpenedHash != ModLister.InstalledModsListHash(true))
            {
                if (RestartOnClose)
                {
                    PlatformHandler.RestartRimWorld();
                }

                //Copy of source from here
                bool assemblyWasLoaded = LoadedModManager.RunningMods.Any((ModContentPack m) => m.LoadedAnyAssembly);
                LongEventHandler.QueueLongEvent(delegate
                {
                    PlayDataLoader.ClearAllPlayData();
                    PlayDataLoader.LoadAllPlayData(false);
                    if (assemblyWasLoaded)
                    {
                        LongEventHandler.ExecuteWhenFinished(delegate
                        {
                            Find.WindowStack.Add(new Dialog_MessageBox("ModWithAssemblyWasUnloaded".Translate(), null, null, null, null, null, false));
                        });
                    }
                }, "LoadingLongEvent", true, null);
            }
        }
Example #10
0
        public static void DeactivateMod()
        {
            _isDeactivating = true;

            ModsConfig.SetActive(Mod.ContentPack.Identifier, false);

            var runningMods = PrivateAccess.Verse_LoadedModManager_RunningMods();

            runningMods.Remove(Mod.ContentPack);

            var addonMods = new StringBuilder();

            foreach (var mod in AddonManager.Mods)
            {
                addonMods.AppendLine(mod.Name);
                ModsConfig.SetActive(mod.Identifier, false);
                runningMods.Remove(mod);
            }

            ModsConfig.Save();

            if (Find.WorldObjects.Contains(Instance))
            {
                Find.WorldObjects.Remove(Instance);
            }

            const string saveName = "PawnRules_Removed";

            GameDataSaveLoader.SaveGame(saveName);

            var message = addonMods.Length > 0 ? Lang.Get("Button.RemoveModAndAddonsComplete", saveName.Bold(), addonMods.ToString()) : Lang.Get("Button.RemoveModComplete", saveName.Bold());

            Find.WindowStack.Add(new Dialog_Alert(message, Dialog_Alert.Buttons.Ok, GenCommandLine.Restart));
        }
Example #11
0
        private static void GenerateOneShootingLine(IntVec3 shootingPosition, Rot4 rotation, ref OG_OutpostData outpostData)
        {
            // Spawn floor.
            for (int xOffset = -1; xOffset <= 1; xOffset++)
            {
                for (int zOffset = -1; zOffset <= 9; zOffset++)
                {
                    Find.TerrainGrid.SetTerrain(shootingPosition + new IntVec3(xOffset, 0, zOffset).RotatedBy(rotation), TerrainDefOf.Concrete);
                }
            }
            Find.TerrainGrid.SetTerrain(shootingPosition + new IntVec3(0, 0, 2).RotatedBy(rotation), TerrainDef.Named("MetalTile"));
            Find.TerrainGrid.SetTerrain(shootingPosition + new IntVec3(0, 0, 3).RotatedBy(rotation), TerrainDef.Named("PavedTile"));
            Find.TerrainGrid.SetTerrain(shootingPosition + new IntVec3(0, 0, 4).RotatedBy(rotation), TerrainDef.Named("MetalTile"));
            Find.TerrainGrid.SetTerrain(shootingPosition + new IntVec3(0, 0, 5).RotatedBy(rotation), TerrainDef.Named("PavedTile"));
            Find.TerrainGrid.SetTerrain(shootingPosition + new IntVec3(0, 0, 6).RotatedBy(rotation), TerrainDef.Named("MetalTile"));
            Find.TerrainGrid.SetTerrain(shootingPosition + new IntVec3(0, 0, 7).RotatedBy(rotation), TerrainDef.Named("PavedTile"));

            // Spawn sandbags.
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, shootingPosition + new IntVec3(-1, 0, 0).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, shootingPosition + new IntVec3(-1, 0, 1).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, shootingPosition + new IntVec3(0, 0, 1).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, shootingPosition + new IntVec3(1, 0, 1).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, shootingPosition + new IntVec3(1, 0, 0).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);

            // Spawn target.
            if (ModsConfig.IsActive("Miscellaneous_TrainingFacility"))
            {
                OG_Common.TrySpawnThingAt(ThingDef.Named("ShootingRangeTarget"), null, shootingPosition + new IntVec3(0, 0, 8).RotatedBy(rotation), true, new Rot4(Rot4.South.AsInt + rotation.AsInt), ref outpostData);
            }
            else
            {
                OG_Common.TrySpawnWallAt(shootingPosition + new IntVec3(0, 0, 8).RotatedBy(rotation), ref outpostData);
            }
        }
Example #12
0
 public override void PostClose()
 {
     ModsConfig.Save();
     if (this.activeModsWhenOpenedHash != ModLister.InstalledModsListHash(true))
     {
         ModsConfig.RestartFromChangedMods();
     }
 }
 /// <summary>
 /// Clears the current active mods
 /// </summary>
 /// <param name="removeCore">Set to true to remove core [Optional](Default:false)</param>
 internal static void ClearLoadedMods(bool removeCore = false)
 {
     ModsConfig.Reset();
     if (removeCore)
     {
         ModsConfig.SetActive(ModContentPack.CoreModIdentifier, false);
     }
 }
 /// <summary>
 /// Set the current active mods
 /// </summary>
 /// <param name="modsToActivate">The mods to set as active</param>
 internal static void SetActiveMods(List <string> modsToActivate)
 {
     ClearLoadedMods(true);
     foreach (string modID in modsToActivate)
     {
         ModsConfig.SetActive(modID, true);
     }
     ModsConfig.Save();
 }
Example #15
0
        public static ModMetaData GetInstalledMod(string id)
        {
            if (ModsConfig.IsActive(id + ModMetaData.SteamModPostfix))
            {
                id += ModMetaData.SteamModPostfix;
            }

            return(ModLister.GetModWithIdentifier(id));
        }
Example #16
0
 public override void PreClose()
 {
     base.PreClose();
     Prefs.Save();
     if (Prefs.SimulateNotOwningRoyalty && !simulateNotOwningRoyaltyWhenOpened && ModsConfig.RoyaltyActive)
     {
         ModsConfig.SetActive(ModContentPack.RoyaltyModPackageId, active: false);
         ModsConfig.RestartFromChangedMods();
     }
 }
Example #17
0
 void RenderLoadFromSaveButton(Rect LoadFromSaveRect)
 {
     if (Widgets.ButtonText(LoadFromSaveRect, "ChangeLoadedMods".Translate()))
     {
         if (Current.ProgramState == ProgramState.Entry)
         {
             ModsConfig.SetActiveToList(ScribeMetaHeaderUtility.loadedModIdsList);
         }
         ModsConfig.SaveFromList(ScribeMetaHeaderUtility.loadedModIdsList);
         ModsConfig.RestartFromChangedMods();
     }
 }
 public override void PostClose()
 {
     ModsConfig.Save();
     foreach (ModMetaData item in ModsConfig.ActiveModsInLoadOrder)
     {
         item.UnsetPreviewImage();
     }
     Resources.UnloadUnusedAssets();
     if (activeModsWhenOpenedHash != ModLister.InstalledModsListHash(activeOnly: true))
     {
         ModsConfig.RestartFromChangedMods();
     }
 }
Example #19
0
 public bool CanShowWithLoadedMods()
 {
     if (!showIfModsLoaded.NullOrEmpty())
     {
         for (int i = 0; i < showIfModsLoaded.Count; i++)
         {
             if (!ModsConfig.IsActive(showIfModsLoaded[i]))
             {
                 return(false);
             }
         }
     }
     return(true);
 }
Example #20
0
        public static void TryAddRecipeMakeMineralSonarModule()
        {
            if (ModsConfig.IsActive("M&Co. MMS"))
            {
                ThingDef electronicWorkbench = DefDatabase <ThingDef> .GetNamed("ElectronicWorkbench");

                if ((Find.ResearchManager.IsFinished(ResearchProjectDef.Named("ResearchMobileMineralSonar")) == true) &&
                    (electronicWorkbench.recipes.Contains(DefDatabase <RecipeDef> .GetNamed("MakeMineralSonarModule")) == false))
                {
                    electronicWorkbench.recipes.Add(DefDatabase <RecipeDef> .GetNamed("MakeMineralSonarModule"));
                    typeof(ThingDef).GetField("allRecipesCached", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).SetValue(electronicWorkbench, null);
                }
            }
        }
        public override void DrawButtons(Rect inRect)
        {
            var btnWidth = 90f;
            var gap      = 10f;

            Rect btnRect = new Rect(gap, inRect.height - ButtonHeight - 10f, btnWidth, ButtonHeight);

            if (Widgets.ButtonText(btnRect, "Details".Translate()))
            {
                var defs = mods.defInfo.Where(kv => kv.Value.status != DefCheckStatus.OK).Join(kv => $"{kv.Key}: {kv.Value.status}", delimiter: "\n");

                Find.WindowStack.Add(new TextAreaWindow($"Mismatches:\n\n{defs}"));
            }

            btnRect.x += btnWidth + gap;

            if (Widgets.ButtonText(btnRect, "MpModList".Translate()))
            {
                ShowModList(mods);
            }
            btnRect.x += btnWidth + gap;

            btnRect.width = 140f;
            if (Widgets.ButtonText(btnRect, "MpSyncModList".Translate()))
            {
                Log.Message("MP remote host's modIds: " + string.Join(", ", mods.remoteModIds));
                Log.Message("MP remote host's workshopIds: " + string.Join(", ", mods.remoteWorkshopModIds));

                LongEventHandler.QueueLongEvent(() => {
                    ModManagement.DownloadWorkshopMods(mods.remoteWorkshopModIds);
                    try {
                        ModManagement.RebuildModsList();
                        ModsConfig.SetActiveToList(mods.remoteModIds.ToList());
                        ModsConfig.Save();
                        ModManagement.PromptRestartAndReconnect(mods.remoteAddress, mods.remotePort);
                    }
                    catch (Exception e) {
                        Log.Error($"MP mod sync error: {e.GetType()} {e.Message}");
                    }
                }, "MpDownloadingWorkshopMods", true, null);
            }

            btnRect.x    += btnRect.width + gap;
            btnRect.width = btnWidth;

            if (Widgets.ButtonText(btnRect, "CloseButton".Translate()))
            {
                Close();
            }
        }
Example #22
0
        public override void PreOpen()
        {
            base.PreOpen();
            if (ModsConfig.IsActive("Lakuna.WellMet"))
            {
                MOD_WELL_MET = true;
            }

            panelSkills = new PanelSkills();
            panelTraits = new PanelTraits();
            panelOthers = new PanelOthers();

            RectButtonResetAll = new Rect(InitialSize.x - (ButtonWidth + 50), ButtonHeight - 8, ButtonWidth, ButtonHeight);
            RectButtonSaveLoad = new Rect(InitialSize.x - (ButtonWidth * 2 + 60), ButtonHeight - 8, ButtonWidth, ButtonHeight);
        }
Example #23
0
 public static void InitializeCloaks()
 {
     Constants.cloaks = new List <Texture>();
     Constants.cloaks.Clear();
     Constants.cloaksNorth = new List <Texture>();
     Constants.cloaksNorth.Clear();
     Constants.cloaksNorth.Add(MaterialPool.MatFrom("Equipment/opencloak_Female_north").mainTexture);
     Constants.cloaksNorth.Add(MaterialPool.MatFrom("Equipment/opencloak_Hulk_north").mainTexture);
     Constants.cloaksNorth.Add(MaterialPool.MatFrom("Equipment/opencloak_Male_north").mainTexture);
     Constants.cloaksNorth.Add(MaterialPool.MatFrom("Equipment/opencloak_Thin_north").mainTexture);
     Constants.cloaksNorth.Add(MaterialPool.MatFrom("Equipment/opencloak_Fat_north").mainTexture);
     Constants.cloaks.Add(MaterialPool.MatFrom("Equipment/opencloak_Female_east").mainTexture);
     Constants.cloaks.Add(MaterialPool.MatFrom("Equipment/opencloak_Female_south").mainTexture);
     Constants.cloaks.Add(MaterialPool.MatFrom("Equipment/opencloak_Fat_east").mainTexture);
     Constants.cloaks.Add(MaterialPool.MatFrom("Equipment/opencloak_Fat_south").mainTexture);
     Constants.cloaks.Add(MaterialPool.MatFrom("Equipment/opencloak_Hulk_east").mainTexture);
     Constants.cloaks.Add(MaterialPool.MatFrom("Equipment/opencloak_Hulk_south").mainTexture);
     Constants.cloaks.Add(MaterialPool.MatFrom("Equipment/opencloak_Thin_east").mainTexture);
     Constants.cloaks.Add(MaterialPool.MatFrom("Equipment/opencloak_Thin_south").mainTexture);
     Constants.cloaks.Add(MaterialPool.MatFrom("Equipment/opencloak_Male_east").mainTexture);
     Constants.cloaks.Add(MaterialPool.MatFrom("Equipment/opencloak_Male_south").mainTexture);
     Constants.cloaksNorth.Add(MaterialPool.MatFrom("Equipment/demonlordcloakc_Female_north").mainTexture);
     Constants.cloaksNorth.Add(MaterialPool.MatFrom("Equipment/demonlordcloakc_Hulk_north").mainTexture);
     Constants.cloaksNorth.Add(MaterialPool.MatFrom("Equipment/demonlordcloakc_Male_north").mainTexture);
     Constants.cloaksNorth.Add(MaterialPool.MatFrom("Equipment/demonlordcloakc_Thin_north").mainTexture);
     Constants.cloaksNorth.Add(MaterialPool.MatFrom("Equipment/demonlordcloakc_Fat_north").mainTexture);
     Constants.cloaks.Add(MaterialPool.MatFrom("Equipment/demonlordcloakc_Female_east").mainTexture);
     Constants.cloaks.Add(MaterialPool.MatFrom("Equipment/demonlordcloakc_Female_south").mainTexture);
     Constants.cloaks.Add(MaterialPool.MatFrom("Equipment/demonlordcloakc_Fat_east").mainTexture);
     Constants.cloaks.Add(MaterialPool.MatFrom("Equipment/demonlordcloakc_Fat_south").mainTexture);
     Constants.cloaks.Add(MaterialPool.MatFrom("Equipment/demonlordcloakc_Hulk_east").mainTexture);
     Constants.cloaks.Add(MaterialPool.MatFrom("Equipment/demonlordcloakc_Hulk_south").mainTexture);
     Constants.cloaks.Add(MaterialPool.MatFrom("Equipment/demonlordcloakc_Thin_east").mainTexture);
     Constants.cloaks.Add(MaterialPool.MatFrom("Equipment/demonlordcloakc_Thin_south").mainTexture);
     Constants.cloaks.Add(MaterialPool.MatFrom("Equipment/demonlordcloakc_Male_east").mainTexture);
     Constants.cloaks.Add(MaterialPool.MatFrom("Equipment/demonlordcloakc_Male_south").mainTexture);
     if (ModsConfig.IsActive("ssulunge.BBBodySupport"))
     {
         Constants.cloaks.Add(MaterialPool.MatFrom("Equipment/demonlordcloakc_FemaleBB_east").mainTexture);
         Constants.cloaks.Add(MaterialPool.MatFrom("Equipment/demonlordcloakc_FemaleBB_south").mainTexture);
         Constants.cloaks.Add(MaterialPool.MatFrom("Equipment/demonlordcloakc_FemaleBB_north").mainTexture);
         Constants.cloaks.Add(MaterialPool.MatFrom("Equipment/opencloak_FemaleBB_east").mainTexture);
         Constants.cloaks.Add(MaterialPool.MatFrom("Equipment/opencloak_FemaleBB_south").mainTexture);
         Constants.cloaks.Add(MaterialPool.MatFrom("Equipment/opencloak_FemaleBB_south").mainTexture);
     }
     Constants.cloaks.AddRange(cloaksNorth);
 }
Example #24
0
        public AttritionSSPatch(ModContentPack content) : base(content)
        {
            // Early patch to avoid generic Def issues
            var harmony = new Harmony("AttritionSSPatch");

            if (ModsConfig.IsActive("petetimessix.simplesidearms"))
            {
                var findBestRangedWeapon = AccessTools.Method("SimpleSidearms.utilities.GettersFilters:findBestRangedWeapon");
                var getCarriedWeapons    = AccessTools.Method("SimpleSidearms.Extensions:getCarriedWeapons");
                if (findBestRangedWeapon != null && getCarriedWeapons != null)
                {
                    Harmony.ReversePatch(getCarriedWeapons, new HarmonyMethod(AccessTools.Method(typeof(Patch), "getCarriedRangedWeapon")),
                                         AccessTools.Method(typeof(Patch), "ReverseTranspiler"));
                    harmony.Patch(findBestRangedWeapon, transpiler: new HarmonyMethod(AccessTools.Method(typeof(Patch), "Transpiler")));
                }
            }
        }
Example #25
0
        public static void GenerateWaterPoolZone(IntVec3 areaSouthWestOrigin, int zoneAbs, int zoneOrd, Rot4 rotation, ref OG_OutpostData outpostData)
        {
            IntVec3 rotatedOrigin     = Zone.GetZoneRotatedOrigin(areaSouthWestOrigin, zoneAbs, zoneOrd, rotation);
            IntVec3 firstPatchCenter  = rotatedOrigin + new IntVec3(4, 0, 4).RotatedBy(rotation);
            IntVec3 secondPatchCenter = rotatedOrigin + new IntVec3(7, 0, 7).RotatedBy(rotation);
            IntVec3 thirdPatchCenter  = rotatedOrigin + new IntVec3(6, 0, 6).RotatedBy(rotation);

            // Generate water patches.
            foreach (IntVec3 cell in GenRadial.RadialCellsAround(firstPatchCenter, 4.2f, true))
            {
                Find.TerrainGrid.SetTerrain(cell, TerrainDefOf.Soil);
            }
            foreach (IntVec3 cell in GenRadial.RadialCellsAround(secondPatchCenter, 3.2f, true))
            {
                Find.TerrainGrid.SetTerrain(cell, TerrainDefOf.Soil);
            }
            foreach (IntVec3 cell in GenRadial.RadialCellsAround(firstPatchCenter, 3.2f, true))
            {
                Find.TerrainGrid.SetTerrain(cell, TerrainDef.Named("WaterShallow"));
            }
            foreach (IntVec3 cell in GenRadial.RadialCellsAround(secondPatchCenter, 2f, true))
            {
                Find.TerrainGrid.SetTerrain(cell, TerrainDef.Named("WaterShallow"));
            }
            foreach (IntVec3 cell in GenRadial.RadialCellsAround(firstPatchCenter, 2f, true))
            {
                Find.TerrainGrid.SetTerrain(cell, TerrainDef.Named("WaterDeep"));
            }
            foreach (IntVec3 cell in GenRadial.RadialCellsAround(secondPatchCenter, 1f, true))
            {
                Find.TerrainGrid.SetTerrain(cell, TerrainDef.Named("WaterDeep"));
            }
            foreach (IntVec3 cell in GenRadial.RadialCellsAround(thirdPatchCenter, 1f, true))
            {
                Find.TerrainGrid.SetTerrain(cell, TerrainDef.Named("WaterDeep"));
            }

            // Spawn fishing pier.
            if (ModsConfig.IsActive("FishIndustry"))
            {
                OG_Common.TrySpawnThingAt(ThingDef.Named("FishingPier"), null, rotatedOrigin + new IntVec3(4, 0, 1).RotatedBy(rotation), true, rotation, ref outpostData);
            }
        }
 private void RecacheSelectedModRequirements()
 {
     anyReqsCached            = false;
     anyReqsInfoToShowCached  = false;
     anyUnfulfilledReqsCached = false;
     anyOrderingIssuesCached  = false;
     visibleReqsCached.Clear();
     if (selectedMod == null)
     {
         return;
     }
     foreach (ModRequirement item in (from r in selectedMod.GetRequirements()
                                      orderby r.IsSatisfied, r.RequirementTypeLabel
                                      select r).ToList())
     {
         bool isSatisfied = item.IsSatisfied;
         if (!isSatisfied || displayFullfilledRequirements)
         {
             visibleReqsCached.Add(item);
             if (!isSatisfied)
             {
                 anyUnfulfilledReqsCached = true;
             }
         }
         anyReqsCached           = true;
         anyReqsInfoToShowCached = true;
     }
     anyOrderingIssuesCached = ModsConfig.ModHasAnyOrderingIssues(selectedMod);
     if (visibleReqsCached.Any() || anyOrderingIssuesCached)
     {
         anyReqsInfoToShowCached     = true;
         modRequirementsHeightCached = (float)visibleReqsCached.Count * 26f + (float)(visibleReqsCached.Count - 1) * 4f + 20f + 1f;
         if (anyOrderingIssuesCached)
         {
             modRequirementsHeightCached += Text.LineHeight * 2f + 4f;
         }
     }
     else
     {
         modRequirementsHeightCached = 0f;
     }
 }
Example #27
0
 public static RimWorld.Planet.Settlement AddNewHome(int tile, Faction faction, WorldObjectDef cityDef = null)
 {
     if (cityDef == null)
     {
         cityDef = WorldObjectDefOf.Settlement;
     }
     if (ModsConfig.IsActive("Cabbage.RimCities"))
     {
         if (cityDef.worldObjectClass.ToString() == "Cities.City")
         {
             return(GenerateCity(tile, faction, cityDef));
         }
         else
         {
             return(SettleUtility.AddNewHome(tile, faction));
         }
     }
     else
     {
         return(SettleUtility.AddNewHome(tile, faction));
     }
 }
        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);
        }
 static SimpleSidearmsPatch()
 {
     SimpleSidearmsActive = ModsConfig.IsActive("PeteTimesSix.SimpleSidearms");
     if (SimpleSidearmsActive)
     {
         var type = AccessTools.TypeByName("PeteTimesSix.SimpleSidearms.Extensions");
         if (type != null)
         {
             var target = AccessTools.Method(type, "IsValidSidearmsCarrier");
             VFECore.VFECore.harmonyInstance.Patch(target, postfix: new HarmonyMethod(AccessTools.Method(typeof(SimpleSidearmsPatch), nameof(IsValidSidearmsCarrierPostfix))));
             type   = AccessTools.TypeByName("SimpleSidearms.rimworld.CompSidearmMemory");
             target = AccessTools.Method(type, "GetMemoryCompForPawn");
             VFECore.VFECore.harmonyInstance.Patch(target, prefix: new HarmonyMethod(AccessTools.Method(typeof(SimpleSidearmsPatch), nameof(GetMemoryCompForPawnPrefix))));
             type   = AccessTools.TypeByName("SimpleSidearms.rimworld.Gizmo_SidearmsList");
             target = AccessTools.Method(type, "DrawGizmoLabel");
             VFECore.VFECore.harmonyInstance.Patch(target, prefix: new HarmonyMethod(AccessTools.Method(typeof(SimpleSidearmsPatch), nameof(GizmoLabelFixer))));
         }
         else
         {
             Log.Error("[Vanilla Expanded Framework] Patching Simple Sidearms failed.");
         }
     }
 }
Example #30
0
        static void WorkshopItems_Notify_Subscribed_Postfix(PublishedFileId_t pfid)
        {
            var longID = pfid.m_PublishedFileId;

            if (subscribingMods.Contains(longID) == false)
            {
                return;
            }
            subscribingMods.Remove(longID);

            LongEventHandler.ExecuteWhenFinished(() =>
            {
                var mod = ModLister.AllInstalledMods.FirstOrDefault(meta => meta.GetPublishedFileId().m_PublishedFileId == longID);
                if (mod == null)
                {
                    return;
                }

                ModsConfig.SetActive(mod, true);
                ModsConfig.Save();
                Find.WindowStack.Add(new MiniDialog(mod.Name + " added"));
            });
        }