using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using CrimsonMoon.Structs;
using CrimsonMoon.Utils;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Microsoft.CodeAnalysis;
using ProjectM;
using ProjectM.Shared;
using Stunlock.Core;
using Unity.Collections;
using Unity.Entities;
using Unity.Mathematics;
using Unity.Transforms;
using UnityEngine;
using VAMP;
using VAMP.Utilities;
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("CrimsonMoon")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("A sacraficial alter to praise the moon! Honor it in return for a blood moon!")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+Branch.master.Sha.0ec0fb1202ac18529de72d45543d85598b3f70a0.0ec0fb1202ac18529de72d45543d85598b3f70a0")]
[assembly: AssemblyProduct("CrimsonMoon")]
[assembly: AssemblyTitle("CrimsonMoon")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace CrimsonMoon
{
[BepInPlugin("CrimsonMoon", "CrimsonMoon", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BasePlugin
{
private Harmony _harmony;
internal static Plugin Instance;
public static Harmony Harmony => Instance._harmony;
public static ManualLogSource LogInstance => ((BasePlugin)Instance).Log;
public static Settings Settings { get; private set; }
public static DropClearSystem DropClearSystem { get; private set; }
public override void Load()
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Expected O, but got Unknown
Instance = this;
Settings = new Settings(((BasePlugin)this).Config);
_harmony = new Harmony("CrimsonMoon");
_harmony.PatchAll(Assembly.GetExecutingAssembly());
CommandRegistry.RegisterAll();
Events.OnCoreLoaded = (Action)Delegate.Combine(Events.OnCoreLoaded, new Action(Loaded));
}
private void Loaded()
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
DropClearSystem = new DropClearSystem();
ManualLogSource log = ((BasePlugin)this).Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(27, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("CrimsonMoon");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" version ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.0.0");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
}
log.LogInfo(val);
}
public override bool Unload()
{
CommandRegistry.UnregisterAssembly();
Harmony harmony = _harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
return true;
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "CrimsonMoon";
public const string PLUGIN_NAME = "CrimsonMoon";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace CrimsonMoon.Utils
{
public class DropClearSystem
{
private EntityQuery dropItemQuery;
public DropClearSystem()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
//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_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: 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_0044: 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_0056: 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_0079: 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_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)
EntityQueryDesc val = new EntityQueryDesc();
val.All = Il2CppStructArray<ComponentType>.op_Implicit((ComponentType[])(object)new ComponentType[4]
{
new ComponentType(Il2CppType.Of<ItemPickup>(), (AccessMode)0),
new ComponentType(Il2CppType.Of<PrefabGUID>(), (AccessMode)0),
new ComponentType(Il2CppType.Of<Translation>(), (AccessMode)0),
new ComponentType(Il2CppType.Of<DestroyWhenNoCharacterNearbyAfterDuration>(), (AccessMode)0)
});
val.None = Il2CppStructArray<ComponentType>.op_Implicit((ComponentType[])(object)new ComponentType[1]
{
new ComponentType(Il2CppType.Of<AttachedBuffer>(), (AccessMode)1)
});
val.Options = (EntityQueryOptions)2;
EntityQueryDesc val2 = val;
EntityManager entityManager = Core.EntityManager;
dropItemQuery = ((EntityManager)(ref entityManager)).CreateEntityQuery(val2.All);
}
private IEnumerable<Entity> GetDropItems()
{
NativeArray<Entity> entities = ((EntityQuery)(ref dropItemQuery)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
Enumerator<Entity> enumerator = entities.GetEnumerator();
while (enumerator.MoveNext())
{
Entity current = enumerator.Current;
EntityUtil.Read<PrefabGUID>(current);
yield return current;
}
entities.Dispose();
}
private int ClearDropItems(Func<Entity, bool> shouldClear = null)
{
//IL_0014: 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_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_0037: 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_00a1: 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_0043: 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_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: 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_005c: 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_0065: 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_007b: 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_0086: Unknown result type (might be due to invalid IL or missing references)
int num = 0;
DynamicBuffer<InventoryBuffer> val = default(DynamicBuffer<InventoryBuffer>);
foreach (Entity dropItem in GetDropItems())
{
if (shouldClear != null && !shouldClear(dropItem))
{
continue;
}
EntityManager entityManager = Core.Server.EntityManager;
if (((EntityManager)(ref entityManager)).TryGetBuffer<InventoryBuffer>(dropItem, ref val))
{
Enumerator<InventoryBuffer> enumerator2 = val.GetEnumerator();
while (enumerator2.MoveNext())
{
InventoryBuffer current2 = enumerator2.Current;
NetworkedEntity itemEntity = current2.ItemEntity;
if (!(((NetworkedEntity)(ref itemEntity)).GetEntityOnServer() == Entity.Null))
{
EntityManager entityManager2 = Core.Server.EntityManager;
itemEntity = current2.ItemEntity;
DestroyUtility.Destroy(entityManager2, ((NetworkedEntity)(ref itemEntity)).GetEntityOnServer(), (DestroyDebugReason)0, (string)null, 0);
}
}
}
DestroyUtility.Destroy(Core.Server.EntityManager, dropItem, (DestroyDebugReason)0, (string)null, 0);
num++;
}
return num;
}
public int ClearDropItemsInRadius(float3 pos, float radius)
{
//IL_0010: 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)
float2 posXZ = ((float3)(ref pos)).xz;
return ClearDropItems(delegate(Entity entity)
{
//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_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
Translation val = EntityUtil.Read<Translation>(entity);
return math.distance(posXZ, ((float3)(ref val.Value)).xz) <= radius;
});
}
}
}
namespace CrimsonMoon.Structs
{
public readonly struct Settings
{
internal readonly ConfigFile CONFIG;
internal readonly ConfigEntry<bool> ENABLE_MOD;
internal readonly ConfigEntry<double> ALTER_LOCATION_X;
internal readonly ConfigEntry<double> ALTER_LOCATION_Y;
internal readonly ConfigEntry<double> ALTER_LOCATION_Z;
internal readonly ConfigEntry<int> SACRAFICE_GUID;
internal readonly ConfigEntry<int> MIN_AMOUNT;
public Settings(ConfigFile config)
{
CONFIG = config;
ENABLE_MOD = config.Bind<bool>("Config", "EnableMod", true, "Enable or disable the mod");
SACRAFICE_GUID = config.Bind<int>("Sacrafice", "SacraficeGUID", 1566989408, "ItemHash for the sacraficed material");
MIN_AMOUNT = config.Bind<int>("Sacrafice", "MinimumRequired", 3, "This is how many must be dropped to trigger blood moon");
ALTER_LOCATION_X = config.Bind<double>("Alter", "AlterLocation_X", -1585.3368, "The float3 position of the alter, accepts sacrafices within 10 distance");
ALTER_LOCATION_Y = config.Bind<double>("Alter", "AlterLocation_Y", -3.8146, (ConfigDescription)null);
ALTER_LOCATION_Z = config.Bind<double>("Alter", "AlterLocation_Z", -937.0102, (ConfigDescription)null);
}
}
}
namespace CrimsonMoon.Hooks
{
[HarmonyPatch]
internal class Sacrafice
{
[HarmonyPatch(typeof(DropItemThrowSystem), "OnUpdate")]
public class DropItemThrowSystem_Prefix
{
private EntityQuery dropItemQuery;
public static void Prefix(DropItemThrowSystem __instance)
{
//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_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_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: 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_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_002a: 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_0033: 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_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: 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_0080: 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_008c: 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_0098: 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_00a4: 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_0107: Unknown result type (might be due to invalid IL or missing references)
EntityQuery _query_2070481713_ = __instance.__query_2070481713_0;
Enumerator<Entity> enumerator = ((EntityQuery)(ref _query_2070481713_)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)3)).GetEnumerator();
DropItemAroundPosition val = default(DropItemAroundPosition);
Vector3 val3 = default(Vector3);
while (enumerator.MoveNext())
{
Entity current = enumerator.Current;
EntityManager entityManager = Core.EntityManager;
if (((EntityManager)(ref entityManager)).TryGetComponentData<DropItemAroundPosition>(current, ref val) && val.ItemHash == new PrefabGUID(Plugin.Settings.SACRAFICE_GUID.Value) && val.Amount >= Plugin.Settings.MIN_AMOUNT.Value)
{
Vector3 val2 = new Vector3(val.Position.x, val.Position.y, val.Position.z);
((Vector3)(ref val3))..ctor((float)Plugin.Settings.ALTER_LOCATION_X.Value, (float)Plugin.Settings.ALTER_LOCATION_Y.Value, (float)Plugin.Settings.ALTER_LOCATION_Z.Value);
if (Vector3.Distance(val2, val3) < 10f)
{
ChatUtil.SystemSendAll("The Blood Alter runs red!");
Core.Server.GetExistingSystemManaged<DebugEventsSystem>().JumpToNextBloodMoon();
Core.StartCoroutine(Clear(val3, 20));
}
}
}
}
private static IEnumerator Clear(Vector3 vector, int radius)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
yield return (object)new WaitForSeconds(1f);
Plugin.DropClearSystem.ClearDropItemsInRadius(float3.op_Implicit(vector), radius);
}
}
}
}
namespace CrimsonMoon.Commands
{
[CommandGroup("crimsonmoon", "cmoon")]
internal class BloodMoon
{
[Command("trigger", "t", null, "Forces next moon to be blood", null, true)]
public static void TriggerBloodMoon(ChatCommandContext ctx)
{
Core.Server.GetExistingSystemManaged<DebugEventsSystem>().JumpToNextBloodMoon();
ctx.Reply("Jumping to Next Blood Moon");
}
}
}