Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed synchronization of weathers and interiors #96

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 23 additions & 10 deletions LethalLevelLoader/Components/LLLSaveFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,45 @@ public class LLLSaveFile : ModDataContainer
{
public string CurrentLevelName { get; internal set; } = string.Empty;

public Dictionary<string, string> customItemDictionary = new Dictionary<string, string>();

public List<string> allItemsList = new List<string>();

public List<AllItemsListItemData> itemSaveDataList = new List<AllItemsListItemData>();
public int parityStepsTaken;
public Dictionary<int, AllItemsListItemData> itemSaveData = new Dictionary<int, AllItemsListItemData>();

public LLLSaveFile(string name)
public LLLSaveFile()
{
//OptionalPrefixSuffix = name;
}

public void Reset()
{
OptionalPrefixSuffix = name;
CurrentLevelName = string.Empty;
parityStepsTaken = 0;
itemSaveData = new Dictionary<int, AllItemsListItemData>();
}
}

public struct AllItemsListItemData
{
public string itemObjectName;
public string itemName;
public string itemDisplayName;
public string modName;
public string modAuthor;
public int allItemsListIndex;
public int modItemsListIndex;
public int itemNameDuplicateIndex;
public bool isScrap;
public bool saveItemVariable;

public AllItemsListItemData(string newItemName, string newItemDisplayName, string newModName, int newAllItemsListIndex)
public AllItemsListItemData(string newItemObjectName, string newItemName, string newModName, string newModAuthor, int newAllItemsListIndex, int newModItemsListIndex, int newItemNameDuplicateIndex, bool newIsScrap, bool newSaveItemVariable)
{
itemObjectName = newItemObjectName;
itemName = newItemName;
itemDisplayName = newItemDisplayName;
modName = newModName;
modAuthor = newModAuthor;
allItemsListIndex = newAllItemsListIndex;
modItemsListIndex = newModItemsListIndex;
itemNameDuplicateIndex = newItemNameDuplicateIndex;
isScrap = newIsScrap;
saveItemVariable = newSaveItemVariable;
}
}
}
25 changes: 17 additions & 8 deletions LethalLevelLoader/General/Patches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Text;
using TMPro;
Expand Down Expand Up @@ -132,6 +133,18 @@ internal static void GameNetworkManagerStart_Prefix(GameNetworkManager __instanc
}
}

[HarmonyPriority(harmonyPriority)]
[HarmonyPatch(typeof(GameNetworkManager), "SaveGameValues")]
[HarmonyPostfix]
internal static void GameNetworkManagerSaveGameValues_Postfix(GameNetworkManager __instance)
{
// Vanilla checks
if (!__instance.isHostingGame || !StartOfRound.Instance.inShipPhase || StartOfRound.Instance.isChallengeFile)
return;

SaveManager.SaveGameValues();
}

[HarmonyPriority(harmonyPriority)]
[HarmonyPatch(typeof(StartOfRound), "Awake")]
[HarmonyPrefix]
Expand All @@ -151,12 +164,10 @@ internal static void StartOfRoundAwake_Prefix(StartOfRound __instance)
SceneManager.sceneLoaded += EventPatches.OnSceneLoaded;

//Removing the broken cardboard box item please understand

//Scrape Vanilla For Content References
if (Plugin.IsSetupComplete == false)
{
StartOfRound.allItemsList.itemsList.RemoveAt(2);
SaveManager.defaultCachedItemsList = new List<Item>(StartOfRound.allItemsList.itemsList);

DebugStopwatch.StartStopWatch("Scrape Vanilla Content");
ContentExtractor.TryScrapeVanillaItems(StartOfRound);
Expand Down Expand Up @@ -308,7 +319,6 @@ internal static void StartOfRoundAwake_Prefix(StartOfRound __instance)
if (LethalLevelLoaderNetworkManager.networkManager.IsServer)
{
SaveManager.InitializeSave();
SaveManager.RefreshSaveItemInfo();
}

DebugStopwatch.StopStopWatch("Initalize Save");
Expand Down Expand Up @@ -385,7 +395,8 @@ public static void StartOfRoundChangeLevel_Postfix(int levelID)
if (RoundManager.currentLevel != null && SaveManager.currentSaveFile.CurrentLevelName != RoundManager.currentLevel.PlanetName)
{
DebugHelper.Log("Saving Current SelectableLevel: " + RoundManager.currentLevel.PlanetName, DebugType.User);
SaveManager.SaveCurrentSelectableLevel(RoundManager.currentLevel);
SaveManager.currentSaveFile.CurrentLevelName = RoundManager.currentLevel.PlanetName;
//SaveManager.SaveCurrentSelectableLevel(RoundManager.currentLevel);
//LevelLoader.RefreshShipAnimatorClips(LevelManager.CurrentExtendedLevel);
}

Expand All @@ -394,11 +405,9 @@ public static void StartOfRoundChangeLevel_Postfix(int levelID)
[HarmonyPriority(harmonyPriority)]
[HarmonyPatch(typeof(StartOfRound), "LoadShipGrabbableItems")]
[HarmonyPrefix]
internal static bool StartOfRoundLoadShipGrabbableItems_Prefix()
internal static void StartOfRoundLoadShipGrabbableItems_Prefix()
{
//SaveManager.LoadShipGrabbableItems();
//return (false);
return (true);
SaveManager.LoadShipGrabbableItems();
}


Expand Down
Loading