using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
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 Bloodstone.API;
using Bloodstone.Hooks;
using Microsoft.CodeAnalysis;
using ProjectM;
using Unity.Collections;
using Unity.Entities;
using UnityEngine;
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 static class GolemAutoManager
{
private static int _lastDayUpdated = -1;
private static Dictionary<int, SiegeWeaponHealth> _dayToHealthMap = new Dictionary<int, SiegeWeaponHealth>();
private static ManualLogSource Logger => RaidForgePlugin.Logger;
public static void LoadConfig()
{
//IL_0173: Unknown result type (might be due to invalid IL or missing references)
//IL_017a: Expected O, but got Unknown
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Expected O, but got Unknown
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Expected O, but got Unknown
_dayToHealthMap.Clear();
string value = Raidschedule.GolemDayToHealthMap.Value;
string[] array = value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries);
string[] array2 = array;
bool flag = default(bool);
foreach (string text in array2)
{
string text2 = text.Trim();
int num = text2.IndexOf('=');
if (num < 0)
{
continue;
}
string text3 = text2.Substring(0, num).Trim();
string text4 = text2.Substring(num + 1).Trim();
SiegeWeaponHealth result2;
if (!int.TryParse(text3, out var result))
{
ManualLogSource logger = Logger;
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(42, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[GolemAuto] Invalid day index: '");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text3);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' in map: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text2);
}
logger.LogWarning(val);
}
else if (!Enum.TryParse<SiegeWeaponHealth>(text4, ignoreCase: true, out result2))
{
ManualLogSource logger2 = Logger;
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(49, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[GolemAuto] Invalid SiegeWeaponHealth '");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text4);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' in map: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text2);
}
logger2.LogWarning(val);
}
else
{
_dayToHealthMap[result] = result2;
}
}
ManualLogSource logger3 = Logger;
BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(50, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[GolemAuto] Parsed ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(_dayToHealthMap.Count);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" day->health pairs from config.");
}
logger3.LogInfo(val2);
_lastDayUpdated = -1;
}
public static void UpdateIfNeeded()
{
//IL_0194: Unknown result type (might be due to invalid IL or missing references)
//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
//IL_01bd: Expected O, but got Unknown
//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
//IL_0153: Unknown result type (might be due to invalid IL or missing references)
//IL_015a: Expected O, but got Unknown
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_0142: Unknown result type (might be due to invalid IL or missing references)
if (!Raidschedule.GolemAutomationEnabled.Value || string.IsNullOrWhiteSpace(Raidschedule.GolemStartDateString.Value))
{
return;
}
if (!DateTime.TryParseExact(Raidschedule.GolemStartDateString.Value, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out var result))
{
Logger.LogWarning((object)("[GolemAuto] Cannot parse GolemStartDateString => " + Raidschedule.GolemStartDateString.Value));
return;
}
DateTime now = DateTime.Now;
int num = (int)Math.Floor((now - result).TotalDays);
if (num < 0)
{
num = 0;
}
if (num == _lastDayUpdated)
{
return;
}
bool flag = default(bool);
if (!_dayToHealthMap.TryGetValue(num, out var value))
{
int num2 = -1;
foreach (int key in _dayToHealthMap.Keys)
{
if (key > num2)
{
num2 = key;
}
}
if (num <= num2 || num2 < 0)
{
ManualLogSource logger = Logger;
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(48, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[GolemAuto] Day ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" not found in map, no HP change.");
}
logger.LogInfo(val);
_lastDayUpdated = num;
return;
}
value = _dayToHealthMap[num2];
}
if (SiegeWeaponManager.SetSiegeWeaponHealth(value, Logger))
{
ManualLogSource logger2 = Logger;
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(28, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[GolemAuto] Day ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": HP set => ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<SiegeWeaponHealth>(value);
}
logger2.LogInfo(val);
}
_lastDayUpdated = num;
}
public static int GetCurrentDay()
{
if (!Raidschedule.GolemAutomationEnabled.Value)
{
return -1;
}
string value = Raidschedule.GolemStartDateString.Value;
if (string.IsNullOrWhiteSpace(value))
{
return -1;
}
if (!DateTime.TryParseExact(value, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out var result))
{
return -1;
}
int num = (int)Math.Floor((DateTime.Now - result).TotalDays);
return (num >= 0) ? num : 0;
}
public static void SetStartDate(DateTime dt)
{
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Expected O, but got Unknown
Raidschedule.GolemStartDateString.Value = dt.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);
((BasePlugin)RaidForgePlugin.Instance).Config.Save();
Raidschedule.LoadFromConfig();
_lastDayUpdated = -1;
ManualLogSource logger = Logger;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(29, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[GolemAuto] StartDate set => ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<DateTime>(dt);
}
logger.LogInfo(val);
}
public static void ClearStartDate()
{
Raidschedule.GolemStartDateString.Value = "";
((BasePlugin)RaidForgePlugin.Instance).Config.Save();
Raidschedule.LoadFromConfig();
_lastDayUpdated = -1;
Logger.LogInfo((object)"[GolemAuto] Cleared start date.");
}
}
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 override mode to ForceOn, ForceOff, or Normal. Example: .raidmode ForceOn", null, null, null, true)]
public void RaidMode(ChatCommandContext ctx, string newMode)
{
newMode = newMode.Trim();
if (!newMode.Equals("ForceOn", StringComparison.OrdinalIgnoreCase) && !newMode.Equals("ForceOff", StringComparison.OrdinalIgnoreCase) && !newMode.Equals("Normal", StringComparison.OrdinalIgnoreCase))
{
ctx.Reply("<color=#FFD700>[RaidForge]</color> <color=#FF0000>Invalid mode. Use ForceOn, ForceOff, or Normal.</color>");
return;
}
Raidschedule.OverrideMode.Value = newMode;
Raidschedule.LoadFromConfig();
RaidtimeManager.ReloadFromConfig(immediate: true);
ctx.Reply("<color=#FFD700>[RaidForge]</color> OverrideMode set to <color=#00FFFF>" + newMode + "</color>. <color=#FFFFFF>(If Normal, day-of-week scheduling is active.)</color>");
}
[Command("raidon", "Immediately turn raids ON (one-time).", null, null, null, true)]
public void RaidOn(ChatCommandContext ctx)
{
RaidtimeManager.SetManualOverride(forcedOn: true);
VrisingRaidToggler.EnableRaids(RaidForgePlugin.Logger);
ctx.Reply("<color=#FFD700>[RaidForge]</color> <color=#00FF00>Raids turned ON</color> now and will remain ON <color=#FFFFFF>(unless manually turned OFF or resumed schedule).</color>");
}
[Command("raidoff", "Immediately turn raids OFF if it was turned on manually.", null, null, null, true)]
public void RaidOff(ChatCommandContext ctx)
{
RaidtimeManager.SetManualOverride(forcedOn: false);
VrisingRaidToggler.DisableRaids(RaidForgePlugin.Logger);
ctx.Reply("<color=#FFD700>[RaidForge]</color> <color=#FF0000>Raids turned OFF.</color>");
}
[Command("raidresume", "Reverts to normal day-of-week schedule right now.", null, null, null, true)]
public void RaidResume(ChatCommandContext ctx)
{
RaidtimeManager.ClearManualOverride();
RaidtimeManager.ReloadFromConfig(immediate: true);
ctx.Reply("<color=#FFD700>[RaidForge]</color> <color=#FFFFFF>Resumed day-of-week schedule! Raids now follow the config again.</color>");
}
[Command("raidtime", "Shows current server date/time and day-of-week.", null, null, null, true)]
public void RaidTime(ChatCommandContext ctx)
{
DateTime now = DateTime.Now;
ctx.Reply($"<color=#FFD700>[RaidForge]</color> <color=#FFFFFF>Server time: {now:F} (DayOfWeek={now.DayOfWeek}).</color>");
}
[Command("raidt", "Shows next scheduled time raids will turn ON automatically.", null, null, null, false)]
public void RaidNextOnTime(ChatCommandContext ctx)
{
DateTime? nextOnTime = RaidtimeManager.GetNextOnTime(DateTime.Now);
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>");
}
[Command("golemcurrent", "Shows the current SiegeWeaponHealth (from SGB).", null, null, null, true)]
public void GolemCurrent(ChatCommandContext ctx)
{
//IL_0039: 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)
SiegeWeaponHealth? siegeWeaponHealth = SiegeWeaponManager.GetSiegeWeaponHealth(RaidForgePlugin.Logger);
if (!siegeWeaponHealth.HasValue)
{
ctx.Reply("<color=#FFD700>[RaidForge]</color> <color=#FF0000>Could not retrieve SiegeWeaponHealth (no SGB entity?).</color>");
return;
}
string value = "";
if (GolemHpEstimates.TryGetValue(siegeWeaponHealth.Value, out var value2))
{
value = $" (~{value2} HP)";
}
ctx.Reply($"<color=#FFD700>[RaidForge]</color> <color=#FFFFFF>Current SiegeWeaponHealth = {siegeWeaponHealth.Value}{value}.</color>");
}
[Command("golemverylow", "Sets SiegeWeaponHealth => VeryLow", null, null, null, true)]
public void GolemVeryLow(ChatCommandContext ctx)
{
ApplySiegeHealth(ctx, (SiegeWeaponHealth)0);
}
[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_005e: 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)
if (!SiegeWeaponManager.SetSiegeWeaponHealth(healthValue, RaidForgePlugin.Logger))
{
ctx.Reply($"<color=#FFD700>[RaidForge]</color> <color=#FF0000>Failed to set SiegeWeaponHealth to {healthValue}!</color>");
return;
}
string text = "";
if (GolemHpEstimates.TryGetValue(healthValue, out var value))
{
text = $" <color=red>{value}</color=red> Health";
}
ctx.Reply("<color=#FFD700>[RaidForge]</color> <color=#00FF00>Golems updated to" + text + ".</color>");
}
[Command("raidmon", "Set Monday’s raid window (HH:mm). Example: .raidmon 3:10 3:15", null, null, null, true)]
public void RaidMonday(ChatCommandContext ctx, string startTimeStr, string endTimeStr)
{
SetRaidWindow(ctx, DayOfWeek.Monday, startTimeStr, endTimeStr);
}
[Command("raidtue", "Set Tuesday’s raid window (HH:mm). Example: .raidtue 19:30 21:00", null, null, null, true)]
public void RaidTuesday(ChatCommandContext ctx, string startTimeStr, string endTimeStr)
{
SetRaidWindow(ctx, DayOfWeek.Tuesday, startTimeStr, endTimeStr);
}
[Command("raidwed", "Set Wednesday’s raid window (HH:mm).", null, null, null, true)]
public void RaidWednesday(ChatCommandContext ctx, string startTimeStr, string endTimeStr)
{
SetRaidWindow(ctx, DayOfWeek.Wednesday, startTimeStr, endTimeStr);
}
[Command("raidthu", "Set Thursday’s raid window (HH:mm).", null, null, null, true)]
public void RaidThursday(ChatCommandContext ctx, string startTimeStr, string endTimeStr)
{
SetRaidWindow(ctx, DayOfWeek.Thursday, startTimeStr, endTimeStr);
}
[Command("raidfri", "Set Friday’s raid window (HH:mm).", null, null, null, true)]
public void RaidFriday(ChatCommandContext ctx, string startTimeStr, string endTimeStr)
{
SetRaidWindow(ctx, DayOfWeek.Friday, startTimeStr, endTimeStr);
}
[Command("raidsat", "Set Saturday’s raid window (HH:mm).", null, null, null, true)]
public void RaidSaturday(ChatCommandContext ctx, string startTimeStr, string endTimeStr)
{
SetRaidWindow(ctx, DayOfWeek.Saturday, startTimeStr, endTimeStr);
}
[Command("raidsun", "Set Sunday’s raid window (HH:mm).", null, null, null, true)]
public void RaidSunday(ChatCommandContext ctx, string startTimeStr, string endTimeStr)
{
SetRaidWindow(ctx, DayOfWeek.Sunday, startTimeStr, endTimeStr);
}
[Command("raidsched", "Displays entire weekly schedule from your config.", null, null, null, true)]
public void RaidSchedule(ChatCommandContext ctx)
{
ctx.Reply("<color=#FFD700>[RaidForge]</color> <color=#FFFFFF>Current Weekly Raid Schedule:</color>");
foreach (KeyValuePair<DayOfWeek, Raidwindow> window in Raidschedule.Windows)
{
DayOfWeek key = window.Key;
Raidwindow value = window.Value;
string value2 = $"{value.Start.Hours:00}:{value.Start.Minutes:00}";
string value3 = $"{value.End.Hours:00}:{value.End.Minutes:00}";
ctx.Reply($" <color=#FFFFFF>- {key}: {value2} - {value3}</color>");
}
}
private void SetRaidWindow(ChatCommandContext ctx, DayOfWeek day, string startTimeStr, string endTimeStr)
{
if (!TimeSpan.TryParse(startTimeStr, out var result))
{
ctx.Reply("<color=#FFD700>[RaidForge]</color> <color=#FF0000>Invalid start time '" + startTimeStr + "'. Use HH:mm format.</color>");
return;
}
if (!TimeSpan.TryParse(endTimeStr, out var result2))
{
ctx.Reply("<color=#FFD700>[RaidForge]</color> <color=#FF0000>Invalid end time '" + endTimeStr + "'. Use HH:mm format.</color>");
return;
}
if (result.TotalHours < 0.0 || result.TotalHours > 24.0 || result2.TotalHours < 0.0 || result2.TotalHours > 24.0)
{
ctx.Reply("<color=#FFD700>[RaidForge]</color> <color=#FF0000>Times must be between 00:00 and 24:00!</color>");
return;
}
if (result2 < result)
{
ctx.Reply("<color=#FFD700>[RaidForge]</color> <color=#FF0000>End time must be >= start time!</color>");
return;
}
string value = $"{result.Hours:00}:{result.Minutes:00}:00";
string value2 = $"{result2.Hours:00}:{result2.Minutes:00}:00";
switch (day)
{
case DayOfWeek.Monday:
Raidschedule.MondayStart.Value = value;
Raidschedule.MondayEnd.Value = value2;
break;
case DayOfWeek.Tuesday:
Raidschedule.TuesdayStart.Value = value;
Raidschedule.TuesdayEnd.Value = value2;
break;
case DayOfWeek.Wednesday:
Raidschedule.WednesdayStart.Value = value;
Raidschedule.WednesdayEnd.Value = value2;
break;
case DayOfWeek.Thursday:
Raidschedule.ThursdayStart.Value = value;
Raidschedule.ThursdayEnd.Value = value2;
break;
case DayOfWeek.Friday:
Raidschedule.FridayStart.Value = value;
Raidschedule.FridayEnd.Value = value2;
break;
case DayOfWeek.Saturday:
Raidschedule.SaturdayStart.Value = value;
Raidschedule.SaturdayEnd.Value = value2;
break;
case DayOfWeek.Sunday:
Raidschedule.SundayStart.Value = value;
Raidschedule.SundayEnd.Value = value2;
break;
}
Raidschedule.LoadFromConfig();
RaidtimeManager.ClearSkipForTodayIfDayMatches(day);
RaidtimeManager.ReloadFromConfig(immediate: true);
ctx.Reply($"<color=#FFD700>[RaidForge]</color> <color=#00FF00>{day} window</color> set to <color=#FFFF00>{value} - {value2}</color>. <color=#FFFFFF>Updated schedule loaded.</color>");
}
[Command("golemauto", "Manage Golem HP automation (on/off/start/check/clear).", null, null, null, true)]
public void GolemAutoCommand(ChatCommandContext ctx, string subCmd, string optionalDateStr = "")
{
subCmd = subCmd.ToLower().Trim();
switch (subCmd)
{
case "on":
Raidschedule.GolemAutomationEnabled.Value = true;
Raidschedule.LoadFromConfig();
GolemAutoManager.LoadConfig();
ctx.Reply("<color=#FFD700>[GolemAuto]</color> <color=#00FF00>Automation enabled.</color>");
break;
case "off":
Raidschedule.GolemAutomationEnabled.Value = false;
Raidschedule.LoadFromConfig();
ctx.Reply("<color=#FFD700>[GolemAuto]</color> <color=#FF0000>Automation disabled.</color>");
break;
case "start":
{
DateTime result;
if (string.IsNullOrWhiteSpace(optionalDateStr))
{
DateTime now = DateTime.Now;
GolemAutoManager.SetStartDate(now);
ctx.Reply($"<color=#FFD700>[GolemAuto]</color> Day-0 set to now: {now}");
}
else if (!DateTime.TryParse(optionalDateStr, out result))
{
ctx.Reply("<color=#FFD700>[GolemAuto]</color> <color=#FF0000>Invalid date/time format!</color>");
}
else
{
GolemAutoManager.SetStartDate(result);
ctx.Reply($"<color=#FFD700>[GolemAuto]</color> Day-0 set to {result}");
}
break;
}
case "check":
{
if (!Raidschedule.GolemAutomationEnabled.Value)
{
ctx.Reply("<color=#FFD700>[GolemAuto]</color> Automation is OFF.");
break;
}
string value = Raidschedule.GolemStartDateString.Value;
if (string.IsNullOrWhiteSpace(value))
{
ctx.Reply("<color=#FFD700>[GolemAuto]</color> Automation is ON, but no start date set. Use '.golemauto start'");
break;
}
int currentDay = GolemAutoManager.GetCurrentDay();
ctx.Reply($"<color=#FFD700>[GolemAuto]</color> Automation is ON. StartDate={value}, currentDay={currentDay}");
GolemAutoManagerCheckMapping(ctx, currentDay);
break;
}
case "clear":
GolemAutoManager.ClearStartDate();
ctx.Reply("<color=#FFD700>[GolemAuto]</color> Start date cleared. Day-0 is now undefined.");
break;
default:
ctx.Reply("<color=#FFD700>[GolemAuto]</color> Usage: '.golemauto on/off/start/check/clear' [optional date]");
break;
}
}
private void GolemAutoManagerCheckMapping(ChatCommandContext ctx, int dayIndex)
{
//IL_011c: 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_015a: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: Unknown result type (might be due to invalid IL or missing references)
//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
string[] array = Raidschedule.GolemDayToHealthMap.Value.Split(',', StringSplitOptions.RemoveEmptyEntries);
int num = -1;
Dictionary<int, SiegeWeaponHealth> dictionary = new Dictionary<int, SiegeWeaponHealth>();
string[] array2 = array;
foreach (string text in array2)
{
string text2 = text.Trim();
int num2 = text2.IndexOf('=');
if (num2 >= 0 && int.TryParse(text2.Substring(0, num2).Trim(), out var result) && Enum.TryParse<SiegeWeaponHealth>(text2.Substring(num2 + 1).Trim(), ignoreCase: true, out SiegeWeaponHealth result2))
{
dictionary[result] = result2;
if (result > num)
{
num = result;
}
}
}
SiegeWeaponHealth value;
if (dayIndex < 0)
{
ctx.Reply("<color=#FFD700>[GolemAuto]</color> Day index < 0, no HP mapping.");
}
else if (dictionary.TryGetValue(dayIndex, out value))
{
ctx.Reply($"<color=#FFD700>[GolemAuto]</color> Day {dayIndex} => {value} (via config map)");
}
else if (dayIndex > num && num >= 0)
{
SiegeWeaponHealth value2 = dictionary[num];
ctx.Reply($"<color=#FFD700>[GolemAuto]</color> Day {dayIndex} not mapped; clamped to day {num} => {value2}");
}
else
{
ctx.Reply($"<color=#FFD700>[GolemAuto]</color> Day {dayIndex} is not mapped; no HP change would occur.");
}
}
}
[BepInPlugin("RaidForge", "RaidForge Mod", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class RaidForgePlugin : BasePlugin
{
public static ManualLogSource Logger;
private static float _timeAccumulator = 0f;
private static readonly float TICK_INTERVAL = 0.1f;
public static RaidForgePlugin Instance { get; private set; }
public override void Load()
{
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Expected O, but got Unknown
Instance = this;
Logger = ((BasePlugin)this).Log;
Logger.LogInfo((object)"[RaidForge] Plugin is loading...");
Raidschedule.Initialize(((BasePlugin)this).Config);
((BasePlugin)this).Config.Save();
CommandRegistry.RegisterAll();
RaidtimeManager.Initialize();
GameFrame.Initialize();
GameFrame.OnUpdate += new GameFrameUpdateEventHandler(GameFrame_OnUpdate);
Logger.LogInfo((object)"[RaidForge] Plugin load finished using Bloodstone GameFrame updates.");
}
public override bool Unload()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
Logger.LogInfo((object)"[RaidForge] Unloading plugin...");
GameFrame.OnUpdate -= new GameFrameUpdateEventHandler(GameFrame_OnUpdate);
GameFrame.Uninitialize();
CommandRegistry.UnregisterAssembly();
RaidtimeManager.Dispose();
return true;
}
private void GameFrame_OnUpdate()
{
_timeAccumulator += Time.deltaTime;
if (_timeAccumulator >= 5f)
{
_timeAccumulator = 0f;
RaidtimeManager.OnServerTick();
}
}
}
public static class Raidschedule
{
public static ConfigEntry<string> OverrideMode;
public static ConfigEntry<bool> GolemAutomationEnabled;
public static ConfigEntry<string> GolemStartDateString;
public static ConfigEntry<string> GolemDayToHealthMap;
public static ConfigEntry<string> MondayStart;
public static ConfigEntry<string> MondayEnd;
public static ConfigEntry<string> TuesdayStart;
public static ConfigEntry<string> TuesdayEnd;
public static ConfigEntry<string> WednesdayStart;
public static ConfigEntry<string> WednesdayEnd;
public static ConfigEntry<string> ThursdayStart;
public static ConfigEntry<string> ThursdayEnd;
public static ConfigEntry<string> FridayStart;
public static ConfigEntry<string> FridayEnd;
public static ConfigEntry<string> SaturdayStart;
public static ConfigEntry<string> SaturdayEnd;
public static ConfigEntry<string> SundayStart;
public static ConfigEntry<string> SundayEnd;
public static Dictionary<DayOfWeek, Raidwindow> Windows { get; private set; } = new Dictionary<DayOfWeek, Raidwindow>();
public static void Initialize(ConfigFile config)
{
if (OverrideMode == null)
{
OverrideMode = config.Bind<string>("RaidSchedule", "OverrideMode", "Normal", "ForceOn => always on, ForceOff => always off, Normal => day-of-week scheduling.");
MondayStart = config.Bind<string>("RaidSchedule", "MondayStart", "20:00:00", "Monday start time");
MondayEnd = config.Bind<string>("RaidSchedule", "MondayEnd", "22:00:00", "Monday end time");
TuesdayStart = config.Bind<string>("RaidSchedule", "TuesdayStart", "20:00:00", "Tuesday start time");
TuesdayEnd = config.Bind<string>("RaidSchedule", "TuesdayEnd", "22:00:00", "Tuesday end time");
WednesdayStart = config.Bind<string>("RaidSchedule", "WednesdayStart", "20:00:00", "Wed start time");
WednesdayEnd = config.Bind<string>("RaidSchedule", "WednesdayEnd", "22:00:00", "Wed end time");
ThursdayStart = config.Bind<string>("RaidSchedule", "ThursdayStart", "20:00:00", "Thu start time");
ThursdayEnd = config.Bind<string>("RaidSchedule", "ThursdayEnd", "22:00:00", "Thu end time");
FridayStart = config.Bind<string>("RaidSchedule", "FridayStart", "20:00:00", "Fri start time");
FridayEnd = config.Bind<string>("RaidSchedule", "FridayEnd", "22:00:00", "Fri end time");
SaturdayStart = config.Bind<string>("RaidSchedule", "SaturdayStart", "20:00:00", "Sat start time");
SaturdayEnd = config.Bind<string>("RaidSchedule", "SaturdayEnd", "22:00:00", "Sat end time");
SundayStart = config.Bind<string>("RaidSchedule", "SundayStart", "20:00:00", "Sun start time");
SundayEnd = config.Bind<string>("RaidSchedule", "SundayEnd", "22:00:00", "Sun end time");
GolemAutomationEnabled = config.Bind<bool>("GolemAutomation", "Enabled", false, "Whether Golem day-based HP automation is enabled (on/off).");
GolemStartDateString = config.Bind<string>("GolemAutomation", "StartDate", "", "Date/time for day-0 in 'yyyy-MM-dd HH:mm:ss' format. If empty, no date is set.");
GolemDayToHealthMap = config.Bind<string>("GolemAutomation", "DayToHealthMap", "0=Low,1=Normal,2=High,3=VeryHigh", "Comma-separated list of day=SiegeWeaponHealth pairs.");
LoadFromConfig();
}
}
public static void LoadFromConfig()
{
Windows.Clear();
ParseDay(DayOfWeek.Monday, MondayStart.Value, MondayEnd.Value);
ParseDay(DayOfWeek.Tuesday, TuesdayStart.Value, TuesdayEnd.Value);
ParseDay(DayOfWeek.Wednesday, WednesdayStart.Value, WednesdayEnd.Value);
ParseDay(DayOfWeek.Thursday, ThursdayStart.Value, ThursdayEnd.Value);
ParseDay(DayOfWeek.Friday, FridayStart.Value, FridayEnd.Value);
ParseDay(DayOfWeek.Saturday, SaturdayStart.Value, SaturdayEnd.Value);
ParseDay(DayOfWeek.Sunday, SundayStart.Value, SundayEnd.Value);
}
private static void ParseDay(DayOfWeek day, string startStr, string endStr)
{
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Expected O, but got Unknown
if (TimeSpan.TryParse(startStr, out var result) && TimeSpan.TryParse(endStr, out var result2))
{
if (!(result == TimeSpan.Zero) || !(result2 == TimeSpan.Zero))
{
if (result2 == TimeSpan.Zero && result != TimeSpan.Zero)
{
result2 = new TimeSpan(24, 0, 0);
}
Windows[day] = new Raidwindow
{
Day = day,
Start = result,
End = result2
};
}
return;
}
ManualLogSource logger = RaidForgePlugin.Logger;
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(39, 3, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Raidschedule] Invalid time for ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<DayOfWeek>(day);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": '");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(startStr);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' '");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(endStr);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'");
}
logger.LogWarning(val);
}
}
public static class RaidtimeManager
{
public enum RaidMode
{
ForceOn,
ForceOff,
Normal
}
private static bool _initialized;
private static RaidMode _currentMode = RaidMode.Normal;
private static bool _skipWindow;
private static DayOfWeek _skipDay;
private static TimeSpan _skipStart;
private static TimeSpan _skipEnd;
private static bool? _manualOverride = null;
private static DayOfWeek _manualOverrideDay;
public static void Initialize()
{
_initialized = false;
_skipWindow = false;
_manualOverride = null;
}
public static void Dispose()
{
_initialized = false;
_skipWindow = false;
_manualOverride = null;
}
public static void OnServerTick()
{
if (!_initialized)
{
_initialized = true;
LoadConfig();
RaidForgePlugin.Logger.LogInfo((object)"[RaidtimeManager] Initialized. Using 5s checks via GameFrame.");
GolemAutoManager.LoadConfig();
}
CheckAndToggleRaidMode();
GolemAutoManager.UpdateIfNeeded();
}
public static void ReloadFromConfig(bool immediate = false)
{
LoadConfig();
if (immediate)
{
CheckAndToggleRaidMode();
GolemAutoManager.LoadConfig();
GolemAutoManager.UpdateIfNeeded();
}
}
private static void LoadConfig()
{
string value = Raidschedule.OverrideMode.Value;
if (value.Equals("ForceOn", StringComparison.OrdinalIgnoreCase) || value.Equals("AlwaysOn", StringComparison.OrdinalIgnoreCase))
{
_currentMode = RaidMode.ForceOn;
}
else if (value.Equals("ForceOff", StringComparison.OrdinalIgnoreCase))
{
_currentMode = RaidMode.ForceOff;
}
else
{
_currentMode = RaidMode.Normal;
}
}
private static void CheckAndToggleRaidMode()
{
if (_currentMode == RaidMode.ForceOn)
{
VrisingRaidToggler.EnableRaids(RaidForgePlugin.Logger);
return;
}
if (_currentMode == RaidMode.ForceOff)
{
VrisingRaidToggler.DisableRaids(RaidForgePlugin.Logger);
return;
}
DateTime now = DateTime.Now;
DayOfWeek dayOfWeek = now.DayOfWeek;
TimeSpan timeOfDay = now.TimeOfDay;
if (_manualOverride.HasValue && dayOfWeek != _manualOverrideDay)
{
_manualOverride = null;
}
if (_manualOverride.HasValue)
{
if (_manualOverride.Value)
{
VrisingRaidToggler.EnableRaids(RaidForgePlugin.Logger);
}
else
{
VrisingRaidToggler.DisableRaids(RaidForgePlugin.Logger);
}
return;
}
if (_skipWindow && dayOfWeek != _skipDay)
{
_skipWindow = false;
}
if (_skipWindow && dayOfWeek == _skipDay && timeOfDay >= _skipStart && timeOfDay <= _skipEnd)
{
VrisingRaidToggler.DisableRaids(RaidForgePlugin.Logger);
return;
}
if (_skipWindow && (dayOfWeek != _skipDay || timeOfDay > _skipEnd))
{
_skipWindow = false;
}
if (Raidschedule.Windows.TryGetValue(dayOfWeek, out var value))
{
if (timeOfDay >= value.Start && timeOfDay <= value.End)
{
VrisingRaidToggler.EnableRaids(RaidForgePlugin.Logger);
}
else
{
VrisingRaidToggler.DisableRaids(RaidForgePlugin.Logger);
}
}
else
{
VrisingRaidToggler.DisableRaids(RaidForgePlugin.Logger);
}
}
public static void SkipCurrentWindowIfAny()
{
if (_currentMode == RaidMode.Normal)
{
DateTime now = DateTime.Now;
DayOfWeek dayOfWeek = now.DayOfWeek;
TimeSpan timeOfDay = now.TimeOfDay;
if (Raidschedule.Windows.TryGetValue(dayOfWeek, out var value) && timeOfDay >= value.Start && timeOfDay <= value.End)
{
_skipWindow = true;
_skipDay = dayOfWeek;
_skipStart = value.Start;
_skipEnd = value.End;
}
}
}
public static DateTime? GetNextOnTime(DateTime now)
{
for (int i = 0; i < 7; i++)
{
DateTime dateTime = now.Date.AddDays(i);
DayOfWeek dayOfWeek = dateTime.DayOfWeek;
if (Raidschedule.Windows.TryGetValue(dayOfWeek, out var value))
{
DateTime dateTime2 = dateTime + value.Start;
DateTime dateTime3 = dateTime + value.End;
if ((i != 0 || !(now >= dateTime2) || !(now <= dateTime3)) && dateTime2 > now)
{
return dateTime2;
}
}
}
return null;
}
public static void SetManualOverride(bool forcedOn)
{
_manualOverride = forcedOn;
_manualOverrideDay = DateTime.Now.DayOfWeek;
}
public static void ClearManualOverride()
{
_manualOverride = null;
_skipWindow = false;
}
public static void ClearSkipForTodayIfDayMatches(DayOfWeek changedDay)
{
DayOfWeek dayOfWeek = DateTime.Now.DayOfWeek;
if (_skipWindow && changedDay == _skipDay && changedDay == dayOfWeek)
{
_skipWindow = false;
}
}
}
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(54, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("[SiegeWeaponManager] Updated SGB.SiegeWeaponHealth => ");
((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<SiegeWeaponHealth>(newValue);
}
logger.LogInfo(val4);
return true;
}
catch (Exception ex)
{
BepInExErrorLogInterpolatedStringHandler val5 = new BepInExErrorLogInterpolatedStringHandler(59, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("[SiegeWeaponManager] Error updating SGB.SiegeWeaponHealth: ");
((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("Never");
bool flag2 = SetServerGameBalanceCastleDamage("Never");
}
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";
}
}