using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using Bloodstone.API;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using ProjectM;
using ProjectM.Network;
using ProjectM.Physics;
using ProjectM.Scripting;
using SemanticVersioning;
using SpiderKiller.VCFCompat;
using SpiderKiller.extensions;
using Stunlock.Core;
using Stunlock.Network;
using Unity.Collections;
using Unity.Entities;
using Unity.Mathematics;
using Unity.Transforms;
using UnityEngine;
using VampireCommandFramework;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("SpiderKiller")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Mod that kills spiders in a range around you and your friends. So you don't have to fight those pesky things")]
[assembly: AssemblyFileVersion("1.5.2.0")]
[assembly: AssemblyInformationalVersion("1.5.2+2.Branch.main.Sha.62bb8fcf39ee2ebe62410e48ec8f8fdc72e85b10.3853f99a2faa27c79dc4524420766f1c1ab7d8f8")]
[assembly: AssemblyProduct("SpiderKiller")]
[assembly: AssemblyTitle("SpiderKiller")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.5.2.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace SpiderKiller
{
public class GiveDrop
{
private static ManualLogSource _log => Plugin.LogInstance;
public static bool AddItemToInventory(Entity recipient, PrefabGUID guid, int amount)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
try
{
ServerGameManager serverGameManager = VWorld.Server.GetExistingSystemManaged<ServerScriptMapper>()._ServerGameManager;
AddItemResponse val = ((ServerGameManager)(ref serverGameManager)).TryAddInventoryItem(recipient, guid, amount);
return ((AddItemResponse)(ref val)).Success;
}
catch (Exception ex)
{
_log.LogError((object)ex);
}
return false;
}
}
[BepInPlugin("SpiderKiller", "SpiderKiller", "1.5.2")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[Reloadable]
public class Plugin : BasePlugin, IRunOnInitialized
{
private Harmony _harmony;
public static ManualLogSource LogInstance { get; private set; }
public override void Load()
{
LogInstance = ((BasePlugin)this).Log;
Settings.Initialize(((BasePlugin)this).Config);
if (!VWorld.IsServer)
{
((BasePlugin)this).Log.LogWarning((object)"This plugin is a server-only plugin!");
}
}
public void OnGameInitialized()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Expected O, but got Unknown
if (!VWorld.IsClient)
{
_harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
ManualLogSource log = ((BasePlugin)this).Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(18, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("SpiderKiller");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
}
log.LogInfo(val);
((BasePlugin)this).Log.LogInfo((object)"Looking if VCF is installed:");
if (Commands.Enabled)
{
Commands.Register();
}
else
{
((BasePlugin)this).Log.LogInfo((object)"This mod has extra admin commands. Install VampireCommandFramework to use them.");
}
}
}
public override bool Unload()
{
Harmony harmony = _harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
return true;
}
}
public static class Settings
{
public static ConfigEntry<bool> ENABLE_CULLING { get; private set; }
public static ConfigEntry<bool> ENABLE_EXTRA_CULL_REWARD { get; private set; }
public static ConfigEntry<bool> CULL_QUEEN { get; private set; }
public static ConfigEntry<double> CULL_WAIT_TIME { get; private set; }
public static ConfigEntry<float> CULL_RANGE { get; private set; }
public static ConfigEntry<int> SILKWORM_GIVE_AMOUNT { get; private set; }
internal static void Initialize(ConfigFile config)
{
ENABLE_CULLING = config.Bind<bool>("Server", "enableCulling", true, "Enable culling of spiders");
ENABLE_EXTRA_CULL_REWARD = config.Bind<bool>("Server", "enableExtraCullReward", false, "Enables the extra cull reward of silkworms");
CULL_QUEEN = config.Bind<bool>("Server", "enableQueenCull", true, "Enable culling of Ungora The Spider Queen VBlood boss (this will turn off her aggro and she will die in one hit))");
CULL_WAIT_TIME = config.Bind<double>("Server", "cullWaitTime", 2.0, "Time in seconds to wait before culling spiders again");
CULL_RANGE = config.Bind<float>("Server", "cullRange", 50f, "Range to check for spiders to cull (5=1tile)");
SILKWORM_GIVE_AMOUNT = config.Bind<int>("Server", "silkwormGiveAmount", 1, "Amount of silkworms to for each spider");
}
}
internal static class SpiderUtil
{
private static NativeArray<Entity> GetSpiders()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
EntityManager entityManager = VWorld.Server.EntityManager;
EntityQueryDesc[] array = new EntityQueryDesc[1];
EntityQueryDesc val = new EntityQueryDesc();
val.All = Il2CppStructArray<ComponentType>.op_Implicit((ComponentType[])(object)new ComponentType[4]
{
ComponentType.ReadOnly<LocalToWorld>(),
ComponentType.ReadOnly<Team>(),
ComponentType.ReadOnly<AiMoveSpeeds>(),
ComponentType.ReadOnly<AiMove_Server>()
});
val.None = Il2CppStructArray<ComponentType>.op_Implicit((ComponentType[])(object)new ComponentType[5]
{
ComponentType.ReadOnly<ServantConvertable>(),
ComponentType.ReadOnly<BlueprintData>(),
ComponentType.ReadOnly<PhysicsRubble>(),
ComponentType.ReadOnly<Dead>(),
ComponentType.ReadOnly<DestroyTag>()
});
array[0] = val;
EntityQuery val2 = ((EntityManager)(ref entityManager)).CreateEntityQuery((EntityQueryDesc[])(object)array);
return ((EntityQuery)(ref val2)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
}
internal static List<Entity> ClosestSpiders(Entity e, float radius, int team = 21)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
NativeArray<Entity> spiders = GetSpiders();
List<Entity> list = new List<Entity>();
EntityManager entityManager = VWorld.Server.EntityManager;
LocalToWorld val = default(LocalToWorld);
if (((EntityManager)(ref entityManager)).TryGetComponentData<LocalToWorld>(e, ref val))
{
float3 position = ((LocalToWorld)(ref val)).Position;
Enumerator<Entity> enumerator = spiders.GetEnumerator();
while (enumerator.MoveNext())
{
Entity current = enumerator.Current;
entityManager = VWorld.Server.EntityManager;
LocalToWorld componentData = ((EntityManager)(ref entityManager)).GetComponentData<LocalToWorld>(current);
float3 position2 = ((LocalToWorld)(ref componentData)).Position;
float num = Vector3.Distance(float3.op_Implicit(position), float3.op_Implicit(position2));
EntityManager entityManager2 = VWorld.Server.EntityManager;
if (((EntityManager)(ref entityManager2)).HasComponent<Team>(current) && num < radius && ((EntityManager)(ref entityManager2)).GetComponentData<Team>(current).FactionIndex == team)
{
list.Add(current);
}
}
return list;
}
return new List<Entity>();
}
internal static Entity GetQueen(ChatCommandContext ctx)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
PrefabGUID comparingvalue = default(PrefabGUID);
((PrefabGUID)(ref comparingvalue))..ctor(-548489519);
List<Entity> list = ClosestSpiders(ctx.Event.SenderCharacterEntity, Settings.CULL_RANGE.Value);
int count = list.Count;
int remaining = count;
foreach (Entity item in list.TakeWhile((Entity _) => remaining != 0))
{
if (item.ComparePrefabGuidString(comparingvalue))
{
return item;
}
remaining--;
}
return Entity.Null;
}
internal static Entity GetQueen(Entity player, float range)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
PrefabGUID comparingvalue = default(PrefabGUID);
((PrefabGUID)(ref comparingvalue))..ctor(-548489519);
List<Entity> list = ClosestSpiders(player, range);
int count = list.Count;
int remaining = count;
foreach (Entity item in list.TakeWhile((Entity _) => remaining != 0))
{
if (item.ComparePrefabGuidString(comparingvalue))
{
return item;
}
remaining--;
}
return Entity.Null;
}
internal static bool DownQueen(Entity queen)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
if (queen == Entity.Null)
{
return false;
}
queen.WithComponentDataC<Health>((VExtensionsSpider.ActionRefs<Health>)delegate(ref Health h)
{
h.Value = 0.1f;
h.MaxRecoveryHealth = 0.1f;
h.MaxHealth._Value = 0.1f;
});
queen.WithComponentDataC<AggroConsumer>((VExtensionsSpider.ActionRefs<AggroConsumer>)delegate(ref AggroConsumer ac)
{
ac.Active._Value = false;
});
queen.WithComponentDataC<UnitLevel>((VExtensionsSpider.ActionRefs<UnitLevel>)delegate(ref UnitLevel lvl)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
lvl.Level = new ModifiableInt(1);
});
queen.WithComponentDataC<Vision>((VExtensionsSpider.ActionRefs<Vision>)delegate(ref Vision vs)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
vs.Range = new ModifiableFloat(0f);
});
queen.WithComponentDataC<UnitStats>((VExtensionsSpider.ActionRefs<UnitStats>)delegate(ref UnitStats us)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
us.PhysicalPower = new ModifiableFloat(0f);
us.PassiveHealthRegen = new ModifiableFloat(0f);
us.HealthRecovery = new ModifiableFloat(0f);
us.ShieldAbsorbModifier = new ModifiableFloat(0f);
us.SpellPower = new ModifiableFloat(0f);
});
return true;
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "SpiderKiller";
public const string PLUGIN_NAME = "SpiderKiller";
public const string PLUGIN_VERSION = "1.5.2";
}
}
namespace SpiderKiller.extensions
{
public static class VExtensionsSpider
{
public delegate void ActionRefs<T>(ref T item);
private static ManualLogSource _log => Plugin.LogInstance;
public static void WithComponentDataC<T>(this Entity entity, ActionRefs<T> action) where T : struct
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
EntityManager entityManager = VWorld.Game.EntityManager;
T item = default(T);
((EntityManager)(ref entityManager)).TryGetComponentData<T>(entity, ref item);
action(ref item);
entityManager = VWorld.Game.EntityManager;
((EntityManager)(ref entityManager)).SetComponentData<T>(entity, item);
}
public static bool ComparePrefabGuidString(this Entity entity, PrefabGUID comparingvalue)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
try
{
EntityManager entityManager = VWorld.Game.EntityManager;
PrefabGUID val = default(PrefabGUID);
((EntityManager)(ref entityManager)).TryGetComponentData<PrefabGUID>(entity, ref val);
return ((object)(PrefabGUID)(ref val)).ToString().Equals(((object)(PrefabGUID)(ref comparingvalue)).ToString());
}
catch (Exception ex)
{
_log.LogError((object)("Couldn't compare component data: " + ex.Message));
return false;
}
}
}
}
namespace SpiderKiller.Patches
{
[HarmonyPatch(typeof(DateTimeSystem), "OnUpdate")]
public class DateTimeSystem_Patch
{
private static DateTime _noUpdateBefore = DateTime.MinValue;
private static int _totalcullamount;
private static Entity _queenEntity = Entity.Null;
private static PrefabGUID _spiderQueen = new PrefabGUID(-548489519);
private static bool _queenDowned;
private static float lastDownedTimesecondcheck = 0f;
private static GameDateTime lastDownedTime = default(GameDateTime);
private static EntityManager em = VWorld.Server.EntityManager;
private static ManualLogSource _log => Plugin.LogInstance;
public static void Prefix(DateTimeSystem __instance)
{
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
//IL_0213: Unknown result type (might be due to invalid IL or missing references)
//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0204: Unknown result type (might be due to invalid IL or missing references)
//IL_0209: Unknown result type (might be due to invalid IL or missing references)
//IL_020e: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_0160: Unknown result type (might be due to invalid IL or missing references)
//IL_013a: Unknown result type (might be due to invalid IL or missing references)
//IL_0176: Unknown result type (might be due to invalid IL or missing references)
//IL_014d: Unknown result type (might be due to invalid IL or missing references)
//IL_018c: Unknown result type (might be due to invalid IL or missing references)
//IL_029d: Unknown result type (might be due to invalid IL or missing references)
//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
//IL_019f: Unknown result type (might be due to invalid IL or missing references)
//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
try
{
if (!Settings.ENABLE_CULLING.Value || !VWorld.IsServer || _noUpdateBefore > DateTime.Now)
{
return;
}
_noUpdateBefore = DateTime.Now.AddSeconds(Settings.CULL_WAIT_TIME.Value);
Enumerator<int> enumerator = InitializePlayer_Patch.playerEntityIndices.GetEnumerator();
while (enumerator.MoveNext())
{
int current = enumerator.Current;
Entity entityByEntityIndex = ((EntityManager)(ref em)).GetEntityByEntityIndex(current);
if (!Settings.CULL_QUEEN.Value)
{
continue;
}
DayNightCycle dayNightCycle = VWorld.Server.GetExistingSystemManaged<ServerScriptMapper>()._ServerGameManager.DayNightCycle;
GameDateTime gameDateTimeNow = dayNightCycle.GameDateTimeNow;
double num = (double)dayNightCycle.DayDurationInSeconds / 24.0;
double num2 = 540.0 / num;
if (!_queenDowned || Time.time - lastDownedTimesecondcheck >= 600f || gameDateTimeNow.Year > lastDownedTime.Year || (gameDateTimeNow.Year == lastDownedTime.Year && gameDateTimeNow.Month > lastDownedTime.Month) || (gameDateTimeNow.Year == lastDownedTime.Year && gameDateTimeNow.Month == lastDownedTime.Month && gameDateTimeNow.Day > lastDownedTime.Day) || (gameDateTimeNow.Year == lastDownedTime.Year && gameDateTimeNow.Month == lastDownedTime.Month && gameDateTimeNow.Day == lastDownedTime.Day && (double)(int)gameDateTimeNow.Hour >= Math.Floor((double)(int)lastDownedTime.Hour + num2)))
{
_queenEntity = SpiderUtil.GetQueen(entityByEntityIndex, Settings.CULL_RANGE.Value);
if (_queenEntity != Entity.Null)
{
SpiderUtil.DownQueen(_queenEntity);
_queenDowned = true;
lastDownedTimesecondcheck = Time.time;
lastDownedTime = dayNightCycle.GameDateTimeNow;
_queenEntity = Entity.Null;
}
}
List<Entity> list = SpiderUtil.ClosestSpiders(entityByEntityIndex, Settings.CULL_RANGE.Value);
list.RemoveAll((Entity e) => e.ComparePrefabGuidString(_spiderQueen));
int remaining;
int num3 = (remaining = list.Count);
if (num3 == 0)
{
continue;
}
foreach (Entity item in list.TakeWhile((Entity _) => remaining != 0))
{
remaining--;
if (!IsQueenSpider(item))
{
KillSpider(item, entityByEntityIndex);
}
}
if (Settings.ENABLE_EXTRA_CULL_REWARD.Value)
{
AddCullAmount(num3);
GiveExtraCullReward(entityByEntityIndex);
}
}
}
catch (Exception ex)
{
_log.LogError((object)ex.Message);
_log.LogError((object)ex.StackTrace);
}
}
private static bool IsQueenSpider(Entity spider)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
return spider.ComparePrefabGuidString(_spiderQueen);
}
private static void KillSpider(Entity spider, Entity player)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
DeathEvent val = default(DeathEvent);
val.Died = spider;
val.Killer = player;
val.Source = player;
DeathEvent val2 = val;
Dead val3 = default(Dead);
val3.ServerTimeOfDeath = Time.time;
val3.DestroyAfterDuration = 5f;
val3.Killer = player;
val3.KillerSource = player;
val3.DoNotDestroy = false;
Dead val4 = val3;
DeathUtilities.Kill(VWorld.Server.EntityManager, spider, val4, val2, default(DeathReason));
}
private static void AddCullAmount(int amount)
{
_totalcullamount += amount;
}
private static int GetCullAmount()
{
return _totalcullamount;
}
private static void ResetCullAmount()
{
_totalcullamount = 0;
}
private static void CheckForCritters(ComponentSystemBase instance)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Expected O, but got Unknown
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Expected O, but got Unknown
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
PrefabGUID comparingvalue = default(PrefabGUID);
((PrefabGUID)(ref comparingvalue))..ctor(-80668474);
PrefabGUID comparingvalue2 = default(PrefabGUID);
((PrefabGUID)(ref comparingvalue2))..ctor(1076806641);
EntityManager entityManager = instance.EntityManager;
EntityQuery val = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly<CritterGroup>() });
NativeArray<Entity> val2 = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
if (val2.Length == 0)
{
return;
}
ManualLogSource log = _log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(23, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Checking for critters: ");
((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(val2.Length);
}
log.LogInfo(val3);
Enumerator<Entity> enumerator = val2.GetEnumerator();
while (enumerator.MoveNext())
{
Entity current = enumerator.Current;
ManualLogSource log2 = _log;
val3 = new BepInExInfoLogInterpolatedStringHandler(13, 0, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("CritterGroup:");
}
log2.LogInfo(val3);
bool flag2 = current.ComparePrefabGuidString(comparingvalue);
bool flag3 = current.ComparePrefabGuidString(comparingvalue2);
if (flag2 || flag3)
{
current.WithComponentDataC<CritterGroup>((VExtensionsSpider.ActionRefs<CritterGroup>)delegate(ref CritterGroup t)
{
t.SpawnZoneRadius = 0f;
t.NumCritters = 0;
t.MaxAliveTime = 0.1f;
});
}
}
}
private static void GiveExtraCullReward(Entity player)
{
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
int num = 1;
int value = Settings.SILKWORM_GIVE_AMOUNT.Value;
PrefabGUID guid = default(PrefabGUID);
((PrefabGUID)(ref guid))..ctor(-11246506);
int cullAmount = GetCullAmount();
if (cullAmount != 0)
{
int num2 = 0;
do
{
num2 = ((num2 != 0) ? (num2 * 2) : (num2 + 1));
}
while (cullAmount >= num * num2);
if (value * num2 > 0)
{
GiveDrop.AddItemToInventory(player, guid, value * num2);
ResetCullAmount();
}
}
}
}
[HarmonyPatch]
public static class InitializePlayer_Patch
{
public static List<int> playerEntityIndices = new List<int>();
[HarmonyPatch(typeof(ServerBootstrapSystem), "OnUserConnected")]
[HarmonyPostfix]
public static void OnUserConnected_Patch(ServerBootstrapSystem __instance, NetConnectionId netConnectionId)
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
try
{
int num = VWorld.Server.GetExistingSystemManaged<ServerBootstrapSystem>()._NetEndPointToApprovedUserIndex[netConnectionId];
Entity userEntity = ((Il2CppArrayBase<ServerClient>)(object)VWorld.Server.GetExistingSystemManaged<ServerBootstrapSystem>()._ApprovedUsersLookup)[num].UserEntity;
EntityManager entityManager = VWorld.Server.EntityManager;
User componentData = ((EntityManager)(ref entityManager)).GetComponentData<User>(userEntity);
Entity entityOnServer = ((NetworkedEntity)(ref componentData.LocalCharacter)).GetEntityOnServer();
playerEntityIndices.Add(entityOnServer.Index);
}
catch (Exception ex)
{
Plugin.LogInstance.LogError((object)ex);
}
}
}
[HarmonyPatch]
public static class UserDisconnected_Patch
{
[HarmonyPatch(typeof(ServerBootstrapSystem), "OnUserDisconnected")]
[HarmonyPrefix]
public static void OnUserDisconnected_Patch(ServerBootstrapSystem __instance, NetConnectionId netConnectionId, ConnectionStatusChangeReason connectionStatusReason, string extraData)
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
if (__instance._NetEndPointToApprovedUserIndex.ContainsKey(netConnectionId))
{
int num = __instance._NetEndPointToApprovedUserIndex[netConnectionId];
Entity userEntity = ((Il2CppArrayBase<ServerClient>)(object)__instance._ApprovedUsersLookup)[num].UserEntity;
EntityManager entityManager = ((ComponentSystemBase)__instance).EntityManager;
User componentData = ((EntityManager)(ref entityManager)).GetComponentData<User>(userEntity);
Entity entityOnServer = ((NetworkedEntity)(ref componentData.LocalCharacter)).GetEntityOnServer();
int num2 = InitializePlayer_Patch.playerEntityIndices.IndexOf(entityOnServer.Index);
if (num2 != -1)
{
ListExtensions.RemoveAtSwapBack<int>(InitializePlayer_Patch.playerEntityIndices, num2);
}
}
}
}
}
namespace SpiderKiller.VCFCompat
{
public static class Commands
{
public record Spider(Entity Entity)
{
[CompilerGenerated]
protected virtual bool PrintMembers(StringBuilder builder)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
RuntimeHelpers.EnsureSufficientExecutionStack();
builder.Append("Entity = ");
Entity entity = Entity;
builder.Append(((object)(Entity)(ref entity)).ToString());
return true;
}
}
public class SpiderRemover : CommandArgumentConverter<Spider, ChatCommandContext>
{
public class SpiderCommands
{
private static Entity _queenEntity = Entity.Null;
[Command("downqueen", "dqueen", "Usage: .dqueen", "Downs Ungora", null, false)]
public void downQueen(ChatCommandContext ctx)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
_queenEntity = SpiderUtil.GetQueen(ctx);
bool flag = SpiderUtil.DownQueen(_queenEntity);
ctx.Reply(flag ? "The queen can't see you and is one hit!" : "Failed to down the queen, are you in range?");
}
[Command("teleportToMeSpiders", "sptp", "Usage: .sptp [range]", "Teleports all spiders(Entities with FactionIndex 21) to you in a defined range", null, true)]
public void TeleportToPlayer(ChatCommandContext ctx, float range = 10f, int factionIndex = 21)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
if (range > 50f)
{
range = 50f;
}
List<Entity> list = SpiderUtil.ClosestSpiders(ctx.Event.SenderCharacterEntity, range, factionIndex);
int count = list.Count;
EntityManager entityManager = VWorld.Server.EntityManager;
float3 userPos = ((EntityManager)(ref entityManager)).GetComponentData<Translation>(ctx.Event.SenderUserEntity).Value;
int remaining = count;
foreach (Entity item in list.TakeWhile((Entity _) => remaining != 0))
{
VExtensions.WithComponentData<Translation>(item, (ActionRef<Translation>)delegate(ref Translation t)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
t.Value = userPos;
});
remaining--;
}
ctx.Reply($"Teleported {count} spiders.");
}
[Command("killSpiders", "spik", "Usage: .spik [range]", "Kills all spiders(Entities with FactionIndex 21) in a defined range", null, false)]
public void KillEnemy(ChatCommandContext ctx, float range = 10f, int factionIndex = 21)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
if (range > 50f)
{
range = 50f;
}
List<Entity> list = SpiderUtil.ClosestSpiders(ctx.Event.SenderCharacterEntity, range, factionIndex);
int remaining;
int value = (remaining = list.Count);
foreach (Entity item in list.TakeWhile((Entity _) => remaining != 0))
{
DeathEvent val = default(DeathEvent);
val.Died = item;
val.Killer = ctx.Event.SenderCharacterEntity;
val.Source = ctx.Event.SenderCharacterEntity;
DeathEvent val2 = val;
Dead val3 = default(Dead);
val3.ServerTimeOfDeath = Time.time;
val3.DestroyAfterDuration = 5f;
val3.Killer = ctx.Event.SenderCharacterEntity;
val3.KillerSource = ctx.Event.SenderCharacterEntity;
val3.DoNotDestroy = false;
Dead val4 = val3;
DeathUtilities.Kill(VWorld.Server.EntityManager, item, val4, val2, default(DeathReason));
remaining--;
}
ctx.Reply($"Killed {value} spiders.");
}
}
private const float Radius = 25f;
public override Spider Parse(ChatCommandContext ctx, string input)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
List<Entity> list = SpiderUtil.ClosestSpiders(ctx.Event.SenderCharacterEntity, 25f);
EntityManager entityManager = VWorld.Server.EntityManager;
foreach (Entity item in list)
{
Team componentData = ((EntityManager)(ref entityManager)).GetComponentData<Team>(item);
bool flag = Team.IsInUnitTeam(componentData);
if (!Team.IsInNeutralTeam(componentData) && flag)
{
return new Spider(item);
}
}
throw ctx.Error($"Could not find a spider within {25f:F1}");
}
}
private static ManualLogSource _log => Plugin.LogInstance;
public static bool Enabled { get; private set; }
static Commands()
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Expected O, but got Unknown
Enabled = ((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.TryGetValue("gg.deca.VampireCommandFramework", out var value);
if (Enabled)
{
ManualLogSource log = _log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(13, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("VCF Version: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Version>(value.Metadata.Version);
}
log.LogInfo(val);
}
}
public static void Register()
{
CommandRegistry.RegisterAll();
}
}
}