Skip to content

Commit

Permalink
Fixes incompatibility with Real Ruins (and possibly other mods), adds…
Browse files Browse the repository at this point in the history
… tattered apparel being dropped by zombies if threat level is above 200%, also dropped apparel is more damaged on higher threat levels
  • Loading branch information
pardeike committed Apr 27, 2023
1 parent 6e04c72 commit 52b4ae5
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 26 deletions.
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>net.pardeike.rimworld.mod.zombieland</identifier>
<version>3.8.0.0</version>
<version>3.9.0.0</version>
<targetVersions>
<li>1.4.0</li>
</targetVersions>
Expand Down
Binary file modified Assemblies/ZombieLand.dll
Binary file not shown.
27 changes: 5 additions & 22 deletions Source/Patches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5344,30 +5344,13 @@ static void Prefix()

// patch to insert our settings page
//
[HarmonyPatch(typeof(Scenario))]
[HarmonyPatch(nameof(Scenario.GetFirstConfigPage))]
static class Scenario_GetFirstConfigPage_Patch
[HarmonyPatch(typeof(PageUtility))]
[HarmonyPatch(nameof(PageUtility.StitchedPages))]
static class PageUtility_StitchedPages_Patch
{
static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
static void Prefix(ref List<Page> pages)
{
var found = false;
foreach (var instruction in instructions)
{
var constructorInfo = instruction.operand as ConstructorInfo;
var constructorName = constructorInfo?.DeclaringType.Name ?? "";

if (constructorName == "Page_SelectLandingSite" || constructorName == "Page_SelectStartingSite")
{
yield return new CodeInstruction(OpCodes.Newobj, AccessTools.Constructor(typeof(Dialog_Settings)));
yield return new CodeInstruction(OpCodes.Callvirt, AccessTools.Method(typeof(List<Page>), nameof(List<Page>.Add)));
yield return new CodeInstruction(OpCodes.Ldloc_0);
found = true;
}
yield return instruction;
}

if (!found)
Error("Unexpected code in patch " + MethodBase.GetCurrentMethod().DeclaringType);
pages.Insert(1, new Dialog_Settings());
}
}

Expand Down
6 changes: 6 additions & 0 deletions Source/ZombieGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ public static IEnumerator GenerateStartingApparelFor(Zombie zombie)
{
var pair = possibleApparel.SafeRandomElement();
var apparel = (Apparel)ThingMaker.MakeThing(pair.thing, pair.stuff);
apparel.wornByCorpseInt = Tools.Difficulty() >= 2f;
yield return null;
PawnGenerator.PostProcessGeneratedGear(apparel, zombie);
yield return null;
Expand Down Expand Up @@ -483,6 +484,11 @@ static void Abort(Exception ex)
{
var _bodyType = PrepareZombieType(zombie, zombieType);
zombie.kindDef = ZombieDefOf.Zombie;
if (Tools.Difficulty() > 1f)
{
var maxHealthRange = GenMath.LerpDoubleClamped(0f, 5f, 1f, 0.02f, Tools.Difficulty());
zombie.kindDef.gearHealthRange = new FloatRange(0.02f, maxHealthRange);
}
zombie.SetFactionDirect(FactionUtility.DefaultFactionFrom(ZombieDefOf.Zombies));
zombie.ideo = null;
return _bodyType;
Expand Down
6 changes: 3 additions & 3 deletions Source/ZombieLand.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<OutputPath>..\1.4\Assemblies\</OutputPath>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<Version>3.8.0.0</Version>
<Version>3.9.0.0</Version>
<Copyright>Copyright © 2017</Copyright>
<Configurations>Release;Debug</Configurations>
</PropertyGroup>
Expand Down Expand Up @@ -46,9 +46,9 @@

<ItemGroup>
<PackageReference Include="Brrainz.RimWorld.CrossPromotion" Version="1.0.0" />
<PackageReference Include="Krafs.Rimworld.Ref" Version="1.4.3580" GeneratePathProperty="true" />
<PackageReference Include="Krafs.Rimworld.Ref" Version="1.4.3704" GeneratePathProperty="true" />
<PackageReference Include="Lib.Harmony" Version="2.2.2" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.NETCore.Platforms" Version="7.0.0" />
<PackageReference Include="Microsoft.NETCore.Platforms" Version="7.0.2" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies.net472" Version="1.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down

0 comments on commit 52b4ae5

Please sign in to comment.