Decompiled source of Torch Embers v1.0.0

Plugins/VentureValheim.TorchEmbers.dll

Decompiled 4 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Jotunn.Entities;
using Jotunn.Extensions;
using Jotunn.Managers;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("VentureValheim.TorchEmbers")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("VentureValheim.TorchEmbers")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("6DE6E052-925B-48D7-B2EF-01055A89C23E")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace VentureValheim.TorchEmbers
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.orianaventure.mod.TorchEmbers", "TorchEmbers", "1.0.0")]
	public class TorchEmbersPlugin : BaseUnityPlugin
	{
		private const string ModName = "TorchEmbers";

		private const string ModVersion = "1.0.0";

		private const string Author = "com.orianaventure.mod";

		private const string ModGUID = "com.orianaventure.mod.TorchEmbers";

		private readonly Harmony HarmonyInstance = new Harmony("com.orianaventure.mod.TorchEmbers");

		public static readonly ManualLogSource TorchEmbersLogger = Logger.CreateLogSource("TorchEmbers");

		internal static AssetBundle EmberBundle = null;

		public void Awake()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			TorchEmbersLogger.LogInfo((object)"I want to be 24 again and able to see in the dark lulz");
			EmberBundle = AssetUtils.LoadAssetBundleFromResources("vv_torchembers", Assembly.GetExecutingAssembly());
			CustomPrefab val = new CustomPrefab(EmberBundle, "VV_TorchEmber", true);
			PrefabManager.Instance.AddPrefab(val);
			PrefabManager.OnVanillaPrefabsAvailable += TorchEmbers.ApplyChanges;
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			HarmonyInstance.PatchAll(executingAssembly);
		}
	}
	public class TorchEmbers
	{
		private struct EmberConfig
		{
			public string Prefab;

			public Vector3 Position;

			public EmberConfig(string prefab, Vector3 position)
			{
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_0009: Unknown result type (might be due to invalid IL or missing references)
				Prefab = prefab;
				Position = position;
			}
		}

		public const string EMBER_PREFAB = "VV_TorchEmber";

		private static readonly List<EmberConfig> Torches = new List<EmberConfig>
		{
			new EmberConfig("piece_groundtorch", new Vector3(0f, 0.74f, 0f)),
			new EmberConfig("piece_groundtorch_blue", new Vector3(0f, 0.74f, 0f)),
			new EmberConfig("piece_groundtorch_green", new Vector3(0f, 0.74f, 0f)),
			new EmberConfig("piece_groundtorch_wood", new Vector3(0f, 0.78f, 0f)),
			new EmberConfig("piece_walltorch", new Vector3(0.135f, 0.48f, 0f))
		};

		public static void ApplyChanges()
		{
			//IL_008d: 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_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)
			GameObject prefab = Cache.GetPrefab<GameObject>("VV_TorchEmber");
			if ((Object)(object)prefab == (Object)null)
			{
				TorchEmbersPlugin.TorchEmbersLogger.LogWarning((object)"Cannot apply ember configurations.");
				return;
			}
			foreach (EmberConfig torch in Torches)
			{
				GameObject prefab2 = Cache.GetPrefab<GameObject>(torch.Prefab);
				if ((Object)(object)prefab2 == (Object)null)
				{
					TorchEmbersPlugin.TorchEmbersLogger.LogDebug((object)$"Cannot find object for {torch}.");
				}
				else if (!((Object)(object)TransformExtensions.FindDeepChild(prefab2.transform, "VV_TorchEmber", (IterativeSearchType)1) != (Object)null))
				{
					GameObject obj = Object.Instantiate<GameObject>(prefab, prefab2.transform.position + torch.Position, Quaternion.identity);
					obj.transform.parent = prefab2.transform;
					((Object)obj).name = "VV_TorchEmber";
					TorchEmbersPlugin.TorchEmbersLogger.LogDebug((object)("Attached ember for " + ((Object)prefab2).name));
				}
			}
			TorchEmbersPlugin.TorchEmbersLogger.LogInfo((object)"Done applying ember configurations.");
		}
	}
}