Skip to content

Commit

Permalink
Fixed unwaveringly loyal issue
Browse files Browse the repository at this point in the history
  • Loading branch information
emipa606 committed Apr 16, 2024
1 parent 5426b54 commit ba5eb98
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 72 deletions.
Binary file modified 1.5/Assemblies/CustomPrisonerInteractions.dll
Binary file not shown.
3 changes: 1 addition & 2 deletions About/About.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,5 @@ Since modding is just a hobby for me I expect no donations to keep modding. If y
[/list]

[url=https://steamcommunity.com/sharedfiles/filedetails/changelog/2841231775][img]https://img.shields.io/github/v/release/emipa606/CustomPrisonerInteractions?label=latest%20version&amp;style=plastic&amp;labelColor=0070cd&amp;color=white[/img][/url]</description>
<modIconPath IgnoreIfNoMatchingField="True">ModIcon/CustomPrisonerInteractions</modIconPath>
<modVersion IgnoreIfNoMatchingField="True">1.5.0</modVersion>
<modVersion IgnoreIfNoMatchingField="True">1.5.1</modVersion>
</ModMetaData>
3 changes: 3 additions & 0 deletions About/Changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog for CustomPrisonerInteractions

1.5.1 - Fixed unwaveringly loyal issue


1.5.0 - Updated for 1.5


Expand Down
2 changes: 1 addition & 1 deletion About/Manifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Manifest>
<identifier>CustomPrisonerInteractions</identifier>
<version>1.5.0</version>
<version>1.5.1</version>
<dependencies />
<incompatibleWith />
<loadBefore />
Expand Down
File renamed without changes
2 changes: 1 addition & 1 deletion About/ModSync.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<ModSyncNinjaData>
<ID>74b7df5b-73c0-4825-884b-61df997d22b7</ID>
<ModName>Custom Prisoner Interactions</ModName>
<Version>1.5.0</Version>
<Version>1.5.1</Version>
<SaveBreaking>False</SaveBreaking>
<Host name="Github">
<Owner>emipa606</Owner>
Expand Down
27 changes: 19 additions & 8 deletions Source/CustomPrisonerInteractions/CustomPrisonerInteractions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,24 @@ public enum ExtraMode

public static Pawn pawnWithIdeologyCrisis = null;

public static Dictionary<ExtraMode, PrisonerInteractionModeDef> ModeDictionary =
new Dictionary<ExtraMode, PrisonerInteractionModeDef>
{
[ExtraMode.Kill] = PrisonerInteractionModeDefOf.Execution,
[ExtraMode.Release] = PrisonerInteractionModeDefOf.Release,
[ExtraMode.ReleaseWhenHealthy] = PrisonerInteractionModeDefOf.Release,
[ExtraMode.ReleaseWhenAbleToWalk] = PrisonerInteractionModeDefOf.Release,
[ExtraMode.ReleaseWhenNotGuilty] = PrisonerInteractionModeDefOf.Release,
[ExtraMode.ReduceResistance] = PrisonerInteractionModeDefOf.ReduceResistance,
[ExtraMode.ReduceResistanceThenKill] = PrisonerInteractionModeDefOf.Execution,
[ExtraMode.ReduceResistanceThenRecruit] = PrisonerInteractionModeDefOf.AttemptRecruit,
[ExtraMode.ReduceResistanceThenRelease] = PrisonerInteractionModeDefOf.Release,
[ExtraMode.Recruit] = PrisonerInteractionModeDefOf.AttemptRecruit,
[ExtraMode.Enslave] = PrisonerInteractionModeDefOf.Enslave,
[ExtraMode.ReduceWill] = PrisonerInteractionModeDefOf.ReduceWill,
[ExtraMode.ReduceWillThenEnslave] = PrisonerInteractionModeDefOf.Enslave
};

static CustomPrisonerInteractions()
{
var harmony = new Harmony("Mlie.CustomPrisonerInteractions");
Expand Down Expand Up @@ -87,14 +105,7 @@ private static bool IsStudiable(Pawn pawn)

public static bool CanUseExtraMode(Pawn pawn, ExtraMode mode)
{
if (!pawn.guest.Recruitable && mode is ExtraMode.Recruit or ExtraMode.ReduceResistanceThenRecruit)
{
return false;
}

return !pawn.IsWildMan() || mode is not (ExtraMode.Recruit or ExtraMode.ReduceResistanceThenRecruit
or ExtraMode.ReduceResistance or ExtraMode.ReduceResistanceThenKill
or ExtraMode.ReduceResistanceThenRelease);
return !ModeDictionary.ContainsKey(mode) || CanUsePrisonerInteractionMode(pawn, ModeDictionary[mode]);
}

public static bool CanUsePrisonerInteractionMode(Pawn pawn, PrisonerInteractionModeDef mode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
<DebugType>None</DebugType>
<LangVersion>latest</LangVersion>
<FileVersion>1.5.0</FileVersion>
<FileVersion>1.5.1</FileVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Krafs.Rimworld.Ref">
<Version>1.5.4041-beta</Version>
<Version>*</Version>
<ExcludeAssets>runtime</ExcludeAssets>
<IncludeAssets>compile; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
97 changes: 43 additions & 54 deletions Source/CustomPrisonerInteractions/ITab_Pawn_Visitor_FillTab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,20 @@ public static void Prefix(out Tuple<List<FloatMenuOption>, string> __state)
extraInteractionsTracker[pawn] = Undefined;
}

__state.Item1.Add(new FloatMenuOption(getExtraInterractionExplanation(ReleaseWhenNotGuilty),
delegate { extraInteractionsTracker[pawn] = ReleaseWhenNotGuilty; },
MenuOptionPriority.Default, null, null, 29f));
__state.Item1.Add(new FloatMenuOption(getExtraInterractionExplanation(ReleaseWhenAbleToWalk),
delegate { extraInteractionsTracker[pawn] = ReleaseWhenAbleToWalk; },
MenuOptionPriority.Default, null, null, 29f));
__state.Item1.Add(new FloatMenuOption(getExtraInterractionExplanation(ReleaseWhenHealthy),
delegate { extraInteractionsTracker[pawn] = ReleaseWhenHealthy; },
MenuOptionPriority.Default, null, null, 29f));
foreach (var extraMode in new List<ExtraMode>
{
ReleaseWhenNotGuilty,
ReleaseWhenAbleToWalk,
ReleaseWhenHealthy
})
{
if (CanUseExtraMode(pawn, extraMode))
{
__state.Item1.Add(new FloatMenuOption(getExtraInterractionExplanation(extraMode),
delegate { extraInteractionsTracker[pawn] = extraMode; },
MenuOptionPriority.Default, null, null, 29f));
}
}

break;
case "Convert":
Expand All @@ -68,49 +73,28 @@ public static void Prefix(out Tuple<List<FloatMenuOption>, string> __state)
extraInteractionsTracker[pawn] = Undefined;
}

__state.Item1.Add(new FloatMenuOption(getExtraInterractionExplanation(Recruit),
delegate { extraInteractionsTracker[pawn] = Recruit; },
MenuOptionPriority.Default, null, null, 29f));
__state.Item1.Add(new FloatMenuOption(getExtraInterractionExplanation(ReduceResistance),
delegate { extraInteractionsTracker[pawn] = ReduceResistance; },
MenuOptionPriority.Default, null, null, 29f));
__state.Item1.Add(new FloatMenuOption(getExtraInterractionExplanation(ReduceResistanceThenRecruit),
delegate
{
extraInteractionsTracker[pawn] =
ReduceResistanceThenRecruit;
},
MenuOptionPriority.Default, null, null, 29f));

__state.Item1.Add(new FloatMenuOption(getExtraInterractionExplanation(Enslave),
delegate { extraInteractionsTracker[pawn] = Enslave; },
MenuOptionPriority.Default, null, null, 29f));
__state.Item1.Add(new FloatMenuOption(getExtraInterractionExplanation(ReduceWill),
delegate { extraInteractionsTracker[pawn] = ReduceWill; },
MenuOptionPriority.Default, null, null, 29f));
__state.Item1.Add(new FloatMenuOption(getExtraInterractionExplanation(ReduceWillThenEnslave),
delegate { extraInteractionsTracker[pawn] = ReduceWillThenEnslave; },
MenuOptionPriority.Default, null, null, 29f));
__state.Item1.Add(new FloatMenuOption(getExtraInterractionExplanation(Release),
delegate { extraInteractionsTracker[pawn] = Release; },
MenuOptionPriority.Default, null, null, 29f));
__state.Item1.Add(new FloatMenuOption(getExtraInterractionExplanation(ReduceResistanceThenRelease),
delegate
{
extraInteractionsTracker[pawn] =
ReduceResistanceThenRelease;
},
MenuOptionPriority.Default, null, null, 29f));
__state.Item1.Add(new FloatMenuOption(getExtraInterractionExplanation(Kill),
delegate { extraInteractionsTracker[pawn] = Kill; },
MenuOptionPriority.Default, null, null, 29f));
__state.Item1.Add(new FloatMenuOption(getExtraInterractionExplanation(ReduceResistanceThenKill),
delegate
foreach (var extraMode in new List<ExtraMode>
{
Recruit,
ReduceResistance,
ReduceResistanceThenRecruit,
Enslave,
ReduceWill,
ReduceWillThenEnslave,
Release,
ReduceResistanceThenRelease,
Kill,
ReduceResistanceThenKill
})
{
if (CanUseExtraMode(pawn, extraMode))
{
extraInteractionsTracker[pawn] =
ReduceResistanceThenKill;
},
MenuOptionPriority.Default, null, null, 29f));
__state.Item1.Add(new FloatMenuOption(getExtraInterractionExplanation(extraMode),
delegate { extraInteractionsTracker[pawn] = extraMode; },
MenuOptionPriority.Default, null, null, 29f));
}
}

break;
default:
extraInteractionsTracker[pawn] = Undefined;
Expand Down Expand Up @@ -152,8 +136,12 @@ public static void Postfix(ref Vector2 ___size, Tuple<List<FloatMenuOption>, str
break;
case "Convert":
case "PrisonLabor_workAndConvertOption":
extraInteractionsTracker[pawn] =
CustomPrisonerInteractionsMod.instance.Settings.DefaultConvertValue;
if (CanUseExtraMode(pawn, CustomPrisonerInteractionsMod.instance.Settings.DefaultConvertValue))
{
extraInteractionsTracker[pawn] =
CustomPrisonerInteractionsMod.instance.Settings.DefaultConvertValue;
}

break;
}
}
Expand All @@ -165,7 +153,8 @@ public static void Postfix(ref Vector2 ___size, Tuple<List<FloatMenuOption>, str
delegate { extraInteractionsTracker[pawn] = None; },
MenuOptionPriority.Default, null, null, 29f));

var buttonArea = new Rect(0f + margin, ___size.y - buttonSpace - margin, ___size.x - (margin * 2), buttonSpace);
var buttonArea = new Rect(0f + margin, ___size.y - buttonSpace - margin, ___size.x - (margin * 2),
buttonSpace);

Widgets.Label(buttonArea, "CPI.options".Translate());

Expand Down
17 changes: 13 additions & 4 deletions Source/CustomPrisonerInteractions/Pawn_GuestTracker_CapturedBy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,13 @@ public static void Postfix(Pawn_GuestTracker __instance, ref Pawn ___pawn, Pawn

if (__instance.ExclusiveInteractionMode == PrisonerInteractionModeDefOf.Release)
{
extraInteractionsTracker[___pawn] =
CustomPrisonerInteractionsMod.instance.Settings.DefaultReleaseValue;
if (CustomPrisonerInteractions.CanUseExtraMode(___pawn,
CustomPrisonerInteractionsMod.instance.Settings.DefaultReleaseValue))
{
extraInteractionsTracker[___pawn] =
CustomPrisonerInteractionsMod.instance.Settings.DefaultReleaseValue;
}

return;
}

Expand All @@ -61,7 +66,11 @@ public static void Postfix(Pawn_GuestTracker __instance, ref Pawn ___pawn, Pawn
}

___pawn.guest.ideoForConversion = Faction.OfPlayer.ideos.PrimaryIdeo;
extraInteractionsTracker[___pawn] =
CustomPrisonerInteractionsMod.instance.Settings.DefaultConvertValue;
if (CustomPrisonerInteractions.CanUseExtraMode(___pawn,
CustomPrisonerInteractionsMod.instance.Settings.DefaultConvertValue))
{
extraInteractionsTracker[___pawn] =
CustomPrisonerInteractionsMod.instance.Settings.DefaultConvertValue;
}
}
}

0 comments on commit ba5eb98

Please sign in to comment.