Skip to content

Commit

Permalink
Tavern Keeper
Browse files Browse the repository at this point in the history
  • Loading branch information
p1xel8ted committed Aug 3, 2024
1 parent 31b959e commit 23c8639
Show file tree
Hide file tree
Showing 13 changed files with 952 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Graveyard Keeper/BeamMeUpGerry/BeamMeUpGerry.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>3.0.6</Version>
<Version>3.0.7</Version>
<AssemblyVersion>$(Version)</AssemblyVersion>
<FileVersion>$(Version)</FileVersion>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion Graveyard Keeper/BeamMeUpGerry/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public static class Helpers

private static bool RemovedQuarryBlockage()
{
return MainGame.me.save.completed_one_time_crafts.Any(craft => craft.StartsWithByLanguage("steep_yellow_blockage"));
return MainGame.me.save.completed_one_time_crafts.Any(craft => craft.StartsWith("steep_yellow_blockage"));
}


Expand Down
35 changes: 35 additions & 0 deletions Graveyard Keeper/BeamMeUpGerry/Patches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,41 @@
[SuppressMessage("ReSharper", "InconsistentNaming")]
public static class Patches
{
private static int OneTimeCraftCount;
private static int KnownZoneCount;
private static int KnownNpcCount;

[HarmonyPrefix]
[HarmonyPatch(typeof(GameSave), nameof(GameSave.OnEnteredWorldZone))]
[HarmonyPatch(typeof(BuildModeLogics), nameof(BuildModeLogics.DoPlace))]
[HarmonyPatch(typeof(GameSave), nameof(GameSave.OnMetNPC))]
public static void BuildModeLogics_DoPlace_Prefix()
{
OneTimeCraftCount = MainGame.me.save.completed_one_time_crafts.Count;
KnownZoneCount = MainGame.me.save.known_world_zones.Count;
KnownNpcCount = MainGame.me.save.known_npcs.npcs.Count;
}

[HarmonyPostfix]
[HarmonyPatch(typeof(GameSave), nameof(GameSave.OnEnteredWorldZone))]
[HarmonyPatch(typeof(BuildModeLogics), nameof(BuildModeLogics.DoPlace))]
[HarmonyPatch(typeof(GameSave), nameof(GameSave.OnMetNPC))]
public static void BuildModeLogics_DoPlace_Postfix()
{
var newCraftCount = MainGame.me.save.completed_one_time_crafts.Count;
var newZoneCount = MainGame.me.save.known_world_zones.Count;
var newNpcCount = MainGame.me.save.known_npcs.npcs.Count;

if (newCraftCount > OneTimeCraftCount || newZoneCount > KnownZoneCount || newNpcCount > KnownNpcCount)
{
PlatformSpecific.SaveGame(MainGame.me.save_slot, MainGame.me.save, OnComplete);

void OnComplete(SaveSlotData __slot)
{
Plugin.InitConfiguration();
}
}
}

[HarmonyPostfix]
[HarmonyWrapSafe]
Expand Down
26 changes: 23 additions & 3 deletions Graveyard Keeper/BeamMeUpGerry/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

[Harmony]
[BepInPlugin(PluginGuid, PluginName, PluginVer)]
[BepInDependency("p1xel8ted.gyk.gykhelper", "3.0.7")]
[BepInDependency("p1xel8ted.gyk.gykhelper", "3.0.9")]
[SuppressMessage("ReSharper", "InconsistentNaming")]
public class Plugin : BaseUnityPlugin
{
private const string PluginGuid = "p1xel8ted.gyk.beammeupgerryrewrite";
private const string PluginName = "Beam Me Up Gerry!";
private const string PluginVer = "3.0.6";
private const string PluginVer = "3.0.7";

internal static ConfigEntry<bool> DebugEnabled { get; private set; }
internal static ConfigEntry<bool> IncreaseMenuAnimationSpeed { get; private set; }
Expand Down Expand Up @@ -110,10 +110,30 @@ private void Update()
}
}


private void InitInternalConfiguration()
{
CustomLocationMessage = Config.Bind("Internal (Dont Touch)", "Custom Location Shown", false, new ConfigDescription("Internal use. Used for tracking if the custom location alert has been shown.", null, new ConfigurationManagerAttributes {Browsable = false, HideDefaultButton = true, IsAdvanced = true, ReadOnly = true, Order = 6}));
Config.Bind("Print Known", "Print Known", false, new ConfigDescription("Click to output known zones to log.", null, new ConfigurationManagerAttributes {CustomDrawer = PrintKnown, HideDefaultButton = true, Order = 5}));
}
private static void PrintKnown(ConfigEntryBase __obj)
{
var button = GUILayout.Button("Print Known Zones & One-Time Crafts", GUILayout.ExpandWidth(true));
if (button)
{
Log.LogInfo("\n");
Log.LogInfo("Known Zones:");
foreach (var zone in MainGame.me.save.known_world_zones)
{
Log.LogInfo(zone);
}
Log.LogInfo("\n");
Log.LogInfo("One-Time Crafts:");
foreach (var craft in MainGame.me.save.completed_one_time_crafts)
{
Log.LogInfo(craft);
}
Log.LogInfo("\n");
}
}

internal static void InitConfiguration()
Expand Down
Loading

0 comments on commit 23c8639

Please sign in to comment.