Skip to content

Commit

Permalink
add umm button to start the project manually
Browse files Browse the repository at this point in the history
  • Loading branch information
alterasc committed Jul 23, 2023
1 parent c617d55 commit 40cb030
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
2 changes: 1 addition & 1 deletion NettleCrossingRestoration/Info.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
"Repository": "https://raw.githubusercontent.com/alterasc/NettleCrossingRestoration/main/Repository.json",
"Requirements": [],
"LoadAfter": [],
"Version": "1.0.0"
"Version": "1.1.0"
}
24 changes: 24 additions & 0 deletions NettleCrossingRestoration/Main.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Harmony12;
using Kingmaker;
using Kingmaker.Blueprints;
using Kingmaker.Designers.EventConditionActionSystem.Actions;
using Kingmaker.Designers.EventConditionActionSystem.Conditions;
Expand All @@ -7,6 +8,7 @@
using Kingmaker.Kingdom;
using Kingmaker.Kingdom.Actions;
using Kingmaker.Kingdom.Blueprints;
using Kingmaker.Kingdom.Tasks;
using Kingmaker.Localization;
using System;
using System.Linq;
Expand All @@ -24,6 +26,7 @@ static bool Load(UnityModManager.ModEntry modEntry)
var harmony = HarmonyInstance.Create(modEntry.Info.Id);
ModEntry = modEntry;
modEntry.OnToggle = OnToggle;
modEntry.OnGUI = OnGUI;
harmony.PatchAll();
return true;
}
Expand All @@ -32,6 +35,27 @@ static bool OnToggle(UnityModManager.ModEntry modEntry, bool value)
Enabled = value;
return true;
}
static void OnGUI(UnityModManager.ModEntry modEntry)
{
if (GUILayout.RepeatButton("Unlock Kingdom project (use if you're installing this mid playthrough)", GUILayout.ExpandWidth(false)))
{
if (Game.Instance == null || Game.Instance.Player == null) return;
var player = Game.Instance.Player;
if (!KingdomState.Founded) return;
var proj = ResourcesLibrary.TryGetBlueprint<BlueprintKingdomProject>("42e3f6af-ce48-474b-b435-5d14ebf12c9c");
var shrike = ResourcesLibrary.TryGetBlueprint<BlueprintRegion>("caacbcf9f6d6561459f526e584ded703");

RegionState rs = player.Kingdom.Regions.First(x => x.Blueprint == shrike);
KingdomTimelineManager kingdomTimelineManager = new();
if (KingdomState.Instance.EventHistory.Any((KingdomEventHistoryEntry e) => e.Event == proj) || KingdomState.Instance.ActiveEvents.Any((KingdomEvent e) => e.EventBlueprint == proj))
{
return;
}
kingdomTimelineManager.StartEventInRegion(proj, rs, 0).CheckTriggerOnStart = false;
}

}

}

[HarmonyPatch(typeof(LibraryScriptableObject), nameof(LibraryScriptableObject.LoadDictionary))]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Costs 50 BP and takes 10 days. Can be solved by Regent or Treasurer.

Has the same conditions as Nettle's Curse research - you just need to kill Stag Lord and talk to Nettle afterwards.

If you're installing this mid-game where you progressed past that point and project doesn't appear - use Bag of Tricks or Kingdom Resolution to uhlock flag `RiverCrossingAllowed`, this will make Crossing available.
If you're installing this mid-game where you progressed past that point use button in UMM settings of the mod. After pressing it, re-enter Kingdom management interface.

## Installation
1. Install Unity Mod Manager
Expand Down
2 changes: 1 addition & 1 deletion Repository.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"Releases": [
{
"Id": "NettleCrossingRestoration",
"Version": "1.0.0"
"Version": "1.1.0"
}
]
}

0 comments on commit 40cb030

Please sign in to comment.