Decompiled source of JaydeeCube REPO v1.0.0

com.github.zehsteam.JaydeeCube.dll

Decompiled 2 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using REPOLib;
using REPOLib.Modules;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Zehs")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyCopyright("Copyright © 2025 Zehs")]
[assembly: AssemblyDescription("Adds a JaydeeMoon cube valuable.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+f96f2880befe0aa503f5ad5fa70ba3b259fd9c1f")]
[assembly: AssemblyProduct("JaydeeCube")]
[assembly: AssemblyTitle("com.github.zehsteam.JaydeeCube")]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace com.github.zehsteam.JaydeeCube
{
	internal static class Assets
	{
		public static GameObject JaydeeCubePrefab { get; private set; }

		public static void Initialize()
		{
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			string text = "jaydeecube_assets";
			string text2 = Path.Combine(directoryName, text);
			if (!File.Exists(text2))
			{
				Logger.LogFatal("Failed to load assets. AssetBundle file could not be found at path \"" + text2 + "\". Make sure the \"" + text + "\" file is in the same folder as the mod's DLL file.");
			}
			else
			{
				BundleLoader.LoadBundle(text2, (Action<AssetBundle>)HandleAssetBundleLoaded, false);
			}
		}

		private static void HandleAssetBundleLoaded(AssetBundle assetBundle)
		{
			JaydeeCubePrefab = LoadAsset<GameObject>("Valuable JaydeeCube", assetBundle);
			Valuables.RegisterValuable(JaydeeCubePrefab);
		}

		private static T LoadAsset<T>(string name, AssetBundle assetBundle) where T : Object
		{
			if (string.IsNullOrWhiteSpace(name))
			{
				Logger.LogError("Failed to load asset of type \"" + typeof(T).Name + "\" from AssetBundle. Name is null or whitespace.");
				return default(T);
			}
			if ((Object)(object)assetBundle == (Object)null)
			{
				Logger.LogError("Failed to load asset of type \"" + typeof(T).Name + "\" with name \"" + name + "\" from AssetBundle. AssetBundle is null.");
				return default(T);
			}
			T val = assetBundle.LoadAsset<T>(name);
			if ((Object)(object)val == (Object)null)
			{
				Logger.LogError("Failed to load asset of type \"" + typeof(T).Name + "\" with name \"" + name + "\" from AssetBundle. No asset found with that type and name.");
				return default(T);
			}
			return val;
		}

		private static bool TryLoadAsset<T>(string name, AssetBundle assetBundle, out T asset) where T : Object
		{
			asset = LoadAsset<T>(name, assetBundle);
			return (Object)(object)asset != (Object)null;
		}
	}
	internal static class ConfigManager
	{
		public static ConfigFile ConfigFile { get; private set; }

		public static void Initialize(ConfigFile configFile)
		{
			ConfigFile = configFile;
			BindConfigs();
		}

		private static void BindConfigs()
		{
		}
	}
	internal static class Logger
	{
		public static ManualLogSource ManualLogSource { get; private set; }

		public static void Initialize(ManualLogSource manualLogSource)
		{
			ManualLogSource = manualLogSource;
		}

		public static void LogDebug(object data)
		{
			Log((LogLevel)32, data);
		}

		public static void LogInfo(object data)
		{
			Log((LogLevel)16, data);
		}

		public static void LogWarning(object data)
		{
			Log((LogLevel)4, data);
		}

		public static void LogError(object data)
		{
			Log((LogLevel)2, data);
		}

		public static void LogFatal(object data)
		{
			Log((LogLevel)1, data);
		}

		public static void Log(LogLevel logLevel, object data)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			ManualLogSource manualLogSource = ManualLogSource;
			if (manualLogSource != null)
			{
				manualLogSource.Log(logLevel, data);
			}
		}
	}
	[BepInPlugin("com.github.zehsteam.JaydeeCube", "JaydeeCube", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	internal class Plugin : BaseUnityPlugin
	{
		private readonly Harmony _harmony = new Harmony("com.github.zehsteam.JaydeeCube");

		internal static Plugin Instance { get; private set; }

		private void Awake()
		{
			Instance = this;
			Logger.Initialize(Logger.CreateLogSource("com.github.zehsteam.JaydeeCube"));
			Logger.LogInfo("JaydeeCube has awoken!");
			Assets.Initialize();
			ConfigManager.Initialize(((BaseUnityPlugin)this).Config);
		}
	}
	internal static class Utils
	{
		public static int GetRandomIndexFromWeightList(IEnumerable<int> weights)
		{
			if (weights == null)
			{
				throw new ArgumentNullException("weights");
			}
			int num = 0;
			int num2 = 0;
			foreach (int weight in weights)
			{
				if (weight < 0)
				{
					throw new ArgumentException("Weights must be non-negative.");
				}
				num += weight;
			}
			if (num == 0)
			{
				throw new ArgumentException("At least one weight must be greater than zero.");
			}
			int num3 = Random.Range(0, num);
			int num4 = 0;
			num2 = 0;
			foreach (int weight2 in weights)
			{
				num4 += weight2;
				if (num3 < num4)
				{
					return num2;
				}
				num2++;
			}
			return num2 - 1;
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "com.github.zehsteam.JaydeeCube";

		public const string PLUGIN_NAME = "JaydeeCube";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace com.github.zehsteam.JaydeeCube.MonoBehaviours
{
	[Serializable]
	internal class JaydeeCubeVariant
	{
		public Material Material;

		[Range(0f, 500f)]
		public int Weight = 100;
	}
	internal class JaydeeCube : MonoBehaviour
	{
		[SerializeField]
		private MeshRenderer _meshRenderer;

		[SerializeField]
		private JaydeeCubeVariant[] _variants = Array.Empty<JaydeeCubeVariant>();

		private PhotonView _photonView;

		private void Start()
		{
			_photonView = ((Component)this).GetComponent<PhotonView>();
			if (SemiFunc.IsMasterClient())
			{
				SetRandomVariant();
			}
		}

		private void SetRandomVariant()
		{
			int randomIndexFromWeightList = Utils.GetRandomIndexFromWeightList(_variants.Select((JaydeeCubeVariant x) => x.Weight));
			SetVariant(randomIndexFromWeightList);
		}

		private void SetVariant(int index)
		{
			if (SemiFunc.IsMultiplayer())
			{
				_photonView.RPC("SetVariantRPC", (RpcTarget)0, new object[1] { index });
			}
			else
			{
				SetVariantLocal(index);
			}
		}

		[PunRPC]
		private void SetVariantRPC(int index)
		{
			SetVariantLocal(index);
		}

		private void SetVariantLocal(int index)
		{
			if ((Object)(object)_meshRenderer == (Object)null || index < 0 || index > _variants.Length - 1)
			{
				return;
			}
			JaydeeCubeVariant jaydeeCubeVariant = _variants[index];
			if (jaydeeCubeVariant != null)
			{
				Material material = jaydeeCubeVariant.Material;
				if (!((Object)(object)material == (Object)null))
				{
					((Renderer)_meshRenderer).sharedMaterial = material;
				}
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}