using System; 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 BepInEx; using BepInEx.Configuration; using HarmonyLib; using Jotunn; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; 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("SakeysJapanese food")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("SakeysJapanese food")] [assembly: AssemblyTitle("SakeysJapanese food")] [assembly: AssemblyVersion("1.0.0.0")] namespace SakeysJapaneseFood; [BepInPlugin("com.sakey.japanesefood", "Sakey's Japanese food", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Class1 : BaseUnityPlugin { public class JapaneseFoodData { public string prefabName; public string itemId; public string basePrefabName; public string displayName; public string description; public string iconName; public float foodHealth; public float foodStamina; public float foodEitr; public float foodRegen; public float foodBurnTime; public int craftAmount; public string recipeItem1; public int recipeAmount1; public string recipeItem2; public int recipeAmount2; public string recipeItem3; public int recipeAmount3; public string recipeItem4; public int recipeAmount4; public int maxStackSize = 10; public bool isFeast; } [HarmonyPatch] private static class FeastRuntimeFoodFixPatch { private static IEnumerable TargetMethods() { return from method in typeof(Feast).GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) where method.Name.Equals("RPC_TryEat", StringComparison.Ordinal) || method.Name.Equals("RPC_EatConfirmation", StringComparison.Ordinal) select method; } private static void Prefix(Feast __instance) { ForceFeastFoodReference(__instance, "Prefix"); } private static void ForceFeastFoodReference(Feast feast, string source) { if ((Object)(object)feast == (Object)null) { return; } string prefabName = Utils.GetPrefabName(((Object)((Component)feast).gameObject).name); JapaneseFoodData japaneseFoodData = null; foreach (JapaneseFoodData food in foodList) { if (food.isFeast && prefabName.Equals(food.itemId, StringComparison.OrdinalIgnoreCase)) { japaneseFoodData = food; break; } } if (japaneseFoodData != null && !((Object)(object)ObjectDB.instance == (Object)null)) { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(japaneseFoodData.itemId); ItemDrop val = ((itemPrefab != null) ? itemPrefab.GetComponent() : null); if ((Object)(object)val == (Object)null || val.m_itemData == null || val.m_itemData.m_shared == null) { Logger.LogWarning((object)("[Sakey's Japanese food] Feast食事RPC修正失敗: " + japaneseFoodData.itemId + " のItemDropがありません。")); return; } feast.m_foodItem = val; SharedData shared = val.m_itemData.m_shared; Logger.LogInfo((object)("[Sakey's Japanese food] Feast食事RPC参照: " + prefabName + " / source=" + source + " / m_foodItem=" + ((Object)val).name + " / " + $"HP={shared.m_food} ST={shared.m_foodStamina} " + $"EITR={shared.m_foodEitr} Regen={shared.m_foodRegen} " + $"Burn={shared.m_foodBurnTime}")); } } } [HarmonyPatch(typeof(Trader), "Start")] private static class TraderStartPatch { private static void Postfix(Trader __instance) { //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Expected O, but got Unknown if ((Object)(object)__instance == (Object)null || !sellAtHaldor.Value || !Utils.GetPrefabName(((Component)__instance).gameObject).Equals("Haldor", StringComparison.OrdinalIgnoreCase)) { return; } foreach (JapaneseFoodData food in foodList) { string text = (food.isFeast ? (food.itemId + "_material") : food.itemId); GameObject prefab = PrefabManager.Instance.GetPrefab(text); if ((Object)(object)prefab == (Object)null) { continue; } ItemDrop component = prefab.GetComponent(); if ((Object)(object)component == (Object)null) { continue; } TradeItem item = new TradeItem { m_prefab = component, m_stack = 1, m_price = foodPrice.Value, m_requiredGlobalKey = "" }; bool flag = false; foreach (TradeItem item2 in __instance.m_items) { if (item2 != null && (Object)(object)item2.m_prefab == (Object)(object)component) { flag = true; break; } } if (!flag) { __instance.m_items.Add(item); } } } } public const string PluginGUID = "com.sakey.japanesefood"; public const string PluginName = "Sakey's Japanese food"; public const string PluginVersion = "1.0.0"; public const string ASSET_BUNDLE_NAME = "japanesefood"; public static readonly Vector3 MODEL_TARGET_SCALE = new Vector3(10f, 10f, 10f); public const float MODEL_Y_OFFSET = 0f; public static List foodList; private static AssetBundle assetBundle; private static ConfigEntry foodPrice; private static ConfigEntry sellAtHaldor; private static CustomLocalization Localization; private void Awake() { //IL_0e5c: Unknown result type (might be due to invalid IL or missing references) foodPrice = ((BaseUnityPlugin)this).Config.Bind("Merchant Settings", "FoodPrice", 10, "ハルドルから購入するときの価格です。"); sellAtHaldor = ((BaseUnityPlugin)this).Config.Bind("Merchant Settings", "SellAtHaldor", true, "ハルドルで販売するかどうか"); RegisterLocalization(); foodList = new List { new JapaneseFoodData { prefabName = "food_okome", itemId = "food_okome", basePrefabName = "CookedMeat", displayName = "$item_food_okome", description = "$item_food_okome_desc", iconName = "icon_okome", foodHealth = 1f, foodStamina = 1f, foodEitr = 0f, foodRegen = 0f, foodBurnTime = 0f, craftAmount = 1, maxStackSize = 50 }, new JapaneseFoodData { prefabName = "food_mame", itemId = "food_mame", basePrefabName = "CookedMeat", displayName = "$item_food_mame", description = "$item_food_mame_desc", iconName = "icon_mame", foodHealth = 1f, foodStamina = 1f, foodEitr = 0f, foodRegen = 0f, foodBurnTime = 0f, craftAmount = 1, maxStackSize = 50 }, new JapaneseFoodData { prefabName = "food_gohan", itemId = "food_gohan", basePrefabName = "CookedMeat", displayName = "$item_food_gohan", description = "$item_food_gohan_desc", iconName = "icon_gohan", foodHealth = 18f, foodStamina = 22f, foodEitr = 5f, foodRegen = 2f, foodBurnTime = 1800f, craftAmount = 2, recipeItem1 = "food_okome", recipeAmount1 = 2 }, new JapaneseFoodData { prefabName = "food_syouyu", itemId = "food_syouyu", basePrefabName = "CookedMeat", displayName = "$item_food_syouyu", description = "$item_food_syouyu_desc", iconName = "icon_syouyu", foodHealth = 1f, foodStamina = 1f, foodEitr = 0f, foodRegen = 0f, foodBurnTime = 0f, craftAmount = 1, recipeItem1 = "food_mame", recipeAmount1 = 3, maxStackSize = 20 }, new JapaneseFoodData { prefabName = "food_miso", itemId = "food_miso", basePrefabName = "CookedMeat", displayName = "$item_food_miso", description = "$item_food_miso_desc", iconName = "icon_miso", foodHealth = 1f, foodStamina = 2f, foodEitr = 0f, foodRegen = 0f, foodBurnTime = 0f, craftAmount = 1, recipeItem1 = "food_mame", recipeAmount1 = 3, maxStackSize = 20 }, new JapaneseFoodData { prefabName = "food_tofu", itemId = "food_tofu", basePrefabName = "CookedMeat", displayName = "$item_food_tofu", description = "$item_food_tofu_desc", iconName = "icon_tofu", foodHealth = 5f, foodStamina = 5f, foodEitr = 0f, foodRegen = 0f, foodBurnTime = 1200f, craftAmount = 1, recipeItem1 = "food_mame", recipeAmount1 = 5 }, new JapaneseFoodData { prefabName = "food_misosiru", itemId = "food_misosiru", basePrefabName = "CookedMeat", displayName = "$item_food_misosiru", description = "$item_food_misosiru_desc", iconName = "icon_misosiru", foodHealth = 20f, foodStamina = 15f, foodEitr = 5f, foodRegen = 3f, foodBurnTime = 1800f, craftAmount = 3, recipeItem1 = "food_miso", recipeAmount1 = 1, recipeItem2 = "food_tofu", recipeAmount2 = 1 }, new JapaneseFoodData { prefabName = "food_nattou", itemId = "food_nattou", basePrefabName = "CookedMeat", displayName = "$item_food_nattou", description = "$item_food_nattou_desc", iconName = "icon_nattou", foodHealth = 10f, foodStamina = 12f, foodEitr = 2f, foodRegen = 3f, foodBurnTime = 1800f, craftAmount = 1, recipeItem1 = "food_mame", recipeAmount1 = 1 }, new JapaneseFoodData { prefabName = "food_syougayaki", itemId = "food_syougayaki", basePrefabName = "CookedMeat", displayName = "$item_food_syougayaki", description = "$item_food_syougayaki_desc", iconName = "icon_syougayaki", foodHealth = 32f, foodStamina = 30f, foodEitr = 9f, foodRegen = 3f, foodBurnTime = 1800f, craftAmount = 1, recipeItem1 = "RawMeat", recipeAmount1 = 1 }, new JapaneseFoodData { prefabName = "food_nikujaga", itemId = "food_nikujaga", basePrefabName = "CookedMeat", displayName = "$item_food_nikujaga", description = "$item_food_nikujaga_desc", iconName = "icon_nikujaga", foodHealth = 30f, foodStamina = 28f, foodEitr = 8f, foodRegen = 3f, foodBurnTime = 1800f, craftAmount = 1, recipeItem1 = "DeerMeat", recipeAmount1 = 1, recipeItem2 = "Carrot", recipeAmount2 = 2 }, new JapaneseFoodData { prefabName = "food_udon", itemId = "food_udon", basePrefabName = "CookedMeat", displayName = "$item_food_udon", description = "$item_food_udon_desc", iconName = "icon_udon", foodHealth = 30f, foodStamina = 40f, foodEitr = 10f, foodRegen = 3f, foodBurnTime = 2400f, craftAmount = 1, recipeItem1 = "BarleyFlour", recipeAmount1 = 1 }, new JapaneseFoodData { prefabName = "food_siromizakanafurai", itemId = "food_siromizakanafurai", basePrefabName = "CookedMeat", displayName = "$item_food_siromizakanafurai", description = "$item_food_siromizakanafurai_desc", iconName = "icon_siromizakanafurai", foodHealth = 40f, foodStamina = 30f, foodEitr = 10f, foodRegen = 3f, foodBurnTime = 1500f, craftAmount = 1, recipeItem1 = "FishRaw", recipeAmount1 = 1, recipeItem2 = "BarleyFlour", recipeAmount2 = 1 }, new JapaneseFoodData { prefabName = "food_tenpura", itemId = "food_tenpura", basePrefabName = "CookedMeat", displayName = "$item_food_tenpura", description = "$item_food_tenpura_desc", iconName = "icon_tenpura", foodHealth = 45f, foodStamina = 38f, foodEitr = 15f, foodRegen = 3f, foodBurnTime = 1800f, craftAmount = 1, recipeItem1 = "BarleyFlour", recipeAmount1 = 1, recipeItem2 = "FishRaw", recipeAmount2 = 1, recipeItem3 = "Carrot", recipeAmount3 = 1, recipeItem4 = "Mushroom", recipeAmount4 = 1 }, new JapaneseFoodData { prefabName = "food_kabayaki", itemId = "food_kabayaki", basePrefabName = "CookedMeat", displayName = "$item_food_kabayaki", description = "$item_food_kabayaki_desc", iconName = "icon_kabayaki", foodHealth = 50f, foodStamina = 56f, foodEitr = 20f, foodRegen = 3f, foodBurnTime = 4800f, craftAmount = 1, recipeItem1 = "SerpentMeat", recipeAmount1 = 1, recipeItem2 = "food_syouyu", recipeAmount2 = 1, recipeItem3 = "food_gohan", recipeAmount3 = 1, recipeItem4 = "Carrot", recipeAmount4 = 1 }, new JapaneseFoodData { prefabName = "feast_sushi", itemId = "feast_sushi", basePrefabName = "FeastMeadows", displayName = "$item_feast_sushi", description = "$item_feast_sushi_desc", iconName = "icon_sushi", foodHealth = 50f, foodStamina = 50f, foodEitr = 15f, foodRegen = 5f, foodBurnTime = 4800f, craftAmount = 1, recipeItem1 = "FishRaw", recipeAmount1 = 3, recipeItem2 = "food_okome", recipeAmount2 = 5, recipeItem3 = "Fish10", recipeAmount3 = 1, recipeItem4 = "Fish3", recipeAmount4 = 1, maxStackSize = 1, isFeast = true }, new JapaneseFoodData { prefabName = "feast_oden", itemId = "feast_oden", basePrefabName = "FeastMeadows", displayName = "$item_feast_oden", description = "$item_feast_oden_desc", iconName = "icon_oden", foodHealth = 40f, foodStamina = 38f, foodEitr = 10f, foodRegen = 5f, foodBurnTime = 4800f, craftAmount = 1, recipeItem1 = "FishRaw", recipeAmount1 = 2, recipeItem2 = "food_syouyu", recipeAmount2 = 1, recipeItem3 = "WolfMeat", recipeAmount3 = 2, recipeItem4 = "food_tofu", recipeAmount4 = 2, maxStackSize = 1, isFeast = true }, new JapaneseFoodData { prefabName = "food_karaage", itemId = "food_karaage", basePrefabName = "CookedMeat", displayName = "$item_food_karaage", description = "$item_food_karaage_desc", iconName = "icon_karaage", foodHealth = 60f, foodStamina = 50f, foodEitr = 30f, foodRegen = 3f, foodBurnTime = 2100f, craftAmount = 1, recipeItem1 = "ChickenMeat", recipeAmount1 = 1 }, new JapaneseFoodData { prefabName = "food_tamagokakegohan", itemId = "food_tamagokakegohan", basePrefabName = "CookedMeat", displayName = "$item_food_tamagokakegohan", description = "$item_food_tamagokakegohan_desc", iconName = "icon_tamagokakegohan", foodHealth = 50f, foodStamina = 45f, foodEitr = 20f, foodRegen = 3f, foodBurnTime = 1800f, craftAmount = 1, recipeItem1 = "food_gohan", recipeAmount1 = 1, recipeItem2 = "ChickenEgg", recipeAmount2 = 1, recipeItem3 = "food_syouyu", recipeAmount3 = 1 }, new JapaneseFoodData { prefabName = "food_tamagoyaki", itemId = "food_tamagoyaki", basePrefabName = "CookedMeat", displayName = "$item_food_tamagoyaki", description = "$item_food_tamagoyaki_desc", iconName = "icon_tamagoyaki", foodHealth = 20f, foodStamina = 25f, foodEitr = 40f, foodRegen = 3f, foodBurnTime = 1800f, craftAmount = 1, recipeItem1 = "ChickenEgg", recipeAmount1 = 1 }, new JapaneseFoodData { prefabName = "food_tikinnanban", itemId = "food_tikinnanban", basePrefabName = "CookedMeat", displayName = "$item_food_tikinnanban", description = "$item_food_tikinnanban_desc", iconName = "icon_tikinnanban", foodHealth = 65f, foodStamina = 65f, foodEitr = 65f, foodRegen = 3f, foodBurnTime = 2100f, craftAmount = 1, recipeItem1 = "ChickenMeat", recipeAmount1 = 1, recipeItem2 = "ChickenEgg", recipeAmount2 = 1 } }; string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "japanesefood"); assetBundle = AssetBundle.LoadFromFile(text); if ((Object)(object)assetBundle == (Object)null) { Logger.LogError((object)("[Sakey's Japanese food] AssetBundleの読み込みに失敗しました: " + text)); return; } PrefabManager.OnPrefabsRegistered += OnPrefabsRegistered; ItemManager.OnItemsRegistered += OnItemsRegistered; new Harmony("com.sakey.japanesefood").PatchAll(); Logger.LogInfo((object)string.Format("[{0}] Awake 完了。登録予定アイテム数: {1}", "Sakey's Japanese food", foodList.Count)); } private void OnPrefabsRegistered() { PrefabManager.OnPrefabsRegistered -= OnPrefabsRegistered; foreach (JapaneseFoodData food in foodList) { RegisterFood(food); } AddEnemyDrop("Troll", "food_okome", 100f, 2, 2); AddEnemyDrop("Greyling", "food_mame", 60f, 2, 2); } private void RegisterFood(JapaneseFoodData data) { //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Expected O, but got Unknown //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_04f3: Unknown result type (might be due to invalid IL or missing references) //IL_04fa: Expected O, but got Unknown //IL_0363: Unknown result type (might be due to invalid IL or missing references) //IL_0374: Unknown result type (might be due to invalid IL or missing references) //IL_0385: Unknown result type (might be due to invalid IL or missing references) //IL_049c: Unknown result type (might be due to invalid IL or missing references) //IL_04b5: Unknown result type (might be due to invalid IL or missing references) string text = (string.IsNullOrEmpty(data.basePrefabName) ? "CookedMeat" : data.basePrefabName); GameObject val = PrefabManager.Instance.CreateClonedPrefab(data.itemId, text); if ((Object)(object)val == (Object)null) { Logger.LogError((object)("[Sakey's Japanese food] Prefab作成失敗: " + data.itemId + " / Base=" + text)); return; } ItemDrop component = val.GetComponent(); if ((Object)(object)component == (Object)null) { Logger.LogError((object)("[Sakey's Japanese food] ItemDropがありません: " + data.itemId)); return; } ZNetView component2 = val.GetComponent(); if ((Object)(object)component2 != (Object)null) { component2.m_persistent = true; } Sprite val2 = assetBundle.LoadAsset(data.iconName); ItemData itemData = component.m_itemData; SharedData shared = itemData.m_shared; shared.m_name = data.displayName; shared.m_description = data.description; shared.m_itemType = (ItemType)2; shared.m_maxStackSize = data.maxStackSize; shared.m_isDrink = false; shared.m_food = data.foodHealth; shared.m_foodStamina = data.foodStamina; shared.m_foodEitr = data.foodEitr; shared.m_foodRegen = data.foodRegen; shared.m_foodBurnTime = data.foodBurnTime; shared.m_consumeStatusEffect = null; shared.m_equipStatusEffect = null; shared.m_attackStatusEffect = null; shared.m_setStatusEffect = null; if ((Object)(object)val2 != (Object)null) { shared.m_icons = (Sprite[])(object)new Sprite[1] { val2 }; } else { shared.m_icons = (Sprite[])(object)new Sprite[0]; Logger.LogWarning((object)("[Sakey's Japanese food] アイコンが見つかりません: " + data.iconName)); } if (data.isFeast) { Renderer[] componentsInChildren = val.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren[i]); } val.transform.localScale = Vector3.one; Piece component3 = val.GetComponent(); if ((Object)(object)component3 != (Object)null) { Object.DestroyImmediate((Object)(object)component3); } WearNTear component4 = val.GetComponent(); if ((Object)(object)component4 != (Object)null) { Object.DestroyImmediate((Object)(object)component4); } Feast val3 = val.GetComponent(); if ((Object)(object)val3 == (Object)null) { val3 = val.AddComponent(); } val3.m_foodItem = component; Logger.LogInfo((object)("[Sakey's Japanese food] Feast結果リンク確定: " + ((Object)val).name + ".Feast.m_foodItem -> " + ((Object)component).name)); } else { for (int num = val.transform.childCount - 1; num >= 0; num--) { Object.DestroyImmediate((Object)(object)((Component)val.transform.GetChild(num)).gameObject); } val.transform.localScale = Vector3.one; } GameObject val4 = new GameObject(data.isFeast ? (data.itemId + "_attach") : "attach"); val4.transform.SetParent(val.transform, false); val4.transform.localPosition = Vector3.zero; val4.transform.localRotation = Quaternion.identity; val4.transform.localScale = Vector3.one; GameObject val5 = assetBundle.LoadAsset(data.prefabName); if ((Object)(object)val5 == (Object)null) { Logger.LogError((object)("[Sakey's Japanese food] モデルが見つかりません: " + data.prefabName)); } else { GameObject val6 = Object.Instantiate(val5, val4.transform); ((Object)val6).name = (data.isFeast ? (data.itemId + "_model") : "model"); val6.transform.localPosition = Vector3.zero; val6.transform.localRotation = Quaternion.identity; val6.transform.localScale = MODEL_TARGET_SCALE; RemoveLODGroups(val6); if (data.isFeast) { RenameFeastModelChildren(val6, data.itemId + "_"); EnableModelRenderers(val6); } int num2 = LayerMask.NameToLayer("item"); if (num2 == -1) { num2 = 12; } Transform[] componentsInChildren2 = val.GetComponentsInChildren(true); foreach (Transform val7 in componentsInChildren2) { if (data.isFeast && (((Object)val7).name == data.itemId + "_model" || ((Object)val7).name.StartsWith(data.itemId + "_"))) { ((Component)val7).gameObject.layer = 0; } else { ((Component)val7).gameObject.layer = num2; } } if (!data.isFeast) { Collider[] componentsInChildren3 = val.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren3.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren3[i]); } BoxCollider obj = val.AddComponent(); obj.center = new Vector3(0f, 0f, 0f); obj.size = new Vector3(0.2f, 0.2f, 0.2f); Rigidbody val8 = val.GetComponent(); if ((Object)(object)val8 == (Object)null) { val8 = val.AddComponent(); } val8.isKinematic = false; val8.useGravity = true; } } itemData.m_dropPrefab = val; CustomItem val9 = new CustomItem(val, true); if (!ItemManager.Instance.AddItem(val9)) { Logger.LogError((object)("[Sakey's Japanese food] Item登録失敗: " + data.itemId)); return; } if (data.isFeast) { RegisterFeastMaterial(data); } RegisterRecipe(data); } private void RegisterFeastMaterial(JapaneseFoodData data) { //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Expected O, but got Unknown //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_035c: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Expected O, but got Unknown string text = data.itemId + "_material"; GameObject val = PrefabManager.Instance.CreateClonedPrefab(text, "FeastMeadows_Material"); if ((Object)(object)val == (Object)null) { Logger.LogError((object)("[Sakey's Japanese food] Feast素材Prefab作成失敗: " + text)); return; } ItemDrop component = val.GetComponent(); if ((Object)(object)component == (Object)null) { Logger.LogError((object)("[Sakey's Japanese food] Feast素材にItemDropがありません: " + text)); return; } ItemData itemData = component.m_itemData; SharedData shared = itemData.m_shared; shared.m_name = data.displayName; shared.m_description = data.description; shared.m_itemType = (ItemType)1; shared.m_maxStackSize = 1; shared.m_isDrink = false; shared.m_food = data.foodHealth; shared.m_foodStamina = data.foodStamina; shared.m_foodEitr = data.foodEitr; shared.m_foodRegen = data.foodRegen; shared.m_foodBurnTime = data.foodBurnTime; shared.m_consumeStatusEffect = null; shared.m_equipStatusEffect = null; shared.m_attackStatusEffect = null; shared.m_setStatusEffect = null; Sprite val2 = assetBundle.LoadAsset(data.iconName); if ((Object)(object)val2 != (Object)null) { shared.m_icons = (Sprite[])(object)new Sprite[1] { val2 }; } Feast val3 = val.GetComponent(); if ((Object)(object)val3 == (Object)null) { val3 = val.AddComponent(); } Feast obj = val3; object foodItem; if (!((Object)(object)ObjectDB.instance != (Object)null)) { GameObject prefab = PrefabManager.Instance.GetPrefab(data.itemId); foodItem = ((prefab != null) ? prefab.GetComponent() : null); } else { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(data.itemId); foodItem = ((itemPrefab != null) ? itemPrefab.GetComponent() : null); } obj.m_foodItem = (ItemDrop)foodItem; if ((Object)(object)val3.m_foodItem == (Object)null) { Logger.LogWarning((object)("[Sakey's Japanese food] Feast素材のm_foodItem設定対象が見つかりません: " + data.itemId)); } Renderer[] componentsInChildren = val.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren[i]); } GameObject val4 = new GameObject(data.itemId + "_material_attach"); val4.transform.SetParent(val.transform, false); val4.transform.localPosition = Vector3.zero; val4.transform.localRotation = Quaternion.identity; val4.transform.localScale = Vector3.one; GameObject val5 = assetBundle.LoadAsset(data.prefabName); if ((Object)(object)val5 != (Object)null) { GameObject obj2 = Object.Instantiate(val5, val4.transform); ((Object)obj2).name = data.itemId + "_material_model"; obj2.transform.localPosition = Vector3.zero; obj2.transform.localRotation = Quaternion.identity; obj2.transform.localScale = MODEL_TARGET_SCALE; RemoveLODGroups(obj2); RenameFeastModelChildren(obj2, data.itemId + "_material_"); EnableModelRenderers(obj2); Transform[] componentsInChildren2 = val.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren2.Length; i++) { ((Component)componentsInChildren2[i]).gameObject.layer = 0; } } itemData.m_dropPrefab = val; string[] obj3 = new string[6] { "[Sakey's Japanese food] Feast素材表示設定: ", text, " / DropPrefab=", null, null, null }; GameObject dropPrefab = itemData.m_dropPrefab; obj3[3] = ((dropPrefab != null) ? ((Object)dropPrefab).name : null); obj3[4] = " / FeastResult="; ItemDrop foodItem2 = val3.m_foodItem; obj3[5] = ((foodItem2 != null) ? ((Object)foodItem2).name : null); Logger.LogInfo((object)string.Concat(obj3)); CustomItem val6 = new CustomItem(val, true); if (!ItemManager.Instance.AddItem(val6)) { Logger.LogError((object)("[Sakey's Japanese food] Feast素材Item登録失敗: " + text)); } else { Logger.LogInfo((object)("[Sakey's Japanese food] Feast素材登録完了: " + text)); } } private void RegisterLocalization() { Localization = LocalizationManager.Instance.GetLocalization(); CustomLocalization localization = Localization; string text = "Japanese"; localization.AddTranslation(ref text, new Dictionary { { "item_feast_sushi", "寿司盛り合わせ" }, { "item_feast_sushi_desc", "魚と米を使った、色とりどりの料理の盛り合わせ。" }, { "item_feast_oden", "おでん" }, { "item_feast_oden_desc", "冬場はほっこりあったまる。" } }); CustomLocalization localization2 = Localization; text = "English"; localization2.AddTranslation(ref text, new Dictionary { { "item_feast_sushi", "Sushi Platter" }, { "item_feast_sushi_desc", "An assortment of sushi made with fish and rice." }, { "item_feast_oden", "Oden" }, { "item_feast_oden_desc", "A comforting Japanese hot pot for cold winter days." } }); } private void PrepareFeastPieceIcons() { //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) foreach (JapaneseFoodData food in foodList) { if (!food.isFeast) { continue; } GameObject val = (((Object)(object)ObjectDB.instance != (Object)null) ? ObjectDB.instance.GetItemPrefab(food.itemId) : PrefabManager.Instance.GetPrefab(food.itemId)); if ((Object)(object)val == (Object)null) { Logger.LogError((object)("[Sakey's Japanese food] Feast Pieceアイコン設定失敗: Prefabなし " + food.itemId)); continue; } Piece component = val.GetComponent(); if ((Object)(object)component == (Object)null) { Logger.LogError((object)("[Sakey's Japanese food] Feast Pieceアイコン設定失敗: Pieceなし " + food.itemId)); continue; } Sprite val2 = assetBundle.LoadAsset(food.iconName); if ((Object)(object)val2 == (Object)null) { Logger.LogError((object)("[Sakey's Japanese food] Feast Pieceアイコン設定失敗: Iconなし " + food.iconName)); continue; } component.m_icon = val2; component.m_category = (PieceCategory)5; component.m_name = food.displayName; component.m_description = food.description; component.m_canBeRemoved = true; GameObject val3 = (((Object)(object)ObjectDB.instance != (Object)null) ? ObjectDB.instance.GetItemPrefab(food.itemId + "_material") : PrefabManager.Instance.GetPrefab(food.itemId + "_material")); if ((Object)(object)val3 != (Object)null) { component.m_destroyedLootPrefab = val3; } Logger.LogInfo((object)("[Sakey's Japanese food] Feast Piece設定完了: " + food.itemId + " / " + $"Icon={food.iconName} / Category={component.m_category} / " + "DestroyLoot=" + (((Object)(object)component.m_destroyedLootPrefab != (Object)null) ? ((Object)component.m_destroyedLootPrefab).name : "null"))); } } private void RegisterFeastPlacement_OLD_NOT_USED() { //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_018c: 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_01a4: Expected O, but got Unknown //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Expected O, but got Unknown foreach (JapaneseFoodData food in foodList) { if (!food.isFeast) { continue; } GameObject val = (((Object)(object)ObjectDB.instance != (Object)null) ? ObjectDB.instance.GetItemPrefab(food.itemId) : PrefabManager.Instance.GetPrefab(food.itemId)); if ((Object)(object)val == (Object)null) { Logger.LogError((object)("[Sakey's Japanese food] Feaster登録用Prefabが見つかりません: " + food.itemId)); continue; } Piece component = val.GetComponent(); if ((Object)(object)component == (Object)null) { Logger.LogError((object)("[Sakey's Japanese food] Feaster登録失敗: " + food.itemId + " にPieceがありません。")); continue; } GameObject val2 = (((Object)(object)ObjectDB.instance != (Object)null) ? ObjectDB.instance.GetItemPrefab(food.itemId + "_material") : PrefabManager.Instance.GetPrefab(food.itemId + "_material")); if ((Object)(object)val2 == (Object)null) { Logger.LogError((object)("[Sakey's Japanese food] Feast素材Prefabが見つかりません: " + food.itemId + "_material")); continue; } if ((Object)(object)val2.GetComponent() == (Object)null) { Logger.LogError((object)("[Sakey's Japanese food] Feast素材にItemDropがありません: " + food.itemId + "_material")); continue; } component.m_category = (PieceCategory)5; component.m_name = food.displayName; component.m_description = food.description; component.m_canBeRemoved = true; component.m_destroyedLootPrefab = val2; PieceConfig val3 = new PieceConfig { Name = food.displayName, Description = food.description, PieceTable = "_FeasterPieceTable", Category = "Banquets" }; val3.AddRequirement(food.itemId + "_material", 1, true); CustomPiece val4 = new CustomPiece(val, true, val3); bool flag = PieceManager.Instance.AddPiece(val4); Logger.LogInfo((object)("[Sakey's Japanese food] Feaster登録: " + food.itemId + " / Prefab=" + ((Object)val).name + " / Piece=" + ((object)component).GetType().Name + " / " + $"成功={flag}")); } } private static void DisableAllRenderers(GameObject root) { if (!((Object)(object)root == (Object)null)) { Renderer[] componentsInChildren = root.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].enabled = false; } } } private static void EnableModelRenderers(GameObject root) { if (!((Object)(object)root == (Object)null)) { Renderer[] componentsInChildren = root.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].enabled = true; } } } private static void RemoveLODGroups(GameObject root) { if (!((Object)(object)root == (Object)null)) { LODGroup[] componentsInChildren = root.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren[i]); } } } private static void RenameFeastModelChildren(GameObject root, string prefix) { if (!((Object)(object)root == (Object)null)) { RenameRecursive(root.transform, prefix); } } private static void RenameRecursive(Transform current, string prefix) { for (int i = 0; i < current.childCount; i++) { Transform child = current.GetChild(i); if (!((Object)child).name.StartsWith(prefix)) { ((Object)child).name = prefix + ((Object)child).name; } RenameRecursive(child, prefix); } } private static Transform FindChildTransform(Transform root, string childName) { if ((Object)(object)root == (Object)null) { return null; } if (((Object)root).name == childName) { return root; } for (int i = 0; i < root.childCount; i++) { Transform val = FindChildTransform(root.GetChild(i), childName); if ((Object)(object)val != (Object)null) { return val; } } return null; } private void RegisterRecipe(JapaneseFoodData data) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Expected O, but got Unknown if (data != null) { RecipeConfig val = new RecipeConfig { Item = (data.isFeast ? (data.itemId + "_material") : data.itemId), Amount = data.craftAmount, CraftingStation = "piece_cauldron", MinStationLevel = 1 }; int num = 0; if (AddValidRequirement(val, data.recipeItem1, data.recipeAmount1)) { num++; } if (AddValidRequirement(val, data.recipeItem2, data.recipeAmount2)) { num++; } if (AddValidRequirement(val, data.recipeItem3, data.recipeAmount3)) { num++; } if (AddValidRequirement(val, data.recipeItem4, data.recipeAmount4)) { num++; } if (num != 0) { ItemManager.Instance.AddRecipe(new CustomRecipe(val)); } } } private bool AddValidRequirement(RecipeConfig recipe, string item, int amount) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown if (recipe == null || string.IsNullOrEmpty(item) || amount <= 0) { return false; } recipe.AddRequirement(new RequirementConfig { Item = item, Amount = amount, Recover = true }); return true; } private void AddEnemyDrop(string creatureName, string itemName, float chance, int minAmount, int maxAmount) { //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Expected O, but got Unknown try { GameObject prefab = PrefabManager.Instance.GetPrefab(creatureName); CharacterDrop val = ((prefab != null) ? prefab.GetComponent() : null); if ((Object)(object)val == (Object)null) { Logger.LogWarning((object)("[Sakey's Japanese food] CharacterDropが見つかりません: " + creatureName)); return; } GameObject prefab2 = PrefabManager.Instance.GetPrefab(itemName); ItemDrop val2 = ((prefab2 != null) ? prefab2.GetComponent() : null); if ((Object)(object)val2 == (Object)null) { Logger.LogWarning((object)("[Sakey's Japanese food] ドロップItemが見つかりません: " + itemName)); return; } Drop item = new Drop { m_prefab = ((Component)val2).gameObject, m_amountMin = minAmount, m_amountMax = maxAmount, m_chance = chance, m_levelMultiplier = false }; val.m_drops.Add(item); Logger.LogInfo((object)("[Sakey's Japanese food] 敵ドロップ追加: " + creatureName + " -> " + itemName)); } catch (Exception ex) { Logger.LogError((object)string.Format("[{0}] 敵ドロップ追加中に例外: {1} -> {2}\n{3}", "Sakey's Japanese food", creatureName, itemName, ex)); } } private void OnItemsRegistered() { ItemManager.OnItemsRegistered -= OnItemsRegistered; ReapplyItemIcons(); ReapplyFeastFoodData(); ReapplyFeastLinks(); ReapplyFeastFoodData(); } private void RegisterFeastPlacementDirect() { //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Expected O, but got Unknown if ((Object)(object)ObjectDB.instance == (Object)null) { Logger.LogError((object)"[Sakey's Japanese food] Feaster直接登録失敗: ObjectDB.instance がnullです。"); return; } GameObject itemPrefab = ObjectDB.instance.GetItemPrefab("Feaster"); if ((Object)(object)itemPrefab == (Object)null) { Logger.LogError((object)"[Sakey's Japanese food] Feaster直接登録失敗: Feaster prefab が見つかりません。"); return; } ItemDrop component = itemPrefab.GetComponent(); PieceTable val = (((Object)(object)component != (Object)null) ? component.m_itemData.m_shared.m_buildPieces : null); if ((Object)(object)val == (Object)null) { Logger.LogError((object)"[Sakey's Japanese food] Feaster直接登録失敗: FeasterのPieceTableが見つかりません。"); return; } foreach (JapaneseFoodData food in foodList) { if (!food.isFeast) { continue; } GameObject itemPrefab2 = ObjectDB.instance.GetItemPrefab(food.itemId); GameObject itemPrefab3 = ObjectDB.instance.GetItemPrefab(food.itemId + "_material"); if ((Object)(object)itemPrefab2 == (Object)null || (Object)(object)itemPrefab3 == (Object)null) { Logger.LogError((object)("[Sakey's Japanese food] Feaster直接登録失敗: Result=" + (((itemPrefab2 != null) ? ((Object)itemPrefab2).name : null) ?? "null") + " / Material=" + (((itemPrefab3 != null) ? ((Object)itemPrefab3).name : null) ?? "null"))); continue; } Piece val2 = itemPrefab2.GetComponent(); if ((Object)(object)val2 == (Object)null) { val2 = itemPrefab2.AddComponent(); } ItemDrop component2 = itemPrefab3.GetComponent(); if ((Object)(object)component2 == (Object)null) { Logger.LogError((object)("[Sakey's Japanese food] Feaster直接登録失敗: " + ((Object)itemPrefab3).name + " にItemDropがありません。")); continue; } Sprite val3 = assetBundle.LoadAsset(food.iconName); val2.m_category = (PieceCategory)5; val2.m_name = food.displayName; val2.m_description = food.description; val2.m_canBeRemoved = true; val2.m_enabled = true; val2.m_repairPiece = false; val2.m_removePiece = false; val2.m_destroyedLootPrefab = itemPrefab3; if ((Object)(object)val3 != (Object)null) { val2.m_icon = val3; } val2.m_resources = (Requirement[])(object)new Requirement[1] { new Requirement { m_resItem = component2, m_amount = 1, m_amountPerLevel = 1, m_recover = true } }; if (!val.m_pieces.Contains(itemPrefab2)) { val.m_pieces.Add(itemPrefab2); Logger.LogInfo((object)("[Sakey's Japanese food] Feaster直接登録: " + food.itemId + " -> " + ((Object)itemPrefab2).name)); } else { Logger.LogInfo((object)("[Sakey's Japanese food] Feaster既存登録を更新: " + food.itemId + " -> " + ((Object)itemPrefab2).name)); } } } private void ReapplyFeastFoodData() { if ((Object)(object)ObjectDB.instance == (Object)null) { Logger.LogWarning((object)"[Sakey's Japanese food] Feast食事データ再適用: ObjectDB.instance がnullです。"); return; } foreach (JapaneseFoodData food in foodList) { if (food.isFeast) { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(food.itemId); GameObject itemPrefab2 = ObjectDB.instance.GetItemPrefab(food.itemId + "_material"); if ((Object)(object)itemPrefab == (Object)null || (Object)(object)itemPrefab2 == (Object)null) { Logger.LogWarning((object)("[Sakey's Japanese food] Feast食事データ再適用失敗: Result=" + (((itemPrefab != null) ? ((Object)itemPrefab).name : null) ?? "null") + " / Material=" + (((itemPrefab2 != null) ? ((Object)itemPrefab2).name : null) ?? "null"))); continue; } ApplyFeastSharedData(itemPrefab.GetComponent(), food, "Result"); ApplyFeastSharedData(itemPrefab2.GetComponent(), food, "Material"); } } } private void ApplyFeastSharedData(ItemDrop itemDrop, JapaneseFoodData data, string label) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)itemDrop == (Object)null || itemDrop.m_itemData == null || itemDrop.m_itemData.m_shared == null) { Logger.LogWarning((object)("[Sakey's Japanese food] Feast食事データ再適用: " + label + " ItemDropがありません。")); return; } SharedData shared = itemDrop.m_itemData.m_shared; shared.m_name = data.displayName; shared.m_description = data.description; shared.m_itemType = (ItemType)(((Object)itemDrop).name.EndsWith("_material") ? 1 : 2); shared.m_maxStackSize = (((Object)itemDrop).name.EndsWith("_material") ? 1 : data.maxStackSize); shared.m_isDrink = false; shared.m_food = data.foodHealth; shared.m_foodStamina = data.foodStamina; shared.m_foodEitr = data.foodEitr; shared.m_foodRegen = data.foodRegen; shared.m_foodBurnTime = data.foodBurnTime; shared.m_consumeStatusEffect = null; shared.m_equipStatusEffect = null; shared.m_attackStatusEffect = null; shared.m_setStatusEffect = null; Logger.LogInfo((object)("[Sakey's Japanese food] Feast食事データ確定: " + ((Object)itemDrop).name + " / " + label + " / " + $"HP={shared.m_food} ST={shared.m_foodStamina} EITR={shared.m_foodEitr} " + $"Regen={shared.m_foodRegen} Burn={shared.m_foodBurnTime}")); } private void ReapplyFeastLinks() { if ((Object)(object)ObjectDB.instance == (Object)null) { Logger.LogWarning((object)"[Sakey's Japanese food] Feastリンク再適用: ObjectDB.instance がnullです。"); return; } foreach (JapaneseFoodData food in foodList) { if (!food.isFeast) { continue; } GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(food.itemId); GameObject itemPrefab2 = ObjectDB.instance.GetItemPrefab(food.itemId + "_material"); if ((Object)(object)itemPrefab == (Object)null || (Object)(object)itemPrefab2 == (Object)null) { Logger.LogWarning((object)("[Sakey's Japanese food] Feastリンク再適用失敗: Result=" + (((itemPrefab != null) ? ((Object)itemPrefab).name : null) ?? "null") + " / Material=" + (((itemPrefab2 != null) ? ((Object)itemPrefab2).name : null) ?? "null"))); continue; } ItemDrop component = itemPrefab.GetComponent(); Feast component2 = itemPrefab.GetComponent(); ItemDrop component3 = itemPrefab2.GetComponent(); Feast component4 = itemPrefab2.GetComponent(); if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null || (Object)(object)component3 == (Object)null || (Object)(object)component4 == (Object)null) { Logger.LogWarning((object)("[Sakey's Japanese food] Feastリンク再適用失敗: " + $"ResultItemDrop={(Object)(object)component != (Object)null} / " + $"ResultFeast={(Object)(object)component2 != (Object)null} / " + $"MaterialItemDrop={(Object)(object)component3 != (Object)null} / " + $"MaterialFeast={(Object)(object)component4 != (Object)null}")); continue; } component2.m_foodItem = component; component4.m_foodItem = component; component3.m_itemData.m_shared.m_appendToolTip = component; component.m_itemData.m_shared.m_appendToolTip = null; component.m_itemData.m_dropPrefab = itemPrefab; component3.m_itemData.m_dropPrefab = itemPrefab2; ApplyFeastSharedData(component, food, "Result"); ApplyFeastSharedData(component3, food, "Material"); Logger.LogInfo((object)("[Sakey's Japanese food] Feastリンク確定: " + ((Object)itemPrefab).name + ".Feast.m_foodItem -> " + ((Object)itemPrefab).name + " / " + ((Object)itemPrefab2).name + ".Feast.m_foodItem -> " + ((Object)itemPrefab).name)); } } private void ReapplyItemIcons() { foreach (JapaneseFoodData food in foodList) { GameObject val = (((Object)(object)ObjectDB.instance != (Object)null) ? ObjectDB.instance.GetItemPrefab(food.itemId) : PrefabManager.Instance.GetPrefab(food.itemId)); if ((Object)(object)val == (Object)null) { continue; } ItemDrop component = val.GetComponent(); if (!((Object)(object)component == (Object)null)) { Sprite val2 = assetBundle.LoadAsset(food.iconName); if ((Object)(object)val2 == (Object)null) { Logger.LogWarning((object)("[Sakey's Japanese food] アイコン再適用失敗: " + food.itemId + " / " + food.iconName)); continue; } component.m_itemData.m_shared.m_icons = (Sprite[])(object)new Sprite[1] { val2 }; } } } }