using System;
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.Bootstrap;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using Bloodstone.API;
using ForgeScheduler;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using ProjectM;
using Unity.Collections;
using Unity.Entities;
using VampireCommandFramework;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("Darrean(Inility) ")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Allows you to start raids and end raids with a command, and set the times of raid on any day not just weekend or weekdays.")]
[assembly: AssemblyFileVersion("0.1.10.0")]
[assembly: AssemblyInformationalVersion("0.1.10+1.Branch.main.Sha.c33d0879382e1a0da34861ec55914ba7e637a80e")]
[assembly: AssemblyProduct("RaidForge")]
[assembly: AssemblyTitle("RaidForge")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.10.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 RaidForge
{
public class RaidCommand
{
private static readonly Dictionary<SiegeWeaponHealth, int> GolemHpEstimates = new Dictionary<SiegeWeaponHealth, int>
{
{
(SiegeWeaponHealth)0,
750
},
{
(SiegeWeaponHealth)1,
1000
},
{
(SiegeWeaponHealth)2,
1250
},
{
(SiegeWeaponHealth)3,
1750
},
{
(SiegeWeaponHealth)4,
2500
},
{
(SiegeWeaponHealth)5,
3250
},
{
(SiegeWeaponHealth)6,
4000
},
{
(SiegeWeaponHealth)7,
5000
},
{
(SiegeWeaponHealth)8,
7500
}
};
[Command("raidmode", "Sets the schedule to ignore or normal scheduling.", null, null, null, true)]
public void RaidMode(ChatCommandContext ctx, string newMode)
{
newMode = newMode.Trim().ToLowerInvariant();
string text = newMode;
string text2 = text;
if (!(text2 == "ignore"))
{
if (text2 == "normal")
{
if (!((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.ContainsKey("forgescheduler"))
{
ctx.Reply("<color=#FFD700>[RaidForge]</color> <color=#FF0000>ForgeScheduler not installed.</color>");
return;
}
RaidForgeScheduleManager.IgnoreScheduleTime.Value = false;
ctx.Reply("<color=#FFD700>[RaidForge]</color> <color=#FFFFFF>Resumed normal day-of-week scheduling.</color>");
}
else
{
ctx.Reply("<color=#FFD700>[RaidForge]</color> <color=#FF0000>Invalid mode. Use <i>ignore</i> or <i>normal</i>.</color>");
}
}
else if (!((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.ContainsKey("forgescheduler"))
{
ctx.Reply("<color=#FFD700>[RaidForge]</color> <color=#FF0000>ForgeScheduler not installed.</color>");
}
else
{
RaidForgeScheduleManager.IgnoreScheduleTime.Value = true;
ctx.Reply("<color=#FFD700>[RaidForge]</color> <color=#FFFFFF>Ignoring schedule time. Raids must be toggled manually.</color>");
}
}
[Command("raidon", "Manually turn raids ON.", null, null, null, true)]
public void RaidOn(ChatCommandContext ctx)
{
VrisingRaidToggler.EnableRaids(RaidForgePlugin.Logger);
ctx.Reply("<color=#FFD700>[RaidForge]</color> <color=#00FF00>Raids turned ON.</color>");
}
[Command("raidoff", "Manually turn raids OFF.", null, null, null, true)]
public void Raidoff(ChatCommandContext ctx)
{
VrisingRaidToggler.DisableRaids(RaidForgePlugin.Logger);
ctx.Reply("<color=#FFD700>[RaidForge]</color> <color=#FF0000>Raids turned OFF.</color>");
}
[Command("raidt", "Shows the next scheduled time raids will turn ON automatically.", null, null, null, false)]
public void RaidNextOnTime(ChatCommandContext ctx)
{
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Expected O, but got Unknown
if (!((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.ContainsKey("forgescheduler"))
{
ctx.Reply("<color=#FFD700>[RaidForge]</color> <color=#FFFFFF>ForgeScheduler not installed. No scheduled raid times.</color>");
return;
}
try
{
DateTime? nextOnTime = RaidForgeScheduleManager.GetNextOnTime(7);
if (!nextOnTime.HasValue)
{
ctx.Reply("<color=#FFD700>[RaidForge]</color> <color=#FFFFFF>No further raid-on time found in the next 7 days.</color>");
return;
}
ctx.Reply($"<color=#FFD700>[RaidForge]</color> <color=#FFFFFF>Next scheduled ON time: {nextOnTime.Value:F}</color>");
}
catch (Exception ex)
{
ctx.Reply("<color=#FFD700>[RaidForge]</color> <color=#FF0000>Error fetching schedule from ForgeScheduler.</color>");
ManualLogSource logger = RaidForgePlugin.Logger;
bool flag = default(bool);
BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(26, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[RaidForge] .raidt error: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
}
logger.LogError(val);
}
}
[Command("golemcurrent", "Shows the current SiegeWeaponHealth (SGB).", null, null, null, true)]
public void GolemCurrent(ChatCommandContext ctx)
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: 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)
SiegeWeaponHealth? siegeWeaponHealth = SiegeWeaponManager.GetSiegeWeaponHealth(RaidForgePlugin.Logger);
int value;
if (!siegeWeaponHealth.HasValue)
{
ctx.Reply("<color=#FFD700>[RaidForge]</color> <color=#FF0000>Could not retrieve SiegeWeaponHealth!</color>");
}
else if (GolemHpEstimates.TryGetValue(siegeWeaponHealth.Value, out value))
{
ctx.Reply($"<color=#FFD700>[RaidForge]</color> <color=#FFFFFF>Current = {siegeWeaponHealth.Value} (~{value} HP)</color>");
}
else
{
ctx.Reply($"<color=#FFD700>[RaidForge]</color> <color=#FFFFFF>Current = {siegeWeaponHealth.Value}</color>");
}
}
[Command("golemlow", "Sets SiegeWeaponHealth => Low", null, null, null, true)]
public void GolemLow(ChatCommandContext ctx)
{
ApplySiegeHealth(ctx, (SiegeWeaponHealth)1);
}
[Command("golemnormal", "Sets SiegeWeaponHealth => Normal", null, null, null, true)]
public void GolemNormal(ChatCommandContext ctx)
{
ApplySiegeHealth(ctx, (SiegeWeaponHealth)2);
}
[Command("golemhigh", "Sets SiegeWeaponHealth => High", null, null, null, true)]
public void GolemHigh(ChatCommandContext ctx)
{
ApplySiegeHealth(ctx, (SiegeWeaponHealth)3);
}
[Command("golemveryhigh", "Sets SiegeWeaponHealth => VeryHigh", null, null, null, true)]
public void GolemVeryHigh(ChatCommandContext ctx)
{
ApplySiegeHealth(ctx, (SiegeWeaponHealth)4);
}
[Command("golemmegahigh", "Sets SiegeWeaponHealth => MegaHigh", null, null, null, true)]
public void GolemMegaHigh(ChatCommandContext ctx)
{
ApplySiegeHealth(ctx, (SiegeWeaponHealth)5);
}
[Command("golemultrahigh", "Sets SiegeWeaponHealth => UltraHigh", null, null, null, true)]
public void GolemUltraHigh(ChatCommandContext ctx)
{
ApplySiegeHealth(ctx, (SiegeWeaponHealth)6);
}
[Command("golemcrazyhigh", "Sets SiegeWeaponHealth => CrazyHigh", null, null, null, true)]
public void GolemCrazyHigh(ChatCommandContext ctx)
{
ApplySiegeHealth(ctx, (SiegeWeaponHealth)7);
}
[Command("golemmax", "Sets SiegeWeaponHealth => Max", null, null, null, true)]
public void GolemMax(ChatCommandContext ctx)
{
ApplySiegeHealth(ctx, (SiegeWeaponHealth)8);
}
private void ApplySiegeHealth(ChatCommandContext ctx, SiegeWeaponHealth healthValue)
{
//IL_0001: 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_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: 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)
int value;
if (!SiegeWeaponManager.SetSiegeWeaponHealth(healthValue, RaidForgePlugin.Logger))
{
ctx.Reply($"<color=#FFD700>[RaidForge]</color> <color=#FF0000>Failed to set SiegeWeaponHealth to {healthValue}!</color>");
}
else if (GolemHpEstimates.TryGetValue(healthValue, out value))
{
ctx.Reply($"<color=#FFD700>[RaidForge]</color> <color=#00FF00>Golems updated to ~{value} HP ({healthValue}).</color>");
}
else
{
ctx.Reply($"<color=#FFD700>[RaidForge]</color> <color=#00FF00>Golems updated: {healthValue}.</color>");
}
}
}
[BepInPlugin("RaidForge", "RaidForge Mod", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[Reloadable]
public class RaidForgePlugin : BasePlugin
{
public static ManualLogSource Logger;
private Harmony _harmony;
public static RaidForgePlugin Instance { get; private set; }
public override void Load()
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Expected O, but got Unknown
Instance = this;
Logger = ((BasePlugin)this).Log;
_harmony = new Harmony("raidforge.plugin");
_harmony.PatchAll();
CommandRegistry.RegisterAll();
Logger.LogInfo((object)"[RaidForge] Loaded.");
}
public override bool Unload()
{
CommandRegistry.UnregisterAssembly();
Harmony harmony = _harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
return true;
}
}
public class Raidwindow
{
public DayOfWeek Day { get; set; }
public TimeSpan Start { get; set; }
public TimeSpan End { get; set; }
}
public static class SiegeWeaponManager
{
public static bool SetSiegeWeaponHealth(SiegeWeaponHealth newValue, ManualLogSource logger)
{
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Expected O, but got Unknown
//IL_0027: 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_0037: 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_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: 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_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: 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_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: 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_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Expected O, but got Unknown
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
World server = VWorld.Server;
if (server == null)
{
logger.LogError((object)"[SiegeWeaponManager] No VWorld.Server; cannot set SiegeWeaponHealth.");
return false;
}
EntityManager entityManager = server.EntityManager;
EntityQuery val = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadWrite<ServerGameBalanceSettings>() });
NativeArray<Entity> val2 = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
bool flag = default(bool);
try
{
if (val2.Length == 0)
{
logger.LogWarning((object)"[SiegeWeaponManager] No entity found with ServerGameBalanceSettings!");
return false;
}
Entity val3 = val2[0];
ServerGameBalanceSettings componentData = ((EntityManager)(ref entityManager)).GetComponentData<ServerGameBalanceSettings>(val3);
componentData.SiegeWeaponHealth = newValue;
((EntityManager)(ref entityManager)).SetComponentData<ServerGameBalanceSettings>(val3, componentData);
BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(45, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("[SiegeWeaponManager] Updated Golem Health => ");
((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<SiegeWeaponHealth>(newValue);
}
logger.LogInfo(val4);
return true;
}
catch (Exception ex)
{
BepInExErrorLogInterpolatedStringHandler val5 = new BepInExErrorLogInterpolatedStringHandler(52, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("[SiegeWeaponManager] Could not update Golem Health: ");
((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<Exception>(ex);
}
logger.LogError(val5);
return false;
}
finally
{
val2.Dispose();
}
}
public static SiegeWeaponHealth? GetSiegeWeaponHealth(ManualLogSource logger)
{
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Expected O, but got Unknown
//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_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_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: 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_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_008d: 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_0096: 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_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: 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)
World server = VWorld.Server;
if (server == null)
{
logger.LogError((object)"[SiegeWeaponManager] No VWorld.Server; cannot read SiegeWeaponHealth.");
return null;
}
EntityManager entityManager = server.EntityManager;
EntityQuery val = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly<ServerGameBalanceSettings>() });
NativeArray<Entity> val2 = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
try
{
if (val2.Length == 0)
{
logger.LogWarning((object)"[SiegeWeaponManager] No entity found with ServerGameBalanceSettings!");
return null;
}
Entity val3 = val2[0];
ServerGameBalanceSettings componentData = ((EntityManager)(ref entityManager)).GetComponentData<ServerGameBalanceSettings>(val3);
return componentData.SiegeWeaponHealth;
}
catch (Exception ex)
{
bool flag = default(bool);
BepInExErrorLogInterpolatedStringHandler val4 = new BepInExErrorLogInterpolatedStringHandler(58, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("[SiegeWeaponManager] Error reading SGB.SiegeWeaponHealth: ");
((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<Exception>(ex);
}
logger.LogError(val4);
return null;
}
finally
{
val2.Dispose();
}
}
}
public static class VrisingRaidToggler
{
private static bool _scanned;
private static FieldInfo _settingsField;
private static FieldInfo _castleDamageField;
public static void EnableRaids(ManualLogSource logger)
{
bool flag = SetCastleDamageMode("Always");
bool flag2 = SetServerGameBalanceCastleDamage("Always");
}
public static void DisableRaids(ManualLogSource logger)
{
bool flag = SetCastleDamageMode("TimeRestricted");
bool flag2 = SetServerGameBalanceCastleDamage("TimeRestricted");
}
private static bool SetCastleDamageMode(string val)
{
World server = VWorld.Server;
if (server == null)
{
return false;
}
ServerGameSettingsSystem existingSystemManaged = server.GetExistingSystemManaged<ServerGameSettingsSystem>();
if (existingSystemManaged == null)
{
return false;
}
if (!_scanned)
{
_scanned = true;
FindCastleDamageField(existingSystemManaged);
}
if (_settingsField == null || _castleDamageField == null)
{
return false;
}
object value = _settingsField.GetValue(existingSystemManaged);
if (value == null)
{
return false;
}
try
{
object value2 = Enum.Parse(_castleDamageField.FieldType, val);
_castleDamageField.SetValue(value, value2);
return true;
}
catch
{
return false;
}
}
private static bool SetServerGameBalanceCastleDamage(string val)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: 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_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_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_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: 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_006d: 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_0076: 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_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)
World server = VWorld.Server;
if (server == null)
{
return false;
}
EntityManager entityManager = server.EntityManager;
EntityQuery val2 = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadWrite<ServerGameBalanceSettings>() });
NativeArray<Entity> val3 = ((EntityQuery)(ref val2)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
try
{
if (val3.Length == 0)
{
return false;
}
Entity val4 = val3[0];
ServerGameBalanceSettings componentData = ((EntityManager)(ref entityManager)).GetComponentData<ServerGameBalanceSettings>(val4);
Type type = ((object)componentData.CastleDamageMode).GetType();
object obj = Enum.Parse(type, val);
componentData.CastleDamageMode = (CastleDamageMode)obj;
((EntityManager)(ref entityManager)).SetComponentData<ServerGameBalanceSettings>(val4, componentData);
return true;
}
finally
{
val3.Dispose();
}
}
private static void FindCastleDamageField(ServerGameSettingsSystem sgsSystem)
{
Type type = ((object)sgsSystem).GetType();
FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
FieldInfo[] array = fields;
foreach (FieldInfo fieldInfo in array)
{
if (!fieldInfo.Name.ToLower().Contains("settings"))
{
continue;
}
object value = fieldInfo.GetValue(sgsSystem);
if (value != null)
{
FieldInfo field = value.GetType().GetField("CastleDamageMode", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (field != null)
{
_settingsField = fieldInfo;
_castleDamageField = field;
return;
}
}
}
FieldInfo[] array2 = fields;
foreach (FieldInfo fieldInfo2 in array2)
{
object value2 = fieldInfo2.GetValue(sgsSystem);
if (value2 != null)
{
FieldInfo field2 = value2.GetType().GetField("CastleDamageMode", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (field2 != null)
{
_settingsField = fieldInfo2;
_castleDamageField = field2;
break;
}
}
}
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "RaidForge";
public const string PLUGIN_NAME = "RaidForge";
public const string PLUGIN_VERSION = "0.1.10";
}
}