105 lines
5.1 KiB
C#
105 lines
5.1 KiB
C#
using System.Collections.Generic;
|
|
|
|
namespace Harmony.AIDirectorChunkEventComponentPatches
|
|
{
|
|
[HarmonyPatch(typeof(AIDirectorChunkEventComponent))]
|
|
[HarmonyPatch("SpawnScouts")]
|
|
public class SpawnScoutsPatch
|
|
{
|
|
public static bool Prefix(AIDirectorChunkEventComponent __instance, Vector3 targetPos)
|
|
{
|
|
if (!RebirthVariables.stopWHSpawns && RebirthVariables.isWHSpawned)
|
|
{
|
|
Log.Out("AIDirectorChunkEventComponentPatches-SpawnScouts CAN'T SPAWN SCREAMERS DURING AN OUTBREAK");
|
|
}
|
|
else
|
|
{
|
|
Vector3 startPos;
|
|
if (__instance.FindScoutStartPos(targetPos, out startPos))
|
|
{
|
|
EntityPlayer closestPlayer = __instance.Director.World.GetClosestPlayer(targetPos, 120f, false);
|
|
if (!(bool)closestPlayer)
|
|
return false;
|
|
int num = GameStageDefinition.CalcGameStageAround(closestPlayer);
|
|
string _esClassname = "Scouts";
|
|
//Log.Out("AIDirectorChunkEventComponentPatches-SpawnScouts num: " + num);
|
|
if (num >= RebirthVariables.spawnThresholdFeral)
|
|
_esClassname = "ScoutsFeral";
|
|
if (num >= RebirthVariables.spawnThresholdRadiated)
|
|
_esClassname = "ScoutsRadiated";
|
|
if (num >= RebirthVariables.spawnThresholdTainted)
|
|
_esClassname = "ScoutsTainted";
|
|
|
|
__instance.scoutSpawnList.Add(new AIScoutHordeSpawner(new EntitySpawner(_esClassname, Vector3i.zero, Vector3i.zero, 0), startPos, targetPos, false));
|
|
AIDirector.LogAI("Spawning {0} at {1}, to {2}", (object)_esClassname, (object)startPos.ToCultureInvariantString(), (object)targetPos.ToCultureInvariantString());
|
|
}
|
|
else
|
|
AIDirector.LogAI("Scout spawning failed");
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|
|
|
|
[HarmonyPatch(typeof(AIDirectorChunkEventComponent))]
|
|
[HarmonyPatch("CheckToSpawn")]
|
|
[HarmonyPatch(new[] { typeof(AIDirectorChunkData) })]
|
|
public class CheckToSpawnPatch
|
|
{
|
|
public static bool Prefix(AIDirectorChunkEventComponent __instance, AIDirectorChunkData _chunkData)
|
|
{
|
|
//Log.Out("AIDirectorChunkEventComponentPatches-CheckToSpawn START");
|
|
|
|
if (!GameStats.GetBool(EnumGameStats.ZombieHordeMeter) || !GameStats.GetBool(EnumGameStats.IsSpawnEnemies) || (double)_chunkData.ActivityLevel < 100.0)
|
|
return false;
|
|
AIDirectorChunkEvent bestEventAndReset = _chunkData.FindBestEventAndReset();
|
|
if (bestEventAndReset != null)
|
|
{
|
|
int searchDistance = 150;
|
|
|
|
List<Entity> entitiesInBounds = __instance.Director.World.GetEntitiesInBounds(typeof(EntityZombieScreamerRebirth), BoundsUtils.BoundsForMinMax(bestEventAndReset.Position.x - searchDistance, bestEventAndReset.Position.y - 50, bestEventAndReset.Position.z - searchDistance, bestEventAndReset.Position.x + searchDistance, bestEventAndReset.Position.y + 50, bestEventAndReset.Position.z + searchDistance), new List<Entity>());
|
|
|
|
//Log.Out("AIDirectorChunkEventComponentPatches-CheckToSpawn NUM Screamers: " + entitiesInBounds.Count);
|
|
//Log.Out("AIDirectorChunkEventComponentPatches-CheckToSpawn RebirthVariables.customScreamerMax: " + RebirthVariables.customScreamerMax);
|
|
|
|
int numActiveScreamers = 0;
|
|
|
|
for (int index = 0; index < entitiesInBounds.Count; ++index)
|
|
{
|
|
EntityZombieScreamerRebirth screamer = (EntityZombieScreamerRebirth)entitiesInBounds[index];
|
|
|
|
if (!screamer.IsDead())
|
|
{
|
|
numActiveScreamers++;
|
|
}
|
|
}
|
|
|
|
if (numActiveScreamers < RebirthVariables.customScreamerMax)
|
|
{
|
|
//Log.Out("AIDirectorChunkEventComponentPatches-CheckToSpawn RebirthVariables.stopWHSpawns: " + RebirthVariables.stopWHSpawns);
|
|
//Log.Out("AIDirectorChunkEventComponentPatches-CheckToSpawn RebirthVariables.isWHSpawned: " + RebirthVariables.isWHSpawned);
|
|
|
|
if (!RebirthVariables.stopWHSpawns && RebirthVariables.isWHSpawned)
|
|
{
|
|
Log.Out("AIDirectorChunkEventComponentPatches-CheckToSpawn CAN'T SPAWN SCREAMERS DURING AN OUTBREAK");
|
|
}
|
|
else
|
|
{
|
|
//Log.Out("AIDirectorChunkEventComponentPatches-CheckToSpawn SPAWNING SCREAMERS");
|
|
__instance.StartCooldownOnNeighbors(bestEventAndReset.Position);
|
|
__instance.SpawnScouts(bestEventAndReset.Position.ToVector3());
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//Log.Out("AIDirectorChunkEventComponentPatches-CheckToSpawn TOO MANY SCREAMERS");
|
|
}
|
|
}
|
|
else
|
|
AIDirector.LogAI("Chunk event not found!");
|
|
|
|
return false;
|
|
}
|
|
}
|
|
}
|