Decompiled source of Repo Flare v0.9.2

repo_flare.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
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_guelikt.repoflare", "Flare Mod Sync", "0.9.3")]
public class Class1 : BaseUnityPlugin
{
	[CompilerGenerated]
	private sealed class <RechargeRoutine>d__11 : 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__11(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

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

		private bool MoveNext()
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			int num = <>1__state;
			if (num != 0)
			{
				if (num != 1)
				{
					return false;
				}
				<>1__state = -1;
				<>4__this.tempsAvantProchaineFlare -= 1f;
				goto IL_0082;
			}
			<>1__state = -1;
			<>4__this.isRecharging = true;
			goto IL_00b1;
			IL_0082:
			if (<>4__this.tempsAvantProchaineFlare > 0f)
			{
				<>2__current = (object)new WaitForSeconds(1f);
				<>1__state = 1;
				return true;
			}
			<>4__this.flaresActuelles++;
			goto IL_00b1;
			IL_00b1:
			if (<>4__this.flaresActuelles < 3)
			{
				<>4__this.tempsAvantProchaineFlare = 50f;
				goto IL_0082;
			}
			<>4__this.tempsAvantProchaineFlare = 0f;
			<>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__12 : 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__12(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(30f);
				<>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 float tempsAvantProchaineFlare = 0f;

	private const float TEMPS_RECHARGE_TOTAL = 50f;

	public static GameObject flarePrefab;

	private void Awake()
	{
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c5: Expected O, but got Unknown
		SceneManager.sceneLoaded += OnSceneLoaded;
		string text = Path.Combine(Paths.PluginPath, "ikt-Repo_Flare", "flare_bundle");
		if (File.Exists(text))
		{
			AssetBundle val = AssetBundle.LoadFromFile(text);
			if ((Object)(object)val != (Object)null)
			{
				flarePrefab = val.LoadAsset<GameObject>("Flare_Mod");
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Flare Mod : 3D Model Loaded Successfully");
			}
			else
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Flare Mod : Failed to load AssetBundle");
			}
		}
		else
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)("Flare Mod : Bundle not found at " + text));
		}
		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 : Network Event Registered");
		}
		catch
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)"Flare Mod : Network Event Registration Failed");
		}
	}

	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;
			tempsAvantProchaineFlare = 0f;
			((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_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)flarePrefab == (Object)null))
		{
			GameObject val = Object.Instantiate<GameObject>(flarePrefab, pos, Random.rotation);
			MeshFilter componentInChildren = val.GetComponentInChildren<MeshFilter>();
			if ((Object)(object)componentInChildren != (Object)null)
			{
			}
			Rigidbody val2 = val.GetComponent<Rigidbody>();
			if ((Object)(object)val2 == (Object)null)
			{
				val2 = val.AddComponent<Rigidbody>();
			}
			val2.interpolation = (RigidbodyInterpolation)1;
			val2.collisionDetectionMode = (CollisionDetectionMode)1;
			val2.AddForce(dir * 15f, (ForceMode)1);
			val2.AddTorque(new Vector3((float)Random.Range(-10, 10), (float)Random.Range(-10, 10), (float)Random.Range(-10, 10)), (ForceMode)1);
			Light val3 = val.GetComponent<Light>();
			if ((Object)(object)val3 == (Object)null)
			{
				val3 = val.AddComponent<Light>();
			}
			val3.type = (LightType)2;
			val3.range = 20f;
			val3.intensity = 5f;
			val3.color = new Color(1f, 0.5f, 0f);
			val3.shadows = (LightShadows)1;
			val3.shadowStrength = 0.9f;
			((MonoBehaviour)this).StartCoroutine(VieDuFlare(val));
		}
	}

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

	[IteratorStateMachine(typeof(<VieDuFlare>d__12))]
	private IEnumerator VieDuFlare(GameObject flare)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <VieDuFlare>d__12(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_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: 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);
			string arg = ((isRecharging && flaresActuelles < 3) ? $" ({Mathf.CeilToInt(tempsAvantProchaineFlare)}s)" : "");
			GUI.Label(new Rect(50f, (float)(Screen.height - 60), 400f, 30f), $"[F] FLARES: {flaresActuelles}/3{arg}");
		}
	}

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