Some mods may be broken due to the recent Alloyed Collective update.
Decompiled source of R2API TempVisualEffect v1.0.3
plugins/R2API.TempVisualEffect/R2API.TempVisualEffect.dll
Decompiled a year agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using Microsoft.CodeAnalysis; using On.RoR2; using R2API.AutoVersionGen; using RoR2; using UnityEngine; [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("R2API.TempVisualEffect")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.3.0")] [assembly: AssemblyInformationalVersion("1.0.3+70f0a26bd0415ddf30b096c408e87605dd37532d")] [assembly: AssemblyProduct("R2API.TempVisualEffect")] [assembly: AssemblyTitle("R2API.TempVisualEffect")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.3.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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 System.Diagnostics.CodeAnalysis { [AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)] [ExcludeFromCodeCoverage] [DebuggerNonUserCode] internal sealed class MemberNotNullAttribute : Attribute { public string[] Members { get; } public MemberNotNullAttribute(string member) { Members = new string[1] { member }; } public MemberNotNullAttribute(params string[] members) { Members = members; } } [AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)] [ExcludeFromCodeCoverage] [DebuggerNonUserCode] internal sealed class MemberNotNullWhenAttribute : Attribute { public bool ReturnValue { get; } public string[] Members { get; } public MemberNotNullWhenAttribute(bool returnValue, string member) { ReturnValue = returnValue; Members = new string[1] { member }; } public MemberNotNullWhenAttribute(bool returnValue, params string[] members) { ReturnValue = returnValue; Members = members; } } } namespace R2API { [AutoVersion] public static class TempVisualEffectAPI { public delegate bool EffectCondition(CharacterBody body); public delegate float EffectRadius(CharacterBody body); internal struct TemporaryVisualEffectInfo { public GameObject effectPrefab; public EffectRadius radius; public bool useBestFitRadius; public EffectCondition condition; public string childLocatorOverride; } [CompilerGenerated] private static class <>O { public static hook_UpdateAllTemporaryVisualEffects <0>__UpdateAllHook; public static Action<CharacterBody> <1>__BodyAwake; public static Action<CharacterBody> <2>__BodyDestroy; } public const string PluginGUID = "com.bepis.r2api.tempvisualeffect"; public const string PluginName = "R2API.TempVisualEffect"; internal static List<TemporaryVisualEffectInfo> temporaryVisualEffectInfos = new List<TemporaryVisualEffectInfo>(); internal static Dictionary<CharacterBody, TemporaryVisualEffect[]> bodyToTemporaryVisualEffects = new Dictionary<CharacterBody, TemporaryVisualEffect[]>(); internal static FixedSizeArrayPool<TemporaryVisualEffect> temporaryVisualEffectArrayPool = new FixedSizeArrayPool<TemporaryVisualEffect>(0); private static bool _hooksEnabled = false; public const string PluginVersion = "1.0.3"; [Obsolete("All submodules are automatically loaded and this property is now unused")] public static bool Loaded => true; public static bool AddTemporaryVisualEffect(GameObject effectPrefab, EffectCondition condition, bool useBestFitRadius = false, string childLocatorOverride = "") { SetHooks(); if (!Object.op_Implicit((Object)(object)effectPrefab)) { TempVisualEffectPlugin.Logger.LogError((object)"Failed to add TemporaryVisualEffect: GameObject is null"); return false; } if (condition == null) { TempVisualEffectPlugin.Logger.LogError((object)("Failed to add TemporaryVisualEffect: " + ((Object)effectPrefab).name + " no condition attached")); return false; } if (!Object.op_Implicit((Object)(object)effectPrefab.GetComponent<TemporaryVisualEffect>())) { TempVisualEffectPlugin.Logger.LogError((object)("Failed to add TemporaryVisualEffect: " + ((Object)effectPrefab).name + " GameObject has no TemporaryVisualEffect component")); return false; } AddTemporaryVisualEffectInternal(effectPrefab, null, condition, useBestFitRadius, childLocatorOverride); return true; } public static bool AddTemporaryVisualEffect(GameObject effectPrefab, EffectRadius radius, EffectCondition condition, string childLocatorOverride = "") { SetHooks(); if (!Object.op_Implicit((Object)(object)effectPrefab)) { TempVisualEffectPlugin.Logger.LogError((object)"Failed to add TemporaryVisualEffect: GameObject is null"); return false; } if (radius == null) { TempVisualEffectPlugin.Logger.LogError((object)("Failed to add TemporaryVisualEffect: " + ((Object)effectPrefab).name + " no radius attached")); return false; } if (condition == null) { TempVisualEffectPlugin.Logger.LogError((object)("Failed to add TemporaryVisualEffect: " + ((Object)effectPrefab).name + " no condition attached")); return false; } if (!Object.op_Implicit((Object)(object)effectPrefab.GetComponent<TemporaryVisualEffect>())) { TempVisualEffectPlugin.Logger.LogError((object)("Failed to add TemporaryVisualEffect: " + ((Object)effectPrefab).name + " GameObject has no TemporaryVisualEffect component")); return false; } AddTemporaryVisualEffectInternal(effectPrefab, radius, condition, useBestFitRadius: false, childLocatorOverride); return true; } internal static void AddTemporaryVisualEffectInternal(GameObject effectPrefab, EffectRadius radius, EffectCondition condition, bool useBestFitRadius, string childLocatorOverride) { TemporaryVisualEffectInfo temporaryVisualEffectInfo = default(TemporaryVisualEffectInfo); temporaryVisualEffectInfo.effectPrefab = effectPrefab; temporaryVisualEffectInfo.radius = radius; temporaryVisualEffectInfo.condition = condition; temporaryVisualEffectInfo.useBestFitRadius = useBestFitRadius; temporaryVisualEffectInfo.childLocatorOverride = childLocatorOverride; TemporaryVisualEffectInfo temporaryVisualEffectInfo2 = temporaryVisualEffectInfo; temporaryVisualEffectInfos.Add(temporaryVisualEffectInfo2); FixedSizeArrayPool<TemporaryVisualEffect> obj = temporaryVisualEffectArrayPool; int lengthOfArrays = obj.lengthOfArrays; obj.lengthOfArrays = lengthOfArrays + 1; TempVisualEffectPlugin.Logger.LogMessage((object)$"Added new TemporaryVisualEffect: {temporaryVisualEffectInfo2}"); } internal static void SetHooks() { //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_0023: Expected O, but got Unknown if (!_hooksEnabled) { object obj = <>O.<0>__UpdateAllHook; if (obj == null) { hook_UpdateAllTemporaryVisualEffects val = UpdateAllHook; <>O.<0>__UpdateAllHook = val; obj = (object)val; } CharacterBody.UpdateAllTemporaryVisualEffects += (hook_UpdateAllTemporaryVisualEffects)obj; CharacterBody.onBodyAwakeGlobal += BodyAwake; CharacterBody.onBodyDestroyGlobal += BodyDestroy; _hooksEnabled = true; } } internal static void UnsetHooks() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__UpdateAllHook; if (obj == null) { hook_UpdateAllTemporaryVisualEffects val = UpdateAllHook; <>O.<0>__UpdateAllHook = val; obj = (object)val; } CharacterBody.UpdateAllTemporaryVisualEffects -= (hook_UpdateAllTemporaryVisualEffects)obj; CharacterBody.onBodyStartGlobal -= BodyAwake; CharacterBody.onBodyDestroyGlobal -= BodyDestroy; _hooksEnabled = false; } private static void BodyAwake(CharacterBody body) { bodyToTemporaryVisualEffects.Add(body, temporaryVisualEffectArrayPool.Request()); } private static void BodyDestroy(CharacterBody body) { if (bodyToTemporaryVisualEffects.TryGetValue(body, out TemporaryVisualEffect[] value)) { temporaryVisualEffectArrayPool.Return(value, (ClearType<TemporaryVisualEffect>)0); } bodyToTemporaryVisualEffects.Remove(body); } private static void UpdateAllHook(orig_UpdateAllTemporaryVisualEffects orig, CharacterBody self) { orig.Invoke(self); if (bodyToTemporaryVisualEffects.TryGetValue(self, out TemporaryVisualEffect[] value)) { for (int i = 0; i < value.Length; i++) { TemporaryVisualEffectInfo temporaryVisualEffectInfo = temporaryVisualEffectInfos[i]; self.UpdateSingleTemporaryVisualEffect(ref value[i], temporaryVisualEffectInfo.effectPrefab, (temporaryVisualEffectInfo.radius != null) ? temporaryVisualEffectInfo.radius(self) : (temporaryVisualEffectInfo.useBestFitRadius ? self.bestFitRadius : self.radius), temporaryVisualEffectInfo.condition(self), temporaryVisualEffectInfo.childLocatorOverride); } } } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("com.bepis.r2api.tempvisualeffect", "R2API.TempVisualEffect", "1.0.3")] public sealed class TempVisualEffectPlugin : BaseUnityPlugin { internal static ManualLogSource Logger { get; set; } private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; } private void OnDestroy() { TempVisualEffectAPI.UnsetHooks(); } } } namespace R2API.AutoVersionGen { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] internal class AutoVersionAttribute : Attribute { } }