Skip to content

Commit 33c3d61

Browse files
committed
Updated to work with 1.4
1 parent e4fac35 commit 33c3d61

8 files changed

Lines changed: 54 additions & 17 deletions

File tree

68.5 KB
Binary file not shown.

Resources/About/About.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<author>mastertea</author>
66
<url>https://github.com/mastertea/RandomPlus</url>
77
<supportedVersions>
8+
<li>1.4</li>
89
<li>1.3</li>
910
<li>1.2</li>
1011
</supportedVersions>

Resources/Languages/English/Keyed/RandomPlus.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
<RandomPlus.PanelOthers.HealthOptions.NoPain>No Pain</RandomPlus.PanelOthers.HealthOptions.NoPain>
4343
<RandomPlus.PanelOthers.HealthOptions.NoAddiction>No Addiction</RandomPlus.PanelOthers.HealthOptions.NoAddiction>
4444
<RandomPlus.PanelOthers.HealthOptions.AllowNone>Allow None</RandomPlus.PanelOthers.HealthOptions.AllowNone>
45+
<RandomPlus.PanelOthers.HealthOptions.OnlyPositiveImplants>Only Positive Implants</RandomPlus.PanelOthers.HealthOptions.OnlyPositiveImplants>
4546

4647
<RandomPlus.PanelOthers.IncapableOptionLabel>Incapable:</RandomPlus.PanelOthers.IncapableOptionLabel>
4748
<RandomPlus.PanelOthers.IncapableOptions.AllowAll>Allow All</RandomPlus.PanelOthers.IncapableOptions.AllowAll>

Source/HarmonyPatches.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> inst
173173
var codes = new List<CodeInstruction>(instructions);
174174
for (int i = 0; i < codes.Count; i++)
175175
{
176-
if (codes[i].opcode == OpCodes.Ldarg_2 &&
177-
codes[i + 1].opcode == OpCodes.Brfalse_S)
176+
if (codes[i].opcode == OpCodes.Ldloc_1 &&
177+
codes[i + 1].opcode == OpCodes.Brfalse)
178178
{
179179
startIndex = i;
180180
break;
@@ -193,7 +193,7 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> inst
193193

194194
public static void InjectCustomUI()
195195
{
196-
Rect editButtonRect = new Rect(620f, 0.0f, 50f, 30f);
196+
Rect editButtonRect = new Rect(540f, 6f, 50f, 30f);
197197
if (ModsConfig.IsActive("hahkethomemah.simplepersonalities"))
198198
editButtonRect.x -= 130;
199199

@@ -203,7 +203,7 @@ public static void InjectCustomUI()
203203
Find.WindowStack.Add(page);
204204
}
205205

206-
Rect rerollLabelRect = new Rect(620f, 40f, 200f, 30f);
206+
Rect rerollLabelRect = new Rect(640f, 4f, 200f, 30f);
207207
if (ModsConfig.IdeologyActive)
208208
rerollLabelRect.y += 40;
209209

@@ -277,7 +277,7 @@ public static void GoToConfigPawnPage()
277277
methodInfo1.Invoke(page_select_scenario, new object[0]);
278278

279279
var page_storyteller = (Page_SelectStoryteller)page_select_scenario.next;
280-
280+
281281
var page_storyteller_methodInfo0 = typeof(Page_SelectStoryteller).GetMethod("CanDoNext", BindingFlags.NonPublic | BindingFlags.Instance);
282282
page_storyteller_methodInfo0.Invoke(page_storyteller, new object[0]);
283283
var page_storyteller_methodInfo1 = typeof(Page_SelectStoryteller).GetMethod("DoNext", BindingFlags.NonPublic | BindingFlags.Instance);
@@ -293,7 +293,8 @@ public static void GoToConfigPawnPage()
293293

294294
var page_select_site = (Page_SelectStartingSite)page_create_world.next;
295295

296-
LongEventHandler.QueueLongEvent(() => {
296+
LongEventHandler.QueueLongEvent(() =>
297+
{
297298
while (Find.World == null) System.Threading.Thread.Sleep(100);
298299
LongEventHandler.ExecuteWhenFinished(() =>
299300
{
@@ -323,7 +324,7 @@ public static void GoToConfigPawnPage()
323324
});
324325
}, "wait", true, null, false);
325326

326-
327+
327328
}
328329
}
329330
}

Source/PawnFilter.cs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,35 @@ public class PawnFilter : IExposable
1818

1919
public static readonly int DefaultPoolSize = 0;
2020
public enum RerollAlgorithmOptions { Normal, Fast }
21-
public readonly static string[] RerollAlgorithmOptionValues = new string[] {
21+
public readonly static string[] _RerollAlgorithmOptionValues = new string[] {
2222
"RandomPlus.PanelOthers.RerollAlgorithmOptionValues.Normal",
2323
"RandomPlus.PanelOthers.RerollAlgorithmOptionValues.Fast",
2424
};
25+
public static string[] RerollAlgorithmOptionValues {
26+
get {
27+
if (ModsConfig.IsActive("erdelf.HumanoidAlienRaces"))
28+
{
29+
return new string[] { "RandomPlus.PanelOthers.RerollAlgorithmOptionValues.Normal" };
30+
}
31+
return _RerollAlgorithmOptionValues;
32+
}
33+
}
2534
public static readonly RerollAlgorithmOptions DefaultRerollAlgorithm = RerollAlgorithmOptions.Fast;
2635

2736
public enum RerollLimitOptions { N100 = 100, N250 = 250, N500 = 500, N1000 = 1000, N2500 = 2500, N5000 = 5000, N10000 = 10000, N50000 = 50000 }
2837
public readonly static string[] RerollLimitOptionValues = new string[] { "100", "250", "500", "1000", "2500", "5000", "10000", "50000" };
2938
public static readonly RerollLimitOptions DefaultRerollLimit = RerollLimitOptions.N1000;
3039

31-
public enum HealthOptions { AllowAll, OnlyStartCondition, NoPain, NoAddiction, AllowNone }
40+
public enum HealthOptions { AllowAll, OnlyStartCondition, NoPain, NoAddiction, AllowNone,
41+
//OnlyPositiveImplants,
42+
}
3243
public readonly static string[] HealthOptionValues = new string[] {
3344
"RandomPlus.PanelOthers.HealthOptions.AllowAll",
3445
"RandomPlus.PanelOthers.HealthOptions.OnlyStartConditions",
3546
"RandomPlus.PanelOthers.HealthOptions.NoPain",
3647
"RandomPlus.PanelOthers.HealthOptions.NoAddiction",
37-
"RandomPlus.PanelOthers.HealthOptions.AllowNone"
48+
"RandomPlus.PanelOthers.HealthOptions.AllowNone",
49+
//"RandomPlus.PanelOthers.HealthOptions.OnlyPositiveImplants",
3850
};
3951

4052
public enum IncapableOptions { AllowAll, NoDumbLabor, AllowNone }

Source/RandomSettings.cs

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public static bool Reroll(Pawn pawn)
9898
pawn.skills = new Pawn_SkillTracker(pawn);
9999
PawnBioAndNameGenerator.GiveAppropriateBioAndNameTo(pawn, pawn.story.birthLastName, request.Faction.def, request.ForceNoBackstory);
100100
randomTraitMethodInfo.Invoke(null, new object[] { pawn, request });
101-
randomSkillMethodInfo.Invoke(null, new object[] { pawn });
101+
randomSkillMethodInfo.Invoke(null, new object[] { pawn, request });
102102
if (!CheckSkillsIsSatisfied(pawn) || !CheckTraitsIsSatisfied(pawn))
103103
continue;
104104

@@ -109,7 +109,6 @@ public static bool Reroll(Pawn pawn)
109109
{
110110
// internally, this method only adds custom Scenario health (as of rimworld v1.3)
111111
Find.Scenario.Notify_NewPawnGenerating(pawn, request.Context);
112-
113112
randomHealthMethodInfo.Invoke(null, new object[] { pawn, request });
114113
if (!(pawn.Dead || pawn.Destroyed || pawn.Downed))
115114
{
@@ -134,7 +133,6 @@ public static bool Reroll(Pawn pawn)
134133
Find.Scenario.Notify_PawnGenerated(pawn, request.Context, true);
135134
if (!CheckPawnIsSatisfied(pawn))
136135
continue;
137-
138136
// Generate Misc
139137
randomBodyTypeMethodInfo.Invoke(null, new object[] { pawn, request });
140138
GeneratePawnStyle(pawn);
@@ -344,6 +342,21 @@ public static bool CheckHealthIsSatisfied(Pawn pawn)
344342
if (pawn.health.hediffSet.hediffs.Count > 0)
345343
return false;
346344
break;
345+
// case PawnFilter.HealthOptions.OnlyPositiveImplants:
346+
// var hediffs = pawn.health.hediffSet.hediffs;
347+
// Hediff onlyPositiveImplants = null;
348+
// for (int i = 0; i < hediffs.Count; i++)
349+
// {
350+
// var hediff = hediffs[i];
351+
// if (hediff is Hediff_Implant)
352+
// {
353+
// onlyPositiveImplants = hediff;
354+
// break;
355+
// }
356+
//; }
357+
// if (onlyPositiveImplants == null)
358+
// return false;
359+
// break;
347360
}
348361
return true;
349362
}
@@ -441,11 +454,11 @@ public static void GeneratePawnStyle(Pawn pawn)
441454
pawn.story.hairDef = PawnStyleItemChooser.RandomHairFor(pawn);
442455
if (pawn.style != null)
443456
{
444-
pawn.style.beardDef = pawn.gender == Gender.Male? PawnStyleItemChooser.ChooseStyleItem<BeardDef>(pawn) : BeardDefOf.NoBeard;
457+
pawn.style.beardDef = pawn.gender == Gender.Male? PawnStyleItemChooser.RandomBeardFor(pawn) : BeardDefOf.NoBeard;
445458
if (ModsConfig.IdeologyActive)
446459
{
447-
pawn.style.FaceTattoo = PawnStyleItemChooser.ChooseStyleItem<TattooDef>(pawn, new TattooType? (TattooType.Face));
448-
pawn.style.BodyTattoo = PawnStyleItemChooser.ChooseStyleItem<TattooDef>(pawn, new TattooType? (TattooType.Body));
460+
pawn.style.FaceTattoo = PawnStyleItemChooser.RandomTattooFor(pawn, TattooType.Face);
461+
pawn.style.BodyTattoo = PawnStyleItemChooser.RandomTattooFor(pawn, TattooType.Body);
449462
}
450463
else
451464
pawn.style.SetupTattoos_NoIdeology();

Source/SaveLoader.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,15 @@ public static void LoadAll()
7777
{
7878
Scribe.loader.FinalizeLoading();
7979
Scribe.mode = LoadSaveMode.Inactive;
80+
81+
// disable fast algorithm when HAR mod is enable
82+
if (ModsConfig.IsActive("erdelf.HumanoidAlienRaces"))
83+
{
84+
foreach (var filter in RandomSettings.pawnFilterList)
85+
{
86+
filter.RerollAlgorithm = PawnFilter.RerollAlgorithmOptions.Normal;
87+
}
88+
}
8089
}
8190
}
8291

dist.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
echo "location: %CD%"
22
if exist bin\Release\RandomPlus.dll (
33
xcopy Resources\* ..\RandomPlus\ /YE
4-
xcopy bin\Release\RandomPlus.dll ..\RandomPlus\1.3\Assemblies\ /Y
4+
xcopy bin\Release\RandomPlus.dll ..\RandomPlus\1.4\Assemblies\ /Y
55
rd /s /q bin
66
rd /s /q obj
77
exit /b 0

0 commit comments

Comments
 (0)