diff --git a/1.3/Assemblies/ZombieLand.dll b/1.3/Assemblies/ZombieLand.dll
index 332ab177..c4dff28a 100644
Binary files a/1.3/Assemblies/ZombieLand.dll and b/1.3/Assemblies/ZombieLand.dll differ
diff --git a/About/About.xml b/About/About.xml
index cb546fb0..fc39f352 100644
--- a/About/About.xml
+++ b/About/About.xml
@@ -16,6 +16,9 @@
https://github.com/pardeike/HarmonyRimWorld/releases/latest
+
+ betterscenes.rimconnect
+
ceteam.combatextended
diff --git a/About/Manifest.xml b/About/Manifest.xml
index a3d0c844..798761db 100644
--- a/About/Manifest.xml
+++ b/About/Manifest.xml
@@ -1,7 +1,7 @@
net.pardeike.rimworld.mod.zombieland
- 2.3.2.0
+ 2.3.3.0
1.0.0
1.1.0
@@ -13,8 +13,10 @@
+ betterscenes.rimconnect
+ ceteam.combatextended
https://raw.githubusercontent.com/pardeike/Zombieland/latest/About/Manifest.xml
https://github.com/pardeike/Zombieland/releases/latest
diff --git a/Source/Dialog_ZombieDebugActionMenu.cs b/Source/Dialog_ZombieDebugActionMenu.cs
index c140037d..31b65df7 100644
--- a/Source/Dialog_ZombieDebugActionMenu.cs
+++ b/Source/Dialog_ZombieDebugActionMenu.cs
@@ -89,7 +89,7 @@ public override void DoListingItems()
{
base.DebugToolMap($"Trigger: Zombie incident ({size})", delegate
{
- var success = ZombiesRising.TryExecute(map, size, IntVec3.Invalid);
+ var success = ZombiesRising.TryExecute(map, size, IntVec3.Invalid, false, false);
if (success == false)
Log.Error("Incident creation failed. Most likely no valid spawn point found.");
}, highlightedIndex == i++);
@@ -97,19 +97,19 @@ public override void DoListingItems()
}
base.DebugToolMap("Spawn: Zombie incident (4)", delegate
{
- _ = ZombiesRising.TryExecute(map, 4, UI.MouseCell(), true);
+ _ = ZombiesRising.TryExecute(map, 4, UI.MouseCell(), false, true);
}, highlightedIndex == i++);
base.DebugToolMap("Spawn: Zombie incident (25)", delegate
{
- _ = ZombiesRising.TryExecute(map, 25, UI.MouseCell(), true);
+ _ = ZombiesRising.TryExecute(map, 25, UI.MouseCell(), false, true);
}, highlightedIndex == i++);
base.DebugToolMap("Spawn: Zombie incident (100)", delegate
{
- _ = ZombiesRising.TryExecute(map, 100, UI.MouseCell(), true);
+ _ = ZombiesRising.TryExecute(map, 100, UI.MouseCell(), false, true);
}, highlightedIndex == i++);
base.DebugToolMap("Spawn: Zombie incident (200)", delegate
{
- _ = ZombiesRising.TryExecute(map, 200, UI.MouseCell(), true);
+ _ = ZombiesRising.TryExecute(map, 200, UI.MouseCell(), false, true);
}, highlightedIndex == i++);
base.DebugToolMap("Convert: Make Zombie", delegate
{
diff --git a/Source/Patches.cs b/Source/Patches.cs
index 25b9ad68..79fb98de 100644
--- a/Source/Patches.cs
+++ b/Source/Patches.cs
@@ -2121,7 +2121,7 @@ static bool Prefix(ref bool __result, IncidentParms parms)
var oldMode = ZombieSettings.Values.spawnHowType;
ZombieSettings.Values.spawnHowType = parms.raidArrivalMode.walkIn ? SpawnHowType.FromTheEdges : SpawnHowType.AllOverTheMap;
- _ = ZombiesRising.TryExecute(Find.CurrentMap, Mathf.FloorToInt(parms.points), parms.spawnCenter);
+ _ = ZombiesRising.TryExecute(Find.CurrentMap, Mathf.FloorToInt(parms.points), parms.spawnCenter, false, false);
ZombieSettings.Values.spawnHowType = oldMode;
__result = false;
return false;
diff --git a/Source/RimConnectSupport.cs b/Source/RimConnectSupport.cs
index 01a234f3..4eca60b0 100644
--- a/Source/RimConnectSupport.cs
+++ b/Source/RimConnectSupport.cs
@@ -1,229 +1,228 @@
using HarmonyLib;
+using RimWorld;
using System;
using System.Collections;
using System.Collections.Generic;
-using System.IO;
+using System.Linq;
using System.Reflection;
-using System.Security.Cryptography;
-using System.Text;
-using System.Xml;
+using System.Reflection.Emit;
+using UnityEngine;
using Verse;
namespace ZombieLand
{
- [HarmonyPatch]
- static class RimConnectAPI_PostValidCommands_Patch
+ [StaticConstructorOnStartup]
+ public class RimConnectSupport
{
- static readonly string configDefault = @"
-
-
- Zombies (albino)
- 20
-
-
- Zombies (dark slimer)
- 15
-
-
- Zombies (electrifier)
- 10
-
-
- Zombies (miner)
- 5
-
-
- Zombies (normal)
- 2
-
-
- Zombies (random)
- 25
-
-
- Zombies (bomber)
- 20
-
-
- Zombies (tanky)
- 20
-
-
- Zombies (toxic)
- 20
-
- ".Replace('\'', '"');
-
- static bool Prepare()
- {
- return TargetMethod() != null;
- }
-
- static MethodBase TargetMethod()
- {
- var tRimConnectAPI = AccessTools.TypeByName("RimConnection.RimConnectAPI");
- if (tRimConnectAPI == null) return null;
- return AccessTools.Method(tRimConnectAPI, "PostValidCommands");
- }
+ static readonly Dictionary> actions = new Dictionary>();
- static void Prefix(object commandList)
+ static RimConnectSupport()
{
- var list = Traverse.Create(commandList).Property("validCommands").GetValue() as IList;
- var path = $"{GenFilePaths.ConfigFolderPath}{Path.DirectorySeparatorChar}ZombieLand-RimConnect.xml";
- if (File.Exists(path) == false)
- File.WriteAllText(path, configDefault);
-
- var contents = File.ReadAllText(path);
- var xmlReaderSettings = new XmlReaderSettings { IgnoreComments = true, IgnoreWhitespace = true, CheckCharacters = false };
- using var stringReader = new StringReader(contents);
- using XmlReader xmlReader = XmlReader.Create(stringReader, xmlReaderSettings);
- var xmlDoc = new XmlDocument();
- xmlDoc.Load(xmlReader);
- foreach (XmlNode command in xmlDoc.DocumentElement.ChildNodes)
- {
- if (Enum.TryParse(command.Attributes["type"].Value, out var confType))
- {
- var confName = "";
- var confCosts = -1;
- for (var i = 0; i < command.ChildNodes.Count; i++)
- {
- var name = command.ChildNodes[i].Name;
- var value = command.ChildNodes[i].InnerText;
- switch (name)
- {
- case "name":
- confName = value;
- break;
- case "costs":
- confCosts = int.Parse(value);
- break;
- }
- }
- if (confCosts > 0 && confName != "")
- RimConnectSupport.AddCommand(list, confName, $"Creates {confName}", confCosts, (Map map, int amount, string user) =>
- {
- var success = ZombiesRising.TryExecute(map, amount, IntVec3.Invalid, true, confType);
- });
- }
- }
+ var tActionList = AccessTools.TypeByName("RimConnection.ActionList");
+ if (tActionList == null) return;
+
+ var tAction = AccessTools.TypeByName("RimConnection.Action");
+ if (tAction == null) return;
+ var mExecute = AccessTools.Method(tAction, "Execute");
+ if (mExecute == null) return;
+ var mBadEventNotification = AccessTools.Method("RimConnection.AlertManager:BadEventNotification", new[] { typeof(string), typeof(IntVec3) });
+ if (mBadEventNotification == null) return;
+
+ var harmony = new Harmony("net.pardeike.zombieland.rimconnect");
+ var postfix = new HarmonyMethod(AccessTools.Method(typeof(RimConnectSupport), nameof(Postfix)));
+ var mGenerateActionList = AccessTools.Method(tActionList, "GenerateActionList");
+ _ = harmony.Patch(mGenerateActionList, postfix: postfix);
}
- }
- [HarmonyPatch]
- static class RimConnectAPI_GetCommands_Patch
- {
- static bool Prepare()
+ static void Postfix(ref IList __result)
{
- return TargetMethod() != null;
+ var cat = "Zombies";
+ _ = __result.Add(CreateActionClass("RandomZombieAction", "Random Zombie Event", "Creates some normal zombies", cat, (amount, boughtBy) => SpawnZombies(amount, boughtBy, ZombieType.Random)));
+ _ = __result.Add(CreateActionClass("SuicideZombieAction", "Suicide Zombie Event", "Creates some suicide bomber zombies", cat, (amount, boughtBy) => SpawnZombies(amount, boughtBy, ZombieType.SuicideBomber)));
+ _ = __result.Add(CreateActionClass("ToxicZombieAction", "Toxic Zombie Event", "Creates some toxic goo zombies", cat, (amount, boughtBy) => SpawnZombies(amount, boughtBy, ZombieType.ToxicSplasher)));
+ _ = __result.Add(CreateActionClass("TankZombieAction", "Tank Zombie Event", "Creates some heavy tank zombies", cat, (amount, boughtBy) => SpawnZombies(amount, boughtBy, ZombieType.TankyOperator)));
+ _ = __result.Add(CreateActionClass("MinerZombieAction", "Miner Zombie Event", "Creates some mining zombies", cat, (amount, boughtBy) => SpawnZombies(amount, boughtBy, ZombieType.Miner)));
+ _ = __result.Add(CreateActionClass("ElectricZombieAction", "Electric Zombie Event", "Creates some electrical zombies", cat, (amount, boughtBy) => SpawnZombies(amount, boughtBy, ZombieType.Electrifier)));
+ _ = __result.Add(CreateActionClass("AlbinoZombieAction", "Albino Zombie Event", "Creates some albino zombies", cat, (amount, boughtBy) => SpawnZombies(amount, boughtBy, ZombieType.Albino)));
+ _ = __result.Add(CreateActionClass("DarkZombieAction", "Dark Zombie Event", "Creates some dark slimer zombies", cat, (amount, boughtBy) => SpawnZombies(amount, boughtBy, ZombieType.DarkSlimer)));
+ _ = __result.Add(CreateActionClass("NormalZombieAction", "Normal Zombie Event", "Creates some normal zombies", cat, (amount, boughtBy) => SpawnZombies(amount, boughtBy, ZombieType.Normal)));
+ _ = __result.Add(CreateActionClass("KillAllZombies", "Kill All Zombies", "Instantly kills all zombies on the map", cat, (amount, boughtBy) => KillAllZombies(boughtBy)));
+ _ = __result.Add(CreateActionClass("AllZombiesRage", "Zombies Rage Event", "Makes all zombies rage", cat, (amount, boughtBy) => AllZombiesRage(boughtBy)));
+ _ = __result.Add(CreateActionClass("SuperZombieDropRaid", "Super Zombie Drop", "Creates a drop raid with super zombies", cat, (amount, boughtBy) => SuperZombieDropRaid(amount, boughtBy)));
}
- static MethodBase TargetMethod()
+ public static (string, IntVec3) SpawnZombies(int amount, string boughtBy, ZombieType type)
{
- var tRimConnectAPI = AccessTools.TypeByName("RimConnection.RimConnectAPI");
- if (tRimConnectAPI == null) return null;
- return AccessTools.Method(tRimConnectAPI, "GetCommands");
+ var map = Find.CurrentMap;
+ if (map == null) return (null, IntVec3.Invalid);
+ var tickManager = map.GetComponent();
+ if (tickManager == null) return (null, IntVec3.Invalid);
+ var available = Mathf.Max(0, ZombieSettings.Values.maximumNumberOfZombies - tickManager.ZombieCount());
+ amount = Mathf.Min(available, amount);
+ if (amount == 0) return (null, IntVec3.Invalid);
+
+ var cellValidator = Tools.ZombieSpawnLocator(map, true);
+ var spot = ZombiesRising.GetValidSpot(map, IntVec3.Invalid, cellValidator);
+ tickManager.rimConnectActions.Enqueue(map => ZombiesRising.TryExecute(map, amount, spot, false, true, type));
+ return ($"{boughtBy} created an event with {amount} {type.ToString().ToLower()} zombies", spot);
}
- static void Postfix(IList __result)
+ public static (string, IntVec3) KillAllZombies(string boughtBy)
{
- var zlObj = new List