Skip to content

Commit

Permalink
v4.3.5 fixes selection of zombie corpses
Browse files Browse the repository at this point in the history
  • Loading branch information
pardeike committed Oct 3, 2023
1 parent 3742a25 commit afb6f92
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 40 deletions.
2 changes: 1 addition & 1 deletion About/About.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<li>Multiplayer</li>
</incompatibleWith>
<packageId>brrainz.zombieland</packageId>
<modVersion>4.3.4.0</modVersion>
<modVersion>4.3.5.0</modVersion>
<steamAppId>928376710</steamAppId>
<description>Do you like The Walking Dead? Are you afraid of The Undead? Good. Because this mod will give you the Heebie-jeebies!

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>net.pardeike.rimworld.mod.zombieland</identifier>
<version>4.3.4.0</version>
<version>4.3.5.0</version>
<targetVersions>
<li>1.4.0</li>
</targetVersions>
Expand Down
Binary file modified Assemblies/ZombieLand.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<ModName>ZombieLand</ModName>
<ModFileName>ZombieLand</ModFileName>
<Repository>https://github.com/pardeike/Zombieland</Repository>
<ModVersion>4.3.4.0</ModVersion>
<ModVersion>4.3.5.0</ModVersion>
<ProjectGuid>{34AA2AF2-8E82-4C5B-8ABA-9AC53DA7C110}</ProjectGuid>
</PropertyGroup>

Expand Down
90 changes: 53 additions & 37 deletions Source/Patches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4570,6 +4570,21 @@ static bool Prefix(Pawn pawn, ref Color __result)
}
}

// allow clicks on zombie corpses that were colonists
//
[HarmonyPatch(typeof(Selector))]
[HarmonyPatch(nameof(Selector.SelectInternal))]
static class Selector_SelectInternal_Patch
{
[HarmonyPriority(Priority.First)]
static bool Prefix(object obj)
{
if (obj is ZombieCorpse corpse && corpse.InnerPawn is Zombie zombie && zombie.wasMapPawnBefore == false)
return false;
return true;
}
}

// allow clicks on zombies that were colonists
//
[HarmonyPatch(typeof(ThingSelectionUtility))]
Expand All @@ -4579,7 +4594,12 @@ static class ThingSelectionUtility_SelectableByMapClick_Patch
[HarmonyPriority(Priority.First)]
static bool Prefix(Thing t, ref bool __result)
{
if (t is Zombie zombie && zombie.wasMapPawnBefore)
if (t is Zombie zombie1 && zombie1.wasMapPawnBefore)
{
__result = true;
return false;
}
if (t is ZombieCorpse corpse && corpse.InnerPawn is Zombie zombie2 && zombie2.wasMapPawnBefore)
{
__result = true;
return false;
Expand Down Expand Up @@ -4649,49 +4669,45 @@ static bool Prefix(ThingDef td, ref bool __result)
[HarmonyPatch(nameof(ThingMaker.MakeThing))]
static class ThingMaker_MakeThing_Patch
{
static void FixDef(ThingDef def)
{
def.smeltable = false;
def.mineable = false;
def.stealable = false;
def.burnableByRecipe = false;
def.canLoadIntoCaravan = false;
def.neverMultiSelect = true;
def.butcherProducts = null;
def.smeltProducts = null;
def.drawGUIOverlay = false;
def.hasTooltip = false;
def.hideAtSnowDepth = 99f;
def.inspectorTabs = new List<Type>();
def.passability = Traversability.Standable;
def.stackLimit = 1;
}

static void Prefix(ThingDef def)
{
if (def == null || def.IsCorpse == false)
return;
if (def.ingestible == null)
return;
if (def.ingestible.sourceDef is ThingDef_Zombie)
{
def.selectable = false;
def.smeltable = false;
def.mineable = false;
def.stealable = false;
def.burnableByRecipe = false;
def.canLoadIntoCaravan = false;
def.neverMultiSelect = true;
def.butcherProducts = null;
def.smeltProducts = null;
def.drawGUIOverlay = false;
def.hasTooltip = false;
def.hideAtSnowDepth = 99f;
def.inspectorTabs = new List<Type>();
def.passability = Traversability.Standable;
def.stackLimit = 1;

var ingestibleSourceDef = def.ingestible?.sourceDef;

if (ingestibleSourceDef is ThingDef_Zombie)
{
FixDef(def);
def.selectable = true;
def.thingClass = typeof(ZombieCorpse);
return;
}
if (def.ingestible.sourceDef is ThingDef_ZombieSpitter)
{
def.selectable = false;
def.smeltable = false;
def.mineable = false;
def.stealable = false;
def.burnableByRecipe = false;
def.canLoadIntoCaravan = false;
def.neverMultiSelect = true;
def.butcherProducts = null;
def.smeltProducts = null;
def.drawGUIOverlay = false;
def.hasTooltip = false;
def.hideAtSnowDepth = 99f;
def.inspectorTabs = new List<Type>();
def.passability = Traversability.Standable;
def.stackLimit = 1;

if (ingestibleSourceDef is ThingDef_ZombieSpitter)
{
FixDef(def);
def.selectable = true;
def.thingClass = typeof(ZombieSpitterCorpse);
return;
}
}
}
Expand Down

0 comments on commit afb6f92

Please sign in to comment.