Upload from upload_mods.ps1
This commit is contained in:
144
Harmony/Harmony_ConsoleCmdKillAll.cs
Normal file
144
Harmony/Harmony_ConsoleCmdKillAll.cs
Normal file
@@ -0,0 +1,144 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Harmony.ConsoleCmdKillAllPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(ConsoleCmdKillAll))]
|
||||
[HarmonyPatch("Execute")]
|
||||
public class ExecutePatch
|
||||
{
|
||||
public static void Kill(Entity entity)
|
||||
{
|
||||
entity.DamageEntity(new DamageSource(EnumDamageSource.Internal, EnumDamageTypes.Suicide), 99999, false);
|
||||
SingletonMonoBehaviour<SdtdConsole>.Instance.Output("Gave " + 99999.ToString() + " damage to entity " + entity.GetDebugName());
|
||||
}
|
||||
|
||||
public static bool Prefix(ConsoleCmdKillAll __instance, List<string> _params, CommandSenderInfo _senderInfo)
|
||||
{
|
||||
bool flag1 = _params.Count > 0 && RebirthUtilities.ConvertStringToInt(_params[0]) != -1;
|
||||
|
||||
int distanceParameter = -1;
|
||||
if (flag1)
|
||||
{
|
||||
distanceParameter = RebirthUtilities.ConvertStringToInt(_params[0]);
|
||||
}
|
||||
|
||||
//Log.Out("ConsoleCmdKillAllPatches-Execute distanceParameter: " + distanceParameter);
|
||||
|
||||
bool flag2 = _params.Count > 0 && _params[0].EqualsCaseInsensitive("all");
|
||||
bool flag3 = _params.Count > 0 && _params[0].EqualsCaseInsensitive("vehicles");
|
||||
bool flag4 = _params.Count > 0 && _params[0].EqualsCaseInsensitive("turrets");
|
||||
bool flag5 = _params.Count > 0 && _params[0].EqualsCaseInsensitive("whiteriver");
|
||||
bool flag6 = _params.Count > 0 && _params[0].EqualsCaseInsensitive("bandits");
|
||||
bool flag7 = _params.Count > 0 && _params[0].EqualsCaseInsensitive("loot");
|
||||
|
||||
//Log.Out("ConsoleCmdKillAllPatches-Execute flag1: " + flag1);
|
||||
//Log.Out("ConsoleCmdKillAllPatches-Execute flag2: " + flag2);
|
||||
//Log.Out("ConsoleCmdKillAllPatches-Execute flag3: " + flag3);
|
||||
//Log.Out("ConsoleCmdKillAllPatches-Execute flag4: " + flag4);
|
||||
//Log.Out("ConsoleCmdKillAllPatches-Execute flag5: " + flag5);
|
||||
//Log.Out("ConsoleCmdKillAllPatches-Execute flag6: " + flag6);
|
||||
//Log.Out("ConsoleCmdKillAllPatches-Execute flag7: " + flag7);
|
||||
|
||||
List<Entity> entityList = new List<Entity>((IEnumerable<Entity>)GameManager.Instance.World.Entities.list);
|
||||
for (int index = 0; index < entityList.Count; ++index)
|
||||
{
|
||||
Entity entity = entityList[index];
|
||||
if (entity != null && !(entity is EntityPlayer))
|
||||
{
|
||||
//Log.Out("ConsoleCmdKillAllPatches-Execute entity: " + entity.EntityClass.entityClassName);
|
||||
if (entity is EntityAlive && !flag7)
|
||||
{
|
||||
//Log.Out("ConsoleCmdKillAllPatches-Execute IS ENTITYALIVE");
|
||||
switch (entity)
|
||||
{
|
||||
case EntityVehicle _:
|
||||
if (flag3)
|
||||
{
|
||||
//Log.Out("ConsoleCmdKillAllPatches-Execute IS VEHICLE");
|
||||
Kill(entity);
|
||||
}
|
||||
break;
|
||||
case EntityTurret _:
|
||||
if (flag4)
|
||||
{
|
||||
//Log.Out("ConsoleCmdKillAllPatches-Execute IS TURRET");
|
||||
Kill(entity);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
//Log.Out("ConsoleCmdKillAllPatches-Execute DEFAULT");
|
||||
if (EntityClass.list[entity.entityClass].bIsEnemyEntity)
|
||||
{
|
||||
//Log.Out("ConsoleCmdKillAllPatches-Execute IS ENEMY");
|
||||
if (flag1)
|
||||
{
|
||||
int playerId = GameManager.Instance.World.GetPrimaryPlayerId();
|
||||
if (_senderInfo.RemoteClientInfo != null)
|
||||
playerId = _senderInfo.RemoteClientInfo.entityId;
|
||||
//Log.Out("ConsoleCmdKillAllPatches-Execute playerId: " + playerId);
|
||||
if (playerId == -1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
Vector3i playerPosition = new Vector3i(GameManager.Instance.World.Players.list.FirstOrDefault<EntityPlayer>((Func<EntityPlayer, bool>)(d => d.entityId == playerId)).GetPosition());
|
||||
|
||||
//Log.Out("ConsoleCmdKillAllPatches-Execute playerPosition: " + playerPosition);
|
||||
//Log.Out("ConsoleCmdKillAllPatches-Execute entity.position: " + entity.position);
|
||||
|
||||
float distance = Vector3.Distance(entity.position, playerPosition);
|
||||
|
||||
//Log.Out("ConsoleCmdKillAllPatches-Execute distance: " + distance);
|
||||
|
||||
if (distance <= distanceParameter)
|
||||
{
|
||||
Kill(entity);
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
Kill(entity);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("ConsoleCmdKillAllPatches-Execute 1");
|
||||
if (flag2)
|
||||
{
|
||||
//Log.Out("ConsoleCmdKillAllPatches-Execute 2");
|
||||
Kill(entity);
|
||||
}
|
||||
|
||||
string faction = "";
|
||||
|
||||
if (entity.EntityClass.Properties.Values.TryGetValue("Faction", out faction))
|
||||
{
|
||||
//Log.Out("ConsoleCmdKillAllPatches-Execute 3");
|
||||
if (flag5 && faction.ToLower() == "whiteriver")
|
||||
{
|
||||
//Log.Out("ConsoleCmdKillAllPatches-Execute 4");
|
||||
Kill(entity);
|
||||
}
|
||||
else if (flag6 && faction.ToLower() == "bandits")
|
||||
{
|
||||
//Log.Out("ConsoleCmdKillAllPatches-Execute 5");
|
||||
Kill(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (entity is EntityLootContainer && flag7 && !(entity is EntityAlive))
|
||||
{
|
||||
//Log.Out("ConsoleCmdKillAllPatches-Execute 6");
|
||||
Kill(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user