using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using HedgehogUtils.Forms; using HedgehogUtils.Forms.SuperForm; using Microsoft.CodeAnalysis; using MonoMod.RuntimeDetour.HookGen; using On.RoR2; using On.RoR2.UI; using RoR2; using RoR2.ContentManagement; using RoR2.UI; using ShaderSwapper; using SonicTheHedgehog.SkillStates; using UnityEngine; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("AdventurousSkinForSonicTheHedgehog")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+4e677b0eefeda1f048ef1478386add03e5fd46bd")] [assembly: AssemblyProduct("AdventurousSkinForSonicTheHedgehog")] [assembly: AssemblyTitle("AdventurousSkinForSonicTheHedgehog")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace AdventurousSkinForSonicTheHedgehog { public class AdventurousSkinForSonicTheHedgehogContent : IContentPackProvider { internal static AssetBundle Bundle; internal static Dictionary LoadedAssets = new Dictionary(); internal static ContentPack AdventurousSkinForSonicTheHedgehogContentPack { get; } = new ContentPack(); public static ReadOnlyContentPack ReadOnlyContentPack => new ReadOnlyContentPack(AdventurousSkinForSonicTheHedgehogContentPack); public string identifier => "com.MushroomMerchant.AdventurousSkinforSonicTheHedgehog"; public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args) { AssetBundleCreateRequest asyncOperation = AssetBundle.LoadFromFileAsync(AdventurousSkinForSonicTheHedgehogMain.AssetBundleDir); while (!((AsyncOperation)asyncOperation).isDone) { args.ReportProgress(((AsyncOperation)asyncOperation).progress); yield return null; } Bundle = asyncOperation.assetBundle; } public IEnumerator GenerateContentPackAsync(GetContentPackAsyncArgs args) { ContentPack.Copy(AdventurousSkinForSonicTheHedgehogContentPack, args.output); args.ReportProgress(1f); yield break; } public IEnumerator FinalizeAsync(FinalizeAsyncArgs args) { ShaderSwapping.SwapShaders(); PopulateLoadedAssets(); ((ResourceAvailability)(ref BodyCatalog.availability)).CallWhenAvailable((Action)BodyCatalogInit); SoundReplacements.SetUpHooks(); args.ReportProgress(1f); yield break; } internal static T GetLoadedAsset(AssetID assetID) where T : Object { return (T)(object)LoadedAssets[assetID]; } private void PopulateLoadedAssets() { LoadedAssets.Add(AssetID.AnimatorOverrideController, (Object)(object)Bundle.LoadAsset("Assets/Animation/SonicAdventurousAnimatorOverrideController.overrideController")); LoadedAssets.Add(AssetID.PortraitIcon, (Object)(object)Bundle.LoadAsset("Assets/Icons/texSASonicIcon.png")); LoadedAssets.Add(AssetID.SkinIcon, (Object)(object)Bundle.LoadAsset("Assets/Icons/FromColors/texSonicAdventureSkinIcon.png")); LoadedAssets.Add(AssetID.SonicMesh, (Object)(object)Bundle.LoadAsset("Assets/Imports/SASonicMesh.mesh")); LoadedAssets.Add(AssetID.SonicMaterial, (Object)(object)Bundle.LoadAsset("Assets/Materials/matSASonic.mat")); LoadedAssets.Add(AssetID.SonicBallMesh, (Object)(object)Bundle.LoadAsset("Assets/Imports/SASonicBallMesh.mesh")); LoadedAssets.Add(AssetID.SonicBallMaterial, (Object)(object)Bundle.LoadAsset("Assets/Materials/matSASonicBall.mat")); LoadedAssets.Add(AssetID.SonicBallVFXPrefab, (Object)(object)Bundle.LoadAsset("Assets/Imports/SASonicBallVFX.prefab")); LoadedAssets.Add(AssetID.SonicBallVFXMaterial, (Object)(object)Bundle.LoadAsset("Assets/Materials/matSASonicBallVFX.mat")); LoadedAssets.Add(AssetID.SonicBallParticleMaterial, (Object)(object)Bundle.LoadAsset("Assets/Materials/matSASonicBallParticle.mat")); LoadedAssets.Add(AssetID.SuperSonicMesh, (Object)(object)Bundle.LoadAsset("Assets/Imports/SASuperSonicMesh2.mesh")); LoadedAssets.Add(AssetID.SuperSonicMaterial, (Object)(object)Bundle.LoadAsset("Assets/Materials/matSASuperSonic.mat")); LoadedAssets.Add(AssetID.SuperSonicBallMaterial, (Object)(object)Bundle.LoadAsset("Assets/Materials/matSASuperSonicBall.mat")); LoadedAssets.Add(AssetID.SuperSonicBallVFXPrefab, (Object)(object)Bundle.LoadAsset("Assets/Materials/matSASuperSonicBallVFX.mat")); LoadedAssets.Add(AssetID.SuperSonicBallVFXMaterial, (Object)(object)Bundle.LoadAsset("Assets/Materials/matSASuperSonicBallParticle.mat")); LoadedAssets.Add(AssetID.SuperSonicBallParticleMaterial, (Object)(object)Bundle.LoadAsset("Assets/Materials/matSASuperSonicBallParticle.mat")); } private void BodyCatalogInit() { //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) AdventurousSkinForSonicTheHedgehogMain.SonicBodyIndex = BodyCatalog.FindBodyIndex("SonicTheHedgehog"); SkinManagement.BodyCatalogInit(); AnimationChanges.BodyCatalogInit(); PortraitChanges.BodyCatalogInit(); } private void AddSelf(AddContentPackProviderDelegate addContentPackProvider) { addContentPackProvider.Invoke((IContentPackProvider)(object)this); } internal AdventurousSkinForSonicTheHedgehogContent() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown ContentManager.collectContentPackProviders += new CollectContentPackProvidersDelegate(AddSelf); } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("com.MushroomMerchant.AdventurousSkinforSonicTheHedgehog", "AdventurousSkinforSonicTheHedgehog", "1.0.2")] public class AdventurousSkinForSonicTheHedgehogMain : BaseUnityPlugin { public const string GUID = "com.MushroomMerchant.AdventurousSkinforSonicTheHedgehog"; public const string AUTHOR = "MushroomMerchant"; public const string MOD_NAME = "AdventurousSkinforSonicTheHedgehog"; public const string VERSION = "1.0.2"; public const string BODY_NAME = "SonicTheHedgehog"; public const string BODY_NAME_TOKEN = "DS_GAMING_SONIC_THE_HEDGEHOG_BODY_NAME"; internal static BodyIndex SonicBodyIndex; public static PluginInfo PluginInfo { get; private set; } public static AdventurousSkinForSonicTheHedgehogMain Instance { get; private set; } public static ConfigEntry ReplaceHomingImpactSoundConfig { get; set; } public static ConfigEntry ApplyCustomPortraitForSkin { get; set; } public static ConfigEntry BallFormForGrandSlamConfig { get; set; } public static ConfigEntry BallFormForHomingAttackConfig { get; set; } public static ConfigEntry BallFormForJumpConfig { get; set; } public static ConfigEntry CurlVFXConfig { get; set; } internal static AssetBundle AssetBundle { get; private set; } internal static string AssetBundleDir => Path.Combine(Path.GetDirectoryName(PluginInfo.Location), "adventurousskinforsonicthehedgehogassets"); private void Awake() { Instance = this; PluginInfo = ((BaseUnityPlugin)this).Info; BindConfig(); new AdventurousSkinForSonicTheHedgehogContent(); } private void Start() { LanguageSettings.AddLoadStringsHook(); } private void OnGUI() { if (!((Object)(object)AdventurousSkinForSonicTheHedgehogContent.Bundle == (Object)null)) { PortraitChanges.OnGUI(); } } private void BindConfig() { ReplaceHomingImpactSoundConfig = ((BaseUnityPlugin)this).Config.Bind("Sound Replacements: Homing Attack Impact", "ReplaceHomingImpactSound", true, "Replaces the metallic impact sound from landing a homing attack with a cartoony slap sound.\r\nThis replaces the sound for all skins."); ApplyCustomPortraitForSkin = ((BaseUnityPlugin)this).Config.Bind("Texture Replacements: Custom Portrait", "ApplyCustomPortraitForSkin", BasicConfigConditionSetting.Depends, "Replaces Sonic's portrait with a custom one whenever the Adventurous skin is active.\r\nA value of \"Default\" means that under certain circumstances (e.g. portrait-replacing mods are installed) the portrait will not be replaced; otherwise it will be.\r\nThis replaces the texture for the Adventurous skin."); BallFormForGrandSlamConfig = ((BaseUnityPlugin)this).Config.Bind("Mesh Replacements: Ball Form", "BallFormForGrandSlam", true, "Replaces Sonic's mesh with a sphere when performing the spindash at the beginning of his Grand Slam.\r\nThis replaces the mesh for the Adventurous skin."); BallFormForHomingAttackConfig = ((BaseUnityPlugin)this).Config.Bind("Mesh Replacements: Ball Form", "BallFormForHomingAttack", true, "Replaces Sonic's mesh with a sphere when performing his Homing Attack.\r\nThis replaces the mesh for the Adventurous skin."); BallFormForJumpConfig = ((BaseUnityPlugin)this).Config.Bind("Mesh Replacements: Ball Form", "BallFormForJump", false, "Replaces Sonic's mesh with a sphere when jumping.\r\nThis replaces the mesh for the Adventurous skin."); CurlVFXConfig = ((BaseUnityPlugin)this).Config.Bind("VFX: Curled Up (Jump, Homing Attack, Grand Slam)", "CurlVFX", true, "Adds a blue aura around Sonic when jumping and when performing a Homing Attack or a Grand Slam.\r\nThe aura also leaves a trail behind Sonic.\r\nThis adds the visual effect for the Adventurous skin."); } internal static void LogFatal(object data) { ((BaseUnityPlugin)Instance).Logger.LogFatal(data); } internal static void LogError(object data) { ((BaseUnityPlugin)Instance).Logger.LogError(data); } internal static void LogWarning(object data) { ((BaseUnityPlugin)Instance).Logger.LogWarning(data); } internal static void LogMessage(object data) { ((BaseUnityPlugin)Instance).Logger.LogMessage(data); } internal static void LogInfo(object data) { ((BaseUnityPlugin)Instance).Logger.LogInfo(data); } internal static void LogDebug(object data) { ((BaseUnityPlugin)Instance).Logger.LogDebug(data); } } public class AnimationChanges { private enum AnimatorOverrideInPlace { Yes, No } [CompilerGenerated] private static class <>O { public static hook_Update <0>__Run_Update; public static hook_Start <1>__ModelSkinController_Start; } private static readonly Dictionary AdventurousSonicAnimators = new Dictionary(); private static readonly Dictionary AdventurousSonicAnimatorsToSkinControllers = new Dictionary(); private static readonly Dictionary PreviousMeshesForSkinControllers = new Dictionary(); private static readonly Dictionary PreviousMaterialsForSkinControllers = new Dictionary(); private static readonly Dictionary PreviousVFXForSkinControllers = new Dictionary(); internal static void BodyCatalogInit() { //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 //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown object obj = <>O.<0>__Run_Update; if (obj == null) { hook_Update val = Run_Update; <>O.<0>__Run_Update = val; obj = (object)val; } Run.Update += (hook_Update)obj; object obj2 = <>O.<1>__ModelSkinController_Start; if (obj2 == null) { hook_Start val2 = ModelSkinController_Start; <>O.<1>__ModelSkinController_Start = val2; obj2 = (object)val2; } ModelSkinController.Start += (hook_Start)obj2; } private static void Run_Update(orig_Update orig, Run self) { ApplyAnimatorOverrideController(); ReplaceMeshWithBall(); ApplyVFX(); orig.Invoke(self); } private static void ModelSkinController_Start(orig_Start orig, ModelSkinController self) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) orig.Invoke(self); if (((ResourceAvailability)(ref BodyCatalog.availability)).available && !((Object)(object)self.characterModel == (Object)null) && !((Object)(object)self.characterModel.body == (Object)null) && self.characterModel.body.bodyIndex == AdventurousSkinForSonicTheHedgehogMain.SonicBodyIndex && (Object)(object)self.animator != (Object)null) { AdventurousSonicAnimators.Add(self.animator, AnimatorOverrideInPlace.No); AdventurousSonicAnimatorsToSkinControllers.Add(self.animator, self); } } internal static void ApplyAnimatorOverrideController() { //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown if ((Object)(object)AdventurousSkinForSonicTheHedgehogContent.Bundle == (Object)null) { return; } AnimatorOverrideController loadedAsset = AdventurousSkinForSonicTheHedgehogContent.GetLoadedAsset(AssetID.AnimatorOverrideController); Dictionary dictionary = new Dictionary(); foreach (KeyValuePair adventurousSonicAnimator in AdventurousSonicAnimators) { Animator key = adventurousSonicAnimator.Key; AnimatorOverrideInPlace value = adventurousSonicAnimator.Value; if (!((Object)(object)key == (Object)null) && value != AnimatorOverrideInPlace.Yes && AdventurousSonicAnimatorsToSkinControllers[key].currentSkinIndex == SkinManagement.AdventurousSkinIndex) { AnimatorOverrideController val = new AnimatorOverrideController(key.runtimeAnimatorController); AnimationClip[] animationClips = ((RuntimeAnimatorController)loadedAsset).animationClips; foreach (AnimationClip val2 in animationClips) { val[((Object)val2).name] = loadedAsset[((Object)val2).name]; } key.runtimeAnimatorController = (RuntimeAnimatorController)(object)val; dictionary.Add(key, AnimatorOverrideInPlace.Yes); } } dictionary.ToList().ForEach(delegate(KeyValuePair update) { AdventurousSonicAnimators[update.Key] = update.Value; }); } internal static void ApplyVFX() { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) foreach (KeyValuePair adventurousSonicAnimatorsToSkinController in AdventurousSonicAnimatorsToSkinControllers) { Animator key = adventurousSonicAnimatorsToSkinController.Key; ModelSkinController value = adventurousSonicAnimatorsToSkinController.Value; if (AdventurousSonicAnimators[key] != AnimatorOverrideInPlace.Yes || (Object)(object)key == (Object)null || !((Behaviour)key).isActiveAndEnabled) { continue; } AnimatorStateInfo currentAnimatorStateInfo = key.GetCurrentAnimatorStateInfo(0); AnimatorStateInfo currentAnimatorStateInfo2 = key.GetCurrentAnimatorStateInfo(1); bool flag = typeof(HomingAttack).IsAssignableFrom(((object)EntityStateMachine.FindByCustomName(((Component)value.characterModel.body).gameObject, "Body").state).GetType()); if ((((AnimatorStateInfo)(ref currentAnimatorStateInfo2)).IsName("Ball") || ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("Jump") || ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("BonusJump") || flag) && AdventurousSkinForSonicTheHedgehogMain.CurlVFXConfig.Value) { GameObject loadedAsset = AdventurousSkinForSonicTheHedgehogContent.GetLoadedAsset(AssetID.SonicBallVFXPrefab); if (!PreviousVFXForSkinControllers.ContainsKey(value)) { PreviousVFXForSkinControllers[value] = Object.Instantiate(loadedAsset, value.characterModel.coreTransform); } if (flag) { PreviousVFXForSkinControllers[value].GetComponent().emitting = true; } else if (((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("Jump") || ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("Ball") || ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("BonusJump")) { PreviousVFXForSkinControllers[value].GetComponent().emitting = false; } else { PreviousVFXForSkinControllers[value].GetComponent().emitting = true; } ParticleSystem component = PreviousVFXForSkinControllers[value].GetComponent(); MainModule main = component.main; Particle[] array = (Particle[])(object)new Particle[((MainModule)(ref main)).maxParticles]; int particles = component.GetParticles(array); for (int i = 0; i < particles; i++) { ((Particle)(ref array[i])).position = new Vector3(0f, 0.01f, 0f); } component.SetParticles(array, particles); } else if (!((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("Ball") && PreviousVFXForSkinControllers.ContainsKey(value)) { GameObject obj = PreviousVFXForSkinControllers[value]; PreviousVFXForSkinControllers.Remove(value); Object.Destroy((Object)(object)obj); } if (PreviousVFXForSkinControllers.ContainsKey(value)) { if (key.GetFloat("isSuperFloat") == 1f) { ((Renderer)PreviousVFXForSkinControllers[value].GetComponent()).material = AdventurousSkinForSonicTheHedgehogContent.GetLoadedAsset(AssetID.SuperSonicBallVFXMaterial); ((Renderer)((Component)PreviousVFXForSkinControllers[value].GetComponent()).GetComponent()).material = AdventurousSkinForSonicTheHedgehogContent.GetLoadedAsset(AssetID.SuperSonicBallParticleMaterial); } else { ((Renderer)PreviousVFXForSkinControllers[value].GetComponent()).material = AdventurousSkinForSonicTheHedgehogContent.GetLoadedAsset(AssetID.SonicBallVFXMaterial); ((Renderer)((Component)PreviousVFXForSkinControllers[value].GetComponent()).GetComponent()).material = AdventurousSkinForSonicTheHedgehogContent.GetLoadedAsset(AssetID.SonicBallParticleMaterial); } } } } internal static void ReplaceMeshWithBall() { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) foreach (KeyValuePair adventurousSonicAnimatorsToSkinController in AdventurousSonicAnimatorsToSkinControllers) { Animator key = adventurousSonicAnimatorsToSkinController.Key; ModelSkinController value = adventurousSonicAnimatorsToSkinController.Value; if (AdventurousSonicAnimators[key] != AnimatorOverrideInPlace.Yes || (Object)(object)key == (Object)null || !((Behaviour)key).isActiveAndEnabled) { continue; } key.GetCurrentAnimatorStateInfo(0); AnimatorStateInfo currentAnimatorStateInfo = key.GetCurrentAnimatorStateInfo(1); Type type = ((object)EntityStateMachine.FindByCustomName(((Component)value.characterModel.body).gameObject, "Body").state).GetType(); bool flag = typeof(HomingAttack).IsAssignableFrom(type) && ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("Ball"); bool num = typeof(GrandSlamSpin).IsAssignableFrom(type) || typeof(GrandSlamDash).IsAssignableFrom(type); bool num2 = key.GetBool("isBall"); bool flag2 = flag && AdventurousSkinForSonicTheHedgehogMain.BallFormForHomingAttackConfig.Value; bool flag3 = num2 && AdventurousSkinForSonicTheHedgehogMain.BallFormForJumpConfig.Value; bool flag4 = num && AdventurousSkinForSonicTheHedgehogMain.BallFormForGrandSlamConfig.Value; if (flag2 || flag3 || flag4) { Mesh loadedAsset = AdventurousSkinForSonicTheHedgehogContent.GetLoadedAsset(AssetID.SonicBallMesh); Material val = AdventurousSkinForSonicTheHedgehogContent.GetLoadedAsset(AssetID.SonicBallMaterial); Material loadedAsset2 = AdventurousSkinForSonicTheHedgehogContent.GetLoadedAsset(AssetID.SuperSonicBallMaterial); if (key.GetFloat("isSuperFloat") == 1f) { val = loadedAsset2; } if ((Object)(object)value.characterModel.mainSkinnedMeshRenderer.sharedMesh != (Object)(object)loadedAsset) { PreviousMeshesForSkinControllers[value] = value.characterModel.mainSkinnedMeshRenderer.sharedMesh; value.characterModel.mainSkinnedMeshRenderer.sharedMesh = loadedAsset; PreviousMaterialsForSkinControllers[value] = value.characterModel.baseRendererInfos[0].defaultMaterial; } ((Renderer)value.characterModel.mainSkinnedMeshRenderer).material = val; value.characterModel.baseRendererInfos[0].defaultMaterial = val; } else if (PreviousMeshesForSkinControllers.ContainsKey(value) && PreviousMaterialsForSkinControllers.ContainsKey(value)) { Mesh loadedAsset3 = AdventurousSkinForSonicTheHedgehogContent.GetLoadedAsset(AssetID.SonicBallMesh); if ((Object)(object)value.characterModel.mainSkinnedMeshRenderer.sharedMesh == (Object)(object)loadedAsset3) { value.characterModel.mainSkinnedMeshRenderer.sharedMesh = PreviousMeshesForSkinControllers[value]; } if (key.GetFloat("isSuperFloat") < 1f && (Object)(object)PreviousMaterialsForSkinControllers[value] == (Object)(object)AdventurousSkinForSonicTheHedgehogContent.GetLoadedAsset(AssetID.SuperSonicMaterial)) { PreviousMaterialsForSkinControllers[value] = AdventurousSkinForSonicTheHedgehogContent.GetLoadedAsset(AssetID.SonicMaterial); } else if (key.GetFloat("isSuperFloat") == 1f && (Object)(object)PreviousMaterialsForSkinControllers[value] == (Object)(object)AdventurousSkinForSonicTheHedgehogContent.GetLoadedAsset(AssetID.SonicMaterial)) { PreviousMaterialsForSkinControllers[value] = AdventurousSkinForSonicTheHedgehogContent.GetLoadedAsset(AssetID.SuperSonicMaterial); } ((Renderer)value.characterModel.mainSkinnedMeshRenderer).material = PreviousMaterialsForSkinControllers[value]; value.characterModel.baseRendererInfos[0].defaultMaterial = PreviousMaterialsForSkinControllers[value]; } } } } public enum AssetID { AnimatorOverrideController, SkinIcon, PortraitIcon, SonicMaterial, SonicMesh, SonicBallMaterial, SonicBallMesh, SonicBallVFXPrefab, SonicBallVFXMaterial, SonicBallParticleMaterial, SuperSonicMaterial, SuperSonicMesh, SuperSonicBallMaterial, SuperSonicBallVFXPrefab, SuperSonicBallVFXMaterial, SuperSonicBallParticleMaterial } public enum BasicConfigConditionSetting { Never, Depends, Always } public class LanguageSettings { internal const string SKIN_NAME_TOKEN = "MUSHROOMMERCHANT_SONIC_THE_HEDGEHOG_ADVENTUROUS_SKIN_NAME"; internal const string SKIN_FLAVOUR_TEXT_TOKEN = "MUSHROOMMERCHANT_SONIC_THE_HEDGEHOG_ADVENTUROUS_SKIN_DESC"; internal static void AddLoadStringsHook() { HookEndpointManager.Add((MethodBase)typeof(Language).GetMethod("LoadStrings"), (Delegate)new Action, Language>(LoadStrings)); } private static void LoadStrings(Action orig, Language self) { orig(self); self.SetStringByToken("MUSHROOMMERCHANT_SONIC_THE_HEDGEHOG_ADVENTUROUS_SKIN_NAME", "Adventurous"); self.SetStringByToken("MUSHROOMMERCHANT_SONIC_THE_HEDGEHOG_ADVENTUROUS_SKIN_DESC", "Restless by nature, this hedgehog has an intense glint in his eye and an insatiable curiosity. As distinctive as his curved, deep-blue quills are, you'll still miss him if you blink."); } } public class PortraitChanges { [CompilerGenerated] private static class <>O { public static hook_GetSurvivorPortrait <0>__SurvivorCatalog_GetSurvivorPortrait; public static hook_Awake <1>__SurvivorIconController_Awake; public static hook_SetDisplayData <2>__GameEndReportPanelController_SetDisplayData; public static hook_Awake <3>__CharacterBody_Awake; } private static Texture2D SonicSASurvivorIcon; private static Texture2D SonicDefaultSurvivorIcon; private static readonly List SurvivorIconControllers = new List(); private static readonly List CharacterBodies = new List(); private static readonly Dictionary PlayerSonicSkinSelected = new Dictionary(); internal static bool ApplyingCustomIcon() { if (AdventurousSkinForSonicTheHedgehogMain.ApplyCustomPortraitForSkin.Value == BasicConfigConditionSetting.Never) { return false; } if (Chainloader.PluginInfos.ContainsKey("DTEE.Icons") && AdventurousSkinForSonicTheHedgehogMain.ApplyCustomPortraitForSkin.Value == BasicConfigConditionSetting.Depends) { return false; } return true; } internal static void BodyCatalogInit() { LoadIcons(); IconReplacementHooks(); } internal static void LoadIcons() { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown if ((Object)(object)SonicSASurvivorIcon == (Object)null && (Object)(object)AdventurousSkinForSonicTheHedgehogContent.Bundle != (Object)null) { SonicSASurvivorIcon = AdventurousSkinForSonicTheHedgehogContent.GetLoadedAsset(AssetID.PortraitIcon); } if ((Object)(object)SonicDefaultSurvivorIcon == (Object)null && (Object)(object)BodyCatalog.FindBodyPrefab("SonicTheHedgehog") != (Object)null && (Object)(object)BodyCatalog.FindBodyPrefab("SonicTheHedgehog").GetComponent() != (Object)null) { SonicDefaultSurvivorIcon = (Texture2D)BodyCatalog.FindBodyPrefab("SonicTheHedgehog").GetComponent().portraitIcon; } } internal static void IconReplacementHooks() { //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 //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_0050: 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_005b: Expected O, but got Unknown //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown object obj = <>O.<0>__SurvivorCatalog_GetSurvivorPortrait; if (obj == null) { hook_GetSurvivorPortrait val = SurvivorCatalog_GetSurvivorPortrait; <>O.<0>__SurvivorCatalog_GetSurvivorPortrait = val; obj = (object)val; } SurvivorCatalog.GetSurvivorPortrait += (hook_GetSurvivorPortrait)obj; object obj2 = <>O.<1>__SurvivorIconController_Awake; if (obj2 == null) { hook_Awake val2 = SurvivorIconController_Awake; <>O.<1>__SurvivorIconController_Awake = val2; obj2 = (object)val2; } SurvivorIconController.Awake += (hook_Awake)obj2; object obj3 = <>O.<2>__GameEndReportPanelController_SetDisplayData; if (obj3 == null) { hook_SetDisplayData val3 = GameEndReportPanelController_SetDisplayData; <>O.<2>__GameEndReportPanelController_SetDisplayData = val3; obj3 = (object)val3; } GameEndReportPanelController.SetDisplayData += (hook_SetDisplayData)obj3; object obj4 = <>O.<3>__CharacterBody_Awake; if (obj4 == null) { hook_Awake val4 = CharacterBody_Awake; <>O.<3>__CharacterBody_Awake = val4; obj4 = (object)val4; } CharacterBody.Awake += (hook_Awake)obj4; } private static Texture SurvivorCatalog_GetSurvivorPortrait(orig_GetSurvivorPortrait orig, SurvivorIndex survivorIndex) { //IL_0042: 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) if (ApplyingCustomIcon() && SkinCatalog.GetSkinDef((SkinIndex)LocalUserManager.GetFirstLocalUser().userProfile.loadout.bodyLoadoutManager.GetSkinIndex(AdventurousSkinForSonicTheHedgehogMain.SonicBodyIndex)).nameToken == "MUSHROOMMERCHANT_SONIC_THE_HEDGEHOG_ADVENTUROUS_SKIN_NAME") { return (Texture)(object)SonicSASurvivorIcon; } return orig.Invoke(survivorIndex); } private static void SurvivorIconController_Awake(orig_Awake orig, SurvivorIconController self) { orig.Invoke(self); if (ApplyingCustomIcon()) { SurvivorIconControllers.Add(self); } } private static void GameEndReportPanelController_SetDisplayData(orig_SetDisplayData orig, GameEndReportPanelController self, DisplayData newDisplayData) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) orig.Invoke(self, newDisplayData); if (ApplyingCustomIcon()) { PlayerInfo val = newDisplayData.runReport.playerInfos[newDisplayData.playerIndex]; if (val.bodyName == "SonicTheHedgehog" && PlayerSonicSkinSelected.ContainsKey(val.name) && PlayerSonicSkinSelected[val.name] == "MUSHROOMMERCHANT_SONIC_THE_HEDGEHOG_ADVENTUROUS_SKIN_NAME") { self.playerBodyPortraitImage.texture = (Texture)(object)SonicSASurvivorIcon; } } } private static void CharacterBody_Awake(orig_Awake orig, CharacterBody self) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) orig.Invoke(self); if (ApplyingCustomIcon() && self.bodyIndex == AdventurousSkinForSonicTheHedgehogMain.SonicBodyIndex) { CharacterBodies.Add(self); } } internal static void OnGUI() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Invalid comparison between Unknown and I4 //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_033f: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)SonicSASurvivorIcon == (Object)null || !ApplyingCustomIcon()) { return; } SkinDef[] array = SkinCatalog.FindSkinsForBody(AdventurousSkinForSonicTheHedgehogMain.SonicBodyIndex); int num = -1; for (int i = 0; i < array.Length; i++) { if (array[i].nameToken == "MUSHROOMMERCHANT_SONIC_THE_HEDGEHOG_ADVENTUROUS_SKIN_NAME") { num = i; } } CharacterBodies.RemoveAll((CharacterBody characterBody) => (Object)(object)characterBody == (Object)null); foreach (CharacterBody characterBody in CharacterBodies) { if (characterBody.skinIndex == num) { characterBody.portraitIcon = (Texture)(object)SonicSASurvivorIcon; } } if ((Object)(object)Run.instance != (Object)null && Run.instance.isRunning && Run.instance.livingPlayerCount > 0) { foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances) { if ((Object)(object)instance == (Object)null || (Object)(object)instance.body == (Object)null || (Object)(object)instance.body.modelLocator == (Object)null || (Object)(object)instance.body.modelLocator.modelTransform == (Object)null || (Object)(object)((Component)instance.body.modelLocator.modelTransform).gameObject == (Object)null) { continue; } ModelSkinController component = ((Component)instance.body.modelLocator.modelTransform).gameObject.GetComponent(); if ((Object)(object)component == (Object)null || (Object)(object)component.characterModel == (Object)null || (Object)(object)component.characterModel.body == (Object)null) { continue; } BodyIndex bodyIndex = component.characterModel.body.bodyIndex; int currentSkinIndex = component.currentSkinIndex; if (currentSkinIndex >= 0) { string nameToken = component.skins[currentSkinIndex].nameToken; string displayName = instance.GetDisplayName(); if (bodyIndex == AdventurousSkinForSonicTheHedgehogMain.SonicBodyIndex) { PlayerSonicSkinSelected[displayName] = nameToken; } } } } SurvivorIconControllers.RemoveAll((SurvivorIconController survivorIconController) => (Object)(object)survivorIconController == (Object)null || (Object)(object)survivorIconController.survivorIcon == (Object)null); foreach (SurvivorIconController survivorIconController in SurvivorIconControllers) { if ((int)survivorIconController.survivorIndex != (int)SurvivorCatalog.bodyIndexToSurvivorIndex[AdventurousSkinForSonicTheHedgehogMain.SonicBodyIndex]) { continue; } Texture texture = survivorIconController.survivorIcon.texture; foreach (LocalUser localUsers in LocalUserManager.localUsersList) { texture = (Texture)(object)((localUsers.userProfile.loadout.bodyLoadoutManager.GetSkinIndex(AdventurousSkinForSonicTheHedgehogMain.SonicBodyIndex) != num) ? SonicDefaultSurvivorIcon : SonicSASurvivorIcon); } foreach (NetworkUser instances in NetworkUser.instancesList) { CharacterBody currentBody = instances.GetCurrentBody(); if (!((Object)(object)currentBody == (Object)null) && instances.networkLoadout.loadout.bodyLoadoutManager.GetSkinIndex(AdventurousSkinForSonicTheHedgehogMain.SonicBodyIndex) == num && currentBody.bodyIndex == AdventurousSkinForSonicTheHedgehogMain.SonicBodyIndex) { texture = (Texture)(object)SonicSASurvivorIcon; } } survivorIconController.survivorIcon.texture = texture; } } } public class ShaderSwapping { public static void SwapShaders() { ((MonoBehaviour)AdventurousSkinForSonicTheHedgehogMain.Instance).StartCoroutine(ShaderSwapper.UpgradeStubbedShadersAsync(AdventurousSkinForSonicTheHedgehogContent.Bundle)); } } public class SkinManagement { internal static int AdventurousSkinIndex; internal static void BodyCatalogInit() { AddAdventurousSkin(); } private static void AddAdventurousSkin() { //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) string name = "Sonic Adventurous Skin"; GameObject gameObject = ((Component)BodyCatalog.FindBodyPrefab("SonicTheHedgehog").GetComponent().modelTransform).gameObject; ModelSkinController component = gameObject.GetComponent(); Renderer[] componentsInChildren = gameObject.GetComponentsInChildren(true); gameObject.GetComponentsInChildren(true); SkinDef val = ScriptableObject.CreateInstance(); SkinDefParams val2 = ScriptableObject.CreateInstance(); ((Object)val).name = name; val.nameToken = "MUSHROOMMERCHANT_SONIC_THE_HEDGEHOG_ADVENTUROUS_SKIN_NAME"; val.icon = AdventurousSkinForSonicTheHedgehogContent.GetLoadedAsset(AssetID.SkinIcon); val.rootObject = gameObject; val.baseSkins = (SkinDef[])(object)new SkinDef[1] { ((IEnumerable)component.skins).FirstOrDefault((Func)((SkinDef skin) => ((Object)skin).name == "DS_GAMING_SONIC_THE_HEDGEHOG_BODY_NAME")) }; val2.rendererInfos = (RendererInfo[])(object)new RendererInfo[1] { new RendererInfo { defaultMaterial = AdventurousSkinForSonicTheHedgehogContent.GetLoadedAsset(AssetID.SonicMaterial), defaultShadowCastingMode = (ShadowCastingMode)1, ignoreOverlays = false, renderer = ((IEnumerable)componentsInChildren).FirstOrDefault((Func)((Renderer renderer) => ((Object)renderer).name == "SonicMesh")) } }; val2.meshReplacements = (MeshReplacement[])(object)new MeshReplacement[1] { new MeshReplacement { mesh = AdventurousSkinForSonicTheHedgehogContent.GetLoadedAsset(AssetID.SonicMesh), renderer = ((IEnumerable)componentsInChildren).FirstOrDefault((Func)((Renderer renderer) => ((Object)renderer).name == "SonicMesh")) } }; val.skinDefParams = val2; Array.Resize(ref component.skins, component.skins.Length + 1); component.skins[component.skins.Length - 1] = val; AdventurousSkinIndex = component.skins.Length - 1; AddAdventurousSuperFormSkin(val); } private static void AddAdventurousSuperFormSkin(SkinDef skinDef) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) Forms.AddSkinForForm(skinDef.nameToken, new RenderReplacements { material = AdventurousSkinForSonicTheHedgehogContent.GetLoadedAsset(AssetID.SuperSonicMaterial), mesh = AdventurousSkinForSonicTheHedgehogContent.GetLoadedAsset(AssetID.SuperSonicMesh) }, ref SuperFormDef.superFormDef); } } public class SoundReplacements : MonoBehaviour { [CompilerGenerated] private static class <>O { public static hook_PlaySound_string_GameObject <0>__Util_PlaySound_string_GameObject; } internal static void SetUpHooks() { //IL_0021: 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_002c: Expected O, but got Unknown if (Chainloader.PluginInfos.ContainsKey("com.bepis.r2api.sound")) { object obj = <>O.<0>__Util_PlaySound_string_GameObject; if (obj == null) { hook_PlaySound_string_GameObject val = Util_PlaySound_string_GameObject; <>O.<0>__Util_PlaySound_string_GameObject = val; obj = (object)val; } Util.PlaySound_string_GameObject += (hook_PlaySound_string_GameObject)obj; } } private static uint Util_PlaySound_string_GameObject(orig_PlaySound_string_GameObject orig, string soundString, GameObject gameObject) { if ((Object)(object)gameObject != (Object)null && (Object)(object)gameObject.GetComponent() != (Object)null && gameObject.GetComponent().baseNameToken == "DS_GAMING_SONIC_THE_HEDGEHOG_BODY_NAME" && gameObject.GetComponent().skinIndex == SkinManagement.AdventurousSkinIndex) { switch (soundString) { case "Play_hedgehogutils_jump_ball": soundString = "Play_sonicadventurous_jump_ball"; break; case "Play_sonicthehedgehog_homing_attack": soundString = "Play_sonicadventurous_homing_attack"; break; case "Play_sonicthehedgehog_spindash_charge": soundString = "Play_sonicadventurous_spindash_charge"; break; case "Play_sonicthehedgehog_spindash_release": soundString = "Play_sonicadventurous_spindash_release"; break; case "Play_char_land": soundString = "Play_sonicadventurous_land"; break; case "Play_player_footstep": soundString = "Play_sonicadventurous_footstep"; break; case "Play_hedgehogutils_brake": soundString = "Play_sonicadventurous_brake"; break; case "Play_hedgehogutils_boost": soundString = "Play_sonicadventurous_boost"; if (gameObject.GetComponent().HasBuff(SuperFormDef.superFormDef.buff)) { soundString = "Play_sonicadventurous_super_boost"; } break; case "Play_sonicthehedgehog_swing": soundString = "Play_sonicadventurous_swing"; break; case "Play_sonicthehedgehog_swing_low": soundString = "Play_sonicadventurous_swing_low"; break; case "Play_sonicthehedgehog_swing_strong": soundString = "Play_sonicadventurous_swing_strong"; break; case "Play_hedgehogutils_emerald": soundString = "Play_sonicadventurous_emerald"; break; case "Play_hedgehogutils_super_transform": soundString = "Play_sonicadventurous_super_transform"; break; } } return orig.Invoke(soundString, gameObject); } } }