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.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using ProjectM;
using ScarletCore;
using ScarletCore.Data;
using ScarletCore.Events;
using ScarletCore.Systems;
using ScarletCore.Utils;
using Stunlock.Core;
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("ScarletBrazier")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("ScarletBrazier")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+c4b00f3cc866c2bd6244444ebe553e66dea03809")]
[assembly: AssemblyProduct("ScarletBrazier")]
[assembly: AssemblyTitle("ScarletBrazier")]
[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.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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace ScarletBrazier
{
[BepInPlugin("ScarletBrazier", "ScarletBrazier", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BasePlugin
{
[CommandGroup("brazier", null)]
public class BrazierCommands
{
[Command("enable", "Enables free braziers globally", null, null, null, true)]
public static void Enable(ChatCommandContext ctx)
{
Settings.Set<bool>("EnableGlobally", true);
SetAllBraziersFree();
ctx.Reply(RichTextFormatter.Format("~Free Braziers~ have been enabled globally! All braziers now work without needing bones as fuel.", (List<string>)null));
}
[Command("disable", "Disables free braziers globally", null, null, null, true)]
public static void Disable(ChatCommandContext ctx)
{
Settings.Set<bool>("EnableGlobally", false);
ClearAllBraziers();
ctx.Reply(RichTextFormatter.Format("~Free Braziers~ have been disabled globally. Braziers returned to normal operation.", (List<string>)null));
}
[Command("force", "Forces all braziers to be free", null, null, null, true)]
public static void Force(ChatCommandContext ctx)
{
SetAllBraziersFree();
ctx.Reply(RichTextFormatter.Format("All ~Braziers~ have been forced to be free! They now burn indefinitely without fuel.", (List<string>)null));
}
}
private static Harmony _harmony;
public const string ENABLE_GLOBALLY = "EnableGlobally";
public static Harmony Harmony => _harmony;
public static Plugin Instance { get; private set; }
public static ManualLogSource LogInstance { get; private set; }
public static Settings Settings { get; private set; }
public static Database Database { get; private set; }
public override void Load()
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Expected O, but got Unknown
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Expected O, but got Unknown
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Expected O, but got Unknown
Instance = this;
LogInstance = ((BasePlugin)this).Log;
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>("ScarletBrazier");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" version ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.0.0");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
}
log.LogInfo(val);
_harmony = new Harmony("ScarletBrazier");
_harmony.PatchAll(Assembly.GetExecutingAssembly());
Settings = new Settings("ScarletBrazier", (BasePlugin)(object)Instance);
LoadSettings();
EventManager.OnInitialize += delegate
{
if (Settings.Get<bool>("EnableGlobally"))
{
SetAllBraziersFree();
}
else
{
ClearAllBraziers();
}
};
CommandRegistry.RegisterAll();
}
public override bool Unload()
{
Harmony harmony = _harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
CommandRegistry.UnregisterAssembly();
return true;
}
public static void ReloadSettings()
{
Settings.Dispose();
LoadSettings();
}
public static void LoadSettings()
{
Settings.Section("General").Add<bool>("EnableGlobally", true, "If true, all braziers will work for free without needing bones as fuel.");
}
public static void SetAllBraziersFree()
{
//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_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_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_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_002e: 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_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_0044: 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_0056: 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)
EntityManager entityManager = GameSystems.EntityManager;
EntityQuery val = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly<Bonfire>() });
Enumerator<Entity> enumerator = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)).GetEnumerator();
while (enumerator.MoveNext())
{
Entity current = enumerator.Current;
if (!ECSExtensions.IsNull(current) && ECSExtensions.Exists(current) && ECSExtensions.Has<Bonfire>(current))
{
ECSExtensions.With<Bonfire>(current, (WithRefHandler<Bonfire>)delegate(ref Bonfire bonfire)
{
bonfire.IsActive = true;
bonfire.BurnTime = 31536000f;
});
}
}
}
public static void ClearAllBraziers()
{
//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_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_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_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_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Expected O, but got Unknown
//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_0045: 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_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
EntityManager entityManager = GameSystems.EntityManager;
EntityQuery val = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly<Bonfire>() });
NativeArray<Entity> val2 = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
try
{
Enumerator<Entity> enumerator = val2.GetEnumerator();
while (enumerator.MoveNext())
{
Entity current = enumerator.Current;
if (!ECSExtensions.IsNull(current) && ECSExtensions.Exists(current) && ECSExtensions.Has<Bonfire>(current))
{
ECSExtensions.With<Bonfire>(current, (WithRefHandler<Bonfire>)delegate(ref Bonfire bonfire)
{
bonfire.IsActive = false;
bonfire.BurnTime = 60f;
});
}
}
}
catch (Exception ex)
{
ManualLogSource logInstance = LogInstance;
bool flag = default(bool);
BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(31, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Error while clearing braziers: ");
((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex.Message);
}
logInstance.LogError(val3);
LogInstance.LogDebug((object)ex.StackTrace);
}
finally
{
val2.Dispose();
}
}
}
[HarmonyPatch(typeof(SetTeamOnSpawnSystem), "OnUpdate")]
public static class SetTeamOnSpawnSystemPatch
{
[HarmonyPostfix]
public static void Postfix(SetTeamOnSpawnSystem __instance)
{
//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_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_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_003b: 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_0043: 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_0055: 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_005e: 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_0069: 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)
if (Plugin.Settings.Get<bool>("EnableGlobally"))
{
return;
}
EntityQuery _query_57018132_ = __instance.__query_57018132_0;
Enumerator<Entity> enumerator = ((EntityQuery)(ref _query_57018132_)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)).GetEnumerator();
while (enumerator.MoveNext())
{
Entity current = enumerator.Current;
if (ECSExtensions.IsNull(current) || !ECSExtensions.Exists(current) || !ECSExtensions.Has<Bonfire>(current) || !ECSExtensions.Has<PrefabGUID>(current))
{
continue;
}
PrefabGUID val = ECSExtensions.Read<PrefabGUID>(current);
if (((PrefabGUID)(ref val)).GuidHash == 1756900697)
{
ECSExtensions.With<Bonfire>(current, (WithRefHandler<Bonfire>)delegate(ref Bonfire bonfire)
{
bonfire.IsActive = true;
bonfire.BurnTime = 31536000f;
});
}
}
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "ScarletBrazier";
public const string PLUGIN_NAME = "ScarletBrazier";
public const string PLUGIN_VERSION = "1.0.0";
}
}