Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of SakeysYumekawaWeapons v0.0.4
BepInEx/plugins/Sakey's Yumekawa Weapons/Sakey's Yumekawa Weapons.dll
Decompiled 4 hours agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("Sakey's Yumekawa Weapons")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("Sakey's Yumekawa Weapons")] [assembly: AssemblyTitle("Sakey's Yumekawa Weapons")] [assembly: AssemblyVersion("1.0.0.0")] namespace SakeysYumekawaWeapons; internal sealed class YumekawaConfigManagerAttributes { public float? Step; } [BepInPlugin("com.sakey.yumekawaweapons", "Sakey's Yumekawa Weapons", "0.0.4")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class YumekawaWeaponsPlugin : BaseUnityPlugin { private sealed class WeaponDefinition { public string PrefabName; public string BasePrefabName; public string ModelAssetName; public string IconAssetName; public string DisplayName; public string Description; public float LightningDamageMultiplier = 1f; } private sealed class WearableDefinition { public string PrefabName; public string BasePrefabName; public string ModelAssetName; public string IconAssetName; public string DisplayName; public string Description; public string RequirementItem; public int CraftAmount; public int UpgradeAmount; public ConfigEntry<float> OffsetX; public ConfigEntry<float> OffsetY; public ConfigEntry<float> OffsetZ; public ConfigEntry<float> RotationX; public ConfigEntry<float> RotationY; public ConfigEntry<float> RotationZ; public ConfigEntry<float> SizeMultiplier; public GameObject ModelSource; public readonly List<Transform> ActiveModels = new List<Transform>(); } private sealed class MiniHatPreset { public ConfigEntry<float> X; public ConfigEntry<float> Y; public ConfigEntry<float> Z; public ConfigEntry<float> RotX; public ConfigEntry<float> RotY; public ConfigEntry<float> RotZ; public ConfigEntry<float> Scale; } [HarmonyPatch] [HarmonyPriority(800)] private static class YumekawaSkipMeshOnlyHeadBoneReorderPatch { private static MethodBase TargetMethod() { Type type = AccessTools.TypeByName("Jotunn.Utils.BoneReorder"); if (type == null) { return null; } return AccessTools.Method(type, "ReorderBones", new Type[3] { typeof(VisEquipment), typeof(int), typeof(List<GameObject>) }, (Type[])null); } private static bool Prefix(object[] __args) { if ((Object)(object)Instance == (Object)null || __args == null) { return true; } int itemHash = 0; List<GameObject> list = null; foreach (object obj in __args) { if (obj is int) { itemHash = (int)obj; } else if (obj is List<GameObject>) { list = (List<GameObject>)obj; } } WearableDefinition wearableDefinition = Instance.FindWearableByHash(itemHash); if (wearableDefinition == null || !wearableDefinition.PrefabName.StartsWith("head_", StringComparison.Ordinal)) { return true; } bool flag = false; if (list != null) { foreach (GameObject item in list) { if (!((Object)(object)item == (Object)null) && item.GetComponentsInChildren<SkinnedMeshRenderer>(true).Length != 0) { flag = true; break; } } } if (flag) { return true; } ((BaseUnityPlugin)Instance).Logger.LogInfo((object)("[Sakey's Yumekawa Weapons] Jotunn BoneReorder skipped: mesh-only wearable=" + wearableDefinition.PrefabName + " itemHash=" + itemHash + " instances=" + (list?.Count ?? 0))); return false; } private static void Postfix(object[] __args) { if ((Object)(object)Instance == (Object)null || __args == null) { return; } int itemHash = 0; List<GameObject> list = null; foreach (object obj in __args) { if (obj is int) { itemHash = (int)obj; } else if (obj is List<GameObject>) { list = (List<GameObject>)obj; } } WearableDefinition wearableDefinition = Instance.FindWearableByHash(itemHash); if (wearableDefinition == null || !wearableDefinition.PrefabName.StartsWith("head_", StringComparison.Ordinal)) { return; } if (list == null || list.Count == 0) { ((BaseUnityPlugin)Instance).Logger.LogWarning((object)("[Sakey's Yumekawa Weapons] Mesh-only head attach skipped: no runtime instances. item=" + wearableDefinition.PrefabName + " hash=" + itemHash)); return; } GameObject val = null; foreach (GameObject item in list) { if (!((Object)(object)item == (Object)null)) { if ((Object)(object)val == (Object)null) { val = item; } if (string.Equals(((Object)item).name, "attach", StringComparison.OrdinalIgnoreCase)) { val = item; break; } } } if ((Object)(object)val == (Object)null) { ((BaseUnityPlugin)Instance).Logger.LogWarning((object)("[Sakey's Yumekawa Weapons] Mesh-only head attach skipped: runtime instance is null. item=" + wearableDefinition.PrefabName + " hash=" + itemHash)); } else { Instance.QueueMeshOnlyHeadAttach(val, wearableDefinition); } } } public const string PluginGUID = "com.sakey.yumekawaweapons"; public const string PluginName = "Sakey's Yumekawa Weapons"; public const string PluginVersion = "0.0.4"; private const string ASSET_BUNDLE_NAME = "yumekawa"; private const int BONE_CRAFT_AMOUNT = 500; private const int BONE_UPGRADE_AMOUNT = 50; private const string CRAFTING_STATION = "piece_workbench"; private const int CRAFTING_STATION_LEVEL = 1; private AssetBundle assetBundle; private bool registrationStarted; private ConfigEntry<float> railgunLightningDamageMultiplier; private Harmony wearableVisualHarmony; private static YumekawaWeaponsPlugin Instance; private readonly HashSet<int> pendingHeadAttachRoots = new HashSet<int>(); private MiniHatPreset miniHatDeepPreset; private MiniHatPreset miniHatTopPreset; private ConfigEntry<string> miniHatPresetSelection; private bool changingMiniHatPreset; private readonly List<WeaponDefinition> weapons = new List<WeaponDefinition> { new WeaponDefinition { PrefabName = "armor_heartstick", BasePrefabName = "MaceGold_BloodLightning", ModelAssetName = "armor_heartstick", IconAssetName = "icon_heartstick", DisplayName = "ハートの杖", Description = "ハートと翼が可愛い。意外と実用的な棍棒のようだ。" }, new WeaponDefinition { PrefabName = "armor_yumekawapickaxe", BasePrefabName = "PickaxeBlackMetal", ModelAssetName = "armor_yumekawapickaxe", IconAssetName = "icon_yumekawapickaxe", DisplayName = "ゆめかわツルハシ", Description = "キラキラしたツルハシ。可愛いさと裏腹に採掘力は抜群。" }, new WeaponDefinition { PrefabName = "armor_pizzashield", BasePrefabName = "ShieldGold", ModelAssetName = "armor_pizzashield", IconAssetName = "icon_pizzashield", DisplayName = "ピザシールド", Description = "ピザ型の盾。" }, new WeaponDefinition { PrefabName = "armor_strawberryshield", BasePrefabName = "ShieldGold", ModelAssetName = "armor_strawberryshield", IconAssetName = "icon_strawberryshield", DisplayName = "ストロベリーシールド", Description = "イチゴ好きによるいちご好きのためのゆめかわ盾。" }, new WeaponDefinition { PrefabName = "armor_starshield", BasePrefabName = "ShieldGoldTower", ModelAssetName = "armor_starshield", IconAssetName = "icon_starshield", DisplayName = "星の盾", Description = "星の形の可愛い盾。" }, new WeaponDefinition { PrefabName = "armor_pikopikohammer", BasePrefabName = "SledgeGold_BloodLightning", ModelAssetName = "armor_pikopikohammer", IconAssetName = "icon_pikopikohammer", DisplayName = "ピコピコハンマー", Description = "おなじみのピコハン。見た目に寄らずガチつよである。" }, new WeaponDefinition { PrefabName = "armor_yumekawasword", BasePrefabName = "SwordGold_BloodLightning", ModelAssetName = "armor_yumekawasword", IconAssetName = "icon_yumekawasword", DisplayName = "片翼のソード", Description = "羽根の着いたかっこかわいい片手剣。" }, new WeaponDefinition { PrefabName = "armor_ikayaki", BasePrefabName = "SwordGold", ModelAssetName = "armor_ikayaki", IconAssetName = "icon_ikayaki", DisplayName = "イカ焼き", Description = "美味しい片手剣。" }, new WeaponDefinition { PrefabName = "armor_darkstick", BasePrefabName = "StaffFireball", ModelAssetName = "armor_darkstick", IconAssetName = "icon_darkstick", DisplayName = "闇墜ちステッキ", Description = "悪魔っぽい杖。" }, new WeaponDefinition { PrefabName = "armor_karaagebou", BasePrefabName = "AxeGold_BloodLightning", ModelAssetName = "armor_karaagebou", IconAssetName = "icon_karaagebou", DisplayName = "唐揚げ棒", Description = "コンビニでお馴染みの唐揚げ棒。" }, new WeaponDefinition { PrefabName = "armor_triprice", BasePrefabName = "SwordGold_BloodLightning", ModelAssetName = "armor_triprice", IconAssetName = "icon_triprice", DisplayName = "トリプルアイス", Description = "三段重ねのアイスクリーム。見かけほど甘くない魔法武器" }, new WeaponDefinition { PrefabName = "armor_maguro", BasePrefabName = "THSwordGold_FrostFire", ModelAssetName = "armor_maguro", IconAssetName = "icon_maguro", DisplayName = "冷凍本マグロ", Description = "冷凍マグロ。ある世界ではお馴染み。" }, new WeaponDefinition { PrefabName = "armor_minecraftPickaxe", BasePrefabName = "PickaxeBlackMetal", ModelAssetName = "armor_minecraftPickaxe", IconAssetName = "icon_minecraftPickaxe", DisplayName = "異世界のツルハシ", Description = "どこかの世界のボクセルツルハシ。" }, new WeaponDefinition { PrefabName = "armor_konbinionigiri", BasePrefabName = "ShieldGoldBuckler", ModelAssetName = "armor_konbinionigiri", IconAssetName = "icon_konbinionigiri", DisplayName = "コンビニおにぎり", Description = "いつのまにこんなに高級品になったんだろう・・・" }, new WeaponDefinition { PrefabName = "armor_haruyokoihou", BasePrefabName = "StaffLightning", ModelAssetName = "armor_haruyokoihou", IconAssetName = "icon_haruyokoihou", DisplayName = "鯉のショットガン", Description = "どこかで見たことがあるような?" }, new WeaponDefinition { PrefabName = "armor_railgun", BasePrefabName = "StaffLightning", ModelAssetName = "armor_railgun", IconAssetName = "icon_railgun", DisplayName = "レールガン。", Description = "どこかで見たような気がする強力な武器。", LightningDamageMultiplier = 10f }, new WeaponDefinition { PrefabName = "armor_heartsheild", BasePrefabName = "ShieldGoldBuckler", ModelAssetName = "armor_heartsheild", IconAssetName = "icon_heartsheild", DisplayName = "ハートの盾", Description = "ハート型のカワイイ盾" }, new WeaponDefinition { PrefabName = "armor_rion", BasePrefabName = "MaceGold", ModelAssetName = "armor_rion", IconAssetName = "icon_rion", DisplayName = "りおんの棍棒", Description = "幸島梨苑を振り回す。可愛いのに激つよ棍棒" }, new WeaponDefinition { PrefabName = "armor_magicrion", BasePrefabName = "StaffThunderBlood", ModelAssetName = "armor_magicrion", IconAssetName = "icon_rionstick", DisplayName = "りおんの杖", Description = "幸島梨苑の可愛い魔法の杖。可愛さとは裏腹にめちゃ強い" }, new WeaponDefinition { PrefabName = "armor_moonstick", BasePrefabName = "StaffShield", ModelAssetName = "armor_moonstick", IconAssetName = "icon_monnstick", DisplayName = "月の杖", Description = "月とお花の可愛い杖。" }, new WeaponDefinition { PrefabName = "armor_heartmagicstick", BasePrefabName = "StaffOrbofAhri", ModelAssetName = "armor_heartmagicstick", IconAssetName = "icon_heartmagicstick", DisplayName = "ハートの魔法杖", Description = "可愛いクセにつよつよな武器。" } }; private readonly List<WearableDefinition> wearables = new List<WearableDefinition> { new WearableDefinition { PrefabName = "head_minihut", BasePrefabName = "HelmetCrownofValheim", ModelAssetName = "head_minihut", IconAssetName = "icon_minihut", DisplayName = "ミニハット", Description = "うさ耳付きのミニハット。", RequirementItem = "Feathers", CraftAmount = 200, UpgradeAmount = 25 }, new WearableDefinition { PrefabName = "head_catear", BasePrefabName = "HelmetCrownofValheim", ModelAssetName = "head_catear", IconAssetName = "icon_nekomimi", DisplayName = "ねこみみ", Description = "ねこみみをつけよう。かわいい。", RequirementItem = "Feathers", CraftAmount = 200, UpgradeAmount = 25 }, new WearableDefinition { PrefabName = "head_rabbitear", BasePrefabName = "HelmetCrownofValheim", ModelAssetName = "head_rabbitear", IconAssetName = "icon_usamimi", DisplayName = "うさみみ", Description = "バニーの耳。かわいい。", RequirementItem = "Feathers", CraftAmount = 200, UpgradeAmount = 25 }, new WearableDefinition { PrefabName = "access_brooch2", BasePrefabName = "Lantern_DN", ModelAssetName = "access_brooch2", IconAssetName = "icon_brooch2", DisplayName = "りぼんのブローチ", Description = "羽根ケープの装備効果を受け継いだ、背中に飾るリボンブローチ。", RequirementItem = "Feathers", CraftAmount = 200, UpgradeAmount = 25 } }; private void Awake() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Expected O, but got Unknown Instance = this; wearableVisualHarmony = new Harmony("com.sakey.yumekawaweapons.WearableVisuals"); wearableVisualHarmony.PatchAll(typeof(YumekawaWeaponsPlugin).Assembly); try { BoneReorder.ApplyOnEquipmentChanged(); ((BaseUnityPlugin)this).Logger.LogInfo((object)("[Sakey's Yumekawa Weapons] Jotunn BoneReorder explicitly enabled by this mod. IsReorderingEnabled=" + BoneReorder.IsReorderingEnabled())); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("[Sakey's Yumekawa Weapons] Jotunn BoneReorder initialization failed; mesh-only head visuals may not attach.\n" + ex)); } railgunLightningDamageMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Weapon - レールガン", "雷ダメージ倍率", 10f, new ConfigDescription("Dundr由来の12発すべてに適用する雷ダメージ倍率。10なら元の10倍。", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 100f), Array.Empty<object>())); BindWearablePositionConfigs(); ((BaseUnityPlugin)this).Config.Save(); ((BaseUnityPlugin)this).Logger.LogInfo((object)("[Sakey's Yumekawa Weapons] 設定ファイル保存先: " + ((BaseUnityPlugin)this).Config.ConfigFilePath)); ((BaseUnityPlugin)this).Logger.LogInfo((object)"[Sakey's Yumekawa Weapons] Wearable transform mode: Light-style absolute local position/rotation; existing cfg values are retained."); string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location) ?? string.Empty, "yumekawa"); assetBundle = AssetBundle.LoadFromFile(text); if ((Object)(object)assetBundle == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)("[Sakey's Yumekawa Weapons] AssetBundle読み込み失敗: " + text)); return; } ((BaseUnityPlugin)this).Logger.LogInfo((object)("[Sakey's Yumekawa Weapons] AssetBundle読み込み成功: " + text)); PrefabManager.OnVanillaPrefabsAvailable += RegisterAllWeapons; } private void OnDestroy() { try { ((BaseUnityPlugin)this).Config.Save(); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("[Sakey's Yumekawa Weapons] 終了時の設定保存失敗: " + ex)); } PrefabManager.OnVanillaPrefabsAvailable -= RegisterAllWeapons; if (wearableVisualHarmony != null) { wearableVisualHarmony.UnpatchSelf(); wearableVisualHarmony = null; } if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } if ((Object)(object)assetBundle != (Object)null) { assetBundle.Unload(false); assetBundle = null; } } private void RegisterAllWeapons() { //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) if (registrationStarted) { return; } registrationStarted = true; PrefabManager.OnVanillaPrefabsAvailable -= RegisterAllWeapons; int num = 0; int num2 = 0; foreach (WeaponDefinition weapon in weapons) { try { float lightningDamageMultiplier = weapon.LightningDamageMultiplier; if (string.Equals(weapon.PrefabName, "armor_railgun", StringComparison.Ordinal) && railgunLightningDamageMultiplier != null) { lightningDamageMultiplier = railgunLightningDamageMultiplier.Value; } if (RegisterItem(weapon.PrefabName, weapon.BasePrefabName, weapon.ModelAssetName, weapon.IconAssetName, weapon.DisplayName, weapon.Description, "BoneFragments", 500, 50, Vector3.zero, lightningDamageMultiplier)) { num++; } else { num2++; } } catch (Exception ex) { num2++; ((BaseUnityPlugin)this).Logger.LogError((object)("[Sakey's Yumekawa Weapons] 登録例外: " + weapon.PrefabName + "\n" + ex)); } } Vector3 modelOffset = default(Vector3); foreach (WearableDefinition wearable in wearables) { try { ((Vector3)(ref modelOffset))..ctor(GetOffsetX(wearable), GetOffsetY(wearable), GetOffsetZ(wearable)); if (RegisterItem(wearable.PrefabName, wearable.BasePrefabName, wearable.ModelAssetName, wearable.IconAssetName, wearable.DisplayName, wearable.Description, wearable.RequirementItem, wearable.CraftAmount, wearable.UpgradeAmount, modelOffset)) { num++; } else { num2++; } } catch (Exception ex2) { num2++; ((BaseUnityPlugin)this).Logger.LogError((object)("[Sakey's Yumekawa Weapons] 装備登録例外: " + wearable.PrefabName + "\n" + ex2)); } } ((BaseUnityPlugin)this).Logger.LogInfo((object)("[Sakey's Yumekawa Weapons] 登録終了 成功=" + num + " / 失敗=" + num2)); } private void SaveWearableConfig(string settingName) { } private void BindWearablePositionConfigs() { //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Expected O, but got Unknown //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Expected O, but got Unknown //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Expected O, but got Unknown //IL_04c7: Unknown result type (might be due to invalid IL or missing references) //IL_04d1: Expected O, but got Unknown //IL_0503: Unknown result type (might be due to invalid IL or missing references) //IL_050d: Expected O, but got Unknown //IL_053f: Unknown result type (might be due to invalid IL or missing references) //IL_0549: Expected O, but got Unknown //IL_057b: Unknown result type (might be due to invalid IL or missing references) //IL_0585: Expected O, but got Unknown //IL_06e0: Unknown result type (might be due to invalid IL or missing references) //IL_06ea: Expected O, but got Unknown BindMiniHatPresets(); foreach (WearableDefinition def in wearables) { if (def.PrefabName == "head_minihut") { continue; } string text = "Position - " + def.DisplayName; bool num = def.PrefabName == "access_brooch1"; float num2 = ((def.PrefabName == "head_catear") ? 0.004201678f : ((def.PrefabName == "head_rabbitear") ? 7.665802E-09f : ((def.PrefabName == "access_brooch1") ? (-1.740341f) : ((def.PrefabName == "access_brooch2") ? 0.09663869f : 0f)))); float num3 = ((def.PrefabName == "head_catear") ? 0.09663866f : ((def.PrefabName == "head_rabbitear") ? 0.1344538f : ((def.PrefabName == "access_brooch1") ? 0.004201584f : ((def.PrefabName == "access_brooch2") ? 0.5f : 0f)))); float num4 = ((def.PrefabName == "head_catear") ? (-0.004201671f) : ((def.PrefabName == "head_rabbitear") ? 0.06722689f : ((def.PrefabName == "access_brooch1") ? 0.004201679f : ((def.PrefabName == "access_brooch2") ? (-0.1554622f) : 0f)))); float num5 = (num ? (-1.7874f) : (-0.5f)); float num6 = (num ? (-1.6874f) : 0.5f); float num7 = (num ? (-0.0458f) : (-0.5f)); float num8 = (num ? 0.0542f : 0.5f); object[] array = ((!num) ? new object[0] : new object[1] { new YumekawaConfigManagerAttributes { Step = 0.0001f } }); def.OffsetX = ((BaseUnityPlugin)this).Config.Bind<float>(text, "X", num2, new ConfigDescription("装着モデルの左右位置(ハートのブローチは0.0001刻み)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(num5, num6), array)); def.OffsetY = ((BaseUnityPlugin)this).Config.Bind<float>(text, "Y", num3, new ConfigDescription("装着モデルの上下位置(ハートのブローチは0.0001刻み)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(num7, num8), array)); def.OffsetZ = ((BaseUnityPlugin)this).Config.Bind<float>(text, "Z", num4, new ConfigDescription("装着モデルの前後位置(ハートのブローチは0.0001刻み)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(num7, num8), array)); float num9 = ((def.PrefabName == "head_catear") ? 36.30251f : ((def.PrefabName == "head_rabbitear") ? 19.66386f : ((def.PrefabName == "access_brooch2") ? (-6.050422f) : 0f))); float num10 = ((def.PrefabName == "head_catear") ? 4.117313E-08f : ((def.PrefabName == "head_rabbitear") ? (-7.803617E-08f) : ((def.PrefabName == "access_brooch2") ? 69.57986f : 0f))); float num11 = ((def.PrefabName == "head_catear") ? 4.537816f : ((def.PrefabName == "head_rabbitear") ? 4.310087E-09f : ((def.PrefabName == "access_brooch2") ? 22.68907f : 0f))); float num12 = ((def.PrefabName == "head_catear") ? 1.587059f : ((def.PrefabName == "head_rabbitear") ? 0.7228571f : ((def.PrefabName == "access_brooch1") ? 2.567899f : ((def.PrefabName == "access_brooch2") ? 1.775757f : 1f)))); def.RotationX = ((BaseUnityPlugin)this).Config.Bind<float>(text, "角度X", num9, new ConfigDescription("装着モデルのローカルX軸回転(度)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-180f, 180f), Array.Empty<object>())); def.RotationY = ((BaseUnityPlugin)this).Config.Bind<float>(text, "角度Y", num10, new ConfigDescription("装着モデルのローカルY軸回転(度)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-180f, 180f), Array.Empty<object>())); def.RotationZ = ((BaseUnityPlugin)this).Config.Bind<float>(text, "角度Z", num11, new ConfigDescription("装着モデルのローカルZ軸回転(度)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-180f, 180f), Array.Empty<object>())); def.SizeMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>(text, "サイズ倍率", num12, new ConfigDescription("モデル本来のインポート縮尺に掛ける倍率。小さくすると縮小", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 5f), Array.Empty<object>())); def.OffsetX.SettingChanged += delegate { ApplyWearableOffset(def); }; def.OffsetY.SettingChanged += delegate { ApplyWearableOffset(def); }; def.OffsetZ.SettingChanged += delegate { ApplyWearableOffset(def); }; def.RotationX.SettingChanged += delegate { ApplyWearableOffset(def); }; def.RotationY.SettingChanged += delegate { ApplyWearableOffset(def); }; def.RotationZ.SettingChanged += delegate { ApplyWearableOffset(def); }; def.SizeMultiplier.SettingChanged += delegate { ApplyWearableOffset(def); }; if (!(def.PrefabName == "head_catear") && !(def.PrefabName == "head_rabbitear")) { continue; } ConfigEntry<string> preset = ((BaseUnityPlugin)this).Config.Bind<string>("Headwear Presets - " + def.DisplayName, "位置プリセット", "カスタム", new ConfigDescription("『頭基準』は位置・角度をゼロ、サイズを1.0に戻します。『カスタム』は保存済みの数値を使用します。", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[2] { "カスタム", "頭基準" }), Array.Empty<object>())); preset.SettingChanged += delegate { if (preset.Value == "頭基準") { def.OffsetX.Value = 0f; def.OffsetY.Value = 0f; def.OffsetZ.Value = 0f; def.RotationX.Value = 0f; def.RotationY.Value = 0f; def.RotationZ.Value = 0f; def.SizeMultiplier.Value = 1f; } ApplyWearableOffset(def); }; } } private void BindMiniHatPresets() { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown miniHatPresetSelection = ((BaseUnityPlugin)this).Config.Bind<string>("ミニハット専用", "表示プリセット", "深くかぶる", new ConfigDescription("ミニハットの装着位置を切り替えます。各プリセットの座標は個別に保存されます。", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[2] { "深くかぶる", "上に乗せる" }), Array.Empty<object>())); miniHatDeepPreset = BindMiniHatPreset("ミニハット専用 - 深くかぶる", -0.004208567f, 0.1512605f, -0.03361348f, -7.563025f, 6.43271f, -18.151f, 2.40474f); miniHatTopPreset = BindMiniHatPreset("ミニハット専用 - 上に乗せる", -1f / 17f, 0.08403363f, 0.03781513f, 24.20168f, -1.512605f, 0f, 1.079286f); miniHatPresetSelection.SettingChanged += delegate { ApplyMiniHatPreset(); SaveWearableConfig("ミニハット 表示プリセット"); }; BindMiniHatPresetEvents(miniHatDeepPreset); BindMiniHatPresetEvents(miniHatTopPreset); } private MiniHatPreset BindMiniHatPreset(string section, float x, float y, float z, float rx, float ry, float rz, float scale) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Expected O, but got Unknown //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Expected O, but got Unknown //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Expected O, but got Unknown //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Expected O, but got Unknown //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Expected O, but got Unknown return new MiniHatPreset { X = ((BaseUnityPlugin)this).Config.Bind<float>(section, "X", x, new ConfigDescription("左右位置", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-0.5f, 0.5f), Array.Empty<object>())), Y = ((BaseUnityPlugin)this).Config.Bind<float>(section, "Y", y, new ConfigDescription("上下位置", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-0.5f, 0.5f), Array.Empty<object>())), Z = ((BaseUnityPlugin)this).Config.Bind<float>(section, "Z", z, new ConfigDescription("前後位置", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-0.5f, 0.5f), Array.Empty<object>())), RotX = ((BaseUnityPlugin)this).Config.Bind<float>(section, "角度X", rx, new ConfigDescription("ローカルX回転(度)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-180f, 180f), Array.Empty<object>())), RotY = ((BaseUnityPlugin)this).Config.Bind<float>(section, "角度Y", ry, new ConfigDescription("ローカルY回転(度)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-180f, 180f), Array.Empty<object>())), RotZ = ((BaseUnityPlugin)this).Config.Bind<float>(section, "角度Z", rz, new ConfigDescription("ローカルZ回転(度)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-180f, 180f), Array.Empty<object>())), Scale = ((BaseUnityPlugin)this).Config.Bind<float>(section, "サイズ倍率", scale, new ConfigDescription("モデル本来の縮尺に掛ける倍率", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 5f), Array.Empty<object>())) }; } private void BindMiniHatPresetEvents(MiniHatPreset preset) { ConfigEntry<float>[] array = new ConfigEntry<float>[7] { preset.X, preset.Y, preset.Z, preset.RotX, preset.RotY, preset.RotZ, preset.Scale }; for (int i = 0; i < array.Length; i++) { array[i].SettingChanged += delegate { if (miniHatPresetSelection != null && ((miniHatPresetSelection.Value == "深くかぶる" && preset == miniHatDeepPreset) || (miniHatPresetSelection.Value == "上に乗せる" && preset == miniHatTopPreset))) { ApplyMiniHatPreset(); } SaveWearableConfig("ミニハット プリセット座標"); }; } } private MiniHatPreset GetActiveMiniHatPreset() { if (miniHatPresetSelection == null || !(miniHatPresetSelection.Value == "上に乗せる")) { return miniHatDeepPreset; } return miniHatTopPreset; } private void ApplyFinalWearableTransform(Transform model, WearableDefinition def) { //IL_0023: 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_006d: 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_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)model == (Object)null) && def != null) { model.localPosition = new Vector3(GetOffsetX(def), GetOffsetY(def), GetOffsetZ(def)); model.localRotation = Quaternion.Euler(GetRotationX(def), GetRotationY(def), GetRotationZ(def)); Vector3 val = (((Object)(object)def.ModelSource != (Object)null) ? def.ModelSource.transform.localScale : Vector3.one); model.localScale = val * Mathf.Clamp(GetSize(def), 0.01f, 5f); } } private void ApplyMiniHatPreset() { WearableDefinition wearableDefinition = wearables.Find((WearableDefinition w) => w.PrefabName == "head_minihut"); MiniHatPreset activeMiniHatPreset = GetActiveMiniHatPreset(); if (wearableDefinition == null || activeMiniHatPreset == null) { return; } for (int num = wearableDefinition.ActiveModels.Count - 1; num >= 0; num--) { Transform val = wearableDefinition.ActiveModels[num]; if ((Object)(object)val == (Object)null) { wearableDefinition.ActiveModels.RemoveAt(num); } else { ApplyFinalWearableTransform(val, wearableDefinition); } } } private float GetOffsetX(WearableDefinition def) { if (!(def.PrefabName == "head_minihut")) { return def.OffsetX.Value; } return GetActiveMiniHatPreset().X.Value; } private float GetOffsetY(WearableDefinition def) { if (!(def.PrefabName == "head_minihut")) { return def.OffsetY.Value; } return GetActiveMiniHatPreset().Y.Value; } private float GetOffsetZ(WearableDefinition def) { if (!(def.PrefabName == "head_minihut")) { return def.OffsetZ.Value; } return GetActiveMiniHatPreset().Z.Value; } private float GetRotationX(WearableDefinition def) { if (!(def.PrefabName == "head_minihut")) { return def.RotationX.Value; } return GetActiveMiniHatPreset().RotX.Value; } private float GetRotationY(WearableDefinition def) { if (!(def.PrefabName == "head_minihut")) { return def.RotationY.Value; } return GetActiveMiniHatPreset().RotY.Value; } private float GetRotationZ(WearableDefinition def) { if (!(def.PrefabName == "head_minihut")) { return def.RotationZ.Value; } return GetActiveMiniHatPreset().RotZ.Value; } private float GetSize(WearableDefinition def) { if (!(def.PrefabName == "head_minihut")) { return def.SizeMultiplier.Value; } return GetActiveMiniHatPreset().Scale.Value; } private void ApplyWearableOffset(WearableDefinition def) { if (def == null) { return; } for (int num = def.ActiveModels.Count - 1; num >= 0; num--) { Transform val = def.ActiveModels[num]; if ((Object)(object)val == (Object)null) { def.ActiveModels.RemoveAt(num); } else { ApplyFinalWearableTransform(val, def); } } string targetName = "yumekawa_drop_model_" + def.PrefabName; ItemDrop[] array = Object.FindObjectsOfType<ItemDrop>(); foreach (ItemDrop val2 in array) { if (!((Object)(object)val2 == (Object)null)) { Transform val3 = FindChildRecursive(((Component)val2).transform, targetName); if (!((Object)(object)val3 == (Object)null)) { ApplyFinalWearableTransform(val3, def); } } } } private int DisableHolderRenderersOnly(Transform holder) { if ((Object)(object)holder == (Object)null) { return 0; } int num = 0; Renderer[] componentsInChildren = ((Component)holder).GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && !((Object)((Component)val).transform).name.StartsWith("yumekawa_", StringComparison.Ordinal)) { val.enabled = false; num++; } } return num; } private string GetTransformPath(Transform target, Transform root) { if ((Object)(object)target == (Object)null) { return "<null>"; } List<string> list = new List<string>(); Transform val = target; while ((Object)(object)val != (Object)null) { list.Add(((Object)val).name); if ((Object)(object)val == (Object)(object)root) { break; } val = val.parent; } list.Reverse(); return string.Join("/", list.ToArray()); } private void CopyModelVisualStatesRecursive(Transform source, Transform clone, bool isRoot) { if ((Object)(object)source == (Object)null || (Object)(object)clone == (Object)null) { return; } if (!isRoot) { ((Component)clone).gameObject.SetActive(((Component)source).gameObject.activeSelf); } Renderer[] components = ((Component)source).GetComponents<Renderer>(); Renderer[] components2 = ((Component)clone).GetComponents<Renderer>(); int num = Math.Min(components.Length, components2.Length); for (int i = 0; i < num; i++) { if ((Object)(object)components[i] != (Object)null && (Object)(object)components2[i] != (Object)null) { components2[i].enabled = components[i].enabled; } } int num2 = Math.Min(source.childCount, clone.childCount); for (int j = 0; j < num2; j++) { CopyModelVisualStatesRecursive(source.GetChild(j), clone.GetChild(j), isRoot: false); } } private void CopyModelVisualStates(GameObject source, GameObject clone) { if (!((Object)(object)source == (Object)null) && !((Object)(object)clone == (Object)null)) { CopyModelVisualStatesRecursive(source.transform, clone.transform, isRoot: true); clone.SetActive(true); } } private Transform AddWearableModel(WearableDefinition def, Transform holder, string objectName) { //IL_0065: Unknown result type (might be due to invalid IL or missing references) if (def == null || (Object)(object)def.ModelSource == (Object)null || (Object)(object)holder == (Object)null) { return null; } Transform val = holder.Find(objectName); if ((Object)(object)val != (Object)null) { Object.DestroyImmediate((Object)(object)((Component)val).gameObject); } GameObject val2 = Object.Instantiate<GameObject>(def.ModelSource, holder, false); ((Object)val2).name = objectName; CopyModelVisualStates(def.ModelSource, val2); _ = def.ModelSource.transform.localScale; ApplyFinalWearableTransform(val2.transform, def); Collider[] componentsInChildren = val2.GetComponentsInChildren<Collider>(true); foreach (Collider val3 in componentsInChildren) { if ((Object)(object)val3 != (Object)null) { val3.enabled = false; } } Rigidbody[] componentsInChildren2 = val2.GetComponentsInChildren<Rigidbody>(true); foreach (Rigidbody val4 in componentsInChildren2) { if (!((Object)(object)val4 == (Object)null)) { val4.isKinematic = true; val4.detectCollisions = false; } } def.ActiveModels.Add(val2.transform); Renderer[] componentsInChildren3 = val2.GetComponentsInChildren<Renderer>(true); int num = 0; Renderer[] array = componentsInChildren3; foreach (Renderer val5 in array) { if ((Object)(object)val5 == (Object)null) { continue; } if (val5.enabled && ((Component)val5).gameObject.activeSelf) { num++; } SkinnedMeshRenderer val6 = (SkinnedMeshRenderer)(object)((val5 is SkinnedMeshRenderer) ? val5 : null); if ((Object)(object)val6 != (Object)null && (Object)(object)val6.sharedMesh != (Object)null) { _ = ((Object)val6.sharedMesh).name; continue; } MeshFilter component = ((Component)val5).GetComponent<MeshFilter>(); if ((Object)(object)component != (Object)null && (Object)(object)component.sharedMesh != (Object)null) { _ = ((Object)component.sharedMesh).name; } } if (componentsInChildren3.Length == 0) { ((BaseUnityPlugin)this).Logger.LogError((object)("[Sakey's Yumekawa Weapons] 独自モデルにRendererがありません: " + def.ModelAssetName)); } else if (num == 0) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("[Sakey's Yumekawa Weapons] 有効なRendererがありません。AssetBundle側のRenderer設定を確認: " + def.ModelAssetName)); } return val2.transform; } private StatusEffect CloneWearableStatusEffect(StatusEffect sourceEffect, Sprite itemIcon, string prefabName, string effectSuffix) { if ((Object)(object)sourceEffect == (Object)null) { return null; } StatusEffect val = Object.Instantiate<StatusEffect>(sourceEffect); if ((Object)(object)val == (Object)null) { return null; } ((Object)val).name = "SakeyYumekawa_" + prefabName + "_" + effectSuffix; if ((Object)(object)itemIcon != (Object)null) { val.m_icon = itemIcon; } ((BaseUnityPlugin)this).Logger.LogInfo((object)("[Sakey's Yumekawa Weapons] 装備効果アイコンを独自アイコンへ変更: " + prefabName + " / sourceEffect=" + ((Object)sourceEffect).name + " / clonedEffect=" + ((Object)val).name + " / icon=" + (((Object)(object)val.m_icon != (Object)null) ? ((Object)val.m_icon).name : "null"))); return val; } private void CopyWearableEffectData(SharedData sourceShared, SharedData targetShared, Sprite itemIcon, string prefabName) { if (sourceShared != null && targetShared != null) { targetShared.m_equipStatusEffect = CloneWearableStatusEffect(sourceShared.m_equipStatusEffect, itemIcon, prefabName, prefabName.StartsWith("head_", StringComparison.Ordinal) ? "extreme" : "cape"); targetShared.m_fullAdrenalineSE = sourceShared.m_fullAdrenalineSE; targetShared.m_maxAdrenaline = sourceShared.m_maxAdrenaline; targetShared.m_movementModifier = sourceShared.m_movementModifier; targetShared.m_damageModifiers = sourceShared.m_damageModifiers; } } private void PrepareWearablePrefab(WearableDefinition def, GameObject prefab, GameObject modelSource, SharedData shared, SharedData effectSourceShared) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Invalid comparison between Unknown and I4 //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Invalid comparison between Unknown and I4 //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Invalid comparison between Unknown and I4 //IL_0043: 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_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_0417: Unknown result type (might be due to invalid IL or missing references) //IL_041c: Unknown result type (might be due to invalid IL or missing references) def.ModelSource = modelSource; if ((Object)(object)def.ModelSource == (Object)null) { throw new InvalidOperationException("AssetBundle内モデルがありません: " + def.ModelAssetName); } bool flag = def.PrefabName == "access_brooch2"; if (flag) { shared.m_itemType = (ItemType)56; shared.m_attachOverride = (ItemType)19; shared.m_movementModifier = 0f; } bool flag2 = (int)shared.m_itemType == 6; bool flag3 = (int)shared.m_itemType == 24; bool flag4 = (int)shared.m_itemType == 17; if (def.PrefabName.StartsWith("head_", StringComparison.Ordinal) && !flag2) { throw new InvalidOperationException("頭装備のItemTypeがHelmetではありません: " + ((object)Unsafe.As<ItemType, ItemType>(ref shared.m_itemType)/*cast due to .constrained prefix*/).ToString()); } if (def.PrefabName == "access_brooch2" && (effectSourceShared == null || (Object)(object)effectSourceShared.m_equipStatusEffect == (Object)null)) { throw new InvalidOperationException("CapeFeatherの装備効果 m_equipStatusEffect が取得できません。"); } Transform val = prefab.transform.Find("model"); if ((Object)(object)val == (Object)null) { GameObject val2 = new GameObject("model"); val2.transform.SetParent(prefab.transform, false); val = val2.transform; ((BaseUnityPlugin)this).Logger.LogWarning((object)("[Sakey's Yumekawa Weapons] " + def.PrefabName + " にmodelがないため標準名modelを追加しました。")); } DisableHolderRenderersOnly(val); AddWearableModel(def, val, "yumekawa_drop_model_" + def.PrefabName); if (flag3) { Transform val3 = FindChildRecursive(prefab.transform, "yumekawa_drop_model_" + def.PrefabName); Renderer[] componentsInChildren = prefab.GetComponentsInChildren<Renderer>(true); foreach (Renderer val4 in componentsInChildren) { if (!((Object)(object)val4 == (Object)null) && (!((Object)(object)val3 != (Object)null) || !((Component)val4).transform.IsChildOf(val3))) { val4.enabled = false; } } } Transform val5 = prefab.transform.Find("attach"); Transform val6 = prefab.transform.Find("attach_skin"); if (flag) { if ((Object)(object)val5 != (Object)null) { Object.DestroyImmediate((Object)(object)((Component)val5).gameObject); } Transform val7 = prefab.transform.Find("attach_back"); if ((Object)(object)val7 == (Object)null) { GameObject val8 = new GameObject("attach_back"); val8.transform.SetParent(prefab.transform, false); val7 = val8.transform; } Transform val9 = val7.Find("default"); if ((Object)(object)val9 == (Object)null) { GameObject val10 = new GameObject("default"); val10.transform.SetParent(val7, false); val9 = val10.transform; } DisableHolderRenderersOnly(val9); AddWearableModel(def, val9, "yumekawa_back_ribbon"); } else if (!flag3) { if (flag2) { Transform val11 = FindChildRecursive(prefab.transform, "yumekawa_drop_model_" + def.PrefabName); Renderer[] componentsInChildren = prefab.GetComponentsInChildren<Renderer>(true); foreach (Renderer val12 in componentsInChildren) { if (!((Object)(object)val12 == (Object)null) && (!((Object)(object)val11 != (Object)null) || !((Component)val12).transform.IsChildOf(val11))) { val12.enabled = false; } } } else if (flag4) { if ((Object)(object)val5 != (Object)null) { DisableHolderRenderersOnly(val5); } if ((Object)(object)val6 != (Object)null) { DisableHolderRenderersOnly(val6); } } } ((BaseUnityPlugin)this).Logger.LogInfo((object)("[Sakey's Yumekawa Weapons] Wearable prefab prepared: " + def.PrefabName + " ItemType=" + ((object)Unsafe.As<ItemType, ItemType>(ref shared.m_itemType)/*cast due to .constrained prefix*/).ToString() + " EquipHolder=" + (flag3 ? "SetTrinketItem/chest-bone" : "runtime VisEquipment result") + " AttachExists=" + ((Object)(object)val5 != (Object)null || def.PrefabName == "access_brooch2") + " AttachSkinExists=" + ((Object)(object)val6 != (Object)null) + " DropHolder=" + ((Object)val).name + " ImportedScale=" + ((object)modelSource.transform.localScale/*cast due to .constrained prefix*/).ToString() + " ConfigScale=" + GetSize(def) + " EquipSE=" + (((Object)(object)shared.m_equipStatusEffect != (Object)null) ? ((Object)shared.m_equipStatusEffect).name : "none") + " FullAdrenalineSE=" + (((Object)(object)shared.m_fullAdrenalineSE != (Object)null) ? ((Object)shared.m_fullAdrenalineSE).name : "none") + " MaxAdrenaline=" + shared.m_maxAdrenaline + " MovementModifier=" + shared.m_movementModifier + " CenterCamera=" + shared.m_centerCamera)); } internal static void ApplyRibbonRuntimeTransform(GameObject attachedRoot) { //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Instance == (Object)null || (Object)(object)attachedRoot == (Object)null) { return; } WearableDefinition wearableDefinition = Instance.wearables.Find((WearableDefinition w) => w.PrefabName == "access_brooch2"); if (wearableDefinition == null || (Object)(object)wearableDefinition.ModelSource == (Object)null) { return; } Transform val = Instance.FindChildRecursive(attachedRoot.transform, "yumekawa_back_ribbon"); if (!((Object)(object)val == (Object)null)) { Instance.ApplyFinalWearableTransform(val, wearableDefinition); if (!wearableDefinition.ActiveModels.Contains(val)) { wearableDefinition.ActiveModels.Add(val); } ((BaseUnityPlugin)Instance).Logger.LogInfo((object)("[Sakey's Yumekawa Weapons] Ribbon back-slot visual attached: root=" + ((Object)attachedRoot).name + " model=" + ((Object)val).name + " position=" + ((object)val.localPosition/*cast due to .constrained prefix*/).ToString() + " scale=" + ((object)val.localScale/*cast due to .constrained prefix*/).ToString())); } } private IEnumerator AttachMeshOnlyHeadAfterPose(GameObject attachedRoot, WearableDefinition def, int rootId) { yield return (object)new WaitForEndOfFrame(); pendingHeadAttachRoots.Remove(rootId); if (!((Object)(object)attachedRoot == (Object)null) && def != null && !((Object)(object)def.ModelSource == (Object)null)) { ReplaceRuntimeEquipmentVisual(attachedRoot, def); } } private void QueueMeshOnlyHeadAttach(GameObject attachedRoot, WearableDefinition def) { if (!((Object)(object)attachedRoot == (Object)null) && def != null) { int instanceID = ((Object)attachedRoot).GetInstanceID(); if (pendingHeadAttachRoots.Add(instanceID)) { ((MonoBehaviour)this).StartCoroutine(AttachMeshOnlyHeadAfterPose(attachedRoot, def, instanceID)); } } } private void ReplaceRuntimeEquipmentVisual(GameObject attachedRoot, WearableDefinition def) { if ((Object)(object)attachedRoot == (Object)null || def == null || (Object)(object)def.ModelSource == (Object)null) { return; } string text = "yumekawa_runtime_" + def.PrefabName; Transform val = attachedRoot.transform.Find(text); Renderer[] componentsInChildren; if ((Object)(object)val != (Object)null) { bool activeSelf = ((Component)val).gameObject.activeSelf; if (!((Component)val).gameObject.activeSelf) { ((Component)val).gameObject.SetActive(true); } bool flag = false; componentsInChildren = def.ModelSource.GetComponentsInChildren<Renderer>(true); foreach (Renderer val2 in componentsInChildren) { if ((Object)(object)val2 != (Object)null && val2.enabled && ((Component)val2).gameObject.activeInHierarchy) { flag = true; break; } } bool flag2 = false; componentsInChildren = ((Component)val).GetComponentsInChildren<Renderer>(true); foreach (Renderer val3 in componentsInChildren) { if ((Object)(object)val3 != (Object)null && val3.enabled && ((Component)val3).gameObject.activeInHierarchy) { flag2 = true; break; } } if (flag && !flag2) { CopyModelVisualStates(def.ModelSource, ((Component)val).gameObject); } ApplyFinalWearableTransform(val, def); if (!def.ActiveModels.Contains(val)) { def.ActiveModels.Add(val); } if (!activeSelf) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("[Sakey's Yumekawa Weapons] Runtime wearable visual reactivated: " + def.PrefabName + " AttachedRoot=" + ((Object)attachedRoot).name)); } return; } componentsInChildren = attachedRoot.GetComponentsInChildren<Renderer>(true); foreach (Renderer val4 in componentsInChildren) { if (!((Object)(object)val4 == (Object)null) && !((Object)((Component)val4).transform).name.StartsWith("yumekawa_", StringComparison.Ordinal)) { val4.enabled = false; } } GameObject val5 = Object.Instantiate<GameObject>(def.ModelSource, attachedRoot.transform, false); ((Object)val5).name = text; CopyModelVisualStates(def.ModelSource, val5); ApplyFinalWearableTransform(val5.transform, def); Collider[] componentsInChildren2 = val5.GetComponentsInChildren<Collider>(true); foreach (Collider val6 in componentsInChildren2) { if ((Object)(object)val6 != (Object)null) { val6.enabled = false; } } Rigidbody[] componentsInChildren3 = val5.GetComponentsInChildren<Rigidbody>(true); foreach (Rigidbody val7 in componentsInChildren3) { if (!((Object)(object)val7 == (Object)null)) { val7.isKinematic = true; val7.detectCollisions = false; } } def.ActiveModels.Add(val5.transform); } private WearableDefinition FindWearableByHash(int itemHash) { if ((Object)(object)ObjectDB.instance == (Object)null) { return null; } GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(itemHash); if ((Object)(object)itemPrefab == (Object)null) { return null; } foreach (WearableDefinition wearable in wearables) { if (string.Equals(wearable.PrefabName, ((Object)itemPrefab).name, StringComparison.Ordinal)) { return wearable; } } return null; } private Transform FindTrinketAnchor(VisEquipment visEquipment) { Animator val = ((Component)visEquipment).GetComponentInParent<Animator>(); if ((Object)(object)val == (Object)null) { val = ((Component)visEquipment).GetComponentInChildren<Animator>(true); } if ((Object)(object)val != (Object)null && val.isHuman) { Transform boneTransform = val.GetBoneTransform((HumanBodyBones)8); if ((Object)(object)boneTransform == (Object)null) { boneTransform = val.GetBoneTransform((HumanBodyBones)54); } if ((Object)(object)boneTransform == (Object)null) { boneTransform = val.GetBoneTransform((HumanBodyBones)7); } if ((Object)(object)boneTransform != (Object)null) { return boneTransform; } } string[] array = new string[6] { "Spine2", "Chest", "spine2", "Spine1", "spine1", "Spine" }; foreach (string targetName in array) { Transform val2 = FindChildRecursive(((Component)visEquipment).transform, targetName); if ((Object)(object)val2 != (Object)null) { return val2; } } return null; } private Transform FindChildRecursive(Transform root, string targetName) { if ((Object)(object)root == (Object)null) { return null; } if (string.Equals(((Object)root).name, targetName, StringComparison.OrdinalIgnoreCase)) { return root; } for (int i = 0; i < root.childCount; i++) { Transform val = FindChildRecursive(root.GetChild(i), targetName); if ((Object)(object)val != (Object)null) { return val; } } return null; } private unsafe bool RegisterItem(string prefabName, string basePrefabName, string modelAssetName, string iconAssetName, string displayName, string description, string requirementItem, int craftAmount, int upgradeAmount, Vector3 modelOffset, float lightningDamageMultiplier = 1f) { //IL_040c: Unknown result type (might be due to invalid IL or missing references) //IL_0411: Unknown result type (might be due to invalid IL or missing references) //IL_0418: Unknown result type (might be due to invalid IL or missing references) //IL_0423: Unknown result type (might be due to invalid IL or missing references) //IL_042a: Unknown result type (might be due to invalid IL or missing references) //IL_0437: Unknown result type (might be due to invalid IL or missing references) //IL_0446: Expected O, but got Unknown //IL_0448: Unknown result type (might be due to invalid IL or missing references) //IL_044d: Unknown result type (might be due to invalid IL or missing references) //IL_0455: Unknown result type (might be due to invalid IL or missing references) //IL_045d: Unknown result type (might be due to invalid IL or missing references) //IL_0465: Unknown result type (might be due to invalid IL or missing references) //IL_0471: Expected O, but got Unknown //IL_0476: Unknown result type (might be due to invalid IL or missing references) //IL_047d: Expected O, but got Unknown //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Unknown result type (might be due to invalid IL or missing references) //IL_030e: Unknown result type (might be due to invalid IL or missing references) //IL_0313: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_0343: Unknown result type (might be due to invalid IL or missing references) //IL_034a: Unknown result type (might be due to invalid IL or missing references) //IL_034c: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_0673: Unknown result type (might be due to invalid IL or missing references) //IL_0675: Unknown result type (might be due to invalid IL or missing references) GameObject prefab = PrefabManager.Instance.GetPrefab(basePrefabName); if ((Object)(object)prefab == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)("[Sakey's Yumekawa Weapons] クローン元Prefabなし: " + basePrefabName + " / " + prefabName)); return false; } ItemDrop component = prefab.GetComponent<ItemDrop>(); if ((Object)(object)component == (Object)null || component.m_itemData == null || component.m_itemData.m_shared == null) { ((BaseUnityPlugin)this).Logger.LogError((object)("[Sakey's Yumekawa Weapons] クローン元ItemDrop/SharedDataなし: " + basePrefabName)); return false; } GameObject val = assetBundle.LoadAsset<GameObject>(modelAssetName); Sprite val2 = assetBundle.LoadAsset<Sprite>(iconAssetName); if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)("[Sakey's Yumekawa Weapons] AssetBundle内アセット不足: model=" + modelAssetName + " icon=" + iconAssetName)); return false; } GameObject val3 = PrefabManager.Instance.CreateClonedPrefab(prefabName, basePrefabName); if ((Object)(object)val3 == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)("[Sakey's Yumekawa Weapons] クローン失敗: " + prefabName)); return false; } ItemDrop component2 = val3.GetComponent<ItemDrop>(); if ((Object)(object)component2 == (Object)null || component2.m_itemData == null || component2.m_itemData.m_shared == null) { ((BaseUnityPlugin)this).Logger.LogError((object)("[Sakey's Yumekawa Weapons] クローン後ItemDrop/SharedDataなし: " + prefabName)); return false; } SharedData shared = component.m_itemData.m_shared; if (string.Equals(prefabName, "access_brooch2", StringComparison.Ordinal)) { GameObject prefab2 = PrefabManager.Instance.GetPrefab("CapeFeather"); ItemDrop val4 = (((Object)(object)prefab2 != (Object)null) ? prefab2.GetComponent<ItemDrop>() : null); if ((Object)(object)val4 == (Object)null || val4.m_itemData == null || val4.m_itemData.m_shared == null || (Object)(object)val4.m_itemData.m_shared.m_equipStatusEffect == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)"[Sakey's Yumekawa Weapons] CapeFeatherの装備効果を取得できません。リボン登録を中止します。"); return false; } shared = val4.m_itemData.m_shared; } WearableDefinition wearableDefinition = null; foreach (WearableDefinition wearable in wearables) { if (string.Equals(wearable.PrefabName, prefabName, StringComparison.Ordinal)) { wearableDefinition = wearable; break; } } if (wearableDefinition != null) { PrepareWearablePrefab(wearableDefinition, val3, val, component2.m_itemData.m_shared, shared); } else { Transform val5 = val3.transform.Find("attach"); if ((Object)(object)val5 == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)("[Sakey's Yumekawa Weapons] attach Transformなし: " + basePrefabName + " / " + prefabName)); return false; } Renderer[] componentsInChildren = ((Component)val5).GetComponentsInChildren<Renderer>(true); foreach (Renderer val6 in componentsInChildren) { if ((Object)(object)val6 != (Object)null) { val6.enabled = false; } } GameObject obj = Object.Instantiate<GameObject>(val, val5); ((Object)obj).name = "yumekawa_model"; obj.transform.localPosition = modelOffset; obj.transform.localRotation = Quaternion.identity; obj.transform.localScale = Vector3.one; } SharedData shared2 = component2.m_itemData.m_shared; if (lightningDamageMultiplier > 1f) { DamageTypes damages = shared2.m_damages; DamageTypes damagesPerLevel = shared2.m_damagesPerLevel; float lightning = damages.m_lightning; float lightning2 = damagesPerLevel.m_lightning; damages.m_lightning = lightning * lightningDamageMultiplier; damagesPerLevel.m_lightning = lightning2 * lightningDamageMultiplier; shared2.m_damages = damages; shared2.m_damagesPerLevel = damagesPerLevel; ((BaseUnityPlugin)this).Logger.LogInfo((object)("[Sakey's Yumekawa Weapons] 雷ダメージ倍率適用: " + prefabName + " Base=" + lightning + " PerLevel=" + lightning2 + " Multiplier=" + lightningDamageMultiplier + " Result=" + damages.m_lightning + " PerLevelResult=" + damagesPerLevel.m_lightning)); } shared2.m_name = displayName; shared2.m_description = description; shared2.m_icons = (Sprite[])(object)new Sprite[1] { val2 }; component2.m_itemData.m_dropPrefab = val3; ItemConfig val7 = new ItemConfig { Amount = 1, CraftingStation = "piece_workbench", MinStationLevel = 1, Name = shared2.m_name, Description = shared2.m_description }; val7.AddRequirement(new RequirementConfig { Item = requirementItem, Amount = craftAmount, AmountPerLevel = upgradeAmount, Recover = false }); CustomItem val8 = new CustomItem(val3, true, val7); if (!ItemManager.Instance.AddItem(val8)) { ((BaseUnityPlugin)this).Logger.LogError((object)("[Sakey's Yumekawa Weapons] ItemManager登録失敗: " + prefabName)); return false; } ItemDrop component3 = val3.GetComponent<ItemDrop>(); if ((Object)(object)component3 != (Object)null && component3.m_itemData != null) { component3.m_itemData.m_dropPrefab = val3; if (wearableDefinition != null) { CopyWearableEffectData(shared, component3.m_itemData.m_shared, val2, wearableDefinition.PrefabName); ((BaseUnityPlugin)this).Logger.LogInfo((object)("[Sakey's Yumekawa Weapons] 継承効果確認: " + wearableDefinition.PrefabName + " EquipSE=" + (((Object)(object)component3.m_itemData.m_shared.m_equipStatusEffect != (Object)null) ? ((Object)component3.m_itemData.m_shared.m_equipStatusEffect).name : "none") + " DamageModifiers=" + ((component3.m_itemData.m_shared.m_damageModifiers != null) ? component3.m_itemData.m_shared.m_damageModifiers.Count : 0) + " MovementModifier=" + component3.m_itemData.m_shared.m_movementModifier + " EffectIcon=" + (((Object)(object)component3.m_itemData.m_shared.m_equipStatusEffect != (Object)null && (Object)(object)component3.m_itemData.m_shared.m_equipStatusEffect.m_icon == (Object)(object)val2) ? "CustomItemIcon" : "NotCustomItemIcon"))); } } ManualLogSource logger = ((BaseUnityPlugin)this).Logger; string[] obj2 = new string[16] { "[Sakey's Yumekawa Weapons] 登録成功: ", prefabName, " Base=", basePrefabName, " Material=", requirementItem, "=", craftAmount.ToString(), " + ", upgradeAmount.ToString(), "/level Offset=", null, null, null, null, null }; Vector3 val9 = modelOffset; obj2[11] = ((object)(*(Vector3*)(&val9))/*cast due to .constrained prefix*/).ToString(); obj2[12] = " WearableSize="; obj2[13] = ((wearableDefinition != null) ? GetSize(wearableDefinition).ToString() : "n/a"); obj2[14] = " LightningMultiplier="; obj2[15] = lightningDamageMultiplier.ToString(); logger.LogInfo((object)string.Concat(obj2)); return true; } } internal static class YumekawaRibbonState { private sealed class HumanoidState { internal ItemData Item; } private sealed class VisState { internal string ItemName = ""; internal List<GameObject> Instances; internal int CurrentHash; } private static readonly ConditionalWeakTable<Humanoid, HumanoidState> Humanoids = new ConditionalWeakTable<Humanoid, HumanoidState>(); private static readonly ConditionalWeakTable<VisEquipment, VisState> Visuals = new ConditionalWeakTable<VisEquipment, VisState>(); private static readonly MethodInfo SetupEquipmentMethod = AccessTools.Method(typeof(Humanoid), "SetupEquipment", (Type[])null, (Type[])null); private static readonly MethodInfo AttachBackItemMethod = AccessTools.Method(typeof(VisEquipment), "AttachBackItem", new Type[4] { typeof(int), typeof(int), typeof(bool), typeof(int) }, (Type[])null); internal static bool Is(ItemData item) { if (item != null && (Object)(object)item.m_dropPrefab != (Object)null) { return string.Equals(((Object)item.m_dropPrefab).name, "access_brooch2", StringComparison.Ordinal); } return false; } internal static ItemData Get(Humanoid humanoid) { if (!((Object)(object)humanoid == (Object)null)) { return Humanoids.GetOrCreateValue(humanoid).Item; } return null; } internal static void Set(Humanoid humanoid, ItemData item) { if ((Object)(object)humanoid != (Object)null) { Humanoids.GetOrCreateValue(humanoid).Item = item; } } internal static void SetupEquipment(Humanoid humanoid) { if ((Object)(object)humanoid != (Object)null && SetupEquipmentMethod != null) { SetupEquipmentMethod.Invoke(humanoid, null); } } private static object GetSEMan(Humanoid humanoid) { if ((Object)(object)humanoid == (Object)null) { return null; } FieldInfo fieldInfo = AccessTools.Field(typeof(Character), "m_seman"); if (!(fieldInfo != null)) { return null; } return fieldInfo.GetValue(humanoid); } internal static void ApplyEquipEffect(Humanoid humanoid, ItemData item) { StatusEffect val = ((item != null && item.m_shared != null) ? item.m_shared.m_equipStatusEffect : null); if ((Object)(object)humanoid == (Object)null || (Object)(object)val == (Object)null) { return; } object sEMan = GetSEMan(humanoid); if (sEMan == null) { return; } MethodInfo[] methods = sEMan.GetType().GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); MethodInfo[] array = methods; foreach (MethodInfo methodInfo in array) { if (!(methodInfo.Name != "AddStatusEffect")) { ParameterInfo[] parameters = methodInfo.GetParameters(); if (parameters.Length == 5 && parameters[0].ParameterType == typeof(StatusEffect) && parameters[1].ParameterType == typeof(bool) && parameters[2].ParameterType == typeof(int) && parameters[3].ParameterType == typeof(float) && parameters[4].ParameterType == typeof(short)) { methodInfo.Invoke(sEMan, new object[5] { val, false, 0, 0f, (short)(-1) }); Debug.Log((object)("[Sakey's Yumekawa Weapons] Ribbon equip effect applied: " + ((Object)val).name + " hash=" + val.NameHash())); return; } } } array = methods; foreach (MethodInfo methodInfo2 in array) { if (!(methodInfo2.Name != "AddStatusEffect")) { ParameterInfo[] parameters2 = methodInfo2.GetParameters(); if (parameters2.Length == 4 && parameters2[0].ParameterType == typeof(StatusEffect) && parameters2[1].ParameterType == typeof(bool) && parameters2[2].ParameterType == typeof(int) && parameters2[3].ParameterType == typeof(float)) { methodInfo2.Invoke(sEMan, new object[4] { val, false, 0, 0f }); Debug.Log((object)("[Sakey's Yumekawa Weapons] Ribbon equip effect applied: " + ((Object)val).name + " hash=" + val.NameHash())); return; } } } Debug.LogError((object)"[Sakey's Yumekawa Weapons] Compatible SEMan.AddStatusEffect(StatusEffect, ...) overload not found for ribbon."); } internal static void RemoveEquipEffect(Humanoid humanoid, ItemData item) { StatusEffect val = ((item != null && item.m_shared != null) ? item.m_shared.m_equipStatusEffect : null); if ((Object)(object)humanoid == (Object)null || (Object)(object)val == (Object)null) { return; } object sEMan = GetSEMan(humanoid); if (sEMan == null) { return; } int num = val.NameHash(); MethodInfo[] methods = sEMan.GetType().GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (MethodInfo methodInfo in methods) { if (!(methodInfo.Name != "RemoveStatusEffect")) { ParameterInfo[] parameters = methodInfo.GetParameters(); if (parameters.Length == 2 && parameters[0].ParameterType == typeof(int) && parameters[1].ParameterType == typeof(bool)) { methodInfo.Invoke(sEMan, new object[2] { num, false }); Debug.Log((object)("[Sakey's Yumekawa Weapons] Ribbon equip effect removed: hash=" + num)); break; } if (parameters.Length == 1 && parameters[0].ParameterType == typeof(int)) { methodInfo.Invoke(sEMan, new object[1] { num }); Debug.Log((object)("[Sakey's Yumekawa Weapons] Ribbon equip effect removed: hash=" + num)); break; } } } } internal static void SetVisualItem(VisEquipment vis, string name) { if ((Object)(object)vis != (Object)null) { Visuals.GetOrCreateValue(vis).ItemName = name ?? ""; } } internal static void UpdateVisual(VisEquipment vis) { if ((Object)(object)vis == (Object)null) { return; } VisState orCreateValue = Visuals.GetOrCreateValue(vis); int num = ((!string.IsNullOrEmpty(orCreateValue.ItemName)) ? StringExtensionMethods.GetStableHashCode(orCreateValue.ItemName) : 0); if (orCreateValue.CurrentHash == num) { return; } if (orCreateValue.Instances != null) { foreach (GameObject instance in orCreateValue.Instances) { if ((Object)(object)instance != (Object)null) { Object.Destroy((Object)(object)instance); } } orCreateValue.Instances = null; } orCreateValue.CurrentHash = num; if (num == 0) { return; } if (AttachBackItemMethod == null) { Debug.LogError((object)"[Sakey's Yumekawa Weapons] VisEquipment.AttachBackItem(int,int,bool,int) not found; ribbon visual cannot be attached."); return; } object? obj = AttachBackItemMethod.Invoke(vis, new object[4] { num, -1, false, 0 }); GameObject val = (GameObject)((obj is GameObject) ? obj : null); if ((Object)(object)val != (Object)null) { orCreateValue.Instances = new List<GameObject> { val }; YumekawaWeaponsPlugin.ApplyRibbonRuntimeTransform(val); } else { Debug.LogWarning((object)("[Sakey's Yumekawa Weapons] AttachBackItem returned null for ribbon hash=" + num)); } } } [HarmonyPatch(typeof(Humanoid), "EquipItem")] internal static class YumekawaRibbonEquipPatch { private static void Postfix(Humanoid __instance, ItemData item, ref bool __result, bool triggerEquipEffects, VisEquipment ___m_visEquipment) { if (!YumekawaRibbonState.Is(item)) { return; } ItemData val = YumekawaRibbonState.Get(__instance); if (val != null && val != item) { __instance.UnequipItem(val, triggerEquipEffects); if ((Object)(object)___m_visEquipment != (Object)null) { ___m_visEquipment.UpdateEquipmentVisuals(); } } YumekawaRibbonState.Set(__instance, item); item.m_equipped = true; __result = true; YumekawaRibbonState.SetupEquipment(__instance); YumekawaRibbonState.ApplyEquipEffect(__instance, item); } } [HarmonyPatch(typeof(Humanoid), "UnequipItem")] internal static class YumekawaRibbonUnequipPatch { private static void Postfix(Humanoid __instance, ItemData item) { if (item != null && item == YumekawaRibbonState.Get(__instance)) { YumekawaRibbonState.Set(__instance, null); YumekawaRibbonState.SetupEquipment(__instance); YumekawaRibbonState.RemoveEquipEffect(__instance, item); } } } [HarmonyPatch(typeof(Humanoid), "UnequipAllItems")] internal static class YumekawaRibbonUnequipAllPatch { private static void Postfix(Humanoid __instance) { ItemData val = YumekawaRibbonState.Get(__instance); if (val != null) { __instance.UnequipItem(val, false); } } } [HarmonyPatch(typeof(Humanoid), "IsItemEquiped")] internal static class YumekawaRibbonIsEquippedPatch { private static void Postfix(Humanoid __instance, ItemData item, ref bool __result) { if (item != null && item == YumekawaRibbonState.Get(__instance)) { __result = true; } } } [HarmonyPatch(typeof(ItemData), "IsEquipable")] internal static class YumekawaRibbonIsEquipablePatch { private static void Postfix(ItemData __instance, ref bool __result) { if (YumekawaRibbonState.Is(__instance)) { __result = true; } } } [HarmonyPatch(typeof(Humanoid), "GetEquipmentWeight")] internal static class YumekawaRibbonWeightPatch { private static void Postfix(Humanoid __instance, ref float __result) { ItemData val = YumekawaRibbonState.Get(__instance); if (val != null) { __result += val.m_shared.m_weight; } } } [HarmonyPatch(typeof(Humanoid), "SetupVisEquipment")] internal static class YumekawaRibbonSetupVisPatch { private static void Postfix(Humanoid __instance, VisEquipment visEq, bool isRagdoll) { ItemData val = YumekawaRibbonState.Get(__instance); YumekawaRibbonState.SetVisualItem(visEq, YumekawaRibbonState.Is(val) ? ((Object)val.m_dropPrefab).name : ""); } } [HarmonyPatch(typeof(VisEquipment), "UpdateEquipmentVisuals")] internal static class YumekawaRibbonUpdateVisualPatch { private static void Prefix(VisEquipment __instance) { YumekawaRibbonState.UpdateVisual(__instance); } } [HarmonyPatch(typeof(Inventory), "Changed")] internal static class YumekawaRibbonInventoryPatch { private static void Prefix(Inventory __instance) { Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null) && __instance == ((Humanoid)localPlayer).GetInventory()) { ItemData val = YumekawaRibbonState.Get((Humanoid)(object)localPlayer); if (val != null && !__instance.ContainsItem(val)) { YumekawaRibbonState.Set((Humanoid)(object)localPlayer, null); YumekawaRibbonState.SetupEquipment((Humanoid)(object)localPlayer); YumekawaRibbonState.RemoveEquipEffect((Humanoid)(object)localPlayer, val); } } } }