Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Power Star v1.0.0
BepInEx/plugins/Omniscye-Empress_Powerstar/EmpressPowerstar.dll
Decompiled 10 hours agousing 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; [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("EmpressPowerstar")] [assembly: AssemblyTitle("EmpressPowerstar")] [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.Powerstar { [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("com.empress.repo.powerstar", "Empress Powerstar", "1.0.0")] public sealed class EmpressPowerstarPlugin : BaseUnityPlugin { public const string PluginGuid = "com.empress.repo.powerstar"; public const string PluginName = "Empress Powerstar"; public const string PluginVersion = "1.0.0"; public const string ItemName = "Empress Power Star"; internal const byte StarUseEventCode = 183; internal const byte StarKillEventCode = 184; private static bool _photonHooked; private static LoadBalancingClient _hookedClient; private Harmony _harmony; internal static EmpressPowerstarPlugin Instance { get; private set; } internal static ManualLogSource Log { get; private set; } internal static PowerstarSettings 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 PowerstarSettings(((BaseUnityPlugin)this).Config); ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); PowerstarAssets.Load(); PowerstarItemBuilder.RegisterItem(); _harmony = new Harmony("com.empress.repo.powerstar"); _harmony.PatchAll(typeof(EmpressPowerstarPlugin).Assembly); PowerstarRuntime.EnsureHost(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Empress Powerstar 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)) { return; } PowerstarRuntime instance = PowerstarRuntime.Instance; if (!((Object)(object)instance == (Object)null)) { if (ev.Code == 183) { instance.ReceiveStarUse(data); } else if (ev.Code == 184) { instance.ReceiveStarKill(data); } } } internal static void RaiseToAll(byte code, object[] data) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown //IL_004e: Unknown result type (might be due to invalid IL or missing references) EnsurePhotonHooked(); if (!PhotonNetwork.InRoom) { switch (code) { case 183: PowerstarRuntime.Instance?.ReceiveStarUse(data); break; case 184: PowerstarRuntime.Instance?.ReceiveStarKill(data); break; } } else { RaiseEventOptions val = new RaiseEventOptions { Receivers = (ReceiverGroup)1 }; PhotonNetwork.RaiseEvent(code, (object)data, val, SendOptions.SendReliable); } } } internal sealed class PowerstarSettings { public readonly ConfigEntry<int> PriceThousands; public readonly ConfigEntry<float> Duration; public readonly ConfigEntry<float> SpeedMultiplier; public readonly ConfigEntry<float> KillRadius; public readonly ConfigEntry<float> Volume; public readonly ConfigEntry<float> HearingRange; public PowerstarSettings(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_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Expected O, but got Unknown //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Expected O, but got Unknown PriceThousands = config.Bind<int>("Star", "PriceThousands", 10, new ConfigDescription("Shop price in thousands of K. 10 means 10,000.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 500), Array.Empty<object>())); Duration = config.Bind<float>("Star", "Duration", 10f, new ConfigDescription("Seconds the star power lasts.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(3f, 30f), Array.Empty<object>())); SpeedMultiplier = config.Bind<float>("Star", "SpeedMultiplier", 1.9f, new ConfigDescription("Movement speed multiplier while invincible.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1.1f, 3.5f), Array.Empty<object>())); KillRadius = config.Bind<float>("Star", "KillRadius", 2.2f, new ConfigDescription("How close things must be to die to the star runner.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 6f), Array.Empty<object>())); Volume = config.Bind<float>("Audio", "Volume", 0.55f, new ConfigDescription("Star sound volume.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); HearingRange = config.Bind<float>("Audio", "HearingRange", 11f, new ConfigDescription("How many meters away other players can hear the star. Smaller means only close players hear it.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(4f, 30f), Array.Empty<object>())); } } internal static class PowerstarAccess { private delegate void EnemyHurt(EnemyHealth instance, int damage, Vector3 direction); private delegate void PlayerHurtOther(PlayerHealth instance, int damage, Vector3 position, bool savingGrace, int enemyIndex, bool hurtByHeal); private static readonly FieldInfo ItemLocalizedNameField = AccessTools.Field(typeof(Item), "itemNameLocalized"); private static readonly FieldRef<PlayerAvatar, PlayerAvatarVisuals> AvatarVisualsRef = AccessTools.FieldRefAccess<PlayerAvatar, PlayerAvatarVisuals>("playerAvatarVisuals"); private static readonly FieldRef<PlayerAvatar, PlayerHealth> AvatarHealthRef = AccessTools.FieldRefAccess<PlayerAvatar, PlayerHealth>("playerHealth"); private static readonly FieldRef<EnemyHealth, bool> EnemyDeadRef = AccessTools.FieldRefAccess<EnemyHealth, bool>("dead"); private static readonly FieldRef<EnemyHealth, PhotonView> EnemyViewRef = AccessTools.FieldRefAccess<EnemyHealth, PhotonView>("photonView"); private static readonly FieldRef<PlayerController, float> InputDisableTimerRef = AccessTools.FieldRefAccess<PlayerController, float>("InputDisableTimer"); private static readonly FieldRef<PlayerController, float> MoveSpeedRef = AccessTools.FieldRefAccess<PlayerController, float>("MoveSpeed"); private static readonly FieldRef<PlayerController, float> SprintSpeedRef = AccessTools.FieldRefAccess<PlayerController, float>("SprintSpeed"); private static readonly FieldRef<PlayerHealth, bool> GodModeRef = AccessTools.FieldRefAccess<PlayerHealth, bool>("godMode"); private static readonly FieldRef<PlayerHealth, float> InvincibleTimerRef = AccessTools.FieldRefAccess<PlayerHealth, float>("invincibleTimer"); private static readonly FieldRef<PhysGrabObject, bool> HeldByLocalRef = AccessTools.FieldRefAccess<PhysGrabObject, bool>("heldByLocalPlayer"); private static readonly FieldRef<ItemAttributes, string> ItemNameRef = AccessTools.FieldRefAccess<ItemAttributes, string>("itemName"); private static readonly FieldRef<ItemAttributes, string> InstanceNameRef = AccessTools.FieldRefAccess<ItemAttributes, string>("instanceName"); private static readonly FieldRef<PlayerAvatar, bool> IsDisabledRef = AccessTools.FieldRefAccess<PlayerAvatar, bool>("isDisabled"); private static readonly EnemyHurt EnemyHurtCall = AccessTools.MethodDelegate<EnemyHurt>(AccessTools.Method(typeof(EnemyHealth), "Hurt", new Type[2] { typeof(int), typeof(Vector3) }, (Type[])null), (object)null, true); private static readonly PlayerHurtOther PlayerHurtOtherCall = AccessTools.MethodDelegate<PlayerHurtOther>(AccessTools.Method(typeof(PlayerHealth), "HurtOther", new Type[5] { typeof(int), typeof(Vector3), typeof(bool), typeof(int), typeof(bool) }, (Type[])null), (object)null, true); internal static float GetMoveSpeed(PlayerController controller) { if (!((Object)(object)controller != (Object)null)) { return 0.5f; } return MoveSpeedRef.Invoke(controller); } internal static float GetSprintSpeed(PlayerController controller) { if (!((Object)(object)controller != (Object)null)) { return 1f; } return SprintSpeedRef.Invoke(controller); } internal static void SetMoveSpeed(PlayerController controller, float value) { if ((Object)(object)controller != (Object)null) { MoveSpeedRef.Invoke(controller) = value; } } internal static void SetSprintSpeed(PlayerController controller, float value) { if ((Object)(object)controller != (Object)null) { SprintSpeedRef.Invoke(controller) = value; } } internal static bool GetGodMode(PlayerHealth health) { if ((Object)(object)health != (Object)null) { return GodModeRef.Invoke(health); } return false; } internal static void SetGodMode(PlayerHealth health, bool value) { if ((Object)(object)health != (Object)null) { GodModeRef.Invoke(health) = value; } } internal static void SetInvincible(PlayerHealth health, float time) { if ((Object)(object)health != (Object)null) { InvincibleTimerRef.Invoke(health) = time; } } internal static bool HeldByLocal(PhysGrabObject grab) { if ((Object)(object)grab != (Object)null) { return HeldByLocalRef.Invoke(grab); } return false; } internal static bool InputAllowed() { if ((Object)(object)PlayerController.instance != (Object)null) { return InputDisableTimerRef.Invoke(PlayerController.instance) <= 0f; } return false; } 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 bool IsDisabled(PlayerAvatar avatar) { if ((Object)(object)avatar != (Object)null) { return IsDisabledRef.Invoke(avatar); } return false; } internal static Renderer[] BodyRenderers(PlayerAvatar avatar) { if ((Object)(object)avatar == (Object)null) { return Array.Empty<Renderer>(); } PlayerAvatarVisuals val = AvatarVisualsRef.Invoke(avatar); Renderer[] componentsInChildren = ((Component)(((Object)(object)val != (Object)null) ? ((Component)val).transform : ((Component)avatar).transform)).GetComponentsInChildren<Renderer>(true); List<Renderer> list = new List<Renderer>(componentsInChildren.Length); foreach (Renderer val2 in componentsInChildren) { if (!((Object)(object)val2 == (Object)null) && (val2 is SkinnedMeshRenderer || val2 is MeshRenderer) && !((Object)(object)((Component)val2).GetComponent("TextMeshPro") != (Object)null)) { list.Add(val2); } } return list.ToArray(); } internal static void HurtEnemy(EnemyHealth enemy, int damage, Vector3 direction) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) EnemyHurtCall?.Invoke(enemy, damage, direction); } internal static void HurtPlayer(PlayerHealth health, int damage, Vector3 position) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) PlayerHurtOtherCall?.Invoke(health, damage, position, savingGrace: false, -1, hurtByHeal: false); } internal static PlayerHealth Health(PlayerAvatar avatar) { if (!((Object)(object)avatar != (Object)null)) { return null; } return AvatarHealthRef.Invoke(avatar); } internal static bool EnemyDead(EnemyHealth enemy) { if ((Object)(object)enemy != (Object)null) { return EnemyDeadRef.Invoke(enemy); } return false; } internal static PhotonView EnemyView(EnemyHealth enemy) { if (!((Object)(object)enemy != (Object)null)) { return null; } return EnemyViewRef.Invoke(enemy); } internal static List<PlayerAvatar> Players() { if (!((Object)(object)GameDirector.instance != (Object)null) || GameDirector.instance.PlayerList == null) { return new List<PlayerAvatar>(); } return GameDirector.instance.PlayerList; } internal static PlayerAvatar LocalAvatar() { if (!((Object)(object)PlayerController.instance != (Object)null)) { return null; } return PlayerController.instance.playerAvatarScript; } internal static PlayerAvatar AvatarByViewId(int viewId) { List<PlayerAvatar> list = Players(); for (int i = 0; i < list.Count; i++) { if ((Object)(object)list[i] != (Object)null && (Object)(object)list[i].photonView != (Object)null && list[i].photonView.ViewID == viewId) { return list[i]; } } return null; } } internal static class PowerstarAssets { private const string BundleFile = "empresspowerstar.empress"; private const string PrefabName = "EmpressPowerStar"; private static AssetBundle _bundle; private static bool _loaded; private static readonly Dictionary<string, AudioClip> Clips = new Dictionary<string, AudioClip>(StringComparer.OrdinalIgnoreCase); internal static GameObject StarPrefab { 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(EmpressPowerstarPlugin.PluginDirectory ?? string.Empty, "bundles", "empresspowerstar.empress"); if (File.Exists(text)) { _bundle = AssetBundle.LoadFromFile(text); StarPrefab = (((Object)(object)_bundle != (Object)null) ? _bundle.LoadAsset<GameObject>("EmpressPowerStar") : null); if ((Object)(object)StarPrefab == (Object)null && (Object)(object)_bundle != (Object)null) { string text2 = _bundle.GetAllAssetNames().FirstOrDefault((string name) => name.EndsWith(".prefab")); if (!string.IsNullOrEmpty(text2)) { StarPrefab = _bundle.LoadAsset<GameObject>(text2); } } } else { ManualLogSource log = EmpressPowerstarPlugin.Log; if (log != null) { log.LogError((object)("Empress Powerstar bundle missing: " + text)); } } ManualLogSource log2 = EmpressPowerstarPlugin.Log; if (log2 != null) { log2.LogInfo((object)("Empress Powerstar assets loaded. Star: " + (((Object)(object)StarPrefab != (Object)null) ? ((Object)StarPrefab).name : "MISSING"))); } } internal static IEnumerator LoadAudio() { string path = Path.Combine(EmpressPowerstarPlugin.PluginDirectory ?? string.Empty, "audio"); if (!Directory.Exists(path)) { yield break; } string[] files = Directory.GetFiles(path, "*.ogg"); foreach (string file in files) { UnityWebRequest request = UnityWebRequestMultimedia.GetAudioClip("file://" + file, (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 = Path.GetFileNameWithoutExtension(file); Clips[((Object)content).name] = content; } } } finally { ((IDisposable)request)?.Dispose(); } } ManualLogSource log = EmpressPowerstarPlugin.Log; if (log != null) { log.LogInfo((object)("Empress Powerstar audio loaded: " + Clips.Count + " clips.")); } } } internal sealed class PowerstarItem : MonoBehaviour { private PhysGrabObject _grab; private PhotonView _view; private bool _used; private void Awake() { _grab = ((Component)this).GetComponent<PhysGrabObject>(); _view = ((Component)this).GetComponent<PhotonView>(); } private void Update() { if (_used || (Object)(object)_grab == (Object)null || !PowerstarAccess.HeldByLocal(_grab) || !PowerstarAccess.InputAllowed() || !SemiFunc.InputDown((InputKey)2)) { return; } PlayerAvatar val = PowerstarAccess.LocalAvatar(); if (!((Object)(object)val == (Object)null) && !((Object)(object)val.photonView == (Object)null)) { _used = true; int viewID = val.photonView.ViewID; int num = (((Object)(object)_view != (Object)null) ? _view.ViewID : (-1)); EmpressPowerstarPlugin.EnsurePhotonHooked(); EmpressPowerstarPlugin.RaiseToAll(183, new object[2] { viewID, num }); Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<Renderer>(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].enabled = false; } } } } internal static class PowerstarItemBuilder { 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_0269: 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) //IL_01bd: 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<GameObject>(TemplatePaths[i]); if ((Object)(object)val != (Object)null) { break; } } if ((Object)(object)val == (Object)null) { EmpressPowerstarPlugin.Log.LogError((object)"Empress Powerstar could not find a template item."); return; } ItemAttributes component = val.GetComponent<ItemAttributes>(); if ((Object)(object)component == (Object)null || (Object)(object)component.item == (Object)null) { EmpressPowerstarPlugin.Log.LogError((object)"Empress Powerstar template has no ItemAttributes."); return; } GameObject val2 = new GameObject("Empress Powerstar Prefabs"); Object.DontDestroyOnLoad((Object)(object)val2); ((Object)val2).hideFlags = (HideFlags)61; val2.SetActive(false); _prefab = Object.Instantiate<GameObject>(val, val2.transform); ((Object)_prefab).name = "Empress Power Star"; MonoBehaviour[] componentsInChildren = _prefab.GetComponentsInChildren<MonoBehaviour>(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<Renderer>(true); for (int j = 0; j < componentsInChildren2.Length; j++) { componentsInChildren2[j].enabled = false; } if ((Object)(object)PowerstarAssets.StarPrefab != (Object)null) { GameObject val4 = Object.Instantiate<GameObject>(PowerstarAssets.StarPrefab, _prefab.transform, false); ((Object)val4).name = "Empress Power Star Visual"; val4.transform.localPosition = new Vector3(0f, 0.05f, 0f); val4.transform.localScale = Vector3.one * 0.09f; Collider[] componentsInChildren3 = val4.GetComponentsInChildren<Collider>(true); for (int j = 0; j < componentsInChildren3.Length; j++) { Object.DestroyImmediate((Object)(object)componentsInChildren3[j]); } componentsInChildren2 = val4.GetComponentsInChildren<Renderer>(true); for (int j = 0; j < componentsInChildren2.Length; j++) { componentsInChildren2[j].enabled = true; } val4.AddComponent<PowerstarSpin>(); } _prefab.AddComponent<PowerstarItem>(); Item item = component.item; _item = Object.Instantiate<Item>(item); ((Object)_item).name = "Empress Power Star"; _item.itemName = "Empress Power Star"; PowerstarAccess.ClearLocalizedName(_item); _item.itemSecretShopType = (itemSecretShopType)0; _item.maxAmount = 3; _item.maxAmountInShop = 2; _item.maxPurchase = false; _item.maxPurchaseAmount = 3; float value = (float)EmpressPowerstarPlugin.Settings.PriceThousands.Value * 1000f; Value val5 = (((Object)(object)item.value != (Object)null) ? Object.Instantiate<Value>(item.value) : ScriptableObject.CreateInstance<Value>()); SetFloatFieldContaining(val5, "min", value); SetFloatFieldContaining(val5, "max", value); _item.value = val5; ItemAttributes component2 = _prefab.GetComponent<ItemAttributes>(); component2.item = _item; PowerstarAccess.SetItemName(component2, "Empress Power Star"); _registered = Items.RegisterItem(component2) != null; EmpressPowerstarPlugin.Log.LogInfo((object)("Empress Powerstar item registered: " + _registered)); } 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 PowerstarSpin : MonoBehaviour { private void Update() { ((Component)this).transform.Rotate(0f, 90f * Time.deltaTime, 0f, (Space)1); } } internal sealed class PowerstarRuntime : MonoBehaviour { private sealed class Buff { internal int ViewId; internal PlayerAvatar Avatar; internal bool Active; internal float FlyStart; internal double ActiveEnd; internal GameObject Star; internal Transform StarModel; internal GameObject GlowRoot; internal Light GlowLight; internal AudioSource PowerAudio; internal Renderer[] BodyRenderers; internal bool Local; internal float SavedMove; internal float SavedSprint; internal bool SavedGod; internal bool BuffApplied; internal readonly Dictionary<int, float> KillCooldown = new Dictionary<int, float>(); } private const float FlyInTime = 1.6f; private static readonly int EmissionColorId = Shader.PropertyToID("_EmissionColor"); private readonly List<Buff> _buffs = new List<Buff>(); private readonly MaterialPropertyBlock _propertyBlock = new MaterialPropertyBlock(); private EnemyHealth[] _enemyCache = Array.Empty<EnemyHealth>(); private float _enemyCacheTimer; public static PowerstarRuntime Instance { get; private set; } public static PowerstarRuntime 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 Powerstar Runtime"); val.transform.parent = null; ((Object)val).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)val); Instance = val.AddComponent<PowerstarRuntime>(); return Instance; } private void Awake() { Instance = this; ((MonoBehaviour)this).StartCoroutine(PowerstarAssets.LoadAudio()); } private void Update() { //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) EmpressPowerstarPlugin.EnsurePhotonHooked(); _enemyCacheTimer -= Time.deltaTime; if (_enemyCacheTimer <= 0f) { _enemyCacheTimer = 0.25f; _enemyCache = Object.FindObjectsOfType<EnemyHealth>(); } double num = NetworkNow(); for (int num2 = _buffs.Count - 1; num2 >= 0; num2--) { Buff buff = _buffs[num2]; if ((Object)(object)buff.Avatar == (Object)null || (Object)(object)buff.GlowRoot == (Object)null) { EndBuff(buff); _buffs.RemoveAt(num2); } else { Vector3 head = ((Component)buff.Avatar).transform.position + Vector3.up * 1.1f; float num3 = Time.time - buff.FlyStart; if (!buff.Active) { TickFlyIn(buff, head, num3); if (num3 >= 1.6f) { Activate(buff, num); } } else { TickGlow(buff, head); if (buff.Local) { ReassertLocalBuff(buff); } RunKills(buff); if (num >= buff.ActiveEnd) { EndBuff(buff); _buffs.RemoveAt(num2); } } } } } internal void ReceiveStarUse(object[] data) { if (data == null || data.Length < 2) { return; } int viewId = Convert.ToInt32(data[0]); int num = Convert.ToInt32(data[1]); if (HasBuff(viewId)) { return; } PlayerAvatar val = PowerstarAccess.AvatarByViewId(viewId); if ((Object)(object)val == (Object)null) { return; } Buff buff = new Buff { ViewId = viewId, Avatar = val, FlyStart = Time.time, Local = ((Object)(object)PowerstarAccess.LocalAvatar() == (Object)(object)val) }; BuildStar(buff); _buffs.Add(buff); if (!SemiFunc.IsMasterClientOrSingleplayer() || num <= 0) { return; } PhotonView val2 = PhotonView.Find(num); if ((Object)(object)val2 != (Object)null && (Object)(object)((Component)val2).gameObject != (Object)null) { string text = PowerstarAccess.InstanceName(((Component)val2).gameObject.GetComponent<ItemAttributes>()); if ((Object)(object)StatsManager.instance != (Object)null && !string.IsNullOrEmpty(text)) { StatsManager.instance.ItemRemove(text); } if (PhotonNetwork.InRoom) { PhotonNetwork.Destroy(((Component)val2).gameObject); } else { Object.Destroy((Object)(object)((Component)val2).gameObject); } } } internal void ReceiveStarKill(object[] data) { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) if (data == null || data.Length < 2 || !SemiFunc.IsMasterClientOrSingleplayer()) { return; } int num = Convert.ToInt32(data[0]); if (Convert.ToBoolean(data[1])) { PlayerAvatar val = PowerstarAccess.AvatarByViewId(num); PlayerHealth val2 = PowerstarAccess.Health(val); if ((Object)(object)val != (Object)null && (Object)(object)val2 != (Object)null && !PowerstarAccess.IsDisabled(val)) { PowerstarAccess.HurtPlayer(val2, 999, ((Component)val).transform.position); } return; } EnemyHealth[] array = Object.FindObjectsOfType<EnemyHealth>(); foreach (EnemyHealth val3 in array) { if (!((Object)(object)val3 == (Object)null) && !PowerstarAccess.EnemyDead(val3)) { PhotonView val4 = PowerstarAccess.EnemyView(val3); if ((Object)(object)val4 != (Object)null && val4.ViewID == num) { PowerstarAccess.HurtEnemy(val3, 999, Vector3.up); break; } } } } private void BuildStar(Buff buff) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Expected O, but got Unknown //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) GameObject val = (buff.Star = new GameObject("Empress Powerstar Effect")); if ((Object)(object)PowerstarAssets.StarPrefab != (Object)null) { GameObject val2 = Object.Instantiate<GameObject>(PowerstarAssets.StarPrefab, val.transform, false); ((Object)val2).name = "Star"; val2.transform.localScale = Vector3.one * 0.18f; Collider[] componentsInChildren = val2.GetComponentsInChildren<Collider>(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.Destroy((Object)(object)componentsInChildren[i]); } buff.StarModel = val2.transform; } Light obj = val.AddComponent<Light>(); obj.type = (LightType)2; obj.color = new Color(1f, 0.9f, 0.3f); obj.range = 8f; obj.intensity = 3f; float value = EmpressPowerstarPlugin.Settings.HearingRange.Value; AudioSource val3 = val.AddComponent<AudioSource>(); val3.spatialBlend = 1f; val3.minDistance = Mathf.Min(2f, value * 0.2f); val3.maxDistance = value; val3.rolloffMode = (AudioRolloffMode)1; val3.volume = EmpressPowerstarPlugin.Settings.Volume.Value; AudioClip val4 = PowerstarAssets.Clip("star_use"); if ((Object)(object)val4 != (Object)null) { val3.PlayOneShot(val4, EmpressPowerstarPlugin.Settings.Volume.Value); } GameObject val5 = new GameObject("Empress Powerstar Glow"); val5.transform.SetParent(((Component)buff.Avatar).transform, false); val5.transform.localPosition = Vector3.up * 0.15f; buff.GlowRoot = val5; Light val6 = val5.AddComponent<Light>(); val6.type = (LightType)2; val6.color = new Color(1f, 0.9f, 0.35f); val6.range = 3.5f; val6.intensity = 0f; val6.shadows = (LightShadows)0; buff.GlowLight = val6; AudioSource val7 = val5.AddComponent<AudioSource>(); val7.spatialBlend = 1f; val7.loop = true; val7.minDistance = Mathf.Min(2f, value * 0.2f); val7.maxDistance = value; val7.rolloffMode = (AudioRolloffMode)1; val7.volume = EmpressPowerstarPlugin.Settings.Volume.Value; buff.PowerAudio = val7; } private void TickFlyIn(Buff buff, Vector3 head, float t) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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_0085: 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_0088: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)buff.Star == (Object)null)) { float num = Mathf.Clamp01(t / 1.6f); float num2 = t * 720f; float num3 = Mathf.Lerp(1.9f, 0.05f, num); float num4 = Mathf.Sin(num * MathF.PI) * 1.1f; Vector3 val = Quaternion.Euler(0f, num2, 0f) * (Vector3.forward * num3) + Vector3.up * num4; buff.Star.transform.position = head + val; if ((Object)(object)buff.StarModel != (Object)null) { buff.StarModel.Rotate(0f, 360f * Time.deltaTime, 0f, (Space)1); } } } private void Activate(Buff buff, double now) { buff.Active = true; buff.ActiveEnd = now + (double)EmpressPowerstarPlugin.Settings.Duration.Value; if ((Object)(object)buff.Star != (Object)null) { Object.Destroy((Object)(object)buff.Star); } ApplyBodyGlow(buff); AudioClip val = PowerstarAssets.Clip("star_power"); if ((Object)(object)buff.PowerAudio != (Object)null && (Object)(object)val != (Object)null) { buff.PowerAudio.clip = val; buff.PowerAudio.Play(); } if (buff.Local) { PlayerController instance = PlayerController.instance; PlayerHealth val2 = PowerstarAccess.Health(buff.Avatar); buff.SavedMove = PowerstarAccess.GetMoveSpeed(instance); buff.SavedSprint = PowerstarAccess.GetSprintSpeed(instance); buff.SavedGod = (Object)(object)val2 != (Object)null && PowerstarAccess.GetGodMode(val2); buff.BuffApplied = true; } } private void ReassertLocalBuff(Buff buff) { if (buff.BuffApplied) { PlayerController instance = PlayerController.instance; float value = EmpressPowerstarPlugin.Settings.SpeedMultiplier.Value; PowerstarAccess.SetMoveSpeed(instance, buff.SavedMove * value); PowerstarAccess.SetSprintSpeed(instance, buff.SavedSprint * value); PlayerHealth val = PowerstarAccess.Health(buff.Avatar); if ((Object)(object)val != (Object)null) { PowerstarAccess.SetGodMode(val, value: true); PowerstarAccess.SetInvincible(val, 0.5f); } } } private void TickGlow(Buff buff, Vector3 head) { //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_009d: 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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) float num = 0.5f + 0.5f * Mathf.Sin(Time.time * 18f); if ((Object)(object)buff.GlowLight != (Object)null) { buff.GlowLight.intensity = 1.1f + num * 1.2f; buff.GlowLight.color = Color.Lerp(new Color(1f, 0.85f, 0.25f), new Color(1f, 0.97f, 0.6f), num); } Color val = new Color(1f, 0.82f, 0.16f) * (2.4f + num * 3.2f); if (buff.BodyRenderers == null) { return; } for (int i = 0; i < buff.BodyRenderers.Length; i++) { Renderer val2 = buff.BodyRenderers[i]; if (!((Object)(object)val2 == (Object)null)) { val2.GetPropertyBlock(_propertyBlock); _propertyBlock.SetColor(EmissionColorId, val); val2.SetPropertyBlock(_propertyBlock); } } } private void ApplyBodyGlow(Buff buff) { buff.BodyRenderers = PowerstarAccess.BodyRenderers(buff.Avatar); } private void RemoveBodyGlow(Buff buff) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) if (buff.BodyRenderers == null) { return; } for (int i = 0; i < buff.BodyRenderers.Length; i++) { Renderer val = buff.BodyRenderers[i]; if (!((Object)(object)val == (Object)null)) { val.GetPropertyBlock(_propertyBlock); _propertyBlock.SetColor(EmissionColorId, Color.black); val.SetPropertyBlock(_propertyBlock); } } buff.BodyRenderers = null; } private void RunKills(Buff buff) { //IL_0024: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) if (!buff.Local) { return; } float value = EmpressPowerstarPlugin.Settings.KillRadius.Value; Vector3 val = ((Component)buff.Avatar).transform.position + Vector3.up * 0.6f; for (int i = 0; i < _enemyCache.Length; i++) { EnemyHealth val2 = _enemyCache[i]; if ((Object)(object)val2 == (Object)null || PowerstarAccess.EnemyDead(val2)) { continue; } PhotonView val3 = PowerstarAccess.EnemyView(val2); if (!((Object)(object)val3 == (Object)null) && !(Vector3.Distance(((Component)val2).transform.position, val) > value + 0.8f)) { int viewID = val3.ViewID; if (!OnCooldown(buff, viewID)) { buff.KillCooldown[viewID] = Time.time + 1.2f; EmpressPowerstarPlugin.RaiseToAll(184, new object[2] { viewID, false }); } } } List<PlayerAvatar> list = PowerstarAccess.Players(); for (int j = 0; j < list.Count; j++) { PlayerAvatar val4 = list[j]; if (!((Object)(object)val4 == (Object)null) && !((Object)(object)val4 == (Object)(object)buff.Avatar) && !((Object)(object)val4.photonView == (Object)null) && !PowerstarAccess.IsDisabled(val4) && !HasBuff(val4.photonView.ViewID) && !(Vector3.Distance(((Component)val4).transform.position, ((Component)buff.Avatar).transform.position) > value)) { int viewID2 = val4.photonView.ViewID; if (!OnCooldown(buff, viewID2)) { buff.KillCooldown[viewID2] = Time.time + 2f; EmpressPowerstarPlugin.RaiseToAll(184, new object[2] { viewID2, true }); } } } } private bool OnCooldown(Buff buff, int id) { if (buff.KillCooldown.TryGetValue(id, out var value)) { return Time.time < value; } return false; } private void EndBuff(Buff buff) { if (buff.Local && buff.BuffApplied) { PlayerController instance = PlayerController.instance; PowerstarAccess.SetMoveSpeed(instance, buff.SavedMove); PowerstarAccess.SetSprintSpeed(instance, buff.SavedSprint); PlayerHealth val = PowerstarAccess.Health(buff.Avatar); if ((Object)(object)val != (Object)null) { PowerstarAccess.SetGodMode(val, buff.SavedGod); } } RemoveBodyGlow(buff); if ((Object)(object)buff.Star != (Object)null) { Object.Destroy((Object)(object)buff.Star); } if ((Object)(object)buff.GlowRoot != (Object)null) { Object.Destroy((Object)(object)buff.GlowRoot); } } private bool HasBuff(int viewId) { for (int i = 0; i < _buffs.Count; i++) { if (_buffs[i].ViewId == viewId) { return true; } } return false; } private static double NetworkNow() { if (!PhotonNetwork.InRoom) { return Time.realtimeSinceStartup; } return PhotonNetwork.Time; } } }