Decompiled source of Repo Flare v0.9.1

guelikt_repo_flare.dll

Decompiled 2 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using ExitGames.Client.Photon;
using Photon.Pun;
using Photon.Realtime;
using REPOLib.Modules;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("repo_flare")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("repo_flare")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("b5989fba-f677-471a-9db8-559adfc01692")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace repo_flare;

[BepInPlugin("com_tonnom.repoflare", "Flare Mod Sync", "2.1.0")]
public class Class1 : BaseUnityPlugin
{
	[CompilerGenerated]
	private sealed class <RechargeRoutine>d__8 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public Class1 <>4__this;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <RechargeRoutine>d__8(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>4__this.isRecharging = true;
				break;
			case 1:
				<>1__state = -1;
				<>4__this.flaresActuelles++;
				break;
			}
			if (<>4__this.flaresActuelles < 3)
			{
				<>2__current = (object)new WaitForSeconds(50f);
				<>1__state = 1;
				return true;
			}
			<>4__this.isRecharging = false;
			return false;
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	[CompilerGenerated]
	private sealed class <VieDuFlare>d__9 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public GameObject flare;

		public Class1 <>4__this;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <VieDuFlare>d__9(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = (object)new WaitForSeconds(20f);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				if ((Object)(object)flare != (Object)null)
				{
					Object.Destroy((Object)(object)flare);
				}
				return false;
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	private int flaresActuelles = 3;

	private bool isRecharging = false;

	private NetworkedEvent flareEvent;

	private static bool hasRegisteredEvent;

	private void Awake()
	{
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Expected O, but got Unknown
		SceneManager.sceneLoaded += OnSceneLoaded;
		if (hasRegisteredEvent)
		{
			return;
		}
		try
		{
			flareEvent = new NetworkedEvent("SpawnFlare", (Action<EventData>)delegate(EventData photonEvent)
			{
				//IL_0020: 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)
				if (photonEvent.CustomData != null)
				{
					object[] array = (object[])photonEvent.CustomData;
					CreerFlarePhysique((Vector3)array[0], (Vector3)array[1]);
				}
			});
			hasRegisteredEvent = true;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Flare Mod : online activate");
		}
		catch
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)"Flare Mod : error loading.");
		}
	}

	private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
	{
		if (((Scene)(ref scene)).name.ToLower().Contains("level") && !((Scene)(ref scene)).name.Contains("Lobby"))
		{
			flaresActuelles = 3;
			isRecharging = false;
			((MonoBehaviour)this).StopAllCoroutines();
		}
	}

	private void Update()
	{
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Invalid comparison between Unknown and I4
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: 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_008c: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Expected O, but got Unknown
		//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
		if (!PhotonNetwork.InRoom || (Object)(object)PlayerController.instance == (Object)null || flareEvent == null || (int)Cursor.lockState != 1 || !Input.GetKeyDown((KeyCode)102) || flaresActuelles <= 0)
		{
			return;
		}
		Camera main = Camera.main;
		if (!((Object)(object)main == (Object)null))
		{
			Vector3 val = ((Component)main).transform.position + ((Component)main).transform.forward * 0.8f;
			Vector3 forward = ((Component)main).transform.forward;
			object[] array = new object[2] { val, forward };
			RaiseEventOptions val2 = new RaiseEventOptions
			{
				Receivers = (ReceiverGroup)1
			};
			PhotonNetwork.RaiseEvent(flareEvent.EventCode, (object)array, val2, SendOptions.SendReliable);
			flaresActuelles--;
			if (!isRecharging)
			{
				((MonoBehaviour)this).StartCoroutine(RechargeRoutine());
			}
		}
	}

	private void CreerFlarePhysique(Vector3 pos, Vector3 dir)
	{
		//IL_000e: 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_0025: 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_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: 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_00ce: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = GameObject.CreatePrimitive((PrimitiveType)0);
		val.transform.position = pos;
		val.transform.localScale = Vector3.one * 0.25f;
		Color val2 = default(Color);
		((Color)(ref val2))..ctor(1f, 0.5f, 0f);
		Renderer component = val.GetComponent<Renderer>();
		component.material.color = val2;
		component.material.EnableKeyword("_EMISSION");
		component.material.SetColor("_EmissionColor", val2 * 15f);
		Rigidbody val3 = val.AddComponent<Rigidbody>();
		val3.AddForce(dir * 10f, (ForceMode)1);
		Light val4 = val.AddComponent<Light>();
		val4.type = (LightType)2;
		val4.range = 30f;
		val4.intensity = 6f;
		val4.color = val2;
		val4.shadows = (LightShadows)2;
		val4.shadowStrength = 1f;
		val4.shadowBias = 0.05f;
		val4.shadowNormalBias = 0.4f;
		((MonoBehaviour)this).StartCoroutine(VieDuFlare(val));
	}

	[IteratorStateMachine(typeof(<RechargeRoutine>d__8))]
	private IEnumerator RechargeRoutine()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <RechargeRoutine>d__8(0)
		{
			<>4__this = this
		};
	}

	[IteratorStateMachine(typeof(<VieDuFlare>d__9))]
	private IEnumerator VieDuFlare(GameObject flare)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <VieDuFlare>d__9(0)
		{
			<>4__this = this,
			flare = flare
		};
	}

	private void OnGUI()
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Invalid comparison between Unknown and I4
		//IL_0038: 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)
		if (PhotonNetwork.InRoom && !((Object)(object)PlayerController.instance == (Object)null) && (int)Cursor.lockState == 1)
		{
			GUI.color = new Color(1f, 0.5f, 0f);
			GUI.Label(new Rect(50f, (float)(Screen.height - 60), 300f, 30f), $"[F]FLARES: {flaresActuelles}/3");
		}
	}

	private void OnDestroy()
	{
		SceneManager.sceneLoaded -= OnSceneLoaded;
	}
}