Skip to content

Commit

Permalink
Fix logic in dialogue selection
Browse files Browse the repository at this point in the history
  • Loading branch information
atravita-mods committed Mar 20, 2022
1 parent ea59495 commit 445d638
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 22 deletions.
20 changes: 4 additions & 16 deletions SpecialOrdersExtended/Managers/DialogueManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,7 @@ internal class DialogueManager
/// Gets the current perscreened dialogue log.
/// </summary>
public static DialogueLog? PerscreenedDialogueLog
{
get
{
return InternalDialogueLog.Value;
}
}
=> InternalDialogueLog.Value;

/// <summary>
/// Load the PerScreened Dialogue log.
Expand Down Expand Up @@ -310,8 +305,7 @@ public static void PostfixCheckDialogue(ref bool __result, ref NPC __instance, i
}

// Handle dialogue for recently completed special orders.
IEnumerable<string>? cacheOrders = RecentSOManager.GetKeys(1u);
if (cacheOrders is not null)
if (RecentSOManager.GetKeys(2u) is IEnumerable<string> cacheOrders)
{
foreach (string cacheOrder in cacheOrders)
{
Expand Down Expand Up @@ -426,19 +420,13 @@ private static bool FindBestDialogue(string baseKey, NPC npc, int hearts)
dialogueKey = $"{baseKey}{heartLevel}";
if (npc.Dialogue.ContainsKey(dialogueKey))
{
if (PushAndSaveDialogue(dialogueKey, npc))
{
return true;
}
return PushAndSaveDialogue(dialogueKey, npc);
}
}

if (npc.Dialogue.ContainsKey(baseKey))
{
if (PushAndSaveDialogue(baseKey, npc))
{
return true;
}
return PushAndSaveDialogue(baseKey, npc);
}

if (ModEntry.Config.Verbose)
Expand Down
5 changes: 1 addition & 4 deletions SpecialOrdersExtended/Managers/TagManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ internal static Random Random
{
get
{
if (random is null)
{
random = new Random(((int)Game1.uniqueIDForThisGame * 26) + (int)(Game1.stats.DaysPlayed / 7 * 36));
}
random ??= new Random(((int)Game1.uniqueIDForThisGame * 26) + (int)(Game1.stats.DaysPlayed / 7 * 36));
return random;
}
}
Expand Down
6 changes: 4 additions & 2 deletions SpecialOrdersExtended/ModEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using AtraShared.Integrations;
using AtraShared.Integrations.Interfaces;
using AtraShared.MigrationManager;
using AtraShared.Utils;
using AtraShared.Utils.Extensions;
using HarmonyLib;
using SpecialOrdersExtended.HarmonyPatches;
Expand All @@ -15,8 +16,6 @@ namespace SpecialOrdersExtended;
/// <inheritdoc />
internal class ModEntry : Mod
{
private MigrationManager? migrator;

/// <summary>
/// Spacecore API handle.
/// </summary>
Expand All @@ -29,6 +28,8 @@ internal class ModEntry : Mod
/// <remarks>If null, was not able to be loaded.</remarks>
internal static ISpaceCoreAPI? SpaceCoreAPI => spaceCoreAPI;

private MigrationManager? migrator;

// The following fields are set in the Entry method, which is about as close to the constructor as I can get
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.

Expand Down Expand Up @@ -199,6 +200,7 @@ private void SaveLoaded(object? sender, SaveLoadedEventArgs e)
{
this.Monitor.DebugLog("Event SaveLoaded raised");
DialogueManager.Load(Game1.player.UniqueMultiplayerID);
MultiplayerHelpers.AssertMultiplayerVersions(this.Helper.Multiplayer, this.ModManifest, this.Monitor, this.Helper.Translation);

if (Context.IsSplitScreen && Context.ScreenId != 0)
{
Expand Down
1 change: 1 addition & 0 deletions SpecialOrdersExtended/SpecialOrdersExtended.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<DefineConstants>HARMONY;</DefineConstants>
<Nullable>enable</Nullable>
<WarningsAsErrors>Nullable</WarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2021.3.0" />
Expand Down

0 comments on commit 445d638

Please sign in to comment.