Skip to content

Commit

Permalink
fixed: reshuffleAllBtn via changing reflection binding attribute, sin…
Browse files Browse the repository at this point in the history
…ce game devs changed CharacterContainer.Reshuffle method from private to public
  • Loading branch information
madzohan committed Aug 3, 2024
1 parent 952982f commit 9aa0a1b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
7 changes: 6 additions & 1 deletion RePrint/src/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed
- "mod adds carepackages, even if you disabled them in your game"
Now mod respects this setting on game creation step
Now mod respects this setting on game creation step

## [1.4.2] - 2024-08-04

### Fixed
- fixed reshuffleAllBtn via changing reflection binding attribute, since game devs changed CharacterContainer.Reshuffle method from private to public
15 changes: 12 additions & 3 deletions RePrint/src/RePrintPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ private static KButton MakeReshuffleAllButton(KButton rejectBtnPrefab, KButton c
return reshuffleAllBtn;
}

private static void ReshuffleAllContainers(ImmigrantScreen imScreen)
private static void ReshuffleAllContainers(ImmigrantScreen immigrantScreen)
{
var containers = (List<ITelepadDeliverableContainer>)Traverse.Create(imScreen).Field(
var containers = (List<ITelepadDeliverableContainer>)Traverse.Create(immigrantScreen).Field(
"containers").GetValue();
foreach (var container in containers)
switch (container)
Expand All @@ -41,8 +41,17 @@ private static void ReshuffleAllContainers(ImmigrantScreen imScreen)
private static void ReshuffleContainer(ITelepadDeliverableContainer container)
{
Traverse.Create(container).Field("controller").Method("RemoveLast").GetValue();
var reshuffle = container.GetType().GetMethod("Reshuffle", BindingFlags.NonPublic | BindingFlags.Instance);
var reshuffleParams = new object[] { false };
MethodInfo reshuffle = null;
switch (container)
{
case CharacterContainer characterContainer when characterContainer != null:
reshuffle = typeof(CharacterContainer).GetMethod("Reshuffle", BindingFlags.Public | BindingFlags.Instance);
break;
case CarePackageContainer carePackageContainer when carePackageContainer != null:
reshuffle = typeof(CarePackageContainer).GetMethod("Reshuffle", BindingFlags.NonPublic | BindingFlags.Instance);
break;
}
if (reshuffle != null) reshuffle.Invoke(container, reshuffleParams);
}

Expand Down
2 changes: 1 addition & 1 deletion RePrint/src/mod_info.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
supportedContent: ALL
minimumSupportedBuild: 469112
version: 1.4.1
version: 1.4.2
APIVersion: 2

0 comments on commit 9aa0a1b

Please sign in to comment.