using System; using System.Collections; 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 BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ExitGames.Client.Photon; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using Photon.Realtime; using REPOLib.Modules; using UnityEngine; using UnityEngine.Networking; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Empress")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("EmpressTriforce")] [assembly: AssemblyTitle("EmpressTriforce")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 Empress.REPO.Triforce { [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("com.empress.repo.triforce", "Empress Triforce", "1.0.0")] public sealed class EmpressTriforcePlugin : BaseUnityPlugin { public const string PluginGuid = "com.empress.repo.triforce"; public const string PluginName = "Empress Triforce"; public const string PluginVersion = "1.0.0"; public const string ItemName = "Empress Triforce"; internal const byte TriforceUseEventCode = 187; private static bool _photonHooked; private static LoadBalancingClient _hookedClient; private Harmony _harmony; internal static EmpressTriforcePlugin Instance { get; private set; } internal static ManualLogSource Log { get; private set; } internal static TriforceSettings Settings { get; private set; } internal static string PluginDirectory { get; private set; } private void Awake() { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; PluginDirectory = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); Settings = new TriforceSettings(((BaseUnityPlugin)this).Config); ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); TriforceAssets.Load(); TriforceItemBuilder.RegisterItem(); _harmony = new Harmony("com.empress.repo.triforce"); _harmony.PatchAll(typeof(EmpressTriforcePlugin).Assembly); TriforceRuntime.EnsureHost(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Empress Triforce v1.0.0 loaded."); } private void OnDestroy() { RemovePhotonHook(); } internal static void EnsurePhotonHooked() { LoadBalancingClient networkingClient = PhotonNetwork.NetworkingClient; if (networkingClient != null && (!_photonHooked || _hookedClient != networkingClient)) { if (_hookedClient != null) { _hookedClient.EventReceived -= OnPhotonEvent; } networkingClient.EventReceived -= OnPhotonEvent; networkingClient.EventReceived += OnPhotonEvent; _hookedClient = networkingClient; _photonHooked = true; } } internal static void RemovePhotonHook() { if (_hookedClient != null) { _hookedClient.EventReceived -= OnPhotonEvent; } _hookedClient = null; _photonHooked = false; } private static void OnPhotonEvent(EventData ev) { if (ev.CustomData is object[] data) { TriforceRuntime instance = TriforceRuntime.Instance; if (!((Object)(object)instance == (Object)null) && ev.Code == 187) { instance.ReceiveTriforceUse(data); } } } internal static void RaiseToAll(byte code, object[] data) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_0035: Unknown result type (might be due to invalid IL or missing references) EnsurePhotonHooked(); if (!PhotonNetwork.InRoom) { if (code == 187) { TriforceRuntime.Instance?.ReceiveTriforceUse(data); } } else { RaiseEventOptions val = new RaiseEventOptions { Receivers = (ReceiverGroup)1 }; PhotonNetwork.RaiseEvent(code, (object)data, val, SendOptions.SendReliable); } } } internal sealed class TriforceSettings { public readonly ConfigEntry ShopPrice; public readonly ConfigEntry PulseTime; public readonly ConfigEntry BlastRadius; public readonly ConfigEntry BlastForce; public readonly ConfigEntry HealAmount; public readonly ConfigEntry Volume; public readonly ConfigEntry HearingRange; public TriforceSettings(ConfigFile config) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Expected O, but got Unknown //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Expected O, but got Unknown //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Expected O, but got Unknown //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Expected O, but got Unknown ShopPrice = config.Bind("Triforce", "ShopPrice", 40, new ConfigDescription("In game shop price in thousands. 40 means 40K on the shelf.", (AcceptableValueBase)(object)new AcceptableValueRange(1, 500), Array.Empty())); PulseTime = config.Bind("Triforce", "PulseTime", 5f, new ConfigDescription("Seconds into the use sound when the pulse fires.", (AcceptableValueBase)(object)new AcceptableValueRange(2f, 15f), Array.Empty())); BlastRadius = config.Bind("Triforce", "BlastRadius", 10f, new ConfigDescription("How far the pulse blasts players and items back.", (AcceptableValueBase)(object)new AcceptableValueRange(3f, 30f), Array.Empty())); BlastForce = config.Bind("Triforce", "BlastForce", 12f, new ConfigDescription("How hard the pulse shoves everything.", (AcceptableValueBase)(object)new AcceptableValueRange(2f, 40f), Array.Empty())); HealAmount = config.Bind("Triforce", "HealAmount", 100, new ConfigDescription("How much health every player gets at the pulse.", (AcceptableValueBase)(object)new AcceptableValueRange(10, 200), Array.Empty())); Volume = config.Bind("Audio", "Volume", 0.8f, new ConfigDescription("Triforce sound volume.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), Array.Empty())); HearingRange = config.Bind("Audio", "HearingRange", 14f, new ConfigDescription("How many meters away players can hear the triforce.", (AcceptableValueBase)(object)new AcceptableValueRange(4f, 40f), Array.Empty())); } } internal static class TriforceAccess { private static readonly FieldInfo ItemLocalizedNameField = AccessTools.Field(typeof(Item), "itemNameLocalized"); private static readonly FieldRef ItemNameRef = AccessTools.FieldRefAccess("itemName"); private static readonly FieldRef InstanceNameRef = AccessTools.FieldRefAccess("instanceName"); private static readonly FieldRef InputDisableTimerRef = AccessTools.FieldRefAccess("InputDisableTimer"); private static readonly FieldRef HeldByLocalRef = AccessTools.FieldRefAccess("heldByLocalPlayer"); private static readonly FieldRef IsDisabledRef = AccessTools.FieldRefAccess("isDisabled"); private static readonly FieldRef AvatarHealthRef = AccessTools.FieldRefAccess("playerHealth"); private static readonly FieldRef LevelIsShopRef = AccessTools.FieldRefAccess("levelIsShop"); internal static bool InputAllowed() { if ((Object)(object)PlayerController.instance != (Object)null) { return InputDisableTimerRef.Invoke(PlayerController.instance) <= 0f; } return false; } internal static bool InShop() { if (!SemiFunc.RunIsShop() && !SemiFunc.RunIsLobby()) { if ((Object)(object)RunManager.instance != (Object)null) { return LevelIsShopRef.Invoke(RunManager.instance); } return false; } return true; } internal static bool HeldByLocal(PhysGrabObject grab) { if ((Object)(object)grab != (Object)null) { return HeldByLocalRef.Invoke(grab); } return false; } internal static bool IsDisabled(PlayerAvatar avatar) { if ((Object)(object)avatar != (Object)null) { return IsDisabledRef.Invoke(avatar); } return false; } internal static PlayerHealth Health(PlayerAvatar avatar) { if (!((Object)(object)avatar != (Object)null)) { return null; } return AvatarHealthRef.Invoke(avatar); } internal static PlayerAvatar LocalAvatar() { if (!((Object)(object)PlayerController.instance != (Object)null)) { return null; } return PlayerController.instance.playerAvatarScript; } internal static List Players() { if (!((Object)(object)GameDirector.instance != (Object)null) || GameDirector.instance.PlayerList == null) { return new List(); } return GameDirector.instance.PlayerList; } internal static void SetItemName(ItemAttributes attributes, string name) { if (!((Object)(object)attributes == (Object)null)) { ItemNameRef.Invoke(attributes) = name; InstanceNameRef.Invoke(attributes) = name; } } internal static string InstanceName(ItemAttributes attributes) { if (!((Object)(object)attributes != (Object)null)) { return null; } return InstanceNameRef.Invoke(attributes); } internal static void ClearLocalizedName(Item item) { if ((Object)(object)item != (Object)null) { ItemLocalizedNameField?.SetValue(item, null); } } } internal static class TriforceAssets { private const string BundleFile = "empresstriforce.empress"; private const string PrefabName = "EmpressTriforce"; private static AssetBundle _bundle; private static bool _loaded; private static readonly Dictionary Clips = new Dictionary(StringComparer.OrdinalIgnoreCase); internal static GameObject TriforcePrefab { get; private set; } internal static AudioClip Clip(string name) { Clips.TryGetValue(name, out var value); return value; } internal static void Load() { if (_loaded) { return; } _loaded = true; string text = Path.Combine(EmpressTriforcePlugin.PluginDirectory ?? string.Empty, "bundles", "empresstriforce.empress"); if (File.Exists(text)) { _bundle = AssetBundle.LoadFromFile(text); TriforcePrefab = (((Object)(object)_bundle != (Object)null) ? _bundle.LoadAsset("EmpressTriforce") : null); if ((Object)(object)TriforcePrefab == (Object)null && (Object)(object)_bundle != (Object)null) { string text2 = _bundle.GetAllAssetNames().FirstOrDefault((string name) => name.EndsWith(".prefab")); if (!string.IsNullOrEmpty(text2)) { TriforcePrefab = _bundle.LoadAsset(text2); } } } else { ManualLogSource log = EmpressTriforcePlugin.Log; if (log != null) { log.LogError((object)("Empress Triforce bundle missing: " + text)); } } ManualLogSource log2 = EmpressTriforcePlugin.Log; if (log2 != null) { log2.LogInfo((object)("Empress Triforce assets loaded. Model: " + (((Object)(object)TriforcePrefab != (Object)null) ? ((Object)TriforcePrefab).name : "MISSING"))); } } internal static IEnumerator LoadAudio() { string path = Path.Combine(EmpressTriforcePlugin.PluginDirectory ?? string.Empty, "audio"); if (!Directory.Exists(path)) { yield break; } string[] files = Directory.GetFiles(path, "*.ogg"); foreach (string text in files) { string key = Path.GetFileNameWithoutExtension(text); UnityWebRequest request = UnityWebRequestMultimedia.GetAudioClip("file://" + text, (AudioType)14); try { yield return request.SendWebRequest(); if ((int)request.result == 1) { AudioClip content = DownloadHandlerAudioClip.GetContent(request); if ((Object)(object)content != (Object)null) { ((Object)content).name = key; Clips[key] = content; } } } finally { ((IDisposable)request)?.Dispose(); } } ManualLogSource log = EmpressTriforcePlugin.Log; if (log != null) { log.LogInfo((object)("Empress Triforce audio loaded: " + Clips.Count + " clips.")); } } } internal sealed class TriforceItem : MonoBehaviour { private PhysGrabObject _grab; private PhotonView _view; private bool _used; private void Awake() { _grab = ((Component)this).GetComponent(); _view = ((Component)this).GetComponent(); } private void Update() { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) if (!_used && !((Object)(object)_grab == (Object)null) && !TriforceAccess.InShop() && TriforceAccess.HeldByLocal(_grab) && TriforceAccess.InputAllowed() && SemiFunc.InputDown((InputKey)2)) { _used = true; int num = (((Object)(object)_view != (Object)null) ? _view.ViewID : (-1)); Vector3 position = ((Component)this).transform.position; EmpressTriforcePlugin.EnsurePhotonHooked(); EmpressTriforcePlugin.RaiseToAll(187, new object[4] { num, position.x, position.y, position.z }); Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].enabled = false; } } } } internal static class TriforceItemBuilder { private static readonly string[] TemplatePaths = new string[4] { "Items/Item Grenade Human", "Items/Item Grenade Explosive", "Items/Item Grenade Stun", "Items/Item Grenade Duct Taped" }; private static GameObject _prefab; private static Item _item; private static bool _registered; internal static void RegisterItem() { //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) if (_registered) { return; } GameObject val = null; for (int i = 0; i < TemplatePaths.Length; i++) { val = Resources.Load(TemplatePaths[i]); if ((Object)(object)val != (Object)null) { break; } } if ((Object)(object)val == (Object)null) { EmpressTriforcePlugin.Log.LogError((object)"Empress Triforce could not find a template item."); return; } ItemAttributes component = val.GetComponent(); if ((Object)(object)component == (Object)null || (Object)(object)component.item == (Object)null) { EmpressTriforcePlugin.Log.LogError((object)"Empress Triforce template has no ItemAttributes."); return; } GameObject val2 = new GameObject("Empress Triforce Prefabs"); Object.DontDestroyOnLoad((Object)(object)val2); ((Object)val2).hideFlags = (HideFlags)61; val2.SetActive(false); _prefab = Object.Instantiate(val, val2.transform); ((Object)_prefab).name = "Empress Triforce"; MonoBehaviour[] componentsInChildren = _prefab.GetComponentsInChildren(true); foreach (MonoBehaviour val3 in componentsInChildren) { if (!((Object)(object)val3 == (Object)null)) { string name = ((object)val3).GetType().Name; if (name.StartsWith("ItemGrenade") || name == "ItemToggle" || name == "ItemBattery") { Object.DestroyImmediate((Object)(object)val3); } } } Renderer[] componentsInChildren2 = _prefab.GetComponentsInChildren(true); for (int j = 0; j < componentsInChildren2.Length; j++) { componentsInChildren2[j].enabled = false; } if ((Object)(object)TriforceAssets.TriforcePrefab != (Object)null) { GameObject val4 = Object.Instantiate(TriforceAssets.TriforcePrefab, _prefab.transform, false); ((Object)val4).name = "Empress Triforce Visual"; val4.transform.localPosition = new Vector3(0f, 0.06f, 0f); val4.transform.localRotation = Quaternion.identity; Collider[] componentsInChildren3 = val4.GetComponentsInChildren(true); for (int j = 0; j < componentsInChildren3.Length; j++) { Object.DestroyImmediate((Object)(object)componentsInChildren3[j]); } Animation component2 = val4.GetComponent(); if ((Object)(object)component2 != (Object)null) { AnimationClip clip = component2.clip; if ((Object)(object)clip != (Object)null) { clip.SampleAnimation(val4, Mathf.Max(0f, clip.length - 0.001f)); } Object.DestroyImmediate((Object)(object)component2); } ScaleToSize(val4, 0.5f); componentsInChildren2 = val4.GetComponentsInChildren(true); for (int j = 0; j < componentsInChildren2.Length; j++) { componentsInChildren2[j].enabled = true; } ReplaceColliders(val4); } _prefab.AddComponent(); Item item = component.item; _item = Object.Instantiate(item); ((Object)_item).name = "Empress Triforce"; _item.itemName = "Empress Triforce"; TriforceAccess.ClearLocalizedName(_item); _item.itemSecretShopType = (itemSecretShopType)0; _item.maxAmount = 3; _item.maxAmountInShop = 2; _item.maxPurchase = false; _item.maxPurchaseAmount = 3; float value = (float)EmpressTriforcePlugin.Settings.ShopPrice.Value * 250f; Value val5 = (((Object)(object)item.value != (Object)null) ? Object.Instantiate(item.value) : ScriptableObject.CreateInstance()); SetFloatFieldContaining(val5, "min", value); SetFloatFieldContaining(val5, "max", value); _item.value = val5; ItemAttributes component3 = _prefab.GetComponent(); component3.item = _item; TriforceAccess.SetItemName(component3, "Empress Triforce"); _registered = Items.RegisterItem(component3) != null; EmpressTriforcePlugin.Log.LogInfo((object)("Empress Triforce item registered: " + _registered)); } private static void ReplaceColliders(GameObject visual) { //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: 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) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) List list = new List(); Collider[] componentsInChildren = _prefab.GetComponentsInChildren(true); foreach (Collider val in componentsInChildren) { if ((Object)(object)val != (Object)null && ((Object)(object)visual == (Object)null || !((Component)val).transform.IsChildOf(visual.transform))) { list.Add(val); } } if (list.Count == 0) { return; } GameObject gameObject = ((Component)list[0]).gameObject; PhysicMaterial sharedMaterial = list[0].sharedMaterial; for (int num = list.Count - 1; num >= 0; num--) { if (!((Object)(object)list[num] == (Object)null)) { if ((Object)(object)((Component)list[num]).gameObject == (Object)(object)gameObject) { Object.DestroyImmediate((Object)(object)list[num]); } else { Object.DestroyImmediate((Object)(object)((Component)list[num]).gameObject); } } } Bounds val2 = BoundsInSpace(gameObject.transform, visual); BoxCollider obj = gameObject.AddComponent(); obj.center = ((Bounds)(ref val2)).center; obj.size = Vector3.Max(((Bounds)(ref val2)).size, new Vector3(0.08f, 0.05f, 0.08f)); ((Collider)obj).sharedMaterial = sharedMaterial; } private static Bounds BoundsInSpace(Transform space, GameObject target) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: 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) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) Bounds result = default(Bounds); ((Bounds)(ref result))..ctor(Vector3.zero, Vector3.zero); bool flag = false; MeshFilter[] componentsInChildren = target.GetComponentsInChildren(true); foreach (MeshFilter val in componentsInChildren) { if ((Object)(object)val == (Object)null || (Object)(object)val.sharedMesh == (Object)null) { continue; } Bounds bounds = val.sharedMesh.bounds; Matrix4x4 val2 = space.worldToLocalMatrix * ((Component)val).transform.localToWorldMatrix; for (int j = 0; j < 8; j++) { Vector3 val3 = ((Bounds)(ref bounds)).center + Vector3.Scale(((Bounds)(ref bounds)).extents, new Vector3(((j & 1) == 0) ? (-1f) : 1f, ((j & 2) == 0) ? (-1f) : 1f, ((j & 4) == 0) ? (-1f) : 1f)); Vector3 val4 = ((Matrix4x4)(ref val2)).MultiplyPoint3x4(val3); if (!flag) { ((Bounds)(ref result))..ctor(val4, Vector3.zero); flag = true; } else { ((Bounds)(ref result)).Encapsulate(val4); } } } return result; } internal static void ScaleToSize(GameObject target, float maxDimension) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) Bounds val = default(Bounds); ((Bounds)(ref val))..ctor(target.transform.position, Vector3.zero); bool flag = false; MeshFilter[] componentsInChildren = target.GetComponentsInChildren(true); foreach (MeshFilter val2 in componentsInChildren) { if ((Object)(object)val2 == (Object)null || (Object)(object)val2.sharedMesh == (Object)null) { continue; } Bounds bounds = val2.sharedMesh.bounds; Matrix4x4 val3 = target.transform.worldToLocalMatrix * ((Component)val2).transform.localToWorldMatrix; for (int j = 0; j < 8; j++) { Vector3 val4 = ((Bounds)(ref bounds)).center + Vector3.Scale(((Bounds)(ref bounds)).extents, new Vector3(((j & 1) == 0) ? (-1f) : 1f, ((j & 2) == 0) ? (-1f) : 1f, ((j & 4) == 0) ? (-1f) : 1f)); Vector3 val5 = ((Matrix4x4)(ref val3)).MultiplyPoint3x4(val4); if (!flag) { ((Bounds)(ref val))..ctor(val5, Vector3.zero); flag = true; } else { ((Bounds)(ref val)).Encapsulate(val5); } } } if (flag) { float num = Mathf.Max(((Bounds)(ref val)).size.x, Mathf.Max(((Bounds)(ref val)).size.y, ((Bounds)(ref val)).size.z)); if (!(num <= 0.0001f)) { float num2 = maxDimension / num; target.transform.localScale = target.transform.localScale * num2; } } } private static void SetFloatFieldContaining(object target, string token, float value) { if (target == null) { return; } FieldInfo[] fields = target.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo in fields) { if (fieldInfo.FieldType == typeof(float) && fieldInfo.Name.ToLowerInvariant().Contains(token)) { fieldInfo.SetValue(target, value); } } } } internal sealed class TriforceRuntime : MonoBehaviour { private sealed class UseEffect { internal int ItemViewId; internal GameObject Root; internal Transform Model; internal Renderer[] ModelRenderers; internal Animation Anim; internal AudioSource UseAudio; internal AudioSource PulseAudio; internal Light Glow; internal Transform Shockwave; internal Material ShockwaveMaterial; internal Vector3 StartPos; internal float StartTime; internal bool Pulsed; } private const float RiseTime = 1.2f; private const float RiseHeight = 1f; private readonly List _effects = new List(); public static TriforceRuntime Instance { get; private set; } public static TriforceRuntime EnsureHost() { //IL_0018: 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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown if ((Object)(object)Instance != (Object)null) { return Instance; } GameObject val = new GameObject("Empress Triforce Runtime"); val.transform.parent = null; ((Object)val).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)val); Instance = val.AddComponent(); return Instance; } private void Awake() { Instance = this; ((MonoBehaviour)this).StartCoroutine(TriforceAssets.LoadAudio()); } private void Update() { //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) EmpressTriforcePlugin.EnsurePhotonHooked(); float value = EmpressTriforcePlugin.Settings.PulseTime.Value; float value2 = EmpressTriforcePlugin.Settings.Volume.Value; for (int num = _effects.Count - 1; num >= 0; num--) { UseEffect useEffect = _effects[num]; if ((Object)(object)useEffect.Root == (Object)null) { _effects.RemoveAt(num); } else { float num2 = Time.time - useEffect.StartTime; float num3 = Mathf.SmoothStep(0f, 1f, Mathf.Clamp01(num2 / 1.2f)) * 1f; float num4 = ((num2 > 1.2f) ? (Mathf.Sin((num2 - 1.2f) * 2.2f) * 0.06f) : 0f); useEffect.Root.transform.position = useEffect.StartPos + Vector3.up * (num3 + num4); if ((Object)(object)useEffect.Model != (Object)null && !useEffect.Pulsed) { float num5 = Mathf.Clamp01(num2 / value); float num6 = Mathf.Lerp(60f, 900f, num5 * num5); useEffect.Model.Rotate(0f, num6 * Time.deltaTime, 0f, (Space)0); } if ((Object)(object)useEffect.UseAudio != (Object)null) { float num7 = Mathf.Clamp01(num2 / 0.4f); float num8 = (useEffect.Pulsed ? Mathf.Clamp01(1f - (num2 - value) / 0.6f) : 1f); useEffect.UseAudio.volume = num7 * num8 * value2; } if (!useEffect.Pulsed && num2 >= value) { useEffect.Pulsed = true; DoPulse(useEffect); } if (useEffect.Pulsed) { float num9 = num2 - value; if ((Object)(object)useEffect.PulseAudio != (Object)null && (Object)(object)useEffect.PulseAudio.clip != (Object)null) { float num10 = Mathf.Clamp01(num9 / 0.08f) * Mathf.Clamp01((useEffect.PulseAudio.clip.length - num9) / 0.7f); useEffect.PulseAudio.volume = Mathf.Clamp01(num10) * value2; } if ((Object)(object)useEffect.Shockwave != (Object)null) { float num11 = 1f - Mathf.Pow(1f - Mathf.Clamp01(num9 / 0.6f), 2f); float num12 = Mathf.Lerp(0.6f, EmpressTriforcePlugin.Settings.BlastRadius.Value * 2f, num11); useEffect.Shockwave.localScale = Vector3.one * num12; if ((Object)(object)useEffect.ShockwaveMaterial != (Object)null) { Color color = useEffect.ShockwaveMaterial.color; color.a = 0.22f * (1f - Mathf.Clamp01(num9 / 0.7f)); useEffect.ShockwaveMaterial.color = color; } if (num9 > 0.8f) { ((Component)useEffect.Shockwave).gameObject.SetActive(false); } } if ((Object)(object)useEffect.Glow != (Object)null) { useEffect.Glow.intensity = Mathf.Lerp(6f, 0f, Mathf.Clamp01(num9 / 1.2f)); } } else if ((Object)(object)useEffect.Glow != (Object)null) { useEffect.Glow.intensity = 1.2f + Mathf.Clamp01(num2 / value) * 2f; } if (num2 >= value + 3.2f) { Object.Destroy((Object)(object)useEffect.Root); _effects.RemoveAt(num); } } } } internal void ReceiveTriforceUse(object[] data) { //IL_0065: Unknown result type (might be due to invalid IL or missing references) if (data == null || data.Length < 4) { return; } int num = Convert.ToInt32(data[0]); for (int i = 0; i < _effects.Count; i++) { if (_effects[i].ItemViewId == num) { return; } } Vector3 position = default(Vector3); ((Vector3)(ref position))..ctor(Convert.ToSingle(data[1]), Convert.ToSingle(data[2]), Convert.ToSingle(data[3])); _effects.Add(BuildEffect(num, position)); if (!SemiFunc.IsMasterClientOrSingleplayer() || num <= 0) { return; } PhotonView val = PhotonView.Find(num); if ((Object)(object)val != (Object)null && (Object)(object)((Component)val).gameObject != (Object)null) { string text = TriforceAccess.InstanceName(((Component)val).gameObject.GetComponent()); if ((Object)(object)StatsManager.instance != (Object)null && !string.IsNullOrEmpty(text)) { StatsManager.instance.ItemRemove(text); } if (PhotonNetwork.InRoom) { PhotonNetwork.Destroy(((Component)val).gameObject); } else { Object.Destroy((Object)(object)((Component)val).gameObject); } } } private UseEffect BuildEffect(int itemViewId, Vector3 position) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_015a: 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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Expected O, but got Unknown //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Empress Triforce Effect"); val.transform.position = position; Transform model = null; Renderer[] modelRenderers = null; Animation val2 = null; if ((Object)(object)TriforceAssets.TriforcePrefab != (Object)null) { GameObject val3 = Object.Instantiate(TriforceAssets.TriforcePrefab, val.transform, false); ((Object)val3).name = "Triforce"; val3.transform.localPosition = Vector3.zero; val3.transform.localRotation = Quaternion.identity; Collider[] componentsInChildren = val3.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.Destroy((Object)(object)componentsInChildren[i]); } model = val3.transform; modelRenderers = val3.GetComponentsInChildren(true); val2 = val3.GetComponent(); if ((Object)(object)val2 != (Object)null && (Object)(object)val2.clip != (Object)null) { val2.clip.SampleAnimation(val3, Mathf.Max(0f, val2.clip.length - 0.001f)); } TriforceItemBuilder.ScaleToSize(val3, 0.5f); if ((Object)(object)val2 != (Object)null && (Object)(object)val2.clip != (Object)null) { val2[((Object)val2.clip).name].wrapMode = (WrapMode)1; val2.Play(((Object)val2.clip).name); } } Light val4 = val.AddComponent(); val4.type = (LightType)2; val4.color = new Color(1f, 0.85f, 0.3f); val4.range = 7f; val4.intensity = 1.2f; val4.shadows = (LightShadows)0; float value = EmpressTriforcePlugin.Settings.HearingRange.Value; AudioSource val5 = BuildAudioSource(val, value); val5.clip = TriforceAssets.Clip("triforce_use"); val5.volume = 0f; if ((Object)(object)val5.clip != (Object)null) { val5.Play(); } AudioSource val6 = BuildAudioSource(val, value); val6.clip = TriforceAssets.Clip("triforce_pulse"); GameObject val7 = GameObject.CreatePrimitive((PrimitiveType)0); Object.Destroy((Object)(object)val7.GetComponent()); ((Object)val7).name = "Pulse"; val7.transform.SetParent(val.transform, false); val7.transform.localPosition = Vector3.zero; val7.transform.localScale = Vector3.one * 0.6f; Material val8 = new Material(Shader.Find("Sprites/Default")) { color = new Color(1f, 0.9f, 0.45f, 0f) }; Renderer component = val7.GetComponent(); component.sharedMaterial = val8; component.shadowCastingMode = (ShadowCastingMode)0; val7.SetActive(false); return new UseEffect { ItemViewId = itemViewId, Root = val, Model = model, ModelRenderers = modelRenderers, Anim = val2, UseAudio = val5, PulseAudio = val6, Glow = val4, Shockwave = val7.transform, ShockwaveMaterial = val8, StartPos = position, StartTime = Time.time }; } private static AudioSource BuildAudioSource(GameObject host, float hearing) { AudioSource obj = host.AddComponent(); obj.spatialBlend = 1f; obj.minDistance = Mathf.Min(2f, hearing * 0.15f); obj.maxDistance = hearing; obj.rolloffMode = (AudioRolloffMode)1; obj.playOnAwake = false; return obj; } private void DoPulse(UseEffect effect) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) Vector3 position = effect.Root.transform.position; if ((Object)(object)effect.Anim != (Object)null) { effect.Anim.Stop(); } if (effect.ModelRenderers != null) { for (int i = 0; i < effect.ModelRenderers.Length; i++) { if ((Object)(object)effect.ModelRenderers[i] != (Object)null) { effect.ModelRenderers[i].enabled = false; } } } if ((Object)(object)effect.Shockwave != (Object)null) { ((Component)effect.Shockwave).gameObject.SetActive(true); } if ((Object)(object)effect.PulseAudio != (Object)null && (Object)(object)effect.PulseAudio.clip != (Object)null) { effect.PulseAudio.volume = 0f; effect.PulseAudio.Play(); } float value = EmpressTriforcePlugin.Settings.BlastRadius.Value; float value2 = EmpressTriforcePlugin.Settings.BlastForce.Value; PlayerAvatar val = TriforceAccess.LocalAvatar(); if ((Object)(object)val != (Object)null && !TriforceAccess.IsDisabled(val) && (Object)(object)PlayerController.instance != (Object)null) { Vector3 val2 = ((Component)val).transform.position - position; if (((Vector3)(ref val2)).magnitude <= value) { val2.y *= 0.35f; Vector3 val3 = ((((Vector3)(ref val2)).sqrMagnitude > 0.01f) ? ((Vector3)(ref val2)).normalized : Vector3.up); PlayerController.instance.ForceImpulse(val3 * value2 + Vector3.up * value2 * 0.3f); } } if (!SemiFunc.IsMasterClientOrSingleplayer()) { return; } List list = TriforceAccess.Players(); for (int j = 0; j < list.Count; j++) { PlayerAvatar val4 = list[j]; if ((Object)(object)val4 != (Object)null && TriforceAccess.IsDisabled(val4)) { val4.Revive(false); } } for (int k = 0; k < list.Count; k++) { PlayerHealth val5 = TriforceAccess.Health(list[k]); if ((Object)(object)val5 != (Object)null) { val5.HealOther(EmpressTriforcePlugin.Settings.HealAmount.Value, true); } } PhysGrabObject[] array = Object.FindObjectsOfType(); foreach (PhysGrabObject val6 in array) { if (!((Object)(object)val6 == (Object)null) && !(Vector3.Distance(((Component)val6).transform.position, position) > value)) { Rigidbody component = ((Component)val6).GetComponent(); if ((Object)(object)component != (Object)null && !component.isKinematic) { component.AddExplosionForce(value2 * 2.2f, position, value, 0.5f, (ForceMode)1); } } } } } }