Skip to content

Commit

Permalink
Exclude electrical zombies from avoidance and make colonists attack t…
Browse files Browse the repository at this point in the history
…hem via melee in auto attack response
  • Loading branch information
pardeike committed Sep 20, 2019
1 parent a90d418 commit aee778c
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 15 deletions.
Binary file modified Assemblies/ZombieLand.dll
Binary file not shown.
15 changes: 15 additions & 0 deletions Source/Patches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1134,6 +1134,21 @@ static bool Prefix(Pawn pawn, ref Job __result)
}
return true;
}

public static bool MyCanReachImmediate(Pawn pawn, LocalTargetInfo target, PathEndMode peMode)
{
if (target.Thing is Zombie zombie)
if (zombie.isElectrifier)
return true;
return pawn.CanReachImmediate(target, peMode);
}

static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
var m_CanReachImmediate = SymbolExtensions.GetMethodInfo(() => ReachabilityImmediate.CanReachImmediate(null, default, default));
var m_MyCanReachImmediate = SymbolExtensions.GetMethodInfo(() => MyCanReachImmediate(null, default, default));
return Transpilers.MethodReplacer(instructions, m_CanReachImmediate, m_MyCanReachImmediate);
}
}
[HarmonyPatch(typeof(DangerUtility))]
[HarmonyPatch(nameof(DangerUtility.GetDangerFor))]
Expand Down
4 changes: 2 additions & 2 deletions Source/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.16.7.0")]
[assembly: AssemblyFileVersion("1.16.7.0")]
[assembly: AssemblyVersion("1.16.8.0")]
[assembly: AssemblyFileVersion("1.16.8.0")]
17 changes: 4 additions & 13 deletions Source/TickManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ public override void FinalizeInit()
var grid = map.GetGrid();
grid.IterateCellsQuick(cell => cell.zombieCount = 0);

RecalculateVisibleMap();
visibleGridUpdateCounter = -1;
RecalculateZombieWanderDestination();

var destinations = GetterSetters.reservedDestinationsByRef(map.pawnDestinationReservationManager);
var zombieFaction = Find.FactionManager.FirstFactionOfDef(ZombieDefOf.Zombies);
Expand Down Expand Up @@ -110,17 +111,7 @@ public override void ExposeData()
explosions = new List<IntVec3>();
}

public static void ForceRecalculate()
{
var tickManager = Find.CurrentMap?.GetComponent<TickManager>();
if (tickManager != null)
{
tickManager.visibleGridUpdateCounter = -1;
tickManager.RecalculateVisibleMap();
}
}

public void RecalculateVisibleMap()
public void RecalculateZombieWanderDestination()
{
Tools.UpdateStoryTellerDifficulty();

Expand Down Expand Up @@ -408,7 +399,7 @@ IEnumerator TickTasks()
yield return null;
FetchAvoidGrid();
yield return null;
RecalculateVisibleMap();
RecalculateZombieWanderDestination();
yield return null;
IncreaseZombiePopulation();
yield return null;
Expand Down
2 changes: 2 additions & 0 deletions Source/Tools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,8 @@ public static bool ShouldAvoidZombies(Pawn pawn = null)

public static float ZombieAvoidRadius(Zombie zombie, bool squared = false)
{
if (zombie.isElectrifier)
return 0f;
if (zombie.wasMapPawnBefore)
return squared ? 64f : 8f;
if (zombie.raging > 0)
Expand Down

0 comments on commit aee778c

Please sign in to comment.