mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Patch Ship Log Manager to merge ship log entries with the same ID
This commit is contained in:
parent
66886f9b2f
commit
eef0794446
@ -10,6 +10,7 @@ using System.Collections.Generic;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.InputSystem.HID;
|
||||||
|
|
||||||
namespace NewHorizons.Builder.ShipLog
|
namespace NewHorizons.Builder.ShipLog
|
||||||
{
|
{
|
||||||
@ -154,6 +155,35 @@ namespace NewHorizons.Builder.ShipLog
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void MergeEntries(ShipLogManager manager, ShipLogEntry entry, ShipLogEntry existing)
|
||||||
|
{
|
||||||
|
foreach (var fact in entry.GetRumorFacts())
|
||||||
|
{
|
||||||
|
existing._rumorFacts.Add(fact);
|
||||||
|
fact.OnFactRevealed += existing.OnFactRevealed;
|
||||||
|
|
||||||
|
manager._factRevealCount = Mathf.Max(manager._factRevealCount, fact.GetRevealOrder());
|
||||||
|
manager._factList.Add(fact);
|
||||||
|
manager._factDict.Add(fact.GetID(), fact);
|
||||||
|
}
|
||||||
|
foreach (var fact in entry.GetExploreFacts())
|
||||||
|
{
|
||||||
|
existing._exploreFacts.Add(fact);
|
||||||
|
existing._completionFacts.Add(fact);
|
||||||
|
fact.OnFactRevealed += existing.OnFactRevealed;
|
||||||
|
|
||||||
|
manager._factRevealCount = Mathf.Max(manager._factRevealCount, fact.GetRevealOrder());
|
||||||
|
manager._factList.Add(fact);
|
||||||
|
manager._factDict.Add(fact.GetID(), fact);
|
||||||
|
}
|
||||||
|
foreach (var child in entry.GetChildren())
|
||||||
|
{
|
||||||
|
existing._childEntries.Add(child);
|
||||||
|
|
||||||
|
manager.AddEntry(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static void AddTranslation(XElement entry)
|
private static void AddTranslation(XElement entry)
|
||||||
{
|
{
|
||||||
XElement nameElement = entry.Element("Name");
|
XElement nameElement = entry.Element("Name");
|
||||||
|
|||||||
@ -129,5 +129,18 @@ namespace NewHorizons.Patches.ShipLogPatches
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HarmonyPrefix]
|
||||||
|
[HarmonyPatch(nameof(ShipLogManager.AddEntry))]
|
||||||
|
public static bool ShipLogManager_AddEntry(ShipLogManager __instance, ShipLogEntry entry)
|
||||||
|
{
|
||||||
|
if (__instance._entryDict.TryGetValue(entry.GetID(), out var existing))
|
||||||
|
{
|
||||||
|
NHLogger.LogVerbose($"Merging duplicate shiplog entry: {entry.GetID()}");
|
||||||
|
RumorModeBuilder.MergeEntries(__instance, entry, existing);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user