diff --git a/About/About.xml b/About/About.xml index 60350fbb..01e36dbb 100644 --- a/About/About.xml +++ b/About/About.xml @@ -3,7 +3,7 @@ Zombieland Andreas Pardeike https://ludeon.com/forums/index.php?topic=32601.0 - 0.18.0 + 1.0.0 Do you like The Walking Dead? Are you afraid of The Undead? Good. Because this mod will give you the Heebie-jeebies! This is not your average Zombie mod. In Zombieland, Zombies are everywhere! They crawl out of the ground in masses, hunt you down, bash your doors and eat you alive! At night, their blood lust will steer them towards your base. So better be prepared! diff --git a/Defs/Zombie_Damages.xml b/Defs/Zombie_Damages.xml index 501f52d8..e8e3ef9a 100644 --- a/Defs/Zombie_Damages.xml +++ b/Defs/Zombie_Damages.xml @@ -1,7 +1,7 @@  - + ZombieBite DamageWorker_Bite @@ -15,7 +15,7 @@ 0.67 - + SuicideBomb true @@ -26,7 +26,6 @@ true Blunt Blunt - true false Mote_BlastDry (1, 0, 0) @@ -34,17 +33,17 @@ Explosion_Bomb - 0 + 0 0 0 ToxicSplatter - + false false - 0 + 0 Mote_BlastDry (0, 1, 0, 1) (0, 1, 0, 0.1) diff --git a/Defs/Zombie_Hediffs.xml b/Defs/Zombie_Hediffs.xml index 6a6fad52..cf91b5e7 100644 --- a/Defs/Zombie_Hediffs.xml +++ b/Defs/Zombie_Hediffs.xml @@ -21,7 +21,7 @@ 0.0125 - 0.00625 + 0.00625 0.05 false Bitten off by a zombie diff --git a/Defs/Zombie_Kind.xml b/Defs/Zombie_Kind.xml index 1b72e281..5ff773f4 100644 --- a/Defs/Zombie_Kind.xml +++ b/Defs/Zombie_Kind.xml @@ -18,7 +18,7 @@ 250 true - 0.75 + 0.75 0.0 false diff --git a/Defs/Zombie_Maneuvers.xml b/Defs/Zombie_Maneuvers.xml index eea264af..c5fb94c5 100644 --- a/Defs/Zombie_Maneuvers.xml +++ b/Defs/Zombie_Maneuvers.xml @@ -5,10 +5,14 @@ ZombieBite ZombieBite - Verb_MeleeAttack + Verb_MeleeAttackDamage ZombieBite - Maneuver_Slash + MeleeAttack + Maneuver_Bite_MeleeHit + Maneuver_Bite_MeleeDeflect + Maneuver_Bite_MeleeMiss + Maneuver_Bite_MeleeDodge - \ No newline at end of file + diff --git a/Defs/Zombie_Race.xml b/Defs/Zombie_Race.xml index de91f4c5..efd03adb 100644 --- a/Defs/Zombie_Race.xml +++ b/Defs/Zombie_Race.xml @@ -9,7 +9,7 @@ Pawn false false - BulletImpactFlesh + BulletImpact_Flesh 70 1 @@ -47,7 +47,6 @@ 0 0 0 - 0 0.5 0.05 @@ -105,8 +104,7 @@ 9999 1 1 - (34,113,39) - 0 + Leather_Human OmnivoreRoughAnimal Human HumanStandard @@ -141,4 +139,4 @@ - \ No newline at end of file + diff --git a/Defs/Zombie_Things.xml b/Defs/Zombie_Things.xml index 469e0dcf..22fced3f 100644 --- a/Defs/Zombie_Things.xml +++ b/Defs/Zombie_Things.xml @@ -6,13 +6,18 @@ ZombieLand.BombVest A vest with explosives. - Transcendent + Archotech Never - false - Never + true + None + 0 + 0 + false + false true true false + false false false false @@ -22,6 +27,7 @@ 0 + 0 BombVest/BombVest diff --git a/Source/Alerts.cs b/Source/Alerts.cs index 346580d0..7529789d 100644 --- a/Source/Alerts.cs +++ b/Source/Alerts.cs @@ -69,7 +69,7 @@ public override string NameDecorator(Pawn pawn) .FirstOrDefault(); var percent = string.Format("{0:P0}", tendDuration.InfectionProgress()); - return pawn.NameStringShort + ", " + percent; + return pawn.Name.ToStringShort + ", " + percent; } } @@ -81,7 +81,7 @@ public class Alert_ZombieInfectionProgress : Alert public string label = ""; public virtual void Prepare() { } - public virtual string NameDecorator(Pawn pawn) { return pawn.NameStringShort; } + public virtual string NameDecorator(Pawn pawn) { return pawn.Name.ToStringShort; } public virtual bool ColonistSelector(Pawn pawn) { return false; } public virtual IEnumerable AffectedColonists diff --git a/Source/BombVest.cs b/Source/BombVest.cs index 02b1a6a0..c50fd282 100644 --- a/Source/BombVest.cs +++ b/Source/BombVest.cs @@ -19,7 +19,7 @@ public void Explode() { var damageDef = new SuicideBombDamage(); var radius = 1f + Find.Storyteller.difficulty.difficulty; - GenExplosion.DoExplosion(pos, map, radius, damageDef, null, -1, null, null, null, null, 1f, 1, false, null, 0f, 1); + GenExplosion.DoExplosion(pos, map, radius, damageDef, null); } } @@ -36,7 +36,7 @@ public SuicideBombDamage() var baseDef = CustomDefs.SuicideBomb; Traverse.IterateFields(baseDef, this, (from, to) => { to.SetValue(from.GetValue()); }); - explosionDamage = ScaledValueBetween(8, 120); + defaultDamage = ScaledValueBetween(8, 120); explosionBuildingDamageFactor = ScaledValueBetween(10, 320); explosionHeatEnergyPerCell = ScaledValueBetween(8, 128); } diff --git a/Source/Dialog_ZombieDebugActionMenu.cs b/Source/Dialog_ZombieDebugActionMenu.cs index 85986dae..c4e3782e 100644 --- a/Source/Dialog_ZombieDebugActionMenu.cs +++ b/Source/Dialog_ZombieDebugActionMenu.cs @@ -16,7 +16,7 @@ private void SpawnZombie(ZombieGenerator.ZombieType type, bool appearDirectly) zombie.rubbleCounter = Constants.RUBBLE_AMOUNT; zombie.state = ZombieState.Wandering; } - GenPlace.TryPlaceThing(zombie, UI.MouseCell(), Find.VisibleMap, ThingPlaceMode.Direct, null); + GenPlace.TryPlaceThing(zombie, UI.MouseCell(), Find.CurrentMap, ThingPlaceMode.Direct, null); zombie.Rotation = Rot4.South; TickManager.ForceRecalculate(); } @@ -28,7 +28,7 @@ protected override void DoListingItems() if (Current.ProgramState != ProgramState.Playing) return; - var map = Find.VisibleMap; + var map = Find.CurrentMap; if (map == null) return; @@ -77,7 +77,7 @@ protected override void DoListingItems() }); DebugToolMap("Convert: Make Zombie", delegate { - foreach (var thing in Find.VisibleMap.thingGrid.ThingsAt(UI.MouseCell())) + foreach (var thing in Find.CurrentMap.thingGrid.ThingsAt(UI.MouseCell())) { var pawn = thing as Pawn; if (pawn == null || pawn is Zombie) @@ -87,7 +87,7 @@ protected override void DoListingItems() }); DebugToolMap("Apply: Trigger rotting", delegate { - foreach (var thing in Find.VisibleMap.thingGrid.ThingsAt(UI.MouseCell())) + foreach (var thing in Find.CurrentMap.thingGrid.ThingsAt(UI.MouseCell())) { var compRottable = thing.TryGetComp(); if (compRottable != null) @@ -96,7 +96,7 @@ protected override void DoListingItems() }); DebugToolMap("Apply: Add infection", delegate { - foreach (var thing in Find.VisibleMap.thingGrid.ThingsAt(UI.MouseCell())) + foreach (var thing in Find.CurrentMap.thingGrid.ThingsAt(UI.MouseCell())) { var pawn = thing as Pawn; if (pawn == null || pawn is Zombie) @@ -120,7 +120,7 @@ protected override void DoListingItems() }); DebugToolMap("Apply: Remove infection", delegate { - foreach (var thing in Find.VisibleMap.thingGrid.ThingsAt(UI.MouseCell())) + foreach (var thing in Find.CurrentMap.thingGrid.ThingsAt(UI.MouseCell())) { var pawn = thing as Pawn; if (pawn == null || pawn is Zombie) diff --git a/Source/GraphicsDatabase.cs b/Source/GraphicsDatabase.cs index bd35fa22..4e251df9 100644 --- a/Source/GraphicsDatabase.cs +++ b/Source/GraphicsDatabase.cs @@ -4,6 +4,7 @@ using UnityEngine; using Verse; using System; +using RimWorld; namespace ZombieLand { @@ -77,7 +78,7 @@ static GraphicsDatabase() var graphicData = new GraphicData() { - shaderType = ShaderType.Cutout, + shaderType = ShaderTypeDefOf.Cutout, texPath = "Twinkie", graphicClass = typeof(Graphic_Single) }; diff --git a/Source/Main.cs b/Source/Main.cs index ede7bb05..d92b93f3 100644 --- a/Source/Main.cs +++ b/Source/Main.cs @@ -26,30 +26,6 @@ public ZombielandMod(ModContentPack content) : base(content) { Identifier = content.Identifier; GetSettings(); - - // HarmonyInstance.DEBUG = true; - var harmony = HarmonyInstance.Create("net.pardeike.zombieland"); - harmony.PatchAll(Assembly.GetExecutingAssembly()); - - // prepare Twinkie - LongEventHandler.QueueLongEvent(() => { Tools.EnableTwinkie(false); }, "", true, null); - - // patches for Combat Extended (need to run late or else statics in those classes are not set yet) - LongEventHandler.ExecuteWhenFinished(() => - { - Patches.Projectile_Launch_Patch.PatchCombatExtended(harmony); - Patches.ArmorUtility_GetPostArmorDamage_Patch.PatchCombatExtended(harmony); - }); - - // for debugging - /* - DebugRimworldMethodCalls((Type type) => - { - if (type.Name.Contains("AttackTarget")) return true; - if (type.Name.Contains("_AI")) return true; - if (type.Name.Contains("Reachability")) return true; - return false; - }); */ } public override void DoSettingsWindowContents(Rect inRect) diff --git a/Source/Patches.cs b/Source/Patches.cs index bb5f5dc2..013f57cf 100644 --- a/Source/Patches.cs +++ b/Source/Patches.cs @@ -17,8 +17,36 @@ public class BombVest : Apparel { } public class TankySuit : Apparel { } public class StickyGoo : Filth { } - class Patches + [StaticConstructorOnStartup] + static class Patches { + static Patches() + { + // HarmonyInstance.DEBUG = true; + var harmony = HarmonyInstance.Create("net.pardeike.zombieland"); + harmony.PatchAll(Assembly.GetExecutingAssembly()); + + // prepare Twinkie + LongEventHandler.QueueLongEvent(() => { Tools.EnableTwinkie(false); }, "", true, null); + + // patches for Combat Extended (need to run late or else statics in those classes are not set yet) + LongEventHandler.ExecuteWhenFinished(() => + { + Patches.Projectile_Launch_Patch.PatchCombatExtended(harmony); + Patches.ArmorUtility_GetPostArmorDamage_Patch.PatchCombatExtended(harmony); + }); + + // for debugging + /* + DebugRimworldMethodCalls((Type type) => + { + if (type.Name.Contains("AttackTarget")) return true; + if (type.Name.Contains("_AI")) return true; + if (type.Name.Contains("Reachability")) return true; + return false; + }); */ + } + // used to prevent zombies from being counted as hostiles // both in map exist and for danger music // @@ -37,7 +65,7 @@ static void Postfix() if (Constants.DEBUGGRID == false && DebugViewSettings.drawDoorsDebug == false) return; // debug zombie counts - Find.VisibleMap.GetGrid().IterateCells((x, z, cell) => + Find.CurrentMap.GetGrid().IterateCells((x, z, cell) => { var pos = new Vector3(x, pawnAltitude, z); if (cell.zombieCount > 1) @@ -50,7 +78,7 @@ static void Postfix() // debug timestamps var fadeOff = Tools.PheromoneFadeoff(); var now = Tools.Ticks(); - Find.VisibleMap.GetGrid().IterateCells((x, z, cell) => + Find.CurrentMap.GetGrid().IterateCells((x, z, cell) => { var pos = new Vector3(x, pawnAltitude, z); var diff = now - cell.timestamp; @@ -79,7 +107,7 @@ static void Postfix() if (DebugViewSettings.writePathCosts == false) return; if (ZombieSettings.Values.betterZombieAvoidance == false) return; - var map = Find.VisibleMap; + var map = Find.CurrentMap; var tickManager = map.GetComponent(); if (tickManager == null) return; var avoidGrid = tickManager.avoidGrid; @@ -106,7 +134,7 @@ static void Postfix() if (DebugViewSettings.writePathCosts == false) return; if (Event.current.type != EventType.Repaint) return; - var map = Find.VisibleMap; + var map = Find.CurrentMap; if (map == null) return; var grid = map.GetGrid(); var basePos = UI.MouseCell(); @@ -138,7 +166,7 @@ class GlobalControlsUtility_DoDate_Patch { static void Postfix(float leftX, float width, ref float curBaseY) { - var map = Find.VisibleMap; + var map = Find.CurrentMap; if (map == null) return; var tickManager = map.GetComponent(); @@ -187,7 +215,7 @@ static class Verse_TickManager_TickManagerUpdate_Patch { static void ZombieTick() { - var tickManager = Find.VisibleMap?.GetComponent(); + var tickManager = Find.CurrentMap?.GetComponent(); tickManager?.ZombieTicking(); } @@ -202,7 +230,7 @@ static IEnumerable Transpiler(IEnumerable inst if (firstTime && instruction.opcode == OpCodes.Ldloc_0) { firstTime = false; - yield return new CodeInstruction(OpCodes.Ldloc_0); + yield return new CodeInstruction(OpCodes.Ldloc_1); yield return new CodeInstruction(OpCodes.Ldc_I4_2); yield return new CodeInstruction(OpCodes.Bge, jump); yield return new CodeInstruction(OpCodes.Call, m_ZombieTick); @@ -340,7 +368,7 @@ static void Postfix(ref IAttackTarget __result, Predicate validator, IAtt if (verb != null) { var props = verb.verbProps; - if (props.MeleeRange == false && props.range > 0) + if (props.IsMeleeAttack == false && props.range > 0) { // the following can be improved by choosing targets that // are not too close. unsolved problem: we do not know how @@ -378,8 +406,8 @@ static void Postfix(ref IAttackTarget __result, Predicate validator, IAtt // patch so other zombies do not affect goodwill of other factions // [HarmonyPatch(typeof(Faction))] - [HarmonyPatch("AffectGoodwillWith")] - static class Faction_AffectGoodwillWith_Patch + [HarmonyPatch("TryAffectGoodwillWith")] + static class Faction_TryAffectGoodwillWith_Patch { static bool Prefix(ref bool __result, Faction __instance, Faction other) { @@ -599,14 +627,14 @@ static IEnumerable Transpiler(IEnumerable inst var inList = instructions.ToList(); var idx1 = inList.FirstIndexOf(instr => instr.opcode == OpCodes.Ldfld && instr.operand == f_forcedMissRadius); - var idx2 = inList.FindLastIndex(instr => instr.opcode == OpCodes.Call - && (instr.operand as MethodInfo)?.DeclaringType == typeof(ShotReport) - && (instr.operand as MethodInfo)?.ReturnType == typeof(float) - ); if (idx1 > 0) { - var jump = inList[idx2 + 1]; - if (jump.opcode == OpCodes.Ble_Un) + var idx2 = inList.FindLastIndex(instr => instr.opcode == OpCodes.Call + && (instr.operand as MethodInfo)?.DeclaringType == typeof(ShotReport) + && (instr.operand as MethodInfo)?.ReturnType == typeof(float) + ); + var jump = inList[idx2 + 2]; // skip CALL bool Verse.Rand::Chance(float32) + if (jump.opcode == OpCodes.Brtrue) { idx1 -= 2; inList.Insert(idx1++, new CodeInstruction(OpCodes.Ldarg_0)); @@ -864,7 +892,7 @@ static class EditWindow_DebugInspector_CurrentDebugString_Patch static void DebugGrid(StringBuilder builder) { if (Current.Game == null) return; - var map = Current.Game.VisibleMap; + var map = Current.Game.CurrentMap; if (map == null) return; var pos = UI.MouseCell(); @@ -930,7 +958,7 @@ static void DebugGrid(StringBuilder builder) var gotoPos = zombie.pather.Moving ? zombie.pather.Destination.Cell : IntVec3.Invalid; var wanderTo = zombie.wanderDestination; var sb = new StringBuilder(); - sb.Append("Zombie " + zombie.NameStringShort + " at " + currPos.x + "," + currPos.z); + sb.Append("Zombie " + zombie.Name.ToStringShort + " at " + currPos.x + "," + currPos.z); sb.Append(", " + zombie.state.ToString().ToLower()); if (zombie.raging > 0) sb.Append(", raging "); sb.Append(", going to " + gotoPos.x + "," + gotoPos.z); @@ -952,29 +980,17 @@ static bool Prefix(string __result) static IEnumerable Transpiler(IEnumerable instructions) { var f_writeCellContentsField = typeof(DebugViewSettings).Field(nameof(DebugViewSettings.writeCellContents)); - if (f_writeCellContentsField == null) throw new Exception("Cannot find field DebugViewSettings.writeCellContents"); var found = false; - var previousPopInstruction = false; foreach (var instruction in instructions) { - if (previousPopInstruction == false && instruction.opcode == OpCodes.Pop) - { - previousPopInstruction = true; - yield return instruction; - } - else if (previousPopInstruction && instruction.opcode == OpCodes.Ldsfld && instruction.operand == f_writeCellContentsField) + if (instruction.opcode == OpCodes.Ldsfld && instruction.operand == f_writeCellContentsField) { yield return new CodeInstruction(OpCodes.Ldloc_0); yield return new CodeInstruction(OpCodes.Call, SymbolExtensions.GetMethodInfo(() => DebugGrid(null))); - yield return instruction; found = true; } - else - { - yield return instruction; - previousPopInstruction = false; - } + yield return instruction; } if (!found) Log.Error("Unexpected code in patch " + MethodBase.GetCurrentMethod().DeclaringType); @@ -990,8 +1006,8 @@ static class DebugWindowsOpener_ToggleDebugActionsMenu_Patch [HarmonyPriority(Priority.First)] static IEnumerable Transpiler(IEnumerable instructions) { - var from = typeof(Dialog_DebugActionsMenu).Constructor(); - var to = typeof(Dialog_ZombieDebugActionMenu).Constructor(); + var from = AccessTools.Constructor(typeof(Dialog_DebugActionsMenu)); + var to = AccessTools.Constructor(typeof(Dialog_ZombieDebugActionMenu)); return instructions.MethodReplacer(from, to); } } @@ -1019,16 +1035,16 @@ static void Postfix(FactionManager __instance) var rel1 = new FactionRelation() { other = faction, - goodwill = 0f, - hostile = true + goodwill = 0, + kind = FactionRelationKind.Hostile }; factionRelations(zombies).Add(rel1); var rel2 = new FactionRelation() { other = zombies, - goodwill = 0f, - hostile = true + goodwill = 0, + kind = FactionRelationKind.Hostile }; factionRelations(faction).Add(rel2); @@ -1267,8 +1283,8 @@ static IEnumerable Transpiler(ILGenerator il, IEnumerablec__"); + var inner = typeof(Toils_Jump).InnerTypeStartingWith("c__"); return inner.MethodStartingWith("<>m__"); } @@ -1792,7 +1808,7 @@ static void Postfix(PawnGraphicSet __instance) { var apparel = new Apparel() { def = ThingDef.Named("Apparel_BombVest") }; ApparelGraphicRecord record; - if (ApparelGraphicRecordGetter.TryGetGraphicApparel(apparel, BodyType.Hulk, out record)) + if (ApparelGraphicRecordGetter.TryGetGraphicApparel(apparel, BodyTypeDefOf.Hulk, out record)) __instance.apparelGraphics.Add(record); } } @@ -1863,17 +1879,22 @@ static bool Prefix(Thing thing, StatDef stat, ref float __result) __result = 5000f; return false; } - switch (zombie.story.bodyType) + + var bodyType = zombie.story.bodyType; + if (bodyType == BodyTypeDefOf.Thin) + { + __result = 0.1f; + return false; + } + if (bodyType == BodyTypeDefOf.Hulk) { - case BodyType.Thin: - __result = 0.1f; - return false; - case BodyType.Hulk: - __result = 0.8f; - return false; - case BodyType.Fat: - __result = 10f; - return false; + __result = 0.8f; + return false; + } + else if (bodyType == BodyTypeDefOf.Fat) + { + __result = 10f; + return false; } __result = 0.8f; return false; @@ -1893,7 +1914,7 @@ static bool Prefix(Thing thing, StatDef stat, ref float __result) return false; } - if (zombie.story.bodyType == BodyType.Fat) + if (zombie.story.bodyType == BodyTypeDefOf.Fat) { __result = 0.8f; return false; @@ -1920,22 +1941,14 @@ static bool Prefix(Thing thing, StatDef stat, ref float __result) else speed = ZombieSettings.Values.moveSpeedIdle; - float factor; - switch (zombie.story.bodyType) - { - case BodyType.Thin: - factor = 0.8f; - break; - case BodyType.Hulk: - factor = 0.1f; - break; - case BodyType.Fat: - factor = 0.05f; - break; - default: - factor = 1f; - break; - } + var factor = 1f; + var bodyType = zombie.story.bodyType; + if (bodyType == BodyTypeDefOf.Thin) + factor = 0.8f; + else if (bodyType == BodyTypeDefOf.Hulk) + factor = 0.1f; + else if (bodyType == BodyTypeDefOf.Fat) + factor = 0.05f; // instead of ticking zombies as often as everything else, we tick // them at 1x speed and make them faster instead. Not perfect but @@ -1973,18 +1986,14 @@ static void Postfix(Pawn pawn, ref float __result) } var settings = ZombieSettings.Values.damageFactor; - switch (zombie.story.bodyType) - { - case BodyType.Thin: - __result *= 0.5f * settings; - break; - case BodyType.Hulk: - __result *= 4f * settings; - break; - case BodyType.Fat: - __result *= 10f * settings; - break; - } + var bodyType = zombie.story.bodyType; + if (bodyType == BodyTypeDefOf.Thin) + __result *= 0.5f * settings; + else if (bodyType == BodyTypeDefOf.Hulk) + __result *= 4f * settings; + else if (bodyType == BodyTypeDefOf.Fat) + __result *= 10f * settings; + if (zombie.wasMapPawnBefore) __result *= 10f; } @@ -2201,20 +2210,20 @@ static void PlayTink(Thing thing) } [HarmonyPriority(Priority.First)] - static bool Prefix(Pawn pawn, ref int amountInt, BodyPartRecord part, ref int __result) + static bool Prefix(Pawn pawn, ref float amount, BodyPartRecord part, ref int __result) { var zombie = pawn as Zombie; if (zombie == null) return true; var difficulty = Find.Storyteller.difficulty.difficulty; - if (amountInt > 25) - amountInt = 25 + (int)Math.Sqrt(amountInt - 26); + if (amount > 25) + amount = 25 + Mathf.Sqrt(amount - 26); if (zombie.hasTankyShield > 0f) { PlayTink(zombie); - zombie.hasTankyShield -= amountInt / (1f + difficulty * 150f); + zombie.hasTankyShield -= amount / (1f + difficulty * 150f); if (zombie.hasTankyShield < 0f) zombie.hasTankyShield = -1f; __result = -1; @@ -2227,7 +2236,7 @@ static bool Prefix(Pawn pawn, ref int amountInt, BodyPartRecord part, ref int __ if (zombie.hasTankyHelmet > 0f) { PlayTink(zombie); - zombie.hasTankyHelmet -= amountInt / (1f + difficulty * 10f); + zombie.hasTankyHelmet -= amount / (1f + difficulty * 10f); if (zombie.hasTankyHelmet < 0f) zombie.hasTankyHelmet = -1f; __result = -1; @@ -2239,7 +2248,7 @@ static bool Prefix(Pawn pawn, ref int amountInt, BodyPartRecord part, ref int __ if (zombie.hasTankySuit > 0f) { PlayTink(zombie); - zombie.hasTankySuit -= amountInt / (1f + difficulty * 100f); + zombie.hasTankySuit -= amount / (1f + difficulty * 100f); if (zombie.hasTankySuit < 0f) zombie.hasTankySuit = -1f; __result = -1; @@ -2251,7 +2260,7 @@ static bool Prefix(Pawn pawn, ref int amountInt, BodyPartRecord part, ref int __ if (zombie.hasTankyHelmet > 0f || zombie.hasTankySuit > 0f) { var toughnessLevel = Find.Storyteller.difficulty.difficulty; - amountInt = (amountInt + toughnessLevel) / (toughnessLevel + 1); + amount = (amount + toughnessLevel) / (toughnessLevel + 1); } return true; @@ -2307,7 +2316,7 @@ static bool Prefix(Pawn __instance, LocalTargetInfo targ, ref bool __result) if ((__instance is Zombie) == false) return true; - var verb = __instance.TryGetAttackVerb(); + var verb = __instance.TryGetAttackVerb(targ.Thing); __result = verb != null && verb.TryStartCastOn(targ, false, true); return false; } @@ -2567,7 +2576,6 @@ static void Prefix(ThingDef def) def.hideAtSnowDepth = 99f; def.inspectorTabs = new List(); def.passability = Traversability.Standable; - def.affectsRegions = false; def.stackLimit = 1; def.thingClass = typeof(ZombieCorpse); } @@ -2759,10 +2767,10 @@ static bool Prefix(ImmunityHandler __instance) // [HarmonyPatch(typeof(Projectile))] [HarmonyPatch("Launch")] - [HarmonyPatch(new Type[] { typeof(Thing), typeof(Vector3), typeof(LocalTargetInfo), typeof(Thing), typeof(Thing) })] + [HarmonyPatch(new Type[] { typeof(Thing), typeof(Vector3), typeof(LocalTargetInfo), typeof(LocalTargetInfo), typeof(ProjectileHitFlags), typeof(Thing), typeof(ThingDef) })] public static class Projectile_Launch_Patch { - static void Postfix(Thing launcher, Vector3 origin, LocalTargetInfo targ) + static void Postfix(Thing launcher, Vector3 origin, LocalTargetInfo usedTarget) { var pawn = launcher as Pawn; if (pawn == null) return; @@ -2773,7 +2781,7 @@ static void Postfix(Thing launcher, Vector3 origin, LocalTargetInfo targ) var now = Tools.Ticks(); var pos = origin.ToIntVec3(); - var magnitude = (targ.CenterVector3 - origin).magnitude * noiseScale * Math.Min(1f, ZombieSettings.Values.zombieInstinct.HalfToDoubleValue()); + var magnitude = (usedTarget.CenterVector3 - origin).magnitude * noiseScale * Math.Min(1f, ZombieSettings.Values.zombieInstinct.HalfToDoubleValue()); var radius = Tools.Boxed(magnitude, Constants.MIN_WEAPON_RANGE, Constants.MAX_WEAPON_RANGE); var grid = launcher.Map.GetGrid(); Tools.GetCircle(radius).Do(vec => grid.BumpTimestamp(pos + vec, now - vec.LengthHorizontalSquared)); @@ -2937,14 +2945,14 @@ static class Scenario_GetFirstConfigPage_Patch { static IEnumerable Transpiler(IEnumerable instructions) { - var selectLandingSiteConstructor = typeof(Page_SelectLandingSite).Constructor(); + var selectLandingSiteConstructor = AccessTools.Constructor(typeof(Page_SelectLandingSite)); var found = false; foreach (var instruction in instructions) { if (instruction.operand == selectLandingSiteConstructor) { - yield return new CodeInstruction(OpCodes.Newobj, typeof(SettingsDialog).Constructor()); + yield return new CodeInstruction(OpCodes.Newobj, AccessTools.Constructor(typeof(SettingsDialog))); yield return new CodeInstruction(OpCodes.Callvirt, typeof(List).MethodNamed(nameof(List.Add))); yield return new CodeInstruction(OpCodes.Ldloc_0); found = true; @@ -2972,7 +2980,7 @@ static IEnumerable Transpiler(IEnumerable inst var list = instructions.ToList(); var skipLoopIndex = list.FirstIndexOf(instr => instr.opcode == OpCodes.Add) - 2; - if (skipLoopIndex > 0 && list[skipLoopIndex - 1].opcode == OpCodes.Ret) + if (skipLoopIndex > 0) { list[skipLoopIndex].labels.Add(skipLabel); found1 = true; @@ -2981,9 +2989,9 @@ static IEnumerable Transpiler(IEnumerable inst foreach (var instruction in list) { yield return instruction; - if (instruction.opcode == OpCodes.Stloc_2) + if (instruction.opcode == OpCodes.Stloc_3) { - yield return new CodeInstruction(OpCodes.Ldloc_2); + yield return new CodeInstruction(OpCodes.Ldloc_3); yield return new CodeInstruction(OpCodes.Callvirt, get_InnerPawn); yield return new CodeInstruction(OpCodes.Brfalse_S, skipLabel); @@ -3000,7 +3008,7 @@ static class Pawn_HealthTracker_PreApplyDamage_Patch { static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) { - var m_TryGainMemory = typeof(MemoryThoughtHandler).Method("TryGainMemory", new Type[] { typeof(ThoughtDef), typeof(Pawn) }); + var m_TryGainMemory = typeof(MemoryThoughtHandler).MethodNamed("TryGainMemory", new Type[] { typeof(ThoughtDef), typeof(Pawn) }); var f_pawn = typeof(Pawn_HealthTracker).Field("pawn"); var found1 = false; @@ -3056,9 +3064,8 @@ static void Prefix(ref Rect rect) } } [HarmonyPatch(typeof(Widgets))] - [HarmonyPatch("ButtonText")] - [HarmonyPatch(new Type[] { typeof(Rect), typeof(string), typeof(bool), typeof(bool), typeof(Color), typeof(bool) })] - static class Widgets_DoWindowContents_Path + [HarmonyPatch("ButtonTextWorker")] + static class Widgets_ButtonText_Path { static void NewDrawAtlas(Rect rect, Texture2D atlas, string label) { @@ -3072,7 +3079,7 @@ static void NewDrawAtlas(Rect rect, Texture2D atlas, string label) static IEnumerable Transpiler(IEnumerable instructions) { - var from = typeof(Widgets).Method("DrawAtlas", new Type[] { typeof(Rect), typeof(Texture2D) }); + var from = typeof(Widgets).MethodNamed("DrawAtlas", new Type[] { typeof(Rect), typeof(Texture2D) }); var to = SymbolExtensions.GetMethodInfo(() => NewDrawAtlas(Rect.zero, null, null)); var found = false; diff --git a/Source/Properties/AssemblyInfo.cs b/Source/Properties/AssemblyInfo.cs index 9bca4a2e..61214437 100644 --- a/Source/Properties/AssemblyInfo.cs +++ b/Source/Properties/AssemblyInfo.cs @@ -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.10.4.0")] -[assembly: AssemblyFileVersion("1.10.4.0")] +[assembly: AssemblyVersion("1.11.0.0")] +[assembly: AssemblyFileVersion("1.11.0.0")] diff --git a/Source/Rubble.cs b/Source/Rubble.cs index 352ab850..be2eb465 100644 --- a/Source/Rubble.cs +++ b/Source/Rubble.cs @@ -38,7 +38,6 @@ public void ExposeData() Scribe_Values.Look(ref pY, "pY"); Scribe_Values.Look(ref drop, "drop"); Scribe_Values.Look(ref dropSpeed, "dropSpeed"); - Scribe_Values.Look(ref dropSpeed, "dropSpeed"); Scribe_Values.Look(ref scale, "scale"); Scribe_Values.Look(ref rot, "rot"); } diff --git a/Source/SafeReflections.cs b/Source/SafeReflections.cs index 642f3d35..93b0fe9e 100644 --- a/Source/SafeReflections.cs +++ b/Source/SafeReflections.cs @@ -35,7 +35,7 @@ public static MethodInfo MethodNamed(this Type type, string name) return method; } - public static MethodInfo Method(this Type type, string name, Type[] argumentTypes) + public static MethodInfo MethodNamed(this Type type, string name, Type[] argumentTypes) { var method = AccessTools.Method(type, name, argumentTypes); if (method == null) throw new Exception("Cannot find method " + name + argumentTypes.Description() + " in type " + type.FullName); @@ -51,14 +51,14 @@ public static FieldInfo Field(this Type type, string fieldName) public static MethodInfo PropertyGetter(this Type type, string propertyName) { - var method = AccessTools.Property(type, propertyName)?.GetGetMethod(); + var method = AccessTools.Property(type, propertyName)?.GetGetMethod(true); if (method == null) throw new Exception("Cannot find property getter '" + propertyName + "' in type " + type.FullName); return method; } public static MethodInfo PropertySetter(this Type type, string propertyName) { - var method = AccessTools.Property(type, propertyName)?.GetSetMethod(); + var method = AccessTools.Property(type, propertyName)?.GetSetMethod(true); if (method == null) throw new Exception("Cannot find property getter '" + propertyName + "' in type " + type.FullName); return method; } diff --git a/Source/TickDebugger.cs b/Source/TickDebugger.cs index fde9f57c..1a3c1810 100644 --- a/Source/TickDebugger.cs +++ b/Source/TickDebugger.cs @@ -110,7 +110,7 @@ public static void Update(int idx, string name, Stopwatch sw, bool resetPos = fa public static void Advance() { - if (Find.VisibleMap != null && Find.TickManager.Paused == false) + if (Find.CurrentMap != null && Find.TickManager.Paused == false) { var lastIndex = TickerData.width - 1; for (var t = 0; t < maxTickers; t++) diff --git a/Source/TickManager.cs b/Source/TickManager.cs index 5d686c05..d400f69e 100644 --- a/Source/TickManager.cs +++ b/Source/TickManager.cs @@ -95,7 +95,7 @@ public override void ExposeData() public static void ForceRecalculate() { - var tickManager = Find.VisibleMap?.GetComponent(); + var tickManager = Find.CurrentMap?.GetComponent(); if (tickManager != null) { tickManager.visibleGridUpdateCounter = -1; @@ -379,7 +379,7 @@ public override void MapComponentTick() var volume = 0f; if (allZombiesCached.Any()) { - var hour = GenLocalDate.HourFloat(Find.VisibleMap); + var hour = GenLocalDate.HourFloat(Find.CurrentMap); if (hour < 12f) hour += 24f; if (hour > Constants.HOUR_START_OF_NIGHT && hour < Constants.HOUR_END_OF_NIGHT) volume = 1f; diff --git a/Source/Tools.cs b/Source/Tools.cs index 2b9871b3..50d6ffd6 100644 --- a/Source/Tools.cs +++ b/Source/Tools.cs @@ -274,7 +274,7 @@ public static void ConvertToZombie(ThingWithComps thing, bool force = false) zombie.wasMapPawnBefore = true; zombie.apparel.DestroyAll(); - pawn.apparel.WornApparelInDrawOrder.ToList().ForEach(apparel => + pawn.apparel.WornApparel.ForEach(apparel => { if (pawn.apparel.TryDrop(apparel, out var newApparel)) { @@ -283,7 +283,7 @@ public static void ConvertToZombie(ThingWithComps thing, bool force = false) newApparel.HitPoints = 1; var compQuality = newApparel.TryGetComp(); if (compQuality != null) - compQuality.SetQuality(QualityCategory.Shoddy, ArtGenerationContext.Colony); + compQuality.SetQuality(QualityCategory.Awful, ArtGenerationContext.Colony); zombie.apparel.Notify_ApparelAdded(newApparel); } @@ -302,7 +302,7 @@ public static void ConvertToZombie(ThingWithComps thing, bool force = false) } var label = "BecameAZombieLabel".Translate(); - var text = "BecameAZombieDesc".Translate(new object[] { pawn.NameStringShort }); + var text = "BecameAZombieDesc".Translate(new object[] { pawn.Name.ToStringShort }); Find.LetterStack.ReceiveLetter(label, text, LetterDefOf.ThreatBig, zombie); } @@ -504,8 +504,8 @@ public static bool IsCombatExtendedInstalled() public static int ColonyPoints() { - var colonists = Find.VisibleMap.mapPawns.FreeColonists; - ColonyEvaluation.GetColonistArmouryPoints(colonists, Find.VisibleMap, out var colonistPoints, out var armouryPoints); + var colonists = Find.CurrentMap.mapPawns.FreeColonists; + ColonyEvaluation.GetColonistArmouryPoints(colonists, Find.CurrentMap, out var colonistPoints, out var armouryPoints); return (int)(colonistPoints + armouryPoints); } @@ -600,13 +600,13 @@ public static IEnumerable GetCircle(float radius) public static string TranslateHoursToText(float hours) { var ticks = (int)(GenDate.TicksPerHour * hours); - return ticks.ToStringTicksToPeriod(true, true, false); + return ticks.ToStringTicksToPeriodVerbose(true, false); } public static string TranslateHoursToText(int hours) { var ticks = GenDate.TicksPerHour * hours; - return ticks.ToStringTicksToPeriod(true, true, false); + return ticks.ToStringTicksToPeriodVerbose(true, false); } public static void Look(ref T[] list, string label, params object[] ctorArgs) where T : IExposable @@ -784,4 +784,36 @@ public static IEnumerable DownedReplacer(IEnumerable> (32 - bits)); + } + + public uint GetValue(int x, int y) + { + var num = seed; + for (uint i = 0; i < 16; i++) + { + num = num * 541 + (uint)x; + num = BitRotate(num); + num = num * 809 + (uint)y; + num = BitRotate(num); + num = num * 673 + (uint)i; + num = BitRotate(num); + } + return num % 4; + } + } + */ } \ No newline at end of file diff --git a/Source/VariableGraphic.cs b/Source/VariableGraphic.cs index 457ddd33..3aa53be3 100644 --- a/Source/VariableGraphic.cs +++ b/Source/VariableGraphic.cs @@ -13,10 +13,10 @@ public class VariableGraphic : Graphic, IDisposable public string GraphicPath => path; public override Material MatSingle => mats[2].GetMaterial; - public override Material MatFront => mats[2].GetMaterial; - public override Material MatSide => mats[1].GetMaterial; - public override Material MatBack => mats[0].GetMaterial; - public override bool ShouldDrawRotated => MatSide == MatBack; + public override Material MatSouth => mats[2].GetMaterial; + public override Material MatWest => mats[1].GetMaterial; + public override Material MatNorth => mats[0].GetMaterial; + public override bool ShouldDrawRotated => MatWest == MatNorth; public override void Init(GraphicRequest req) { @@ -32,9 +32,9 @@ public override void Init(GraphicRequest req) mats = new ColorData[] { - GraphicsDatabase.GetColorData(req.path + "_back", bodyColor, true), - GraphicsDatabase.GetColorData(req.path + "_side", bodyColor, true), - GraphicsDatabase.GetColorData(req.path + "_front", bodyColor, true) + GraphicsDatabase.GetColorData(req.path + "_north", bodyColor, true), + GraphicsDatabase.GetColorData(req.path + "_west", bodyColor, true), + GraphicsDatabase.GetColorData(req.path + "_south", bodyColor, true) } .Select(data => { diff --git a/Source/Zombie.cs b/Source/Zombie.cs index 0b1d5a8b..87b1b32c 100644 --- a/Source/Zombie.cs +++ b/Source/Zombie.cs @@ -167,14 +167,14 @@ public override void Kill(DamageInfo? dinfo, Hediff exactCulprit = null) base.Kill(dinfo, exactCulprit); } - public override void DeSpawn() + public override void DeSpawn(DestroyMode mode = DestroyMode.Vanish) { var map = Map; if (map == null) return; var grid = map.GetGrid(); grid.ChangeZombieCount(lastGotoPosition, -1); - base.DeSpawn(); + base.DeSpawn(mode); } static readonly Type[] RenderPawnInternalParameterTypes = { @@ -194,7 +194,14 @@ void DropStickyGoo() var map = Map; if (map == null) return; - var amount = (int)story.bodyType + Find.Storyteller.difficulty.difficulty; // max 10 + var amount = 1 + Find.Storyteller.difficulty.difficulty; + if (story.bodyType == BodyTypeDefOf.Thin) + amount -= 1; + if (story.bodyType == BodyTypeDefOf.Fat) + amount += 1; + if (story.bodyType == BodyTypeDefOf.Hulk) + amount += 2; + var maxRadius = 0f; var count = (int)GenMath.LerpDouble(0, 10, 2, 30, amount); var hasFilth = 0; @@ -207,7 +214,7 @@ void DropStickyGoo() if (r > maxRadius) maxRadius = r; var cell = pos + vec; if (GenSight.LineOfSight(pos, cell, map, true, null, 0, 0) && cell.Walkable(map)) - if (FilthMaker.MakeFilth(cell, map, ThingDef.Named("StickyGoo"), NameStringShort)) + if (FilthMaker.MakeFilth(cell, map, ThingDef.Named("StickyGoo"), Name.ToStringShort, 1)) hasFilth++; } if (hasFilth >= 6) @@ -296,7 +303,7 @@ public override void Tick() public void CustomTick() { - if (!ThingOwnerUtility.ContentsFrozen(ParentHolder) && Map != null) + if (!ThingOwnerUtility.ContentsSuspended(ParentHolder) && Map != null) { if (Spawned) { @@ -324,7 +331,7 @@ public override void DrawGUIOverlay() } } - static readonly MethodInfo m_RenderPawnInternal = typeof(PawnRenderer).Method("RenderPawnInternal", RenderPawnInternalParameterTypes); + static readonly MethodInfo m_RenderPawnInternal = typeof(PawnRenderer).MethodNamed("RenderPawnInternal", RenderPawnInternalParameterTypes); public void Render(PawnRenderer renderer, Vector3 drawLoc, RotDrawMode bodyDrawType) { if (!renderer.graphics.AllResolved) diff --git a/Source/ZombieGenerator.cs b/Source/ZombieGenerator.cs index 30d9de0a..bfc6b934 100644 --- a/Source/ZombieGenerator.cs +++ b/Source/ZombieGenerator.cs @@ -192,12 +192,12 @@ public enum ZombieType Normal = 3 } - private static BodyType PrepareZombieType(Zombie zombie, ZombieType overwriteType) + private static BodyTypeDef PrepareZombieType(Zombie zombie, ZombieType overwriteType) { - var zombieTypeInitializers = new Pair>[] + var zombieTypeInitializers = new Pair>[] { // suicide bomber - new Pair>( + new Pair>( ZombieSettings.Values.suicideBomberChance, delegate { @@ -205,12 +205,12 @@ private static BodyType PrepareZombieType(Zombie zombie, ZombieType overwriteTyp zombie.lastBombTick = Find.TickManager.TicksAbs + Rand.Range(0, (int)zombie.bombTickingInterval); // zombie.gender = Gender.Male; - return BodyType.Hulk; + return BodyTypeDefOf.Hulk; } ), // toxic splasher - new Pair>( + new Pair>( ZombieSettings.Values.toxicSplasherChance, delegate { @@ -220,20 +220,20 @@ private static BodyType PrepareZombieType(Zombie zombie, ZombieType overwriteTyp { case 1: zombie.gender = Gender.Male; - return BodyType.Male; + return BodyTypeDefOf.Male; case 2: zombie.gender = Gender.Female; - return BodyType.Female; + return BodyTypeDefOf.Female; case 3: zombie.gender = Gender.Male; - return BodyType.Thin; + return BodyTypeDefOf.Thin; } - return BodyType.Undefined; + return null; } ), // tanky operator - new Pair>( + new Pair>( ZombieSettings.Values.tankyOperatorChance, delegate { @@ -242,12 +242,12 @@ private static BodyType PrepareZombieType(Zombie zombie, ZombieType overwriteTyp zombie.hasTankySuit = 1f; // zombie.gender = Gender.Male; - return BodyType.Fat; + return BodyTypeDefOf.Fat; } ), // default ordinary zombie - new Pair>( + new Pair>( float.MaxValue, delegate { @@ -255,18 +255,18 @@ private static BodyType PrepareZombieType(Zombie zombie, ZombieType overwriteTyp { case 1: zombie.gender = Gender.Male; - return BodyType.Male; + return BodyTypeDefOf.Male; case 2: zombie.gender = Gender.Female; - return BodyType.Female; + return BodyTypeDefOf.Female; case 3: zombie.gender = Gender.Male; - return BodyType.Thin; + return BodyTypeDefOf.Thin; case 4: zombie.gender = Gender.Male; - return BodyType.Fat; + return BodyTypeDefOf.Fat; } - return BodyType.Undefined; + return null; } ) }; @@ -278,7 +278,7 @@ private static BodyType PrepareZombieType(Zombie zombie, ZombieType overwriteTyp } var typeChance = Rand.Value; - var bodyType = BodyType.Undefined; + BodyTypeDef bodyType = null; foreach (var initializer in zombieTypeInitializers) { if (typeChance < initializer.First) @@ -298,13 +298,13 @@ public static void AssignNewCustomGraphics(Zombie zombie) var bodyPath = "Zombie/Naked_" + zombie.story.bodyType.ToString(); var color = zombie.isToxicSplasher ? "toxic" : GraphicToolbox.RandomSkinColorString(); - var bodyRequest = new GraphicRequest(typeof(VariableGraphic), bodyPath, ShaderDatabase.CutoutSkin, Vector2.one, Color.white, Color.white, null, renderPrecedence); + var bodyRequest = new GraphicRequest(typeof(VariableGraphic), bodyPath, ShaderDatabase.CutoutSkin, Vector2.one, Color.white, Color.white, null, renderPrecedence, new List()); zombie.customBodyGraphic = new VariableGraphic { bodyColor = color }; zombie.customBodyGraphic.Init(bodyRequest); var headShape = zombie.hasTankyHelmet == 1f ? "Wide" : headShapes[Rand.Range(0, 3)]; var headPath = "Zombie/" + zombie.gender + "_" + zombie.story.crownType + "_" + headShape; - var headRequest = new GraphicRequest(typeof(VariableGraphic), headPath, ShaderDatabase.CutoutSkin, Vector2.one, Color.white, Color.white, null, renderPrecedence); + var headRequest = new GraphicRequest(typeof(VariableGraphic), headPath, ShaderDatabase.CutoutSkin, Vector2.one, Color.white, Color.white, null, renderPrecedence, new List()); zombie.customHeadGraphic = new VariableGraphic { bodyColor = color }; zombie.customHeadGraphic.Init(headRequest); diff --git a/Source/ZombieRemover.cs b/Source/ZombieRemover.cs index 3cc8b978..43f373fd 100644 --- a/Source/ZombieRemover.cs +++ b/Source/ZombieRemover.cs @@ -18,7 +18,7 @@ public static void RemoveZombieland(string filename) // note: order is kind of important here - Find.BattleLog.RawEntries.RemoveAll(RemoveItem); + Find.BattleLog.Battles.RemoveAll(battle => Traverse.Create(battle).Field("concerns").GetValue>().Any(RemoveItem)); Find.World.components.RemoveAll(component => component.IsZombieType()); Current.Game.Maps.Do(CleanMap); Current.Game.Maps.Do(map => PawnsOfType(map).Do(RemovePawnRelatedStuff)); @@ -75,7 +75,7 @@ static void CleanMap(Map map) .Select(pile => pile?.settings?.filter).ToList() .Do(RemoveFromFilter); - map.slotGroupManager.AllGroups + map.haulDestinationManager.AllGroups .Select(slot => slot.Settings.filter) .Do(RemoveFromFilter); diff --git a/Source/ZombieStateHandler.cs b/Source/ZombieStateHandler.cs index 47f1ead8..6f5c9f67 100644 --- a/Source/ZombieStateHandler.cs +++ b/Source/ZombieStateHandler.cs @@ -443,7 +443,7 @@ public static void Wander(this JobDriver_Stumble driver, Zombie zombie, Pheromon { var moveTowardsCenter = false; - var hour = GenLocalDate.HourOfDay(Find.VisibleMap); + var hour = GenLocalDate.HourOfDay(Find.CurrentMap); if (hour < 12) hour += 24; if (hour > Constants.HOUR_START_OF_NIGHT && hour < Constants.HOUR_END_OF_NIGHT) moveTowardsCenter = true; @@ -684,18 +684,13 @@ static int EatDelay(this JobDriver_Stumble driver, Zombie zombie) if (driver.eatDelay == 0) { driver.eatDelay = Constants.EAT_DELAY_TICKS; - switch (zombie.story.bodyType) - { - case BodyType.Thin: - driver.eatDelay *= 3; - break; - case BodyType.Hulk: - driver.eatDelay /= 2; - break; - case BodyType.Fat: - driver.eatDelay /= 4; - break; - } + var bodyType = zombie.story.bodyType; + if (bodyType == BodyTypeDefOf.Thin) + driver.eatDelay *= 3; + else if (bodyType == BodyTypeDefOf.Hulk) + driver.eatDelay /= 2; + else if (bodyType == BodyTypeDefOf.Fat) + driver.eatDelay /= 4; } return driver.eatDelay; } diff --git a/Source/ZombieWanderer.cs b/Source/ZombieWanderer.cs index f8639dfc..90b1fd10 100644 --- a/Source/ZombieWanderer.cs +++ b/Source/ZombieWanderer.cs @@ -153,11 +153,12 @@ void ClearCells() IEnumerable GetValidAdjactedCellsInRandomOrder(Map map, IntVec3 basePos, bool ignoreBuildings) { - UnityEngine.Random.InitState(basePos.x + basePos.z * 1000); int[] rndices; int i; + var t = GenTicks.TicksAbs / GenDate.TicksPerHour; + var random = new Random(basePos.x + basePos.z * 1000 + t * 1000000); - rndices = randomOrders[UnityEngine.Random.Range(0, randomOrders.Length)]; + rndices = randomOrders[random.Next(0, 24)]; for (i = 0; i < 4; i++) { var cell = basePos + GenAdj.CardinalDirections[rndices[i]]; @@ -165,7 +166,7 @@ IEnumerable GetValidAdjactedCellsInRandomOrder(Map map, IntVec3 basePos yield return cell; } - rndices = randomOrders[UnityEngine.Random.Range(0, randomOrders.Length)]; + rndices = randomOrders[random.Next(0, 24)]; for (i = 0; i < 4; i++) { var cell = basePos + GenAdj.DiagonalDirections[rndices[i]]; diff --git a/Textures/BombVest/BombVest_Hulk_back.png b/Textures/BombVest/BombVest_Hulk_north.png similarity index 100% rename from Textures/BombVest/BombVest_Hulk_back.png rename to Textures/BombVest/BombVest_Hulk_north.png diff --git a/Textures/BombVest/BombVest_Hulk_front.png b/Textures/BombVest/BombVest_Hulk_south.png similarity index 100% rename from Textures/BombVest/BombVest_Hulk_front.png rename to Textures/BombVest/BombVest_Hulk_south.png diff --git a/Textures/BombVest/BombVest_Hulk_side.png b/Textures/BombVest/BombVest_Hulk_west.png similarity index 100% rename from Textures/BombVest/BombVest_Hulk_side.png rename to Textures/BombVest/BombVest_Hulk_west.png diff --git a/Textures/Parts.cvs b/Textures/Parts.cvs index 285c3298..bd0f2daf 100644 --- a/Textures/Parts.cvs +++ b/Textures/Parts.cvs @@ -11,54 +11,54 @@ 155,1666,170,45,ZombieButtonBackground 325,1666,60,45,PatreonIcon 385,1664,16,47,Stains/Chain -0,1536,128,128,Zombie/Male_Narrow_Wide_front -128,1536,128,128,Zombie/Female_Average_Normal_back -256,1536,128,128,Zombie/Male_Narrow_Wide_side -384,1536,128,128,Zombie/Naked_Fat_front -0,1408,128,128,Zombie/Naked_Fat_back -128,1408,128,128,Zombie/Male_Narrow_Wide_back -256,1408,128,128,Zombie/Male_Narrow_Normal_back -384,1408,128,128,Zombie/Male_Narrow_Pointy_side -0,1280,128,128,Zombie/Male_Narrow_Normal_front -128,1280,128,128,Zombie/Male_Narrow_Pointy_back -256,1280,128,128,Zombie/Male_Narrow_Pointy_front -384,1280,128,128,Zombie/Male_Narrow_Normal_side -0,1152,128,128,Zombie/Naked_Fat_side -128,1152,128,128,Zombie/Naked_Male_side -256,1152,128,128,Zombie/Naked_Female_back -384,1152,128,128,Zombie/Naked_Thin_back -0,1024,128,128,Zombie/Naked_Thin_side -128,1024,128,128,Zombie/Naked_Thin_front -256,1024,128,128,Zombie/Naked_Male_front -384,1024,128,128,Zombie/Naked_Female_front -0,896,128,128,Zombie/Naked_Male_back -128,896,128,128,Zombie/Naked_Female_side -256,896,128,128,Zombie/Naked_Hulk_front -384,896,128,128,Zombie/Naked_Hulk_side -0,768,128,128,Zombie/Naked_Hulk_back -128,768,128,128,Zombie/Male_Average_Wide_side -256,768,128,128,Zombie/Female_Average_Wide_side -384,768,128,128,Zombie/Male_Average_Wide_front -0,640,128,128,Zombie/Female_Narrow_Normal_back -128,640,128,128,Zombie/Female_Narrow_Normal_side -256,640,128,128,Zombie/Female_Narrow_Normal_front -384,640,128,128,Zombie/Female_Average_Wide_front -0,512,128,128,Zombie/Female_Average_Normal_front -128,512,128,128,Zombie/Female_Average_Wide_back -256,512,128,128,Zombie/Female_Average_Normal_side -384,512,128,128,Zombie/Female_Average_Pointy_front -0,384,128,128,Zombie/Female_Average_Pointy_side -128,384,128,128,Zombie/Female_Average_Pointy_back -256,384,128,128,Zombie/Female_Narrow_Pointy_back -384,384,128,128,Zombie/Male_Average_Pointy_back -0,256,128,128,Zombie/Female_Narrow_Pointy_front -128,256,128,128,Zombie/Male_Average_Pointy_front -256,256,128,128,Zombie/Male_Average_Wide_back -384,256,128,128,Zombie/Male_Average_Pointy_side -0,128,128,128,Zombie/Male_Average_Normal_side -128,128,128,128,Zombie/Female_Narrow_Pointy_side -256,128,128,128,Zombie/Male_Average_Normal_front -384,128,128,128,Zombie/Female_Narrow_Wide_back -0,0,128,128,Zombie/Female_Narrow_Wide_side -128,0,128,128,Zombie/Male_Average_Normal_back -256,0,128,128,Zombie/Female_Narrow_Wide_front +0,1536,128,128,Zombie/Male_Narrow_Wide_south +128,1536,128,128,Zombie/Female_Average_Normal_north +256,1536,128,128,Zombie/Male_Narrow_Wide_west +384,1536,128,128,Zombie/Naked_Fat_south +0,1408,128,128,Zombie/Naked_Fat_north +128,1408,128,128,Zombie/Male_Narrow_Wide_north +256,1408,128,128,Zombie/Male_Narrow_Normal_north +384,1408,128,128,Zombie/Male_Narrow_Pointy_west +0,1280,128,128,Zombie/Male_Narrow_Normal_south +128,1280,128,128,Zombie/Male_Narrow_Pointy_north +256,1280,128,128,Zombie/Male_Narrow_Pointy_south +384,1280,128,128,Zombie/Male_Narrow_Normal_west +0,1152,128,128,Zombie/Naked_Fat_west +128,1152,128,128,Zombie/Naked_Male_west +256,1152,128,128,Zombie/Naked_Female_north +384,1152,128,128,Zombie/Naked_Thin_north +0,1024,128,128,Zombie/Naked_Thin_west +128,1024,128,128,Zombie/Naked_Thin_south +256,1024,128,128,Zombie/Naked_Male_south +384,1024,128,128,Zombie/Naked_Female_south +0,896,128,128,Zombie/Naked_Male_north +128,896,128,128,Zombie/Naked_Female_west +256,896,128,128,Zombie/Naked_Hulk_south +384,896,128,128,Zombie/Naked_Hulk_west +0,768,128,128,Zombie/Naked_Hulk_north +128,768,128,128,Zombie/Male_Average_Wide_west +256,768,128,128,Zombie/Female_Average_Wide_west +384,768,128,128,Zombie/Male_Average_Wide_south +0,640,128,128,Zombie/Female_Narrow_Normal_north +128,640,128,128,Zombie/Female_Narrow_Normal_west +256,640,128,128,Zombie/Female_Narrow_Normal_south +384,640,128,128,Zombie/Female_Average_Wide_south +0,512,128,128,Zombie/Female_Average_Normal_south +128,512,128,128,Zombie/Female_Average_Wide_north +256,512,128,128,Zombie/Female_Average_Normal_west +384,512,128,128,Zombie/Female_Average_Pointy_south +0,384,128,128,Zombie/Female_Average_Pointy_west +128,384,128,128,Zombie/Female_Average_Pointy_north +256,384,128,128,Zombie/Female_Narrow_Pointy_north +384,384,128,128,Zombie/Male_Average_Pointy_north +0,256,128,128,Zombie/Female_Narrow_Pointy_south +128,256,128,128,Zombie/Male_Average_Pointy_south +256,256,128,128,Zombie/Male_Average_Wide_north +384,256,128,128,Zombie/Male_Average_Pointy_west +0,128,128,128,Zombie/Male_Average_Normal_west +128,128,128,128,Zombie/Female_Narrow_Pointy_west +256,128,128,128,Zombie/Male_Average_Normal_south +384,128,128,128,Zombie/Female_Narrow_Wide_north +0,0,128,128,Zombie/Female_Narrow_Wide_west +128,0,128,128,Zombie/Male_Average_Normal_north +256,0,128,128,Zombie/Female_Narrow_Wide_south diff --git a/Textures/TankyHelmet/TankyHelmet0_back.png b/Textures/TankyHelmet/TankyHelmet0_north.png similarity index 100% rename from Textures/TankyHelmet/TankyHelmet0_back.png rename to Textures/TankyHelmet/TankyHelmet0_north.png diff --git a/Textures/TankyHelmet/TankyHelmet0_front.png b/Textures/TankyHelmet/TankyHelmet0_south.png similarity index 100% rename from Textures/TankyHelmet/TankyHelmet0_front.png rename to Textures/TankyHelmet/TankyHelmet0_south.png diff --git a/Textures/TankyHelmet/TankyHelmet0_side.png b/Textures/TankyHelmet/TankyHelmet0_west.png similarity index 100% rename from Textures/TankyHelmet/TankyHelmet0_side.png rename to Textures/TankyHelmet/TankyHelmet0_west.png diff --git a/Textures/TankyHelmet/TankyHelmet1_back.png b/Textures/TankyHelmet/TankyHelmet1_north.png similarity index 100% rename from Textures/TankyHelmet/TankyHelmet1_back.png rename to Textures/TankyHelmet/TankyHelmet1_north.png diff --git a/Textures/TankyHelmet/TankyHelmet1_front.png b/Textures/TankyHelmet/TankyHelmet1_south.png similarity index 100% rename from Textures/TankyHelmet/TankyHelmet1_front.png rename to Textures/TankyHelmet/TankyHelmet1_south.png diff --git a/Textures/TankyHelmet/TankyHelmet1_side.png b/Textures/TankyHelmet/TankyHelmet1_west.png similarity index 100% rename from Textures/TankyHelmet/TankyHelmet1_side.png rename to Textures/TankyHelmet/TankyHelmet1_west.png diff --git a/Textures/TankyHelmet/TankyHelmet2_back.png b/Textures/TankyHelmet/TankyHelmet2_north.png similarity index 100% rename from Textures/TankyHelmet/TankyHelmet2_back.png rename to Textures/TankyHelmet/TankyHelmet2_north.png diff --git a/Textures/TankyHelmet/TankyHelmet2_front.png b/Textures/TankyHelmet/TankyHelmet2_south.png similarity index 100% rename from Textures/TankyHelmet/TankyHelmet2_front.png rename to Textures/TankyHelmet/TankyHelmet2_south.png diff --git a/Textures/TankyHelmet/TankyHelmet2_side.png b/Textures/TankyHelmet/TankyHelmet2_west.png similarity index 100% rename from Textures/TankyHelmet/TankyHelmet2_side.png rename to Textures/TankyHelmet/TankyHelmet2_west.png diff --git a/Textures/TankyHelmet/TankyHelmet3_back.png b/Textures/TankyHelmet/TankyHelmet3_north.png similarity index 100% rename from Textures/TankyHelmet/TankyHelmet3_back.png rename to Textures/TankyHelmet/TankyHelmet3_north.png diff --git a/Textures/TankyHelmet/TankyHelmet3_front.png b/Textures/TankyHelmet/TankyHelmet3_south.png similarity index 100% rename from Textures/TankyHelmet/TankyHelmet3_front.png rename to Textures/TankyHelmet/TankyHelmet3_south.png diff --git a/Textures/TankyHelmet/TankyHelmet3_side.png b/Textures/TankyHelmet/TankyHelmet3_west.png similarity index 100% rename from Textures/TankyHelmet/TankyHelmet3_side.png rename to Textures/TankyHelmet/TankyHelmet3_west.png diff --git a/Textures/TankyHelmet/TankyHelmet4_back.png b/Textures/TankyHelmet/TankyHelmet4_north.png similarity index 100% rename from Textures/TankyHelmet/TankyHelmet4_back.png rename to Textures/TankyHelmet/TankyHelmet4_north.png diff --git a/Textures/TankyHelmet/TankyHelmet4_front.png b/Textures/TankyHelmet/TankyHelmet4_south.png similarity index 100% rename from Textures/TankyHelmet/TankyHelmet4_front.png rename to Textures/TankyHelmet/TankyHelmet4_south.png diff --git a/Textures/TankyHelmet/TankyHelmet4_side.png b/Textures/TankyHelmet/TankyHelmet4_west.png similarity index 100% rename from Textures/TankyHelmet/TankyHelmet4_side.png rename to Textures/TankyHelmet/TankyHelmet4_west.png diff --git a/Textures/TankyShield/TankyShield0_front.png b/Textures/TankyShield/TankyShield0_south.png similarity index 100% rename from Textures/TankyShield/TankyShield0_front.png rename to Textures/TankyShield/TankyShield0_south.png diff --git a/Textures/TankyShield/TankyShield0_side.png b/Textures/TankyShield/TankyShield0_west.png similarity index 100% rename from Textures/TankyShield/TankyShield0_side.png rename to Textures/TankyShield/TankyShield0_west.png diff --git a/Textures/TankyShield/TankyShield1_front.png b/Textures/TankyShield/TankyShield1_south.png similarity index 100% rename from Textures/TankyShield/TankyShield1_front.png rename to Textures/TankyShield/TankyShield1_south.png diff --git a/Textures/TankyShield/TankyShield1_side.png b/Textures/TankyShield/TankyShield1_west.png similarity index 100% rename from Textures/TankyShield/TankyShield1_side.png rename to Textures/TankyShield/TankyShield1_west.png diff --git a/Textures/TankyShield/TankyShield2_front.png b/Textures/TankyShield/TankyShield2_south.png similarity index 100% rename from Textures/TankyShield/TankyShield2_front.png rename to Textures/TankyShield/TankyShield2_south.png diff --git a/Textures/TankyShield/TankyShield2_side.png b/Textures/TankyShield/TankyShield2_west.png similarity index 100% rename from Textures/TankyShield/TankyShield2_side.png rename to Textures/TankyShield/TankyShield2_west.png diff --git a/Textures/TankyShield/TankyShield3_front.png b/Textures/TankyShield/TankyShield3_south.png similarity index 100% rename from Textures/TankyShield/TankyShield3_front.png rename to Textures/TankyShield/TankyShield3_south.png diff --git a/Textures/TankyShield/TankyShield3_side.png b/Textures/TankyShield/TankyShield3_west.png similarity index 100% rename from Textures/TankyShield/TankyShield3_side.png rename to Textures/TankyShield/TankyShield3_west.png diff --git a/Textures/TankyShield/TankyShield4_front.png b/Textures/TankyShield/TankyShield4_south.png similarity index 100% rename from Textures/TankyShield/TankyShield4_front.png rename to Textures/TankyShield/TankyShield4_south.png diff --git a/Textures/TankyShield/TankyShield4_side.png b/Textures/TankyShield/TankyShield4_west.png similarity index 100% rename from Textures/TankyShield/TankyShield4_side.png rename to Textures/TankyShield/TankyShield4_west.png diff --git a/Textures/TankySuit/TankySuit0_back.png b/Textures/TankySuit/TankySuit0_north.png similarity index 100% rename from Textures/TankySuit/TankySuit0_back.png rename to Textures/TankySuit/TankySuit0_north.png diff --git a/Textures/TankySuit/TankySuit0_front.png b/Textures/TankySuit/TankySuit0_south.png similarity index 100% rename from Textures/TankySuit/TankySuit0_front.png rename to Textures/TankySuit/TankySuit0_south.png diff --git a/Textures/TankySuit/TankySuit0_side.png b/Textures/TankySuit/TankySuit0_west.png similarity index 100% rename from Textures/TankySuit/TankySuit0_side.png rename to Textures/TankySuit/TankySuit0_west.png diff --git a/Textures/TankySuit/TankySuit1_back.png b/Textures/TankySuit/TankySuit1_north.png similarity index 100% rename from Textures/TankySuit/TankySuit1_back.png rename to Textures/TankySuit/TankySuit1_north.png diff --git a/Textures/TankySuit/TankySuit1_front.png b/Textures/TankySuit/TankySuit1_south.png similarity index 100% rename from Textures/TankySuit/TankySuit1_front.png rename to Textures/TankySuit/TankySuit1_south.png diff --git a/Textures/TankySuit/TankySuit1_side.png b/Textures/TankySuit/TankySuit1_west.png similarity index 100% rename from Textures/TankySuit/TankySuit1_side.png rename to Textures/TankySuit/TankySuit1_west.png diff --git a/Textures/TankySuit/TankySuit2_back.png b/Textures/TankySuit/TankySuit2_north.png similarity index 100% rename from Textures/TankySuit/TankySuit2_back.png rename to Textures/TankySuit/TankySuit2_north.png diff --git a/Textures/TankySuit/TankySuit2_front.png b/Textures/TankySuit/TankySuit2_south.png similarity index 100% rename from Textures/TankySuit/TankySuit2_front.png rename to Textures/TankySuit/TankySuit2_south.png diff --git a/Textures/TankySuit/TankySuit2_side.png b/Textures/TankySuit/TankySuit2_west.png similarity index 100% rename from Textures/TankySuit/TankySuit2_side.png rename to Textures/TankySuit/TankySuit2_west.png diff --git a/Textures/TankySuit/TankySuit3_back.png b/Textures/TankySuit/TankySuit3_north.png similarity index 100% rename from Textures/TankySuit/TankySuit3_back.png rename to Textures/TankySuit/TankySuit3_north.png diff --git a/Textures/TankySuit/TankySuit3_front.png b/Textures/TankySuit/TankySuit3_south.png similarity index 100% rename from Textures/TankySuit/TankySuit3_front.png rename to Textures/TankySuit/TankySuit3_south.png diff --git a/Textures/TankySuit/TankySuit3_side.png b/Textures/TankySuit/TankySuit3_west.png similarity index 100% rename from Textures/TankySuit/TankySuit3_side.png rename to Textures/TankySuit/TankySuit3_west.png diff --git a/Textures/TankySuit/TankySuit4_back.png b/Textures/TankySuit/TankySuit4_north.png similarity index 100% rename from Textures/TankySuit/TankySuit4_back.png rename to Textures/TankySuit/TankySuit4_north.png diff --git a/Textures/TankySuit/TankySuit4_front.png b/Textures/TankySuit/TankySuit4_south.png similarity index 100% rename from Textures/TankySuit/TankySuit4_front.png rename to Textures/TankySuit/TankySuit4_south.png diff --git a/Textures/TankySuit/TankySuit4_side.png b/Textures/TankySuit/TankySuit4_west.png similarity index 100% rename from Textures/TankySuit/TankySuit4_side.png rename to Textures/TankySuit/TankySuit4_west.png