using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using EntityStates;
using HG;
using HG.Reflection;
using IL.RoR2;
using IL.RoR2.Orbs;
using Microsoft.CodeAnalysis;
using Mono.Cecil;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using On.EntityStates;
using On.RoR2;
using R2API.AutoVersionGen;
using RoR2;
using RoR2.Orbs;
using RoR2.UI.MainMenu;
using Unity.Collections;
using Unity.Jobs;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("R2API.Skins")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.2.1.0")]
[assembly: AssemblyInformationalVersion("1.2.1+411af8d0c44901925a88ea0b5057f320e9567461")]
[assembly: AssemblyProduct("R2API.Skins")]
[assembly: AssemblyTitle("R2API.Skins")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.1.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
{
internal struct IconTexJob : IJobParallelFor
{
[ReadOnly]
public Color32 Top;
[ReadOnly]
public Color32 Right;
[ReadOnly]
public Color32 Bottom;
[ReadOnly]
public Color32 Left;
[ReadOnly]
public Color32 Line;
public NativeArray<Color32> TexOutput;
public void Execute(int index)
{
//IL_0033: 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_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
int num = index % 128 - 64;
int num2 = index / 128 - 64;
if (Math.Abs(Math.Abs(num2) - Math.Abs(num)) <= 2)
{
TexOutput[index] = Line;
}
else if (num2 > num && num2 > -num)
{
TexOutput[index] = Top;
}
else if (num2 < num && num2 < -num)
{
TexOutput[index] = Bottom;
}
else if (num2 > num && num2 < -num)
{
TexOutput[index] = Left;
}
else if (num2 < num && num2 > -num)
{
TexOutput[index] = Right;
}
}
}
public static class SkinLightReplacement
{
private struct RuntimeLightReplacement
{
public string path;
public Color color;
}
[CompilerGenerated]
private static class <>O
{
public static hook_ApplySkin <0>__SetLightOverrides;
}
private static List<(SkinDef, LightReplacement[])> _tuples = new List<(SkinDef, LightReplacement[])>();
private static Dictionary<SkinIndex, RuntimeLightReplacement[]> _skinIndexToLightReplacements = new Dictionary<SkinIndex, RuntimeLightReplacement[]>();
private static bool _hooksSet = false;
private static bool _catalogInitialized = false;
public static bool AddLightReplacement(SkinDef targetSkinDef, params LightReplacement[] lightReplacements)
{
SkinDef targetSkinDef2 = targetSkinDef;
SetHooks();
if (_catalogInitialized)
{
SkinsPlugin.Logger.LogInfo((object)$"Cannot add {lightReplacements.Length} light replacement(s) to the SkinDef {targetSkinDef2} because the skin catalog has already initialized.");
return false;
}
if (_tuples.Any<(SkinDef, LightReplacement[])>(((SkinDef, LightReplacement[]) t) => (Object)(object)t.Item1 == (Object)(object)targetSkinDef2))
{
SkinsPlugin.Logger.LogInfo((object)$"Cannot add {lightReplacements.Length} light replacement(s) to the SkinDef {targetSkinDef2} because the skinDef already has light replacements associated to it.");
return false;
}
_tuples.Add((targetSkinDef2, lightReplacements));
return true;
}
private static void SystemInit()
{
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
_catalogInitialized = true;
foreach (var tuple2 in _tuples)
{
var (skin, source) = tuple2;
_skinIndexToLightReplacements.Add(skin.skinIndex, source.Select(delegate(LightReplacement lr)
{
//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)
RuntimeLightReplacement result = default(RuntimeLightReplacement);
result.color = lr.color;
result.path = Util.BuildPrefabTransformPath(skin.rootObject.transform, ((Component)lr.light).transform, false, false);
return result;
}).ToArray());
}
}
private static void SetHooks()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Expected O, but got Unknown
if (!_hooksSet)
{
_hooksSet = true;
object obj = <>O.<0>__SetLightOverrides;
if (obj == null)
{
hook_ApplySkin val = SetLightOverrides;
<>O.<0>__SetLightOverrides = val;
obj = (object)val;
}
ModelSkinController.ApplySkin += (hook_ApplySkin)obj;
}
}
internal static void UnsetHooks()
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
_hooksSet = false;
object obj = <>O.<0>__SetLightOverrides;
if (obj == null)
{
hook_ApplySkin val = SetLightOverrides;
<>O.<0>__SetLightOverrides = val;
obj = (object)val;
}
ModelSkinController.ApplySkin -= (hook_ApplySkin)obj;
}
private static void SetLightOverrides(orig_ApplySkin orig, ModelSkinController self, int skinIndex)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
orig.Invoke(self, skinIndex);
SkinDef safe = ArrayUtils.GetSafe<SkinDef>(self.skins, skinIndex);
if (!Object.op_Implicit((Object)(object)safe) || !_skinIndexToLightReplacements.TryGetValue(safe.skinIndex, out RuntimeLightReplacement[] value))
{
return;
}
RuntimeLightReplacement[] array = value;
for (int i = 0; i < array.Length; i++)
{
RuntimeLightReplacement runtimeLightReplacement = array[i];
Light component = ((Component)((Component)self).transform.Find(runtimeLightReplacement.path)).GetComponent<Light>();
if (Object.op_Implicit((Object)(object)component))
{
component.color = runtimeLightReplacement.color;
}
}
}
}
[Serializable]
public struct LightReplacement
{
[Tooltip("The light which we will modify it's color")]
[PrefabReference]
public Light light;
[Tooltip("The new color for the light")]
public Color color;
}
public struct SkinDefParamsInfo
{
public string Name;
public string NameToken;
public Sprite? Icon;
public UnlockableDef? UnlockableDef;
public GameObject? RootObject;
public SkinDef?[]? BaseSkins;
public SkinDefParams? SkinDefParams;
public RendererInfo[]? RendererInfos;
public MeshReplacement[]? MeshReplacements;
public GameObjectActivation[]? GameObjectActivations;
public ProjectileGhostReplacement[]? ProjectileGhostReplacements;
public MinionSkinReplacement[]? MinionSkinReplacements;
}
[Obsolete]
public struct SkinDefInfo
{
[Obsolete]
public SkinDef?[]? BaseSkins;
[Obsolete]
public Sprite? Icon;
[Obsolete]
public string? NameToken;
[Obsolete]
public UnlockableDef? UnlockableDef;
[Obsolete]
public GameObject? RootObject;
[Obsolete]
public RendererInfo[]? RendererInfos;
[Obsolete]
public MeshReplacement[]? MeshReplacements;
[Obsolete]
public GameObjectActivation[]? GameObjectActivations;
[Obsolete]
public ProjectileGhostReplacement[]? ProjectileGhostReplacements;
[Obsolete]
public MinionSkinReplacement[]? MinionSkinReplacements;
[Obsolete]
public string? Name;
public static implicit operator SkinDefParamsInfo(SkinDefInfo orig)
{
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: 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_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: 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_012e: 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_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_0180: Unknown result type (might be due to invalid IL or missing references)
//IL_0185: Unknown result type (might be due to invalid IL or missing references)
//IL_018a: Unknown result type (might be due to invalid IL or missing references)
SkinDefParamsInfo skinDefParamsInfo = default(SkinDefParamsInfo);
skinDefParamsInfo.BaseSkins = orig.BaseSkins;
skinDefParamsInfo.Icon = orig.Icon;
skinDefParamsInfo.NameToken = orig.NameToken;
skinDefParamsInfo.UnlockableDef = orig.UnlockableDef;
skinDefParamsInfo.RootObject = orig.RootObject;
skinDefParamsInfo.RendererInfos = orig.RendererInfos;
skinDefParamsInfo.Name = orig.Name;
SkinDefParamsInfo result = skinDefParamsInfo;
if (orig.GameObjectActivations != null)
{
result.GameObjectActivations = (GameObjectActivation[]?)(object)new GameObjectActivation[orig.GameObjectActivations.Length];
for (int i = 0; i < orig.GameObjectActivations.Length; i++)
{
result.GameObjectActivations[i] = GameObjectActivation.op_Implicit(orig.GameObjectActivations[i]);
}
}
if (orig.MeshReplacements != null)
{
result.MeshReplacements = (MeshReplacement[]?)(object)new MeshReplacement[orig.MeshReplacements.Length];
for (int j = 0; j < orig.MeshReplacements.Length; j++)
{
result.MeshReplacements[j] = MeshReplacement.op_Implicit(orig.MeshReplacements[j]);
}
}
if (orig.ProjectileGhostReplacements != null)
{
result.ProjectileGhostReplacements = (ProjectileGhostReplacement[]?)(object)new ProjectileGhostReplacement[orig.ProjectileGhostReplacements.Length];
for (int k = 0; k < orig.ProjectileGhostReplacements.Length; k++)
{
result.ProjectileGhostReplacements[k] = ProjectileGhostReplacement.op_Implicit(orig.ProjectileGhostReplacements[k]);
}
}
if (orig.MinionSkinReplacements != null)
{
result.MinionSkinReplacements = (MinionSkinReplacement[]?)(object)new MinionSkinReplacement[orig.MinionSkinReplacements.Length];
for (int l = 0; l < orig.MinionSkinReplacements.Length; l++)
{
result.MinionSkinReplacements[l] = MinionSkinReplacement.op_Implicit(orig.MinionSkinReplacements[l]);
}
}
return result;
}
}
public static class SkinIDRS
{
[CompilerGenerated]
private static class <>O
{
public static hook_ApplySkin <0>__SetCustomIDRS;
public static Action <1>__SystemInit;
}
private static readonly Dictionary<SkinDef, ItemDisplayRuleSet> skinToIDRS = new Dictionary<SkinDef, ItemDisplayRuleSet>();
private static readonly Dictionary<SkinDef, Dictionary<Object, DisplayRuleGroup>> skinIDRSOverrides = new Dictionary<SkinDef, Dictionary<Object, DisplayRuleGroup>>();
private static bool hooksSet = false;
private static bool initialized = false;
internal static void SetHooks()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Expected O, but got Unknown
if (!hooksSet)
{
hooksSet = true;
object obj = <>O.<0>__SetCustomIDRS;
if (obj == null)
{
hook_ApplySkin val = SetCustomIDRS;
<>O.<0>__SetCustomIDRS = val;
obj = (object)val;
}
ModelSkinController.ApplySkin += (hook_ApplySkin)obj;
RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(SystemInit));
}
}
internal static void UnsetHooks()
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
hooksSet = false;
object obj = <>O.<0>__SetCustomIDRS;
if (obj == null)
{
hook_ApplySkin val = SetCustomIDRS;
<>O.<0>__SetCustomIDRS = val;
obj = (object)val;
}
ModelSkinController.ApplySkin -= (hook_ApplySkin)obj;
RoR2Application.onLoad = (Action)Delegate.Remove(RoR2Application.onLoad, new Action(SystemInit));
}
public static bool AddPair(SkinDef skinDef, ItemDisplayRuleSet ruleSet)
{
SetHooks();
if (initialized)
{
SkinsPlugin.Logger.LogInfo((object)$"Cannot add pair {skinDef} && {ruleSet} as the SkinIDRS has already initialized.");
return false;
}
if (skinToIDRS.ContainsKey(skinDef))
{
SkinsPlugin.Logger.LogInfo((object)$"Cannot add pair {skinDef} && {ruleSet}, the skin {skinDef} already has an entry associated to it.");
return false;
}
skinToIDRS[skinDef] = ruleSet;
return true;
}
public static bool AddGroupOverride(SkinDef skinDef, Object keyAsset, DisplayRuleGroup displayRuleGroup)
{
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
SetHooks();
if (initialized)
{
SkinsPlugin.Logger.LogInfo((object)"Cannot add group SkinIDRS has already initialized.");
return false;
}
if (!skinIDRSOverrides.TryGetValue(skinDef, out Dictionary<Object, DisplayRuleGroup> value))
{
value = (skinIDRSOverrides[skinDef] = new Dictionary<Object, DisplayRuleGroup>());
}
value[keyAsset] = displayRuleGroup;
return true;
}
private static void SystemInit()
{
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
initialized = true;
ModelLocator val = default(ModelLocator);
CharacterModel val2 = default(CharacterModel);
foreach (CharacterBody allBodyPrefabBodyBodyComponent in BodyCatalog.allBodyPrefabBodyBodyComponents)
{
if (!Object.op_Implicit((Object)(object)allBodyPrefabBodyBodyComponent) || !((Component)allBodyPrefabBodyBodyComponent).TryGetComponent<ModelLocator>(ref val) || !Object.op_Implicit((Object)(object)val.modelTransform) || !((Component)val.modelTransform).TryGetComponent<CharacterModel>(ref val2))
{
continue;
}
ItemDisplayRuleSet itemDisplayRuleSet = val2.itemDisplayRuleSet;
SkinDef[] bodySkinDefs = SkinCatalog.GetBodySkinDefs(allBodyPrefabBodyBodyComponent.bodyIndex);
foreach (SkinDef key in bodySkinDefs)
{
if (!skinIDRSOverrides.TryGetValue(key, out Dictionary<Object, DisplayRuleGroup> value))
{
if (!skinToIDRS.ContainsKey(key))
{
skinToIDRS[key] = itemDisplayRuleSet;
}
continue;
}
if (!skinToIDRS.TryGetValue(key, out ItemDisplayRuleSet value2))
{
value2 = (skinToIDRS[key] = (Object.op_Implicit((Object)(object)itemDisplayRuleSet) ? Object.Instantiate<ItemDisplayRuleSet>(itemDisplayRuleSet) : ScriptableObject.CreateInstance<ItemDisplayRuleSet>()));
}
foreach (KeyValuePair<Object, DisplayRuleGroup> item in value)
{
value2.SetDisplayRuleGroup(item.Key, item.Value);
}
IEnumerator enumerator3 = value2.GenerateRuntimeValuesAsync();
while (enumerator3.MoveNext())
{
}
}
}
skinIDRSOverrides.Clear();
}
private static void SetCustomIDRS(orig_ApplySkin orig, ModelSkinController self, int skinIndex)
{
orig.Invoke(self, skinIndex);
SkinDef safe = ArrayUtils.GetSafe<SkinDef>(self.skins, skinIndex);
if (Object.op_Implicit((Object)(object)safe) && skinToIDRS.TryGetValue(safe, out ItemDisplayRuleSet value))
{
self.characterModel.itemDisplayRuleSet = value;
}
}
}
[AutoVersion]
public static class Skins
{
public const string PluginGUID = "com.bepis.r2api.skins";
public const string PluginName = "R2API.Skins";
private static bool _hooksSet;
public const string PluginVersion = "1.2.1";
internal static void SetHooks()
{
if (!_hooksSet)
{
_hooksSet = true;
MainMenuController.OnMainMenuInitialised += OnMainMenuInitialized;
}
}
internal static void UnsetHooks()
{
_hooksSet = false;
MainMenuController.OnMainMenuInitialised += OnMainMenuInitialized;
}
private static void OnMainMenuInitialized()
{
MainMenuController.OnMainMenuInitialised -= OnMainMenuInitialized;
SurvivorDef[] survivorDefs = SurvivorCatalog.survivorDefs;
foreach (SurvivorDef val in survivorDefs)
{
if (!Object.op_Implicit((Object)(object)val))
{
continue;
}
GameObject displayPrefab = val.displayPrefab;
GameObject bodyPrefab = val.bodyPrefab;
if (!Object.op_Implicit((Object)(object)displayPrefab) || !Object.op_Implicit((Object)(object)bodyPrefab))
{
SkinsPlugin.Logger.LogWarning((object)("SurvivorDef " + val.cachedName + " is missing a displayPrefab or bodyPrefab! You need to have this! Skipping..."));
continue;
}
ModelSkinController componentInChildren = bodyPrefab.GetComponentInChildren<ModelSkinController>();
if (!Object.op_Implicit((Object)(object)componentInChildren) || componentInChildren.skins == null || componentInChildren.skins.Length == 0)
{
SkinsPlugin.Logger.LogWarning((object)("BodyPrefab for " + val.cachedName + " is missing a ModelSkinController on the bodyPrefab! You need to have this! Skipping..."));
continue;
}
CharacterModel componentInChildren2 = displayPrefab.GetComponentInChildren<CharacterModel>();
if (!Object.op_Implicit((Object)(object)componentInChildren2))
{
SkinsPlugin.Logger.LogWarning((object)("Display prefab " + ((Object)displayPrefab).name + " is missing the CharacterModel component! You need to have this! Skipping..."));
continue;
}
ModelSkinController val2 = ((Component)componentInChildren2).GetComponent<ModelSkinController>();
if (!Object.op_Implicit((Object)(object)val2))
{
SkinsPlugin.Logger.LogWarning((object)("Display prefab " + ((Object)componentInChildren2).name + " is missing a ModelSkinController component!\r\nHighly recommended you set the controller up manually. Adding component..."));
val2 = ((Component)componentInChildren2).gameObject.AddComponent<ModelSkinController>();
}
ModelSkinController val3 = val2;
if (val3.skins == null)
{
val3.skins = Array.Empty<SkinDef>();
}
if (val2.skins.Length != componentInChildren.skins.Length)
{
SkinsPlugin.Logger.LogWarning((object)("ModelSkinController skins array on the displayPrefab " + ((Object)componentInChildren2).name + " array does not match the one on the bodyPrefab!\r\nHighly recommended you set the controller up manually. Cloning from body prefab..."));
val2.skins = ArrayUtils.Clone<SkinDef>(componentInChildren.skins);
}
}
}
public static SkinDef CreateNewSkinDef(SkinDefParamsInfo skin)
{
SetHooks();
SkinDef val = ScriptableObject.CreateInstance<SkinDef>();
((Object)val).name = skin.Name;
val.nameToken = skin.NameToken;
val.icon = skin.Icon;
val.baseSkins = skin.BaseSkins ?? Array.Empty<SkinDef>();
val.unlockableDef = skin.UnlockableDef;
val.rootObject = skin.RootObject;
val.skinDefParams = skin.SkinDefParams;
if ((Object)(object)val.skinDefParams == (Object)null)
{
val.skinDefParams = ScriptableObject.CreateInstance<SkinDefParams>();
val.skinDefParams.rendererInfos = skin.RendererInfos ?? Array.Empty<RendererInfo>();
val.skinDefParams.gameObjectActivations = skin.GameObjectActivations ?? Array.Empty<GameObjectActivation>();
val.skinDefParams.meshReplacements = skin.MeshReplacements ?? Array.Empty<MeshReplacement>();
val.skinDefParams.projectileGhostReplacements = skin.ProjectileGhostReplacements ?? Array.Empty<ProjectileGhostReplacement>();
val.skinDefParams.minionSkinReplacements = skin.MinionSkinReplacements ?? Array.Empty<MinionSkinReplacement>();
}
return val;
}
[Obsolete]
public static SkinDef CreateNewSkinDef(SkinDefInfo skin)
{
SetHooks();
SkinDef obj = CreateNewSkinDef((SkinDefParamsInfo)skin);
obj.rendererInfos = skin.RendererInfos;
obj.gameObjectActivations = skin.GameObjectActivations;
obj.meshReplacements = skin.MeshReplacements;
obj.projectileGhostReplacements = skin.ProjectileGhostReplacements;
obj.minionSkinReplacements = skin.MinionSkinReplacements;
return obj;
}
public static bool AddSkinToCharacter(GameObject? bodyPrefab, SkinDefParamsInfo skin)
{
SetHooks();
SkinDef skin2 = CreateNewSkinDef(skin);
return AddSkinToCharacter(bodyPrefab, skin2);
}
[Obsolete]
public static bool AddSkinToCharacter(GameObject? bodyPrefab, SkinDefInfo skin)
{
SetHooks();
SkinDef skin2 = CreateNewSkinDef(skin);
return AddSkinToCharacter(bodyPrefab, skin2);
}
public static bool AddSkinToCharacter(GameObject? bodyPrefab, SkinDef? skin)
{
//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
SetHooks();
if ((Object)(object)bodyPrefab == (Object)null)
{
SkinsPlugin.Logger.LogError((object)"Tried to add skin to null body prefab.");
return false;
}
if ((Object)(object)skin == (Object)null)
{
SkinsPlugin.Logger.LogError((object)"Tried to add invalid skin.");
return false;
}
if (string.IsNullOrEmpty(((Object)skin).name) || string.IsNullOrEmpty(skin.nameToken))
{
SkinsPlugin.Logger.LogError((object)"Tried to add invalid skin. Please add a name and nameToken.");
return false;
}
ModelLocator val = default(ModelLocator);
if (!bodyPrefab.TryGetComponent<ModelLocator>(ref val))
{
SkinsPlugin.Logger.LogError((object)"Tried to add skin to invalid body prefab (No ModelLocator).");
return false;
}
Transform modelTransform = val.modelTransform;
if ((Object)(object)modelTransform == (Object)null)
{
SkinsPlugin.Logger.LogError((object)"Tried to add skin to body prefab with no modelTransform.");
return false;
}
if ((Object)(object)skin.rootObject != (Object)(object)((Component)modelTransform).gameObject)
{
SkinsPlugin.Logger.LogError((object)"Tried to add skin with improper root object set.");
return false;
}
ModelSkinController val2 = default(ModelSkinController);
if (!((Component)modelTransform).TryGetComponent<ModelSkinController>(ref val2))
{
SkinsPlugin.Logger.LogWarning((object)(((Object)bodyPrefab).name + " does not have a modelSkinController.\nAdding a new one and attempting to populate the default skin.\nHighly recommended you set the controller up manually."));
CharacterModel val3 = default(CharacterModel);
if (!((Component)modelTransform).TryGetComponent<CharacterModel>(ref val3))
{
SkinsPlugin.Logger.LogError((object)"Unable to locate CharacterModel, default skin creation aborted.");
return false;
}
SkinnedMeshRenderer mainSkinnedMeshRenderer = val3.mainSkinnedMeshRenderer;
if ((Object)(object)mainSkinnedMeshRenderer == (Object)null)
{
SkinsPlugin.Logger.LogError((object)"CharacterModel did not contain a main SkinnedMeshRenderer, default skin creation aborted.");
return false;
}
RendererInfo[] baseRendererInfos = val3.baseRendererInfos;
if (baseRendererInfos == null || baseRendererInfos.Length == 0)
{
SkinsPlugin.Logger.LogError((object)"CharacterModel rendererInfos are invalid, default skin creation aborted.");
return false;
}
val2 = ((Component)modelTransform).gameObject.AddComponent<ModelSkinController>();
SkinDefParamsInfo skin2 = default(SkinDefParamsInfo);
skin2.Icon = CreateDefaultSkinIcon();
skin2.Name = "skin" + ((Object)bodyPrefab).name + "Default";
skin2.NameToken = ((Object)bodyPrefab).name.ToUpper() + "_DEFAULT_SKIN_NAME";
skin2.RootObject = ((Component)modelTransform).gameObject;
skin2.UnlockableDef = null;
skin2.RendererInfos = ArrayUtils.Clone<RendererInfo>(val3.baseRendererInfos);
skin2.MeshReplacements = (MeshReplacement[]?)(object)new MeshReplacement[1]
{
new MeshReplacement
{
renderer = (Renderer)(object)mainSkinnedMeshRenderer,
mesh = mainSkinnedMeshRenderer.sharedMesh
}
};
SkinDef val4 = CreateNewSkinDef(skin2);
val2.skins = (SkinDef[])(object)new SkinDef[1] { val4 };
}
ArrayUtils.ArrayAppend<SkinDef>(ref val2.skins, ref skin);
return true;
}
public static Sprite CreateSkinIcon(Color top, Color right, Color bottom, Color left)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: 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_0008: 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)
SetHooks();
return CreateSkinIcon(top, right, bottom, left, new Color(0.6f, 0.6f, 0.6f));
}
public static Sprite CreateSkinIcon(Color top, Color right, Color bottom, Color left, Color line)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: 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_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_0069: 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_007d: 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_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
SetHooks();
Texture2D val = new Texture2D(128, 128, (TextureFormat)4, false);
IconTexJob iconTexJob = default(IconTexJob);
iconTexJob.Top = Color32.op_Implicit(top);
iconTexJob.Bottom = Color32.op_Implicit(bottom);
iconTexJob.Right = Color32.op_Implicit(right);
iconTexJob.Left = Color32.op_Implicit(left);
iconTexJob.Line = Color32.op_Implicit(line);
iconTexJob.TexOutput = val.GetRawTextureData<Color32>();
IconTexJob iconTexJob2 = iconTexJob;
JobHandle val2 = default(JobHandle);
val2 = IJobParallelForExtensions.Schedule<IconTexJob>(iconTexJob2, 16384, 1, val2);
((JobHandle)(ref val2)).Complete();
((Texture)val).wrapMode = (TextureWrapMode)1;
val.Apply();
return Sprite.Create(val, new Rect(0f, 0f, 128f, 128f), new Vector2(0.5f, 0.5f));
}
private static Sprite CreateDefaultSkinIcon()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
return CreateSkinIcon(Color.red, Color.green, Color.blue, Color.black);
}
}
[BepInPlugin("com.bepis.r2api.skins", "R2API.Skins", "1.2.1")]
public sealed class SkinsPlugin : BaseUnityPlugin
{
internal static ManualLogSource Logger { get; set; }
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
}
private void OnEnable()
{
Skins.SetHooks();
SkinIDRS.SetHooks();
SkinVFX.SetHooks();
}
private void OnDisable()
{
Skins.UnsetHooks();
SkinIDRS.UnsetHooks();
SkinVFX.UnsetHooks();
SkinLightReplacement.UnsetHooks();
}
}
public static class SkinVFX
{
public delegate void OnEffectSpawnedDelegate(GameObject spawnedEffect);
[CompilerGenerated]
private static class <>O
{
public static hook_Start <0>__ApplyModifier;
public static hook_SpawnEffect_GameObject_EffectData_bool <1>__ApplyReplacement;
public static Manipulator <2>__ModifyBulletAttack;
public static Manipulator <3>__ModifyMuzzleFlash;
public static hook_BeginMeleeAttackEffect <4>__ModifyGenericMelee;
public static Manipulator <5>__ModifyGenericOrb;
}
private static List<SkinVFXInfo> skinVFXInfos = new List<SkinVFXInfo>();
private static bool hooksSet = false;
private const uint BaseIdentifier = 24000u;
private static uint currentIdentifier = 24000u;
private static bool hasCatalogInitOccured = false;
private static uint nextIdentifier => currentIdentifier++;
internal static void SetHooks()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Expected O, but got Unknown
//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_0049: Expected O, but got Unknown
//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_0069: Expected O, but got Unknown
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Expected O, but got Unknown
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Expected O, but got Unknown
//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_00c9: Expected O, but got Unknown
if (!hooksSet)
{
hooksSet = true;
object obj = <>O.<0>__ApplyModifier;
if (obj == null)
{
hook_Start val = ApplyModifier;
<>O.<0>__ApplyModifier = val;
obj = (object)val;
}
EffectComponent.Start += (hook_Start)obj;
object obj2 = <>O.<1>__ApplyReplacement;
if (obj2 == null)
{
hook_SpawnEffect_GameObject_EffectData_bool val2 = ApplyReplacement;
<>O.<1>__ApplyReplacement = val2;
obj2 = (object)val2;
}
EffectManager.SpawnEffect_GameObject_EffectData_bool += (hook_SpawnEffect_GameObject_EffectData_bool)obj2;
object obj3 = <>O.<2>__ModifyBulletAttack;
if (obj3 == null)
{
Manipulator val3 = ModifyBulletAttack;
<>O.<2>__ModifyBulletAttack = val3;
obj3 = (object)val3;
}
BulletAttack.FireSingle += (Manipulator)obj3;
object obj4 = <>O.<3>__ModifyMuzzleFlash;
if (obj4 == null)
{
Manipulator val4 = ModifyMuzzleFlash;
<>O.<3>__ModifyMuzzleFlash = val4;
obj4 = (object)val4;
}
EffectManager.SimpleMuzzleFlash += (Manipulator)obj4;
object obj5 = <>O.<4>__ModifyGenericMelee;
if (obj5 == null)
{
hook_BeginMeleeAttackEffect val5 = ModifyGenericMelee;
<>O.<4>__ModifyGenericMelee = val5;
obj5 = (object)val5;
}
BasicMeleeAttack.BeginMeleeAttackEffect += (hook_BeginMeleeAttackEffect)obj5;
object obj6 = <>O.<5>__ModifyGenericOrb;
if (obj6 == null)
{
Manipulator val6 = ModifyGenericOrb;
<>O.<5>__ModifyGenericOrb = val6;
obj6 = (object)val6;
}
GenericDamageOrb.Begin += (Manipulator)obj6;
}
}
internal static void UnsetHooks()
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Expected O, but got Unknown
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Expected O, but got Unknown
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Expected O, but got Unknown
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Expected O, but got Unknown
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Expected O, but got Unknown
hooksSet = false;
object obj = <>O.<0>__ApplyModifier;
if (obj == null)
{
hook_Start val = ApplyModifier;
<>O.<0>__ApplyModifier = val;
obj = (object)val;
}
EffectComponent.Start -= (hook_Start)obj;
object obj2 = <>O.<1>__ApplyReplacement;
if (obj2 == null)
{
hook_SpawnEffect_GameObject_EffectData_bool val2 = ApplyReplacement;
<>O.<1>__ApplyReplacement = val2;
obj2 = (object)val2;
}
EffectManager.SpawnEffect_GameObject_EffectData_bool -= (hook_SpawnEffect_GameObject_EffectData_bool)obj2;
object obj3 = <>O.<2>__ModifyBulletAttack;
if (obj3 == null)
{
Manipulator val3 = ModifyBulletAttack;
<>O.<2>__ModifyBulletAttack = val3;
obj3 = (object)val3;
}
BulletAttack.FireSingle -= (Manipulator)obj3;
object obj4 = <>O.<3>__ModifyMuzzleFlash;
if (obj4 == null)
{
Manipulator val4 = ModifyMuzzleFlash;
<>O.<3>__ModifyMuzzleFlash = val4;
obj4 = (object)val4;
}
EffectManager.SimpleMuzzleFlash -= (Manipulator)obj4;
object obj5 = <>O.<4>__ModifyGenericMelee;
if (obj5 == null)
{
hook_BeginMeleeAttackEffect val5 = ModifyGenericMelee;
<>O.<4>__ModifyGenericMelee = val5;
obj5 = (object)val5;
}
BasicMeleeAttack.BeginMeleeAttackEffect -= (hook_BeginMeleeAttackEffect)obj5;
object obj6 = <>O.<5>__ModifyGenericOrb;
if (obj6 == null)
{
Manipulator val6 = ModifyGenericOrb;
<>O.<5>__ModifyGenericOrb = val6;
obj6 = (object)val6;
}
GenericDamageOrb.Begin -= (Manipulator)obj6;
}
[SystemInitializer(new Type[] { typeof(EffectCatalog) })]
private static void FindEffectIndexes()
{
//IL_0047: 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_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
hasCatalogInitOccured = true;
for (int i = 0; i < skinVFXInfos.Count; i++)
{
SkinVFXInfo skinVFXInfo = skinVFXInfos[i];
if (Object.op_Implicit((Object)(object)skinVFXInfo.EffectPrefab))
{
skinVFXInfo.TargetEffect = EffectCatalog.FindEffectIndexFromPrefab(skinVFXInfo.EffectPrefab);
}
else if (!string.IsNullOrEmpty(skinVFXInfo.EffectString))
{
EffectDef val = ((IEnumerable<EffectDef>)EffectCatalog.entries).FirstOrDefault((Func<EffectDef, bool>)((EffectDef effectDef) => effectDef.prefabName == skinVFXInfo.EffectString));
if (val == null)
{
SkinsPlugin.Logger.LogError((object)("Failed to find effect " + skinVFXInfo.EffectString + " for SkinVFXInfo!"));
}
else
{
skinVFXInfo.TargetEffect = val.index;
}
}
}
}
private static SkinVFXInfo FindSkinVFXInfo(uint identifier)
{
if (identifier < 24000 || identifier >= (long)skinVFXInfos.Count + 24000L)
{
return null;
}
return skinVFXInfos[(int)(identifier - 24000)];
}
private static SkinVFXInfo FindSkinVFXInfo(GameObject attacker, GameObject effectPrefab)
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
if (!Object.op_Implicit((Object)(object)attacker) || !Object.op_Implicit((Object)(object)effectPrefab))
{
return null;
}
SkinDef skinDef = SkinCatalog.FindCurrentSkinDefForBodyInstance(attacker);
EffectIndex index = EffectCatalog.FindEffectIndexFromPrefab(effectPrefab);
return skinVFXInfos.FirstOrDefault((SkinVFXInfo skinVFXInfo) => (Object)(object)skinVFXInfo.RequiredSkin == (Object)(object)skinDef && skinVFXInfo.TargetEffect == index);
}
private static void ModifyGenericMelee(orig_BeginMeleeAttackEffect orig, BasicMeleeAttack self)
{
SkinVFXInfo skinVFXInfo = FindSkinVFXInfo(((EntityState)self).gameObject, self.swingEffectPrefab);
if (skinVFXInfo != null && Object.op_Implicit((Object)(object)skinVFXInfo.ReplacementEffectPrefab))
{
self.swingEffectPrefab = skinVFXInfo.ReplacementEffectPrefab;
}
orig.Invoke(self);
if (skinVFXInfo != null && skinVFXInfo.OnEffectSpawned != null)
{
skinVFXInfo.OnEffectSpawned(self.swingEffectInstance);
}
}
private static void ApplyReplacement(orig_SpawnEffect_GameObject_EffectData_bool orig, GameObject effectPrefab, EffectData effectData, bool transmit)
{
if (effectData == null)
{
orig.Invoke(effectPrefab, effectData, transmit);
return;
}
if (effectData.genericUInt < 24000)
{
orig.Invoke(effectPrefab, effectData, transmit);
return;
}
SkinVFXInfo skinVFXInfo = FindSkinVFXInfo(effectData.genericUInt);
if (skinVFXInfo == null)
{
orig.Invoke(effectPrefab, effectData, transmit);
}
else if ((Object)(object)skinVFXInfo.ReplacementEffectPrefab != (Object)null)
{
orig.Invoke(skinVFXInfo.ReplacementEffectPrefab, effectData, transmit);
}
else
{
orig.Invoke(effectPrefab, effectData, transmit);
}
}
private static void ApplyModifier(orig_Start orig, EffectComponent self)
{
orig.Invoke(self);
if (self.effectData != null && self.effectData.genericUInt >= 24000)
{
FindSkinVFXInfo(self.effectData.genericUInt)?.OnEffectSpawned?.Invoke(((Component)self).gameObject);
}
}
private static void ModifyMuzzleFlash(ILContext il)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_0049: 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)
ILCursor val = new ILCursor(il);
if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
{
(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<EffectData>(x, "SetChildLocatorTransformReference")
}))
{
SkinsPlugin.Logger.LogError((object)"Failed to apply SkinVFX IL hook on EffectManager.SimpleMuzzleFlash");
return;
}
val.Emit(OpCodes.Ldarg_0);
val.Emit(OpCodes.Ldarg_1);
val.Emit(OpCodes.Ldloc, 4);
val.EmitDelegate<Action<GameObject, GameObject, EffectData>>((Action<GameObject, GameObject, EffectData>)delegate(GameObject effectPrefab, GameObject owner, EffectData data)
{
SkinVFXInfo skinVFXInfo = FindSkinVFXInfo(owner, effectPrefab);
if (skinVFXInfo != null)
{
data.genericUInt = skinVFXInfo.Identifier;
}
});
}
private static void ModifyGenericOrb(ILContext il)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//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)
ILCursor val = new ILCursor(il);
if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
{
(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<EffectData>(x, "SetHurtBoxReference")
}))
{
SkinsPlugin.Logger.LogError((object)$"Failed to apply SkinVFX IL hook on {il.Method.DeclaringType}.{((MemberReference)il.Method).Name}");
return;
}
val.Emit(OpCodes.Ldloc_0);
val.Emit(OpCodes.Ldarg_0);
val.EmitDelegate<Action<EffectData, GenericDamageOrb>>((Action<EffectData, GenericDamageOrb>)delegate(EffectData data, GenericDamageOrb orb)
{
if (data != null && Object.op_Implicit((Object)(object)orb.attacker))
{
SkinVFXInfo skinVFXInfo = FindSkinVFXInfo(orb.attacker, orb.GetOrbEffect());
if (skinVFXInfo != null)
{
data.genericUInt = skinVFXInfo.Identifier;
}
}
});
}
private static void ModifyBulletAttack(ILContext il)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
{
(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<EffectData>(x, "SetChildLocatorTransformReference")
}))
{
SkinsPlugin.Logger.LogError((object)"Failed to apply SkinVFX IL hook on BulletAttack.FireSingle");
return;
}
val.Emit(OpCodes.Ldarg_0);
val.EmitDelegate<Action<BulletAttack>>((Action<BulletAttack>)delegate(BulletAttack bulletAttack)
{
SkinVFXInfo skinVFXInfo = FindSkinVFXInfo(bulletAttack.owner, bulletAttack.tracerEffectPrefab);
if (skinVFXInfo != null)
{
BulletAttack._effectData.genericUInt = skinVFXInfo.Identifier;
}
});
}
public static SkinVFXInfo AddSkinVFX(SkinDef skinDef, EffectIndex targetEffect, GameObject replacementPrefab)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
SetHooks();
SkinVFXInfo obj = new SkinVFXInfo
{
RequiredSkin = skinDef,
TargetEffect = targetEffect,
ReplacementEffectPrefab = replacementPrefab
};
AddSkinVFX(obj);
return obj;
}
public static SkinVFXInfo AddSkinVFX(SkinDef skinDef, string targetEffect, GameObject replacementPrefab)
{
SetHooks();
SkinVFXInfo obj = new SkinVFXInfo
{
RequiredSkin = skinDef,
EffectString = targetEffect,
ReplacementEffectPrefab = replacementPrefab
};
AddSkinVFX(obj);
return obj;
}
public static SkinVFXInfo AddSkinVFX(SkinDef skinDef, GameObject targetEffect, GameObject replacementPrefab)
{
SetHooks();
SkinVFXInfo obj = new SkinVFXInfo
{
RequiredSkin = skinDef,
EffectPrefab = targetEffect,
ReplacementEffectPrefab = replacementPrefab
};
AddSkinVFX(obj);
return obj;
}
public static SkinVFXInfo AddSkinVFX(SkinDef skinDef, EffectIndex targetEffect, OnEffectSpawnedDelegate onEffectSpawned)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
SetHooks();
SkinVFXInfo obj = new SkinVFXInfo
{
RequiredSkin = skinDef,
TargetEffect = targetEffect,
OnEffectSpawned = onEffectSpawned
};
AddSkinVFX(obj);
return obj;
}
public static SkinVFXInfo AddSkinVFX(SkinDef skinDef, string targetEffect, OnEffectSpawnedDelegate onEffectSpawned)
{
SetHooks();
SkinVFXInfo obj = new SkinVFXInfo
{
RequiredSkin = skinDef,
EffectString = targetEffect,
OnEffectSpawned = onEffectSpawned
};
AddSkinVFX(obj);
return obj;
}
public static SkinVFXInfo AddSkinVFX(SkinDef skinDef, GameObject targetEffect, OnEffectSpawnedDelegate onEffectSpawned)
{
SetHooks();
SkinVFXInfo obj = new SkinVFXInfo
{
RequiredSkin = skinDef,
EffectPrefab = targetEffect,
OnEffectSpawned = onEffectSpawned
};
AddSkinVFX(obj);
return obj;
}
public static bool AddSkinVFX(SkinVFXInfo skinVFXInfo)
{
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Invalid comparison between Unknown and I4
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
SkinVFXInfo skinVFXInfo2 = skinVFXInfo;
SetHooks();
if (hasCatalogInitOccured && (Object)(object)skinVFXInfo2.EffectPrefab != (Object)null)
{
skinVFXInfo2.TargetEffect = EffectCatalog.FindEffectIndexFromPrefab(skinVFXInfo2.EffectPrefab);
EffectDef val = ((IEnumerable<EffectDef>)EffectCatalog.entries).FirstOrDefault((Func<EffectDef, bool>)((EffectDef effectDef) => effectDef.prefabName == skinVFXInfo2.EffectString));
if (val == null)
{
SkinsPlugin.Logger.LogError((object)("Failed to find effect " + skinVFXInfo2.EffectString + " for SkinVFXInfo!"));
return false;
}
skinVFXInfo2.TargetEffect = val.index;
}
if ((Object)(object)skinVFXInfo2.RequiredSkin == (Object)null)
{
SkinsPlugin.Logger.LogError((object)"Cannot add a SkinVFXInfo with no assigned SkinDef.");
return false;
}
if ((int)skinVFXInfo2.TargetEffect == -1 && (Object)(object)skinVFXInfo2.EffectPrefab == (Object)null && skinVFXInfo2.EffectString == null)
{
SkinsPlugin.Logger.LogError((object)"SkinVFXInfo may not have a TargetEffect of EffectIndex.Invalid, or must also specify an EffectPrefab or EffectString.");
return false;
}
if ((Object)(object)skinVFXInfo2.ReplacementEffectPrefab == (Object)null && skinVFXInfo2.OnEffectSpawned == null)
{
SkinsPlugin.Logger.LogError((object)"SkinVFXInfo must have either a ReplacementEffectPrefab or an OnEffectSpawnedDelegate assigned.");
return false;
}
skinVFXInfo2.Identifier = nextIdentifier;
skinVFXInfos.Add(skinVFXInfo2);
return true;
}
}
public class SkinVFXInfo
{
public SkinDef RequiredSkin;
public EffectIndex TargetEffect = (EffectIndex)(-1);
public GameObject? ReplacementEffectPrefab;
public SkinVFX.OnEffectSpawnedDelegate? OnEffectSpawned;
public uint Identifier = uint.MaxValue;
public GameObject EffectPrefab;
public string EffectString;
}
}
namespace R2API.AutoVersionGen
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
internal class AutoVersionAttribute : Attribute
{
}
}