using System;
using System.Collections;
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 System.Text;
using BepInEx;
using BepInEx.Logging;
using HG;
using HG.Coroutines;
using HG.Reflection;
using IL.RoR2;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using On.RoR2;
using R2API.Utils;
using RoR2;
using RoR2.ContentManagement;
using RoR2.DispatachableEffects;
using RoR2BepInExPack.GameAssetPathsBetter;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Events;
using UnityEngine.Rendering;
using UnityEngine.ResourceManagement.AsyncOperations;
using VFiX.GrandparentPreSpawnEffect;
using VFiX.MeteorStrikePredictionEffect;
using VFiX.PooledEffectCleanup;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: NetworkCompatibility(/*Could not decode attribute arguments.*/)]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("VFiX")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+cf448d0254e3b3e8d0339c34c1081e99b4549727")]
[assembly: AssemblyProduct("VFiX")]
[assembly: AssemblyTitle("VFiX")]
[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 VFiX
{
public static class AddressableExtensions
{
public static void CallOnSuccess<T>(this AsyncOperationHandle<T> handle, Action<T> onSuccess)
{
handle.Completed += delegate(AsyncOperationHandle<T> handle)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Invalid comparison between Unknown and I4
if ((int)handle.Status != 1)
{
Log.Error("Failed to load asset " + handle.LocationName, "X:\\Git\\RoR2\\VFiX\\VFiX\\AddressableExtensions.cs", "CallOnSuccess", 24);
}
else
{
onSuccess(handle.Result);
}
};
}
}
public static class AssetLoadUtils
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static AsyncOperationHandle<T> LoadTempAssetAsync<T>(string assetKey) where T : Object
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
return LoadTempAssetAsync<T>(new AssetReferenceT<T>(assetKey));
}
public static AsyncOperationHandle<T> LoadTempAssetAsync<T>(AssetReferenceT<T> assetReference) where T : Object
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
AsyncOperationHandle<T> result = AssetAsyncReferenceManager<T>.LoadAsset(assetReference, (AsyncReferenceHandleUnloadType)2);
result.Completed += delegate
{
AssetAsyncReferenceManager<T>.UnloadAsset(assetReference);
};
return result;
}
}
internal static class Log
{
private static readonly StringBuilder _sharedStringBuilder;
private static readonly int _cachedCallerPathPrefixLength;
private static ManualLogSource _logSource;
static Log()
{
_sharedStringBuilder = new StringBuilder(256);
_cachedCallerPathPrefixLength = getCallerPathPrefixLength("X:\\Git\\RoR2\\VFiX\\VFiX\\Log.cs");
static int getCallerPathPrefixLength([CallerFilePath] string callerPath = null)
{
int num = callerPath.LastIndexOf("VFiX\\");
if (num >= 0)
{
return num + "VFiX\\".Length;
}
Debug.LogError((object)"[VFiX] Logger failed to determine caller path prefix length");
return 0;
}
}
internal static void Init(ManualLogSource logSource)
{
_logSource = logSource;
}
private static StringBuilder AppendCallerPrefix(this StringBuilder stringBuilder, string callerPath, string callerMemberName, int callerLineNumber)
{
return stringBuilder.Append(callerPath, _cachedCallerPathPrefixLength, callerPath.Length - _cachedCallerPathPrefixLength).Append(':').Append(callerLineNumber)
.Append(" (")
.Append(callerMemberName)
.Append("):");
}
private static StringBuilder buildCallerLogString(string callerPath, string callerMemberName, int callerLineNumber, object data)
{
return _sharedStringBuilder.Clear().AppendCallerPrefix(callerPath, callerMemberName, callerLineNumber).Append(' ')
.Append(data);
}
[Conditional("DEBUG")]
internal static void Debug(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
{
_logSource.LogDebug((object)buildCallerLogString(callerPath, callerMemberName, callerLineNumber, data));
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[Conditional("DEBUG")]
internal static void Debug_NoCallerPrefix(object data)
{
_logSource.LogDebug(data);
}
internal static void Error(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
{
_logSource.LogError((object)buildCallerLogString(callerPath, callerMemberName, callerLineNumber, data));
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static void Error_NoCallerPrefix(object data)
{
_logSource.LogError(data);
}
internal static void Fatal(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
{
_logSource.LogFatal((object)buildCallerLogString(callerPath, callerMemberName, callerLineNumber, data));
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static void Fatal_NoCallerPrefix(object data)
{
_logSource.LogFatal(data);
}
internal static void Info(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
{
_logSource.LogInfo((object)buildCallerLogString(callerPath, callerMemberName, callerLineNumber, data));
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static void Info_NoCallerPrefix(object data)
{
_logSource.LogInfo(data);
}
internal static void Message(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
{
_logSource.LogMessage((object)buildCallerLogString(callerPath, callerMemberName, callerLineNumber, data));
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static void Message_NoCallerPrefix(object data)
{
_logSource.LogMessage(data);
}
internal static void Warning(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
{
_logSource.LogWarning((object)buildCallerLogString(callerPath, callerMemberName, callerLineNumber, data));
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static void Warning_NoCallerPrefix(object data)
{
_logSource.LogWarning(data);
}
internal static void LogType(LogLevel level, object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
LogType_NoCallerPrefix(level, buildCallerLogString(callerPath, callerMemberName, callerLineNumber, data));
}
internal static void LogType_NoCallerPrefix(LogLevel level, object data)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: 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_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
if ((level & 1) != 0)
{
Fatal_NoCallerPrefix(data);
}
else if ((level & 2) != 0)
{
Error_NoCallerPrefix(data);
}
else if ((level & 4) != 0)
{
Warning_NoCallerPrefix(data);
}
else if ((level & 8) != 0)
{
Message_NoCallerPrefix(data);
}
else if ((level & 0x10) != 0)
{
Info_NoCallerPrefix(data);
}
else
{
_ = level & 0x20;
}
}
}
[BepInPlugin("Gorakh.VFiX", "VFiX", "1.1.2")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public sealed class VFiXPlugin : BaseUnityPlugin
{
public const string PluginGUID = "Gorakh.VFiX";
public const string PluginAuthor = "Gorakh";
public const string PluginName = "VFiX";
public const string PluginVersion = "1.1.2";
private static VFiXPlugin _instance;
internal static VFiXPlugin Instance => _instance;
private void Awake()
{
Stopwatch stopwatch = Stopwatch.StartNew();
SingletonHelper.Assign<VFiXPlugin>(ref _instance, this);
Log.Init(((BaseUnityPlugin)this).Logger);
EffectPoolPreventInUsePoolClearFix.Init();
GrandparentPreSpawnEffectFix.Init();
MeteorStrikePredictionEffectFix.Init();
PooledEffectCleanupSoundFix.Init();
stopwatch.Stop();
Log.Message_NoCallerPrefix($"Initialized in {stopwatch.Elapsed.TotalMilliseconds:F0}ms");
}
private void OnDestroy()
{
SingletonHelper.Unassign<VFiXPlugin>(ref _instance, this);
}
}
}
namespace VFiX.PooledEffectStart
{
public sealed class ApplyForceOnStartRestarter : MonoBehaviour, IEffectRestarter
{
private ApplyForceOnStart _applyForceOnStart;
private void Awake()
{
_applyForceOnStart = ((Component)this).GetComponent<ApplyForceOnStart>();
}
void IEffectRestarter.Restart()
{
if (Object.op_Implicit((Object)(object)_applyForceOnStart))
{
_applyForceOnStart.Start();
}
}
}
public sealed class ApplyTorqueOnStartRestarter : MonoBehaviour, IEffectRestarter
{
private ApplyTorqueOnStart _applyTorqueOnStart;
private void Awake()
{
_applyTorqueOnStart = ((Component)this).GetComponent<ApplyTorqueOnStart>();
}
void IEffectRestarter.Restart()
{
if (Object.op_Implicit((Object)(object)_applyTorqueOnStart))
{
_applyTorqueOnStart.Start();
}
}
}
public class CoinBehaviorRestarter : MonoBehaviour, IEffectRestarter
{
private CoinBehavior _coinBehavior;
private void Awake()
{
_coinBehavior = ((Component)this).GetComponent<CoinBehavior>();
}
void IEffectRestarter.Restart()
{
//IL_001f: 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)
if (!Object.op_Implicit((Object)(object)_coinBehavior))
{
return;
}
CoinTier[] coinTiers = _coinBehavior.coinTiers;
for (int i = 0; i < coinTiers.Length; i++)
{
ParticleSystem particleSystem = coinTiers[i].particleSystem;
if (Object.op_Implicit((Object)(object)particleSystem))
{
EmissionModule emission = particleSystem.emission;
((EmissionModule)(ref emission)).enabled = false;
particleSystem.Stop();
particleSystem.Clear();
((Component)particleSystem).gameObject.SetActive(false);
}
}
_coinBehavior.Start();
}
}
public sealed class EffectPassArgsToLocalTokenRestarter : MonoBehaviour, IEffectRestarter
{
private EffectPassArgsToLocalToken _effectPassArgsToLocalToken;
private void Awake()
{
_effectPassArgsToLocalToken = ((Component)this).GetComponent<EffectPassArgsToLocalToken>();
}
void IEffectRestarter.Restart()
{
if (Object.op_Implicit((Object)(object)_effectPassArgsToLocalToken))
{
_effectPassArgsToLocalToken.Start();
}
}
}
public sealed class EffectRestarterController : MonoBehaviour
{
private EffectComponent _effectComponent;
private Rigidbody[] _rigidbodies = Array.Empty<Rigidbody>();
private IEffectRestarter[] _restarters = Array.Empty<IEffectRestarter>();
private Vector3 _originalScale = Vector3.one;
private void Awake()
{
//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)
_effectComponent = ((Component)this).GetComponent<EffectComponent>();
if (Object.op_Implicit((Object)(object)_effectComponent))
{
EffectComponent effectComponent = _effectComponent;
effectComponent.OnEffectComponentReset = (Action<bool>)Delegate.Combine(effectComponent.OnEffectComponentReset, new Action<bool>(onEffectComponentReset));
}
_rigidbodies = ((Component)this).GetComponentsInChildren<Rigidbody>(true);
_restarters = ((Component)this).GetComponentsInChildren<IEffectRestarter>(true);
_originalScale = ((Component)this).transform.localScale;
}
private void OnDestroy()
{
if (Object.op_Implicit((Object)(object)_effectComponent))
{
EffectComponent effectComponent = _effectComponent;
effectComponent.OnEffectComponentReset = (Action<bool>)Delegate.Remove(effectComponent.OnEffectComponentReset, new Action<bool>(onEffectComponentReset));
}
}
private void onEffectComponentReset(bool hasEffectData)
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: 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)
if (((Component)this).gameObject.activeSelf)
{
return;
}
if (!hasEffectData || !_effectComponent.applyScale)
{
((Component)this).transform.localScale = _originalScale;
}
Rigidbody[] rigidbodies = _rigidbodies;
foreach (Rigidbody val in rigidbodies)
{
if (Object.op_Implicit((Object)(object)val))
{
val.velocity = Vector3.zero;
val.angularVelocity = Vector3.zero;
}
}
IEffectRestarter[] restarters = _restarters;
foreach (IEffectRestarter effectRestarter in restarters)
{
if (effectRestarter != null)
{
Object val2 = (Object)((effectRestarter is Object) ? effectRestarter : null);
if (val2 == null || Object.op_Implicit(val2))
{
effectRestarter.Restart();
}
}
}
}
}
public sealed class ExplodeRigidbodiesOnStartRestarter : MonoBehaviour, IEffectRestarter
{
private ExplodeRigidbodiesOnStart _explodeRigidbodiesOnStart;
private void Awake()
{
_explodeRigidbodiesOnStart = ((Component)this).GetComponent<ExplodeRigidbodiesOnStart>();
}
void IEffectRestarter.Restart()
{
if (Object.op_Implicit((Object)(object)_explodeRigidbodiesOnStart))
{
_explodeRigidbodiesOnStart.Start();
}
}
}
public interface IEffectRestarter
{
void Restart();
}
public sealed class ImpactEffectRestarter : MonoBehaviour, IEffectRestarter
{
private ImpactEffect _impactEffect;
private void Awake()
{
_impactEffect = ((Component)this).GetComponent<ImpactEffect>();
}
void IEffectRestarter.Restart()
{
if (Object.op_Implicit((Object)(object)_impactEffect))
{
ParticleSystem[] particleSystems = _impactEffect.particleSystems;
foreach (ParticleSystem obj in particleSystems)
{
obj.Stop();
obj.Clear();
}
_impactEffect.Start();
}
}
}
public sealed class LightScaleFromParentRestarter : MonoBehaviour, IEffectRestarter
{
private LightScaleFromParent _lightScaleFromParent;
private Light _light;
private float _originalRange;
private void Awake()
{
_lightScaleFromParent = ((Component)this).GetComponent<LightScaleFromParent>();
Light val = default(Light);
if (((Component)this).TryGetComponent<Light>(ref val))
{
_light = val;
_originalRange = val.range;
}
else
{
Log.Warning("No light reference, light range will not be restored: " + Util.GetGameObjectHierarchyName(((Component)this).gameObject), "X:\\Git\\RoR2\\VFiX\\VFiX\\PooledEffectStart\\LightScaleFromParentRestarter.cs", "Awake", 25);
}
}
void IEffectRestarter.Restart()
{
if (Object.op_Implicit((Object)(object)_light))
{
_light.range = _originalRange;
}
else
{
Log.Warning("No light reference, light range will not be restored: " + Util.GetGameObjectHierarchyName(((Component)this).gameObject), "X:\\Git\\RoR2\\VFiX\\VFiX\\PooledEffectStart\\LightScaleFromParentRestarter.cs", "Restart", 38);
}
if (Object.op_Implicit((Object)(object)_lightScaleFromParent))
{
_lightScaleFromParent.Start();
}
}
}
public sealed class ParticleSystemColorFromEffectDataRestarter : MonoBehaviour, IEffectRestarter
{
private ParticleSystemColorFromEffectData _particleSystemColorFromEffectData;
private void Awake()
{
_particleSystemColorFromEffectData = ((Component)this).GetComponent<ParticleSystemColorFromEffectData>();
}
void IEffectRestarter.Restart()
{
if (Object.op_Implicit((Object)(object)_particleSystemColorFromEffectData))
{
ParticleSystem[] particleSystems = _particleSystemColorFromEffectData.particleSystems;
foreach (ParticleSystem obj in particleSystems)
{
obj.Stop();
obj.Clear();
}
_particleSystemColorFromEffectData.Start();
}
}
}
public sealed class ParticleSystemRandomColorRestarter : MonoBehaviour, IEffectRestarter
{
private ParticleSystemRandomColor _particleSystemRandomColor;
private void Awake()
{
_particleSystemRandomColor = ((Component)this).GetComponent<ParticleSystemRandomColor>();
}
void IEffectRestarter.Restart()
{
if (Object.op_Implicit((Object)(object)_particleSystemRandomColor))
{
_particleSystemRandomColor.Awake();
}
}
}
internal static class PooledEffectStartFix
{
[SystemInitializer(new Type[] { typeof(EffectCatalog) })]
private static void Init()
{
for (int i = 0; i < EffectCatalog.effectCount; i++)
{
EffectDef effectDef = EffectCatalog.GetEffectDef((EffectIndex)i);
GameObject prefab;
if (effectDef != null && Object.op_Implicit((Object)(object)effectDef.prefab) && (!Object.op_Implicit((Object)(object)effectDef.prefabVfxAttributes) || !effectDef.prefabVfxAttributes.DoNotPool))
{
prefab = effectDef.prefab;
if (false | tryAddRestarters<LightScaleFromParent, LightScaleFromParentRestarter>() | tryAddRestarters<ImpactEffect, ImpactEffectRestarter>() | tryAddRestarters<ParticleSystemColorFromEffectData, ParticleSystemColorFromEffectDataRestarter>() | tryAddRestarters<CoinBehavior, CoinBehaviorRestarter>() | tryAddRestarters<VelocityRandomOnStart, VelocityRandomOnStartRestarter>() | tryAddRestarters<ParticleSystemRandomColor, ParticleSystemRandomColorRestarter>() | tryAddRestarters<ApplyTorqueOnStart, ApplyTorqueOnStartRestarter>() | tryAddRestarters<ApplyForceOnStart, ApplyForceOnStartRestarter>() | tryAddRestarters<ExplodeRigidbodiesOnStart, ExplodeRigidbodiesOnStartRestarter>() | tryAddRestarters<SetRandomRotation, SetRandomRotationRestarter>() | tryAddRestarters<EffectPassArgsToLocalToken, EffectPassArgsToLocalTokenRestarter>())
{
UnityObjectExtensions.EnsureComponent<EffectRestarterController>(prefab);
}
}
bool tryAddRestarters<TComponent, TRestarter>() where TComponent : Component where TRestarter : MonoBehaviour, IEffectRestarter
{
bool result = false;
TComponent[] componentsInChildren = prefab.GetComponentsInChildren<TComponent>(true);
for (int j = 0; j < componentsInChildren.Length; j++)
{
((Component)componentsInChildren[j]).gameObject.AddComponent<TRestarter>();
result = true;
}
return result;
}
}
}
[Conditional("DEBUG")]
private static void logUnhandledStartComponents(EffectDef effectDef)
{
MonoBehaviour[] componentsInChildren = effectDef.prefab.GetComponentsInChildren<MonoBehaviour>();
foreach (MonoBehaviour val in componentsInChildren)
{
Type type = ((object)val).GetType();
if (type == typeof(EffectComponent) || type == typeof(DestroyOnTimer) || type == typeof(DestroyOnParticleEnd) || type == typeof(AnimateShaderAlpha) || type == typeof(LightScaleFromParent) || type == typeof(RTPCController) || type == typeof(TeamFilter) || type == typeof(ScaleParticleSystemDuration) || type == typeof(RotateObject) || type == typeof(AlignToNormal) || type == typeof(OmniEffect) || type == typeof(ImpactEffect) || type == typeof(ParticleSystemColorFromEffectData) || type == typeof(LaserPointer) || type == typeof(CoinBehavior) || type == typeof(VelocityRandomOnStart) || type == typeof(ParticleSystemRandomColor) || type == typeof(RigidbodyStickOnImpact) || type == typeof(ApplyTorqueOnStart) || type == typeof(ApplyForceOnStart) || type == typeof(ExplodeRigidbodiesOnStart) || type == typeof(MaintainRotation) || type == typeof(RotateItem) || type == typeof(SetRandomRotation) || type == typeof(Tracer) || type == typeof(BeamPointsFromTransforms) || type == typeof(LineBetweenTransforms) || type == typeof(MultiPointBezierCurveLine) || type == typeof(AddOverlayToReferencedObject) || type == typeof(TemporaryOverlay) || type == typeof(RendererColorFromEffectData) || type == typeof(EffectRetimer) || type == typeof(EffectPassArgsToLocalToken) || type == typeof(RotateIfMoving) || type == typeof(PickRandomObjectOnAwake) || type == typeof(PlatformToggle))
{
continue;
}
bool num = type.GetMethod("Awake", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) != null || type.GetMethod("Start", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) != null;
bool flag = type.GetMethod("OnEnable", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) != null;
if (num && !flag)
{
string text = "Init-only component " + type.FullName + " on " + effectDef.prefabName;
if ((Object)(object)((Component)val).transform != (Object)(object)effectDef.prefab.transform)
{
text = text + ", at " + Util.BuildPrefabTransformPath(effectDef.prefab.transform, ((Component)val).transform, false, true);
}
Log.Info(text, "X:\\Git\\RoR2\\VFiX\\VFiX\\PooledEffectStart\\PooledEffectStartFix.cs", "logUnhandledStartComponents", 92);
}
}
}
}
public sealed class RotateIfMovingRestarter : MonoBehaviour, IEffectRestarter
{
private RotateIfMoving _rotateIfMoving;
private void Awake()
{
_rotateIfMoving = ((Component)this).GetComponent<RotateIfMoving>();
}
void IEffectRestarter.Restart()
{
if (Object.op_Implicit((Object)(object)_rotateIfMoving))
{
_rotateIfMoving.Start();
}
}
}
public sealed class SetRandomRotationRestarter : MonoBehaviour, IEffectRestarter
{
private SetRandomRotation _setRandomRotation;
private Vector3 _originalEulerAngles;
private void Awake()
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
_setRandomRotation = ((Component)this).GetComponent<SetRandomRotation>();
_originalEulerAngles = ((Component)this).transform.localEulerAngles;
}
void IEffectRestarter.Restart()
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
if (Object.op_Implicit((Object)(object)_setRandomRotation))
{
((Component)this).transform.localEulerAngles = _originalEulerAngles;
_setRandomRotation.Start();
}
}
}
public sealed class VelocityRandomOnStartRestarter : MonoBehaviour, IEffectRestarter
{
private VelocityRandomOnStart _velocityRandomOnStart;
private void Awake()
{
_velocityRandomOnStart = ((Component)this).GetComponent<VelocityRandomOnStart>();
}
void IEffectRestarter.Restart()
{
if (Object.op_Implicit((Object)(object)_velocityRandomOnStart))
{
_velocityRandomOnStart.Start();
}
}
}
}
namespace VFiX.PooledEffectEvents
{
internal static class PooledEffectStartEventFix
{
[SystemInitializer(new Type[] { })]
private static void Init()
{
convertStartEventsToEnable(RoR2_Base_Captain.CaptainAirstrikeGhost1_prefab);
static void convertStartEventsToEnable(string assetGuid)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
AssetLoadUtils.LoadTempAssetAsync<GameObject>(assetGuid).CallOnSuccess<GameObject>(transferStartEventsToEnable);
}
}
private static void transferStartEventsToEnable(GameObject obj)
{
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Expected O, but got Unknown
StartEvent val = default(StartEvent);
if (!obj.TryGetComponent<StartEvent>(ref val) || val.action == null)
{
return;
}
List<BaseInvokableCall> list = new List<BaseInvokableCall>();
List<PersistentCall> list2 = new List<PersistentCall>();
if (((UnityEventBase)val.action).m_Calls?.m_ExecutingCalls != null)
{
foreach (BaseInvokableCall executingCall in ((UnityEventBase)val.action).m_Calls.m_ExecutingCalls)
{
list.Add(executingCall);
}
}
if (((UnityEventBase)val.action).m_PersistentCalls != null)
{
foreach (PersistentCall listener in ((UnityEventBase)val.action).m_PersistentCalls.GetListeners())
{
list2.Add(listener);
}
}
if (list.Count <= 0 && list2.Count <= 0)
{
return;
}
OnEnableEvent val2 = UnityObjectExtensions.EnsureComponent<OnEnableEvent>(obj);
OnEnableEvent val3 = val2;
if (val3.action == null)
{
val3.action = new UnityEvent();
}
foreach (BaseInvokableCall item in list)
{
((UnityEventBase)val2.action).AddCall(item);
}
foreach (PersistentCall item2 in list2)
{
((UnityEventBase)val2.action).m_PersistentCalls.AddListener(item2);
}
((Behaviour)val).enabled = false;
}
}
}
namespace VFiX.PooledEffectCleanup
{
internal static class EffectPoolPreventInUsePoolClearFix
{
[CompilerGenerated]
private static class <>O
{
public static Manipulator <0>__EffectManager_UnloadOutdatedPools;
}
public static void Init()
{
//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>__EffectManager_UnloadOutdatedPools;
if (obj == null)
{
Manipulator val = EffectManager_UnloadOutdatedPools;
<>O.<0>__EffectManager_UnloadOutdatedPools = val;
obj = (object)val;
}
EffectManager.UnloadOutdatedPools += (Manipulator)obj;
}
private static void EffectManager_UnloadOutdatedPools(ILContext il)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Expected O, but got Unknown
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
PropertyInfo effectPrefabMapCount = typeof(Dictionary<GameObject, EffectPool>).GetProperty("Count");
if (effectPrefabMapCount == null)
{
Log.Error("Failed to find Dictionary Count property", "X:\\Git\\RoR2\\VFiX\\VFiX\\PooledEffectCleanup\\EffectPoolPreventInUsePoolClearFix.cs", "EffectManager_UnloadOutdatedPools", 26);
return;
}
int num = default(int);
if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[2]
{
(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)effectPrefabMapCount.GetMethod),
(Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, ref num)
}))
{
Log.Error("Failed to find patch location", "X:\\Git\\RoR2\\VFiX\\VFiX\\PooledEffectCleanup\\EffectPoolPreventInUsePoolClearFix.cs", "EffectManager_UnloadOutdatedPools", 34);
return;
}
val.Emit(OpCodes.Pop);
val.Emit(OpCodes.Ldc_I4, int.MaxValue);
}
}
internal static class PooledEffectCleanupSoundFix
{
[CompilerGenerated]
private static class <>O
{
public static hook_PreDestroyObject <0>__EffectPool_PreDestroyObject;
}
public static void Init()
{
//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>__EffectPool_PreDestroyObject;
if (obj == null)
{
hook_PreDestroyObject val = EffectPool_PreDestroyObject;
<>O.<0>__EffectPool_PreDestroyObject = val;
obj = (object)val;
}
EffectPool.PreDestroyObject += (hook_PreDestroyObject)obj;
}
private static void EffectPool_PreDestroyObject(orig_PreDestroyObject orig, EffectPool self, EffectManagerHelper inKillObject)
{
orig.Invoke(self, inKillObject);
AkTriggerHandler val = default(AkTriggerHandler);
if (Object.op_Implicit((Object)(object)inKillObject) && ((Component)inKillObject).TryGetComponent<AkTriggerHandler>(ref val))
{
val.triggerList.Clear();
}
}
}
}
namespace VFiX.MeteorStrikePredictionEffect
{
internal static class MeteorStrikePredictionEffectFix
{
public static void Init()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
AssetLoadUtils.LoadTempAssetAsync<GameObject>(RoR2_Base_Meteor.MeteorStrikePredictionEffect_prefab).CallOnSuccess(delegate(GameObject meteorStrikePredictionEffect)
{
Transform val = meteorStrikePredictionEffect.transform.Find("GroundSlamIndicator");
AnimateShaderAlpha val2 = default(AnimateShaderAlpha);
if (!Object.op_Implicit((Object)(object)val))
{
Log.Error("Failed to find GroundSlamIndicator", "X:\\Git\\RoR2\\VFiX\\VFiX\\MeteorStrikePredictionEffect\\MeteorStrikePredictionEffectFix.cs", "Init", 16);
}
else if (!((Component)val).TryGetComponent<AnimateShaderAlpha>(ref val2))
{
Log.Error(((Object)val).name + " is missing AnimateShaderAlpha component", "X:\\Git\\RoR2\\VFiX\\VFiX\\MeteorStrikePredictionEffect\\MeteorStrikePredictionEffectFix.cs", "Init", 22);
}
else
{
val2.continueExistingAfterTimeMaxIsReached = true;
}
});
}
}
}
namespace VFiX.GrandparentPreSpawnEffect
{
internal static class GrandparentPreSpawnEffectFix
{
public static void Init()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
AssetLoadUtils.LoadTempAssetAsync<GameObject>(RoR2_Base_Grandparent.GrandparentPreSpawnEffect_prefab).CallOnSuccess(delegate(GameObject grandparentPreSpawnEffect)
{
VFXAttributes val = default(VFXAttributes);
if (grandparentPreSpawnEffect.TryGetComponent<VFXAttributes>(ref val))
{
val.DoNotPool = true;
}
});
}
}
}
namespace VFiX.DitherFix
{
internal static class ModelDitherFix
{
[CompilerGenerated]
private sealed class <>c__DisplayClass1_0
{
public HashSet<string> loadedAssets;
public HashSet<Material> handledMaterials;
public int numFixedMaterials;
public ParallelCoroutine loadCoroutine;
public Stopwatch stopwatch;
}
private static readonly int _FadeOn = Shader.PropertyToID("_FadeOn");
[SystemInitializer(new Type[]
{
typeof(SkinCatalog),
typeof(BodyCatalog),
typeof(ItemDisplayRuleSet)
})]
private static void Init()
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Expected O, but got Unknown
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Invalid comparison between Unknown and I4
//IL_003d: 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_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: 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_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: 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_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_0128: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: 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_013f: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: Unknown result type (might be due to invalid IL or missing references)
//IL_016f: Unknown result type (might be due to invalid IL or missing references)
//IL_018e: Unknown result type (might be due to invalid IL or missing references)
<>c__DisplayClass1_0 CS$<>8__locals0 = new <>c__DisplayClass1_0();
CS$<>8__locals0.stopwatch = Stopwatch.StartNew();
CS$<>8__locals0.loadedAssets = new HashSet<string>();
CS$<>8__locals0.handledMaterials = new HashSet<Material>();
CS$<>8__locals0.numFixedMaterials = 0;
CS$<>8__locals0.loadCoroutine = new ParallelCoroutine();
for (SkinIndex val = (SkinIndex)0; (int)val < SkinCatalog.skinCount; val = (SkinIndex)(val + 1))
{
SkinDef skinDef = SkinCatalog.GetSkinDef(val);
if (Object.op_Implicit((Object)(object)skinDef))
{
var (val2, val3) = skinDef.GetSkinParams();
if (Object.op_Implicit((Object)(object)val3))
{
CS$<>8__locals0.loadCoroutine.Add(handleSkinParamsAsync(val3));
}
else if (val2 != null && ((AssetReference)val2).RuntimeKeyIsValid() && CS$<>8__locals0.loadedAssets.Add(((AssetReference)val2).RuntimeKey.ToString()))
{
CS$<>8__locals0.loadCoroutine.Add(loadSkinParamsAsync(val2));
}
}
}
foreach (ItemDisplayRuleSet instances in ItemDisplayRuleSet.instancesList)
{
KeyAssetRuleGroup[] keyAssetRuleGroups = instances.keyAssetRuleGroups;
foreach (KeyAssetRuleGroup val4 in keyAssetRuleGroups)
{
DisplayRuleGroup displayRuleGroup = val4.displayRuleGroup;
if (((DisplayRuleGroup)(ref displayRuleGroup)).isEmpty)
{
continue;
}
ItemDisplayRule[] rules = val4.displayRuleGroup.rules;
foreach (ItemDisplayRule val5 in rules)
{
if (Object.op_Implicit((Object)(object)val5.followerPrefab))
{
CS$<>8__locals0.loadCoroutine.Add(handleDisplayPrefabAsync(val5.followerPrefab));
}
else if (val5.followerPrefabAddress != null && ((AssetReference)val5.followerPrefabAddress).RuntimeKeyIsValid() && CS$<>8__locals0.loadedAssets.Add(((AssetReference)val5.followerPrefabAddress).RuntimeKey.ToString()))
{
CS$<>8__locals0.loadCoroutine.Add(loadDisplayPrefabAsync((AssetReferenceT<GameObject>)(object)val5.followerPrefabAddress));
}
}
}
}
((MonoBehaviour)RoR2Application.instance).StartCoroutine(runLoadCoroutine());
[IteratorStateMachine(typeof(<>c__DisplayClass1_0.<<Init>g__handleDisplayPrefabAsync|7>d))]
IEnumerator handleDisplayPrefabAsync(GameObject displayPrefab)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <>c__DisplayClass1_0.<<Init>g__handleDisplayPrefabAsync|7>d(0)
{
<>4__this = CS$<>8__locals0,
displayPrefab = displayPrefab
};
}
void handleMaterial(Material material)
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: 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)
if (Object.op_Implicit((Object)(object)material))
{
Shader shader = material.shader;
if (Object.op_Implicit((Object)(object)shader) && CS$<>8__locals0.handledMaterials.Add(material))
{
bool flag = false;
LocalKeywordSpace keywordSpace = shader.keywordSpace;
LocalKeyword val6 = ((LocalKeywordSpace)(ref keywordSpace)).FindKeyword("DITHER");
if (((LocalKeyword)(ref val6)).isValid && !material.IsKeywordEnabled("DITHER"))
{
material.EnableKeyword("DITHER");
flag = true;
}
if (material.HasInt(_FadeOn) && material.GetInt(_FadeOn) == 0)
{
material.SetInt(_FadeOn, 1);
flag = true;
}
if (flag)
{
CS$<>8__locals0.numFixedMaterials++;
}
}
}
}
IEnumerator handleRendererInfosAsync(IEnumerable<RendererInfo> rendererInfos)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Expected O, but got Unknown
//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_0016: 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_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
ParallelCoroutine val7 = new ParallelCoroutine();
foreach (RendererInfo rendererInfo in rendererInfos)
{
if (Object.op_Implicit((Object)(object)rendererInfo.defaultMaterial))
{
handleMaterial(rendererInfo.defaultMaterial);
}
else if (rendererInfo.defaultMaterialAddress != null && ((AssetReference)rendererInfo.defaultMaterialAddress).RuntimeKeyIsValid() && CS$<>8__locals0.loadedAssets.Add(((AssetReference)rendererInfo.defaultMaterialAddress).RuntimeKey.ToString()))
{
val7.Add(loadMaterialAsync(rendererInfo.defaultMaterialAddress));
}
}
return (IEnumerator)val7;
}
IEnumerator handleSkinParamsAsync(SkinDefParams skinDefParams)
{
return handleRendererInfosAsync(skinDefParams.rendererInfos);
}
[IteratorStateMachine(typeof(<>c__DisplayClass1_0.<<Init>g__loadDisplayPrefabAsync|6>d))]
IEnumerator loadDisplayPrefabAsync(AssetReferenceT<GameObject> displayPrefabReference)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <>c__DisplayClass1_0.<<Init>g__loadDisplayPrefabAsync|6>d(0)
{
<>4__this = CS$<>8__locals0,
displayPrefabReference = displayPrefabReference
};
}
[IteratorStateMachine(typeof(<>c__DisplayClass1_0.<<Init>g__loadMaterialAsync|1>d))]
IEnumerator loadMaterialAsync(AssetReferenceT<Material> materialReference)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <>c__DisplayClass1_0.<<Init>g__loadMaterialAsync|1>d(0)
{
<>4__this = CS$<>8__locals0,
materialReference = materialReference
};
}
[IteratorStateMachine(typeof(<>c__DisplayClass1_0.<<Init>g__loadSkinParamsAsync|5>d))]
IEnumerator loadSkinParamsAsync(AssetReferenceT<SkinDefParams> skinParamsReference)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <>c__DisplayClass1_0.<<Init>g__loadSkinParamsAsync|5>d(0)
{
<>4__this = CS$<>8__locals0,
skinParamsReference = skinParamsReference
};
}
[IteratorStateMachine(typeof(<>c__DisplayClass1_0.<<Init>g__runLoadCoroutine|3>d))]
IEnumerator runLoadCoroutine()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <>c__DisplayClass1_0.<<Init>g__runLoadCoroutine|3>d(0)
{
<>4__this = CS$<>8__locals0
};
}
}
}
}