Decompiled source of DeziorsFlare v0.8.1

LethalRedFlare.dll

Decompiled 9 months ago
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using LethalLib.Modules;
using LethalRedFlare.Behaviour;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("LethalRedFlare")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LethalRedFlare")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c9ba2e7c-3a74-45db-ac87-24995c20efee")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace LethalGlowStick
{
	[BepInPlugin("DeziorsRedFlareMod", "LethalRedFlare", "0.8.1")]
	public class GlowStick : BaseUnityPlugin
	{
		private const string modGUID = "DeziorsRedFlareMod";

		private const string modName = "LethalRedFlare";

		private const string modVersion = "0.8.1";

		private static GlowStick instance;

		private void Awake()
		{
			instance = this;
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "flaretoggle");
			AssetBundle val = AssetBundle.LoadFromFile(text);
			Item val2 = val.LoadAsset<Item>("Assets/MyGlowStick/extrabright/Flaretoggle.asset");
			val2.toolTips = new string[1] { "ignite Flare: [LMB] \nthis is not synced with other clients jet" };
			Turnonandoff turnonandoff = val2.spawnPrefab.AddComponent<Turnonandoff>();
			((GrabbableObject)turnonandoff).grabbable = true;
			((GrabbableObject)turnonandoff).grabbableToEnemies = true;
			((GrabbableObject)turnonandoff).itemProperties = val2;
			NetworkPrefabs.RegisterNetworkPrefab(val2.spawnPrefab);
			Utilities.FixMixerGroups(val2.spawnPrefab);
			TerminalNode val3 = ScriptableObject.CreateInstance<TerminalNode>();
			val3.clearPreviousText = true;
			val3.displayText = "A flare. Holdit in your hands, drop it on the ground. it emits bright light!\n\n";
			Items.RegisterShopItem(val2, (TerminalNode)null, (TerminalNode)null, val3, 5);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Loaded Item FlareStick");
		}
	}
}
namespace LethalRedFlare.Behaviour
{
	internal class Turnonandoff : PhysicsProp
	{
		private ParticleSystem[] partikles;

		private Light[] lights;

		private bool isOn = false;

		private int timeOn = 0;

		private int maxTime = 80000;

		public override void Start()
		{
			((GrabbableObject)this).Start();
			partikles = ((Component)this).GetComponentsInChildren<ParticleSystem>();
			lights = ((Component)this).GetComponentsInChildren<Light>();
			turnOff();
		}

		public override void EquipItem()
		{
			((PhysicsProp)this).EquipItem();
			if (isOn)
			{
				turnOn();
			}
		}

		public override void DiscardItem()
		{
			((GrabbableObject)this).DiscardItem();
		}

		public override void PocketItem()
		{
			((GrabbableObject)this).PocketItem();
			ParticleSystem[] array = partikles;
			foreach (ParticleSystem val in array)
			{
				val.Stop();
			}
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			if (!buttonDown)
			{
				return;
			}
			if ((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null)
			{
				if (timeOn < maxTime)
				{
					turnOn();
					isOn = true;
					Debug.Log((object)"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA----Flare on");
				}
			}
			else
			{
				Debug.Log((object)"Item used when not held by player ");
			}
		}

		public override void Update()
		{
			((GrabbableObject)this).Update();
			if (isOn)
			{
				timeOn++;
				if (timeOn > maxTime)
				{
					turnOff();
					isOn = true;
				}
			}
		}

		private void turnOff()
		{
			if (partikles != null)
			{
				ParticleSystem[] array = partikles;
				foreach (ParticleSystem val in array)
				{
					val.Stop();
				}
			}
			if (lights != null)
			{
				Light[] array2 = lights;
				foreach (Light val2 in array2)
				{
					((Behaviour)val2).enabled = false;
				}
			}
		}

		private void turnOn()
		{
			if (partikles != null)
			{
				ParticleSystem[] array = partikles;
				foreach (ParticleSystem val in array)
				{
					val.Play();
				}
			}
			if (lights != null)
			{
				Light[] array2 = lights;
				foreach (Light val2 in array2)
				{
					((Behaviour)val2).enabled = true;
				}
			}
		}
	}
}