Skip to content

Commit

Permalink
version 1.1 + 1.2
Browse files Browse the repository at this point in the history
+ Fixed bug where game would deunlock the blueprints sometimes
+ Fixed bug where pressing F1 to open the Slimepedia entry when the popup saying to do so appears would lead to a softlock
+ Removed issue where the Slimepedia blueprint would randomly reunlock itself when loading a save (introduced in 1.1)
  • Loading branch information
Lionmeow committed Jun 2, 2024
1 parent 1863bf2 commit 32b4b5a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 47 deletions.
40 changes: 13 additions & 27 deletions AcceleratorThings/EntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Il2CppMonomiPark.SlimeRancher.Regions;
using Il2CppMonomiPark.SlimeRancher.Script.Util;
using Il2CppMonomiPark.SlimeRancher.UI.Fabricator;
using Il2CppMonomiPark.SlimeRancher.UI.Pedia;
using Il2CppMonomiPark.SlimeRancher.World;
using MelonLoader;
using UnityEngine;
Expand Down Expand Up @@ -43,17 +44,6 @@ public static byte[] GetAsset(string path)
return data;
}

[HarmonyPatch(typeof(AutoSaveDirector), "ResetLookupTables")]
[HarmonyPrefix]
public static void OnAutoSaveDirector(AutoSaveDirector __instance)
{
/*if (autosaveinitialized)
return;
autosaveinitialized = true;*/
Debug.Log("ResetLookupTables");
}

[HarmonyPatch(typeof(LookupDirector), "Awake")]
[HarmonyPrefix]
public static void OnLookupDirector(LookupDirector __instance)
Expand Down Expand Up @@ -83,18 +73,6 @@ public static void OnLookupDirector(LookupDirector __instance)
accelefilterDef._pediaPersistenceSuffix = "accelefilter";
accelefilterDef.Type = GadgetDefinition.Types.ITEM_DISPLAY;
SRLookup.Get<IdentifiableTypeGroup>("GadgetUtilitiesGroup").MemberTypes.Add(accelefilterDef);
}

[HarmonyPatch(typeof(GameContext), "Start")]
[HarmonyPrefix]
public static void OnGameContext(GameContext __instance)
{
if (gcinitialized)
return;

gcinitialized = true;

UnityEngine.Object[] objs = bundle.LoadAllAssets();

LocalizationUtil.GetTable("Pedia").AddEntry("m.gadget.name.vaccelerator", "Vaccelerator");
LocalizationUtil.GetTable("Pedia").AddEntry("m.gadget.desc.vaccelerator", "A ring that not only applies a speed boost to any object that moves through it, but also projects a vacuum stream for twice as much bending of reality.");
Expand Down Expand Up @@ -153,6 +131,18 @@ public static void OnGameContext(GameContext __instance)
filterPedia._description = accelefilterDef._localizedDescription;
blueprintCategory._items = blueprintCategory._items.AddItem(filterPedia).ToArray();
accelefilterDef._pediaLink = filterPedia;
}

[HarmonyPatch(typeof(GameContext), "Start")]
[HarmonyPrefix]
public static void OnGameContext(GameContext __instance)
{
if (gcinitialized)
return;

gcinitialized = true;

UnityEngine.Object[] objs = bundle.LoadAllAssets();

Il2CppSystem.Collections.Generic.List<Il2CppMonomiPark.SlimeRancher.UI.IdentCostEntry> vacCosts =
new Il2CppSystem.Collections.Generic.List<Il2CppMonomiPark.SlimeRancher.UI.IdentCostEntry>();
Expand Down Expand Up @@ -433,9 +423,5 @@ public static void ForceJointToCurrVacuumPatch(Vacuumable vacuumable)
if (currVacuum)
currVacuum.ForceJoint(vacuumable);
}

[HarmonyPatch(typeof(FabricatorCategoryTitle), "SetCategory")]
[HarmonyPrefix]
public static void OnTitleSetCategory() => Debug.Log("category category");
}
}
9 changes: 1 addition & 8 deletions AcceleratorThings/FixPediaThingPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,7 @@ internal static class FixPediaThingPatch // stolen from mSRML because lazy
{
public static void Prefix(SavedGame __instance)
{
if (!__instance.pediaEntryLookup.ContainsKey(EntryPoint.vacceleratorDef.PediaEntry.PersistenceId))
__instance.pediaEntryLookup.Add(EntryPoint.vacceleratorDef.PediaEntry.PersistenceId, EntryPoint.vacceleratorDef.PediaEntry);
if (!__instance.pediaEntryLookup.ContainsKey(EntryPoint.triacceleratorDef.PediaEntry.PersistenceId))
__instance.pediaEntryLookup.Add(EntryPoint.triacceleratorDef.PediaEntry.PersistenceId, EntryPoint.triacceleratorDef.PediaEntry);
if (!__instance.pediaEntryLookup.ContainsKey(EntryPoint.upcceleratorDef.PediaEntry.PersistenceId))
__instance.pediaEntryLookup.Add(EntryPoint.upcceleratorDef.PediaEntry.PersistenceId, EntryPoint.upcceleratorDef.PediaEntry);
if (!__instance.pediaEntryLookup.ContainsKey(EntryPoint.accelefilterDef.PediaEntry.PersistenceId))
__instance.pediaEntryLookup.Add(EntryPoint.accelefilterDef.PediaEntry.PersistenceId, EntryPoint.accelefilterDef.PediaEntry);
// 0.5 automatically adds any persistence IDs to the SavedGame, so no need to add those manually anymore

List<string> idsToRemove = __instance.gameState.Pedia.UnlockedIds.ToArray()
.Where(pediaUnlockedId => !__instance.pediaEntryLookup.ContainsKey(pediaUnlockedId)).ToList();
Expand Down
24 changes: 12 additions & 12 deletions AcceleratorThings/UnlockPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ public static void Postfix()
if (model.unlocked.Contains(SRLookup.Get<GadgetDefinition>("Accelerator").PediaEntry))
{
GadgetDirector dir = __instance.GadgetDirector;
if (!dir.HasBlueprint(EntryPoint.triacceleratorDef))
if (!model.unlocked.Contains(EntryPoint.triacceleratorDef.PediaEntry))
shouldShowPopupTri = true;
if (!dir.HasBlueprint(EntryPoint.upcceleratorDef))
if (!model.unlocked.Contains(EntryPoint.upcceleratorDef.PediaEntry))
shouldShowPopupUp = true;
if (!dir.HasBlueprint(EntryPoint.vacceleratorDef))
if (!model.unlocked.Contains(EntryPoint.vacceleratorDef.PediaEntry))
shouldShowPopupVac = true;
if (!dir.HasBlueprint(EntryPoint.accelefilterDef))
if (!model.unlocked.Contains(EntryPoint.accelefilterDef.PediaEntry))
shouldShowPopupFilter = true;
}
}
Expand Down Expand Up @@ -65,30 +65,30 @@ public void OnDestroy()

if (PediaSetModelPotentialUnlockPatch.shouldShowPopupVac)
{
SceneContext.Instance.GadgetDirector._model.blueprints.Add(EntryPoint.triacceleratorDef);
SceneContext.Instance.PediaDirector.Unlock(EntryPoint.triacceleratorDef._pediaLink, false);
SceneContext.Instance.PediaDirector.ShowPopupIfUnlocked(EntryPoint.vacceleratorDef._pediaLink);
if (SceneContext.Instance.GadgetDirector._model.blueprints.AddIfNotPresent(EntryPoint.triacceleratorDef))
SceneContext.Instance.PediaDirector.ShowPopupIfUnlocked(EntryPoint.vacceleratorDef._pediaLink);
PediaSetModelPotentialUnlockPatch.shouldShowPopupVac = false;
}
if (PediaSetModelPotentialUnlockPatch.shouldShowPopupTri)
{
SceneContext.Instance.GadgetDirector._model.blueprints.Add(EntryPoint.upcceleratorDef);
SceneContext.Instance.PediaDirector.Unlock(EntryPoint.upcceleratorDef._pediaLink, false);
SceneContext.Instance.PediaDirector.ShowPopupIfUnlocked(EntryPoint.triacceleratorDef._pediaLink);
if (SceneContext.Instance.GadgetDirector._model.blueprints.AddIfNotPresent(EntryPoint.upcceleratorDef))
SceneContext.Instance.PediaDirector.ShowPopupIfUnlocked(EntryPoint.triacceleratorDef._pediaLink);
PediaSetModelPotentialUnlockPatch.shouldShowPopupTri = false;
}
if (PediaSetModelPotentialUnlockPatch.shouldShowPopupUp)
{
SceneContext.Instance.GadgetDirector._model.blueprints.Add(EntryPoint.vacceleratorDef);
SceneContext.Instance.PediaDirector.Unlock(EntryPoint.vacceleratorDef._pediaLink, false);
SceneContext.Instance.PediaDirector.ShowPopupIfUnlocked(EntryPoint.upcceleratorDef._pediaLink);
if (SceneContext.Instance.GadgetDirector._model.blueprints.AddIfNotPresent(EntryPoint.vacceleratorDef))
SceneContext.Instance.PediaDirector.ShowPopupIfUnlocked(EntryPoint.upcceleratorDef._pediaLink);
PediaSetModelPotentialUnlockPatch.shouldShowPopupUp = false;
}
if (PediaSetModelPotentialUnlockPatch.shouldShowPopupFilter)
{
SceneContext.Instance.GadgetDirector._model.blueprints.Add(EntryPoint.accelefilterDef);
SceneContext.Instance.PediaDirector.Unlock(EntryPoint.accelefilterDef._pediaLink, false);
SceneContext.Instance.PediaDirector.ShowPopupIfUnlocked(EntryPoint.accelefilterDef._pediaLink);
if (SceneContext.Instance.GadgetDirector._model.blueprints.AddIfNotPresent(EntryPoint.accelefilterDef))
SceneContext.Instance.PediaDirector.ShowPopupIfUnlocked(EntryPoint.accelefilterDef._pediaLink);
PediaSetModelPotentialUnlockPatch.shouldShowPopupFilter = false;
}
}
Expand Down

1 comment on commit 32b4b5a

@Lionmeow
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also removed some debug messages, if those were annoying anyone

Please sign in to comment.