Decompiled source of MinecraftFoods v1.26.0
plugins/MinecraftFoods/MinecraftFoods.dll
Decompiled a month ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using PEAKLib.Core; using PEAKLib.Items; using Peak.Afflictions; using Photon.Pun; using TMPro; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.Rendering; using UnityEngine.UI; using Zorro.Core; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("MinecraftFoods")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.26.0.0")] [assembly: AssemblyInformationalVersion("1.26.0+790490a95cd6a1b27c25c6136d74c1f3815d266a")] [assembly: AssemblyProduct("MinecraftFoods")] [assembly: AssemblyTitle("MinecraftFoods")] [assembly: AssemblyVersion("1.26.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace MinecraftFoods { public sealed class FoodAudio : MonoBehaviour { private Item item; private AudioSource source; private static AudioClip trigger; private bool playing; private void Awake() { item = ((Component)this).GetComponent<Item>(); } private void Update() { //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Expected O, but got Unknown Character val = (Object.op_Implicit((Object)(object)item) ? item.trueHolderCharacter : null); FoodMarker foodMarker = (Object.op_Implicit((Object)(object)item) ? ((Component)item).GetComponent<FoodMarker>() : null); int num; if (Object.op_Implicit((Object)(object)val) && val.IsLocal && !val.data.dead && Object.op_Implicit((Object)(object)foodMarker) && foodMarker.Definition != null && foodMarker.Stage < foodMarker.Definition.wreck && !item.finishedCast && !item.consuming) { if (!item.isUsingPrimary) { num = (item.isUsingSecondary ? 1 : 0); if (num == 0) { goto IL_01ac; } } else { num = 1; } if (!playing) { if (!Object.op_Implicit((Object)(object)source)) { GameObject val2 = new GameObject("MCFoods_EatingSource"); val2.transform.SetParent(((Component)this).transform, false); source = val2.AddComponent<AudioSource>(); source.playOnAwake = false; source.loop = true; source.spatialBlend = 0f; source.volume = 0.7f; source.pitch = 1f; if (Object.op_Implicit((Object)(object)SFX_Player.instance)) { source.outputAudioMixerGroup = SFX_Player.instance.defaultMixerGroup; } if (!Object.op_Implicit((Object)(object)trigger)) { trigger = AudioClip.Create("MCFoods_Eating", 70560, 1, 44100, false); } } source.clip = trigger; source.Play(); playing = true; } } else { num = 0; } goto IL_01ac; IL_01ac: if (num == 0) { Stop(); } } private void Stop() { if (Object.op_Implicit((Object)(object)source) && playing) { source.Stop(); } playing = false; } private void OnDisable() { Stop(); } } [Serializable] public sealed class Catalogue { public FoodDefinition[] foods; } [Serializable] public sealed class FoodDefinition { public string id; public string name; public string texture; public string cookedName; public string cookedTexture; public string rarity; public string description; public string effectDescription; public float hunger; public float bonusStamina; public float cookedHunger; public float cookedBonusStamina; public int scorch; public int wreck; public int weight; public int uses = 1; public float burnPoison; public bool HasCooked => !string.IsNullOrEmpty(cookedTexture); public bool Cooked(int stage) { if (HasCooked) { return stage >= 1; } return false; } public string NameAt(int stage) { string text = L10n.FoodName(Cooked(stage) ? cookedTexture : id, Cooked(stage) ? cookedName : name); if (stage >= wreck) { return text + L10n.T("(烧毁,不能食用)", " (Burnt, inedible)", "(燃え尽き・食べられない)"); } if (stage >= scorch) { return text + L10n.T("(烧焦)", " (Charred)", "(焦げ)"); } if (stage <= 0 || HasCooked) { return text; } return text + L10n.T("(加热" + stage + "次)", " (Heated " + stage + "x)", "(加熱 " + stage + " 回)"); } public string TextureAt(int stage) { if (!Cooked(stage)) { return texture; } return cookedTexture; } public float NutritionFactor(int stage) { if (stage < wreck) { if (stage >= scorch) { return Mathf.Max(0.1f, 1f - 0.5f * (float)(stage - scorch + 1)); } return 1f; } return 0f; } public float HungerAt(int stage) { return ((stage >= 1) ? cookedHunger : hunger) * NutritionFactor(stage); } public float BonusAt(int stage) { return ((stage >= 1) ? cookedBonusStamina : bonusStamina) * NutritionFactor(stage); } public float BurnPoisonAt(int stage) { if (stage >= scorch && stage < wreck) { return Mathf.Min(0.6f, burnPoison * (float)(stage - scorch + 1)); } return 0f; } internal FoodEffectPlan EffectsAt(int stage) { return FoodEffectCatalog.Create(id, stage, scorch, wreck, BurnPoisonAt(stage), Plugin.AppleAftereffects.Value); } public Color TintAt(int stage) { //IL_001d: 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_004f: 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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) if (stage >= wreck) { return new Color(0.08f, 0.065f, 0.055f, 1f); } if (stage >= scorch) { return Color.Lerp(new Color(0.48f, 0.3f, 0.2f), new Color(0.12f, 0.09f, 0.07f), (float)(stage - scorch) / (float)Math.Max(1, wreck - scorch)); } if (stage != 0) { return Color.Lerp(Color.white, new Color(0.77f, 0.64f, 0.47f), (float)stage / (float)scorch); } return Color.white; } } public sealed class FoodMarker : MonoBehaviour { public string foodId; public MeshFilter mesh; public MeshRenderer visual; public float meshSize; private Item item; private int lastStage = -1; public FoodDefinition Definition { get { if (!Plugin.Foods.TryGetValue(foodId ?? "", out var value)) { return null; } return value; } } public int Stage => ReadStage(Object.op_Implicit((Object)(object)item) ? item.data : ((Component)this).GetComponent<Item>()?.data); public static int ReadStage(ItemInstanceData data) { IntItemData val = default(IntItemData); if (data == null || !data.TryGetDataEntry<IntItemData>((DataEntryKey)1, ref val)) { return 0; } return Mathf.Clamp(val.Value, 0, 12); } private void Awake() { item = ((Component)this).GetComponent<Item>(); } private void LateUpdate() { if (Stage != lastStage) { Refresh(); } } public void Refresh() { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) FoodDefinition definition = Definition; if (definition != null && Object.op_Implicit((Object)(object)visual) && Object.op_Implicit((Object)(object)mesh)) { lastStage = Stage; mesh.sharedMesh = Visuals.MeshFor(definition.TextureAt(lastStage)); ((Renderer)visual).sharedMaterial = Visuals.MaterialFor(definition.TextureAt(lastStage), definition.TintAt(lastStage)); BoxCollider component = ((Component)visual).GetComponent<BoxCollider>(); if (Object.op_Implicit((Object)(object)component)) { Bounds bounds = mesh.sharedMesh.bounds; component.center = ((Bounds)(ref bounds)).center; bounds = mesh.sharedMesh.bounds; float x = ((Bounds)(ref bounds)).size.x; bounds = mesh.sharedMesh.bounds; component.size = new Vector3(x, ((Bounds)(ref bounds)).size.y, 0.09f); } } } } internal enum FoodEffectKind { Poison, Hunger, Drowsy, Injury, Heal, Stamina, Invincible, Shield, Resist, Fireproof, AppleAftereffect, CurePoison, Milk, Teleport, LowGravity, Blind } internal sealed class FoodEffect { internal FoodEffectKind Kind; internal float Amount; internal float Seconds; internal string Key; internal bool Harmful { get { if (Kind != FoodEffectKind.Poison && Kind != FoodEffectKind.Hunger && Kind != FoodEffectKind.Drowsy && Kind != FoodEffectKind.Injury && Kind != FoodEffectKind.Blind) { return Kind == FoodEffectKind.AppleAftereffect; } return true; } } internal FoodEffect(FoodEffectKind kind, float amount = 0f, float seconds = 0f, string key = null) { Kind = kind; Amount = amount; Seconds = seconds; Key = key; } internal string Describe() { string text = L10n.N(Amount); string text2 = L10n.N(Seconds); switch (Kind) { case FoodEffectKind.Poison: case FoodEffectKind.Hunger: case FoodEffectKind.Drowsy: case FoodEffectKind.Injury: return ((Key == "burn") ? L10n.T("烧焦附加:", "Burn penalty: ", "焦げの追加効果:") : "") + L10n.Change(Kind, Amount, remove: false, Seconds); case FoodEffectKind.Heal: return L10n.Change(FoodEffectKind.Injury, Amount, remove: true, Seconds); case FoodEffectKind.Stamina: return L10n.Change(Kind, Amount, remove: false); case FoodEffectKind.Invincible: return positive(L10n.T("无敌 持续 " + text2 + " 秒", "Invincibility for " + text2 + "s", "無敵 " + text2 + " 秒")); case FoodEffectKind.Shield: return positive(L10n.T("获得 " + text + " 点吸收盾 持续 " + text2 + " 秒", "Gain " + text + " injury shield for " + text2 + "s", "吸収シールド " + text + " ポイント、" + text2 + " 秒")); case FoodEffectKind.Resist: return positive(L10n.T("受伤减少 " + text + "% 持续 " + text2 + " 秒", text + "% less injury for " + text2 + "s", "負傷を " + text + "% 軽減、" + text2 + " 秒")); case FoodEffectKind.Fireproof: return positive(L10n.T("免疫炎热增长 持续 " + text2 + " 秒", "Block heat gain for " + text2 + "s", "暑さの増加を無効化、" + text2 + " 秒")); case FoodEffectKind.AppleAftereffect: return L10n.Color(L10n.T("无敌结束后:睡意在 " + text2 + " 秒内逐渐升满;实际入睡后维持 " + text2 + " 秒", "After invincibility: drowsiness rises over " + text2 + "s, then sleep lasts " + text2 + "s from actual unconsciousness", "無敵終了後:" + text2 + " 秒で眠気が最大になり、入眠してから " + text2 + " 秒維持"), "CB65BC"); case FoodEffectKind.CurePoison: return L10n.T("清除全部中毒、孢子及持续中毒", "Clear poison, spores and ongoing poison", "毒・胞子・継続毒を解除"); case FoodEffectKind.Milk: return L10n.T("清除临时状态、中毒、孢子与睡意;同时移除正面效果、金苹果后遗症和紫颂果感染", "Clear temporary effects, poison, spores and drowsiness; also remove buffs, apple aftereffects and chorus exposure", "一時効果・毒・胞子・眠気を解除。有利な効果・金のリンゴの反動・コーラス感染も解除"); case FoodEffectKind.Teleport: return L10n.T($"在水平 {text} 米内寻找传送落点;成功后随机增加 {25f} 点饥饿或 {15f} 点孢子(各50%);失败无额外代价;成功传送间隔不超过120秒时累积,第4次在5秒后死亡并生成敌对僵尸;提前喝牛奶解除", $"Find a landing within {text}m horizontally; on success gain {25f} hunger or {15f} spores (50% each); no extra cost if no landing is found. Successful warps at most 120s apart accumulate: the fourth causes death and a hostile zombie after 5s; drink milk before then to cancel", $"水平 {text}m 以内にテレポート。成功時は空腹 {25f} または胞子 {15f} 増加(各50%)。失敗時は追加負担なし。成功間隔120秒以内で累積、4回目の5秒後に死亡し敵ゾンビが出現。事前にミルクで解除"); case FoodEffectKind.LowGravity: return positive(L10n.T("低重力 持续 " + text2 + " 秒", "Low gravity for " + text2 + "s", "低重力 " + text2 + " 秒")); case FoodEffectKind.Blind: return L10n.Color(L10n.T("失明 持续 " + text2 + " 秒", "Blindness for " + text2 + "s", "盲目 " + text2 + " 秒"), "CB65BC"); default: throw new ArgumentOutOfRangeException(); } static string positive(string text3) { return L10n.Color(text3, "BCEB00"); } } } internal sealed class FoodEffectGroup { internal float Chance; internal FoodEffect[] Effects; internal FoodEffectGroup(float chance, params FoodEffect[] effects) { Chance = chance; Effects = effects; } } internal sealed class FoodEffectPlan { internal readonly List<FoodEffectGroup> Groups = new List<FoodEffectGroup>(); internal readonly List<FoodEffectGroup> Choices = new List<FoodEffectGroup>(); internal bool SpecialLost; internal IEnumerable<FoodEffect> AllEffects => Groups.Concat(Choices).SelectMany((FoodEffectGroup g) => g.Effects); internal void Add(params FoodEffect[] effects) { Groups.Add(new FoodEffectGroup(1f, effects)); } internal void Chance(float chance, params FoodEffect[] effects) { Groups.Add(new FoodEffectGroup(chance, effects)); } } internal static class FoodEffectCatalog { internal const float TeleportRadius = 30f; internal const float ChorusHunger = 25f; internal const float ChorusSpores = 15f; private static FoodEffect E(FoodEffectKind k, float amount = 0f, float seconds = 0f, string key = null) { return new FoodEffect(k, amount, seconds, key); } internal static FoodEffectPlan Create(string id, int stage, int scorch, int wreck, float burnPoison, bool appleAftereffects) { FoodEffectPlan foodEffectPlan = new FoodEffectPlan(); if (stage >= wreck) { return foodEffectPlan; } switch (id) { case "pufferfish": foodEffectPlan.Add(E(FoodEffectKind.Poison, 30f + 2.5f * (float)stage), E(FoodEffectKind.Poison, 35 + 5 * stage, 60f, "puffer-poison"), E(FoodEffectKind.Hunger, 15f, 15f, "puffer-hunger"), E(FoodEffectKind.Drowsy, 10f), E(FoodEffectKind.Drowsy, 10f, 15f, "puffer-nausea")); break; case "rotten_flesh": foodEffectPlan.Chance(0.8f, E(FoodEffectKind.Hunger, 20f, 30f, "rotten-hunger")); if (stage > 0) { foodEffectPlan.Add(E(FoodEffectKind.Poison, Math.Min(50, 5 * stage))); } break; case "spider_eye": foodEffectPlan.Add(E(FoodEffectKind.Poison, 5f + 2.5f * (float)stage), E(FoodEffectKind.Poison, 5f + 2.5f * (float)stage, 4f, "spider-poison")); break; case "poisonous_potato": foodEffectPlan.Chance(0.6f, E(FoodEffectKind.Poison, 5f + 2.5f * (float)stage), E(FoodEffectKind.Poison, 5f + 2.5f * (float)stage, 5f, "potato-poison")); break; case "chicken": if (stage == 0) { foodEffectPlan.Chance(0.3f, E(FoodEffectKind.Poison, 12f)); } break; case "mutton": case "rabbit": case "beef": case "porkchop": if (stage == 0) { foodEffectPlan.Chance(0.15f, E(FoodEffectKind.Poison, 8f)); } break; case "salmon": case "cod": case "tropical_fish": if (stage == 0) { foodEffectPlan.Chance(0.2f, E(FoodEffectKind.Poison, 10f)); } break; case "honey_bottle": case "chorus_fruit": case "golden_apple": case "milk_bucket": case "enchanted_golden_apple": case "suspicious_stew": if (stage >= scorch) { foodEffectPlan.SpecialLost = true; break; } switch (id) { case "honey_bottle": foodEffectPlan.Add(E(FoodEffectKind.CurePoison)); break; case "milk_bucket": foodEffectPlan.Add(E(FoodEffectKind.Milk)); break; case "chorus_fruit": foodEffectPlan.Add(E(FoodEffectKind.Teleport, 30f)); break; case "suspicious_stew": foodEffectPlan.Choices.Add(new FoodEffectGroup(1f, E(FoodEffectKind.Heal, 15f, 8f, "regeneration"))); foodEffectPlan.Choices.Add(new FoodEffectGroup(1f, E(FoodEffectKind.Stamina, 20f))); foodEffectPlan.Choices.Add(new FoodEffectGroup(1f, E(FoodEffectKind.LowGravity, 1f, 6f))); foodEffectPlan.Choices.Add(new FoodEffectGroup(1f, E(FoodEffectKind.Fireproof, 0f, 4f))); foodEffectPlan.Choices.Add(new FoodEffectGroup(1f, E(FoodEffectKind.Blind, 0f, 8f))); foodEffectPlan.Choices.Add(new FoodEffectGroup(1f, E(FoodEffectKind.Poison, 5f), E(FoodEffectKind.Poison, 15f, 12f, "stew-poison"))); foodEffectPlan.Choices.Add(new FoodEffectGroup(1f, E(FoodEffectKind.Drowsy, 10f))); foodEffectPlan.Choices.Add(new FoodEffectGroup(1f, E(FoodEffectKind.Injury, 15f, 8f, "stew-wither"))); break; default: { bool flag = id == "enchanted_golden_apple"; foodEffectPlan.Add(E(FoodEffectKind.Invincible, 0f, flag ? 12 : 5), E(FoodEffectKind.Shield, flag ? 80 : 20, 60f), E(FoodEffectKind.Heal, flag ? 80 : 20, flag ? 20 : 5, "regeneration")); if (flag) { foodEffectPlan.Add(E(FoodEffectKind.Resist, 20f, 60f), E(FoodEffectKind.Fireproof, 0f, 60f)); } if (appleAftereffects) { foodEffectPlan.Add(E(FoodEffectKind.AppleAftereffect, 0f, flag ? 12 : 6)); } break; } } break; } if (burnPoison > 0f) { foodEffectPlan.Add(E(FoodEffectKind.Poison, burnPoison * 100f, 0f, "burn")); } return foodEffectPlan; } } internal sealed class AppleSleepClock { private float duration; internal bool Active { get; private set; } internal float Until { get; private set; } internal void Begin(float seconds) { Active = true; duration = seconds; Until = 0f; } internal bool Observe(float now, bool fullyAsleep) { if (!Active) { return false; } if (!fullyAsleep) { Until = 0f; return false; } if (Until == 0f) { Until = now + duration; } if (now < Until) { return false; } Active = false; return true; } internal void Clear() { Active = false; Until = (duration = 0f); } } internal sealed class ChorusExposure { internal const int Limit = 4; internal const float Window = 120f; internal const float Warning = 5f; internal int Count { get; private set; } internal float ExpiresAt { get; private set; } internal float TransformAt { get; private set; } internal bool Triggered { get; private set; } internal void Record(float now) { Expire(now); if (!(TransformAt > 0f) && !Triggered) { Count++; ExpiresAt = now + 120f; if (Count >= 4) { TransformAt = now + 5f; } } } internal void Expire(float now) { if (TransformAt <= 0f && now >= ExpiresAt) { Count = 0; } } internal bool TakeTransformation(float now) { if (Triggered || TransformAt <= 0f || now < TransformAt) { return false; } Triggered = true; return true; } internal void Clear() { Count = 0; float expiresAt = (TransformAt = 0f); ExpiresAt = expiresAt; Triggered = false; } } internal sealed class FoodEffectClock { internal float Remaining { get; private set; } internal float Rate { get; private set; } internal void Refresh(float total, float seconds) { if (seconds <= 0f || total < 0f) { throw new ArgumentOutOfRangeException(); } float num = Math.Max(total, Remaining * Rate); Rate = Math.Max(Rate, total / seconds); Remaining = ((Rate > 0f) ? (num / Rate) : 0f); } internal float Take(float seconds) { float num = Math.Min(Math.Max(0f, seconds), Remaining); Remaining = Math.Max(0f, Remaining - num); return num * Rate; } } internal sealed class AppleAftereffectClock { private float rampSeconds; private bool completionDelivered; internal bool Pending { get; private set; } internal float PendingSeconds { get; private set; } internal float HoldUntil { get; private set; } internal float StartedAt { get; private set; } internal float Duration => rampSeconds; internal void Queue(float now, float seconds) { PendingSeconds = Math.Max(Math.Max(PendingSeconds, HoldUntil - now), seconds); Pending = true; HoldUntil = 0f; completionDelivered = false; } internal bool Tick(float now, bool invincible) { if (Pending && !invincible) { Pending = false; StartedAt = now; rampSeconds = PendingSeconds; HoldUntil = now + PendingSeconds; PendingSeconds = 0f; } return now < HoldUntil; } internal float Progress(float now, bool invincible) { Tick(now, invincible); if (Pending || HoldUntil <= 0f || completionDelivered) { return -1f; } float num = Math.Min(1f, Math.Max(0f, (now - StartedAt) / rampSeconds)); if (num >= 1f) { completionDelivered = true; } return num; } internal void Clear() { Pending = false; float num = (StartedAt = (rampSeconds = 0f)); float pendingSeconds = (HoldUntil = num); PendingSeconds = pendingSeconds; completionDelivered = false; } } public sealed class FoodEatAction : ItemAction { private float lastUse = -100f; public override void RunAction() { Character character = ((ItemActionBase)this).character; FoodMarker component = ((Component)((ItemActionBase)this).item).GetComponent<FoodMarker>(); if (!Object.op_Implicit((Object)(object)character) || !character.IsLocal || character.data.dead || !Object.op_Implicit((Object)(object)component) || component.Definition == null || ((ItemActionBase)this).item.consuming || Time.time - lastUse < 0.3f || component.Stage >= component.Definition.wreck) { return; } if (((ItemActionBase)this).item.totalUses > 0) { OptionableIntItemData data = ((ItemActionBase)this).item.GetData<OptionableIntItemData>((DataEntryKey)2); if (data.HasData && data.Value <= 0) { return; } } lastUse = Time.time; (((Component)character).GetComponent<FoodPlayerState>() ?? ((Component)character).gameObject.AddComponent<FoodPlayerState>()).Eat(component.Definition, component.Stage); if (((ItemActionBase)this).item.totalUses > 1) { ((ItemActionBase)((Component)((ItemActionBase)this).item).GetComponent<Action_ReduceUses>()).RunAction(); } else { ((MonoBehaviour)((ItemActionBase)this).item).StartCoroutine(((ItemActionBase)this).item.ConsumeDelayed(true)); } } } public sealed class FoodPlayerState : MonoBehaviour { private sealed class TimedStatus { internal STATUSTYPE status; internal readonly FoodEffectClock clock = new FoodEffectClock(); internal bool healing; } internal float Shield; private float shieldUntil; private float resistUntil; private float resistFraction; private float fireUntil; private float nextTeleport; private float appleInvincibleUntil; private readonly AppleAftereffectClock aftereffect = new AppleAftereffectClock(); private readonly AppleSleepClock appleSleep = new AppleSleepClock(); private readonly ChorusExposure chorus = new ChorusExposure(); private Character character; private readonly Dictionary<string, TimedStatus> timers = new Dictionary<string, TimedStatus>(); private float tick; private float appleRampStart = -1f; private float appleRampBaseline; private static readonly FieldInfo Airport = AccessTools.Field(typeof(CharacterAfflictions), "m_inAirport"); internal static bool InAirport(CharacterAfflictions a) { if (Airport != null) { return (bool)Airport.GetValue(a); } return false; } private void Awake() { character = ((Component)this).GetComponent<Character>(); } internal void Eat(FoodDefinition f, int stage) { CharacterAfflictions afflictions = character.refs.afflictions; afflictions.SubtractStatus((STATUSTYPE)1, f.HungerAt(stage) / 100f, false, false); character.AddExtraStamina(f.BonusAt(stage) / 100f); FoodEffectPlan foodEffectPlan = f.EffectsAt(stage); foreach (FoodEffectGroup group in foodEffectPlan.Groups) { if (group.Chance >= 1f || Random.value < group.Chance) { FoodEffect[] effects = group.Effects; foreach (FoodEffect e in effects) { ApplyEffect(e); } } } if (foodEffectPlan.Choices.Count > 0) { FoodEffect[] effects = foodEffectPlan.Choices[Random.Range(0, foodEffectPlan.Choices.Count)].Effects; foreach (FoodEffect e2 in effects) { ApplyEffect(e2); } } Plugin.Log.LogInfo((object)$"EAT {f.id} stage={stage} nutrition={f.HungerAt(stage):F2}/{f.BonusAt(stage):F2} receiver={((MonoBehaviourPun)character).photonView.ViewID} airport={InAirport(afflictions)}"); } private void Timed(string key, STATUSTYPE status, float seconds, float total, bool heal = false) { //IL_001d: 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) if (!timers.TryGetValue(key, out var value)) { Dictionary<string, TimedStatus> dictionary = timers; TimedStatus obj = new TimedStatus { status = status, healing = heal }; value = obj; dictionary[key] = obj; } value.clock.Refresh(total, seconds); } internal void Apply(STATUSTYPE status, float amount) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) CharacterAfflictions afflictions = character.refs.afflictions; bool flag = InAirport(afflictions); try { if (flag && Plugin.AirportEffects.Value) { Airport.SetValue(afflictions, false); } afflictions.AddStatus(status, Mathf.Max(0f, amount), false, true, true, false, false); } finally { if (flag) { Airport.SetValue(afflictions, true); } } } private void ApplyEffect(FoodEffect e) { //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Expected O, but got Unknown //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Expected O, but got Unknown //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Expected O, but got Unknown CharacterAfflictions afflictions = character.refs.afflictions; switch (e.Kind) { case FoodEffectKind.Poison: StatusEffect(e, (STATUSTYPE)3); break; case FoodEffectKind.Hunger: StatusEffect(e, (STATUSTYPE)1); break; case FoodEffectKind.Drowsy: StatusEffect(e, (STATUSTYPE)6); break; case FoodEffectKind.Injury: StatusEffect(e, (STATUSTYPE)0); break; case FoodEffectKind.Heal: StatusEffect(e, (STATUSTYPE)0, healing: true); break; case FoodEffectKind.Stamina: character.AddExtraStamina(e.Amount / 100f); break; case FoodEffectKind.Invincible: { Affliction val = default(Affliction); if (!afflictions.HasAfflictionType((AfflictionType)16, ref val) || val.totalTime - val.timeElapsed < e.Seconds) { afflictions.AddAffliction((Affliction)new Affliction_Invincibility { totalTime = e.Seconds }, false); } Affliction val2 = default(Affliction); if (afflictions.HasAfflictionType((AfflictionType)16, ref val2)) { appleInvincibleUntil = Time.time + Mathf.Max(0f, val2.totalTime - val2.timeElapsed); } break; } case FoodEffectKind.Shield: Shield = Mathf.Max((Time.time < shieldUntil) ? Shield : 0f, e.Amount / 100f); shieldUntil = Mathf.Max(shieldUntil, Time.time + e.Seconds); break; case FoodEffectKind.Resist: resistFraction = Mathf.Max((Time.time < resistUntil) ? resistFraction : 0f, e.Amount / 100f); resistUntil = Mathf.Max(resistUntil, Time.time + e.Seconds); break; case FoodEffectKind.Fireproof: fireUntil = Mathf.Max(fireUntil, Time.time + e.Seconds); break; case FoodEffectKind.AppleAftereffect: appleSleep.Clear(); aftereffect.Queue(Time.time, e.Seconds); break; case FoodEffectKind.CurePoison: ClearPoison(); break; case FoodEffectKind.Milk: Milk(); break; case FoodEffectKind.Teleport: Teleport(e.Amount); break; case FoodEffectKind.LowGravity: afflictions.AddAffliction((Affliction)new Affliction_LowGravity((int)e.Amount, e.Seconds), false); break; case FoodEffectKind.Blind: afflictions.AddAffliction((Affliction)new Affliction_Blind { totalTime = e.Seconds }, false); break; } } private void StatusEffect(FoodEffect e, STATUSTYPE status, bool healing = false) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) if (e.Seconds > 0f) { Timed(e.Key, status, e.Seconds, e.Amount / 100f, healing); } else if (healing) { character.refs.afflictions.SubtractStatus(status, e.Amount / 100f, false, false); } else { Apply(status, e.Amount / 100f); } } internal void RemoveFoodPoisonTimers() { string[] array = (from x in timers where (int)x.Value.status == 3 select x.Key).ToArray(); foreach (string key in array) { timers.Remove(key); } } private void ClearPoison() { RemoveFoodPoisonTimers(); CharacterAfflictions afflictions = character.refs.afflictions; afflictions.RemoveAffliction((AfflictionType)0); afflictions.SubtractStatus((STATUSTYPE)3, 1f, false, false); } private void Milk() { ResetEffects(); CharacterAfflictions afflictions = character.refs.afflictions; Affliction[] array = afflictions.afflictionList.ToArray(); foreach (Affliction val in array) { afflictions.RemoveAffliction(val, false, true); } afflictions.SubtractStatus((STATUSTYPE)3, 1f, false, false); afflictions.SubtractStatus((STATUSTYPE)6, 1f, false, false); } private void ResetEffects() { timers.Clear(); Shield = 0f; aftereffect.Clear(); appleSleep.Clear(); chorus.Clear(); appleRampStart = -1f; shieldUntil = (resistUntil = (resistFraction = (fireUntil = (appleInvincibleUntil = (nextTeleport = (tick = 0f)))))); } private void OnDisable() { ResetEffects(); } private unsafe void Teleport(float radius) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) if (Time.time < nextTeleport || character.data.dead || !character.data.fullyConscious) { return; } nextTeleport = Time.time + 1f; Vector3 center = character.Center; RaycastHit val2 = default(RaycastHit); for (int i = 0; i < 16; i++) { Vector2 val = Random.insideUnitCircle * radius; if (!Physics.Raycast(center + new Vector3(val.x, 4f, val.y), Vector3.down, ref val2, 12f, -1, (QueryTriggerInteraction)1) || ((RaycastHit)(ref val2)).normal.y < 0.65f || Object.op_Implicit((Object)(object)((RaycastHit)(ref val2)).rigidbody)) { continue; } Vector3 val3 = ((RaycastHit)(ref val2)).point + Vector3.up * 0.1f; Vector3 val4 = val3 + Vector3.up * 0.9f; if (Vector3.Distance(val4, center) < 1f || Mathf.Abs(val4.y - center.y) > 8f) { continue; } bool flag = false; Collider[] array = Physics.OverlapCapsule(val3 + Vector3.up * 0.36f, val3 + Vector3.up * 1.45f, 0.35f, -1, (QueryTriggerInteraction)2); foreach (Collider val5 in array) { if (!((Object)(object)((Component)val5).GetComponentInParent<Character>() == (Object)(object)character) && !Object.op_Implicit((Object)(object)((Component)val5).GetComponentInParent<Item>())) { string text = ((Object)val5).name.ToLowerInvariant(); bool flag2 = text.Contains("lava") || text.Contains("water") || text.Contains("kill") || text.Contains("death") || text.Contains("fire"); if (!val5.isTrigger || flag2) { flag = true; break; } } } if (!flag) { ((MonoBehaviourPun)character).photonView.RPC("WarpPlayerRPC", (RpcTarget)0, new object[2] { val4, true }); if (Random.value < 0.5f) { Apply((STATUSTYPE)1, 0.25f); } else { Apply((STATUSTYPE)10, 0.15f); } if (!InAirport(character.refs.afflictions) || Plugin.AirportEffects.Value) { chorus.Record(Time.time); } Plugin.Log.LogInfo((object)("Chorus fruit teleport: " + ((object)(*(Vector3*)(&val4))/*cast due to .constrained prefix*/).ToString())); return; } } Plugin.Log.LogInfo((object)"Chorus fruit: no clear landing found in 16 attempts; stayed in place."); } internal void FilterStatus(STATUSTYPE status, ref float amount) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Invalid comparison between Unknown and I4 //IL_0023: Unknown result type (might be due to invalid IL or missing references) if (amount <= 0f) { return; } if ((int)status == 8 && Time.time < fireUntil) { amount = 0f; } else if ((int)status == 0) { if (Time.time < resistUntil) { amount *= 1f - resistFraction; } if (Time.time < shieldUntil) { float num = Mathf.Min(Shield, amount); Shield -= num; amount -= num; } } } private void Update() { //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)character) || !character.IsLocal) { return; } if (character.data.dead) { ResetEffects(); return; } chorus.Expire(Time.time); if (!character.data.zombified && !character.isZombie && chorus.TakeTransformation(Time.time)) { ((MonoBehaviourPun)character).photonView.RPC("RPCA_Zombify", (RpcTarget)0, Array.Empty<object>()); return; } if (Time.time >= shieldUntil) { Shield = 0f; } tick += Time.deltaTime; if (tick < 0.25f) { return; } float seconds = tick; tick = 0f; if (!Plugin.AppleAftereffects.Value) { aftereffect.Clear(); appleSleep.Clear(); } Affliction val = default(Affliction); float num = aftereffect.Progress(Time.time, character.refs.afflictions.HasAfflictionType((AfflictionType)16, ref val)); if (num >= 0f) { CharacterAfflictions afflictions = character.refs.afflictions; float num2 = Mathf.Min(1f, afflictions.GetStatusCap((STATUSTYPE)6)); if (appleRampStart != aftereffect.StartedAt) { appleRampStart = aftereffect.StartedAt; appleRampBaseline = afflictions.GetCurrentStatus((STATUSTYPE)6); } float num3 = Mathf.Lerp(appleRampBaseline, num2, num); Apply((STATUSTYPE)6, Mathf.Max(0f, num3 - afflictions.GetCurrentStatus((STATUSTYPE)6))); if (num >= 1f) { appleSleep.Begin(aftereffect.Duration); } } if (appleSleep.Active) { CharacterAfflictions afflictions2 = character.refs.afflictions; if (appleSleep.Observe(Time.time, character.data.fullyPassedOut)) { afflictions2.SubtractStatus((STATUSTYPE)6, Mathf.Max(0f, afflictions2.GetCurrentStatus((STATUSTYPE)6) - appleRampBaseline), false, false); } else { Apply((STATUSTYPE)6, Mathf.Max(0f, Mathf.Min(1f, afflictions2.GetStatusCap((STATUSTYPE)6)) - afflictions2.GetCurrentStatus((STATUSTYPE)6))); } } string[] array = timers.Keys.ToArray(); foreach (string key in array) { TimedStatus timedStatus = timers[key]; float num4 = timedStatus.clock.Take(seconds); if (timedStatus.healing) { character.refs.afflictions.SubtractStatus(timedStatus.status, num4, false, false); } else { Apply(timedStatus.status, num4); } if (timedStatus.clock.Remaining <= 0f) { timers.Remove(key); } } } internal string CountdownText() { //IL_0384: Unknown result type (might be due to invalid IL or missing references) //IL_038a: Invalid comparison between Unknown and I4 //IL_038d: Unknown result type (might be due to invalid IL or missing references) //IL_0393: Invalid comparison between Unknown and I4 //IL_0396: Unknown result type (might be due to invalid IL or missing references) //IL_039c: Invalid comparison between Unknown and I4 if (!Object.op_Implicit((Object)(object)character) || !character.IsLocal || character.data.dead) { return ""; } StringBuilder b = new StringBuilder(); Affliction val = default(Affliction); if (appleInvincibleUntil > Time.time && character.refs.afflictions.HasAfflictionType((AfflictionType)16, ref val)) { Line(L10n.T("金苹果无敌", "Apple invincibility", "金のリンゴの無敵"), Time.time + Mathf.Max(0f, val.totalTime - val.timeElapsed)); } if (Shield > 0f) { Line(L10n.T($"吸收盾 {Shield * 100f:0.#} 点", $"Shield {Shield * 100f:0.#} points", $"シールド {Shield * 100f:0.#} ポイント"), shieldUntil); } Line(L10n.T($"受伤减少 {resistFraction * 100f:0.#}%", $"Injury reduction {resistFraction * 100f:0.#}%", $"負傷軽減 {resistFraction * 100f:0.#}%"), resistUntil); Line(L10n.T("炎热防护", "Heat protection", "暑さ防御"), fireUntil); if (aftereffect.Pending) { b.AppendLine(L10n.T($"待触发:睡意在 {aftereffect.PendingSeconds:0.#} 秒内升满", $"Pending: drowsiness ramp over {aftereffect.PendingSeconds:0.#}s", $"発動待ち:{aftereffect.PendingSeconds:0.#} 秒で眠気最大")); } Line(L10n.T("睡意逐渐增加", "Drowsiness rising", "眠気上昇中"), aftereffect.HoldUntil); if (appleSleep.Active) { if (appleSleep.Until > 0f) { Line(L10n.T("金苹果睡眠", "Apple sleep", "金のリンゴの睡眠"), appleSleep.Until); } else { b.AppendLine(L10n.T("金苹果:等待进入睡眠后计时", "Apple: sleep timer starts once unconscious", "金のリンゴ:眠ってから計測開始")); } } if (chorus.TransformAt > Time.time) { Line(L10n.T("僵尸化倒计时!喝牛奶解除", "Zombification! Drink milk to cancel", "ゾンビ化!ミルクで解除"), chorus.TransformAt); } else if (chorus.Count > 0 && !chorus.Triggered) { Line(L10n.T($"紫颂果感染 {chorus.Count}/{4}", $"Chorus exposure {chorus.Count}/{4}", $"コーラス感染 {chorus.Count}/{4}"), chorus.ExpiresAt); } foreach (TimedStatus value in timers.Values) { string arg = (value.healing ? L10n.T("恢复受伤", "Injury recovery", "負傷回復") : (((int)value.status == 3) ? L10n.T("持续中毒", "Ongoing poison", "継続毒") : (((int)value.status == 1) ? L10n.T("持续饥饿", "Ongoing hunger", "継続空腹") : (((int)value.status == 6) ? L10n.T("持续睡意", "Ongoing drowsiness", "継続眠気") : L10n.T("持续受伤", "Ongoing injury", "継続負傷"))))); int num = Mathf.CeilToInt(value.clock.Remaining); string arg2 = L10n.N(value.clock.Remaining * value.clock.Rate * 100f); b.AppendLine(L10n.T($"{arg}:{num} 秒,剩余 {arg2} 点", $"{arg}: {num}s, {arg2} points remaining", $"{arg}:{num} 秒、残り {arg2} ポイント")); } return b.ToString().TrimEnd(); void Line(string label, float until) { if (until > Time.time) { b.AppendLine(label + L10n.T($":{Mathf.CeilToInt(until - Time.time)} 秒", $": {Mathf.CeilToInt(until - Time.time)}s", $":{Mathf.CeilToInt(until - Time.time)} 秒")); } } } } internal static class FoodInformation { internal static int RemainingUses(Item item, FoodDefinition f) { OptionableIntItemData val = default(OptionableIntItemData); if (item.data != null && item.data.TryGetDataEntry<OptionableIntItemData>((DataEntryKey)2, ref val) && val.HasData && val.Value >= 0) { return Mathf.Clamp(val.Value, 0, f.uses); } return f.uses; } internal static string Describe(FoodMarker marker) { FoodDefinition definition = marker.Definition; if (definition == null) { return ""; } int stage = marker.Stage; Item component = ((Component)marker).GetComponent<Item>(); string text = FoodTooltip.Render(definition.HungerAt(stage), definition.BonusAt(stage), definition.HungerAt(stage + 1), definition.BonusAt(stage + 1), (float)component.CarryWeight * 2.5f, stage, definition.wreck, definition.uses, RemainingUses(component, definition), definition.EffectsAt(stage), definition.EffectsAt(stage + 1)); if (Plugin.DetailedInfo.Value && stage < definition.wreck) { text = text + "\n" + L10n.T($"{definition.scorch} 次起烧焦,{definition.wreck} 次烧毁", $"Charring starts at {definition.scorch} cooks; destroyed at {definition.wreck}.", $"調理 {definition.scorch} 回で焦げ、{definition.wreck} 回で燃え尽き。"); } return text; } } internal static class FoodTooltip { internal static string Group(FoodEffectGroup group) { return ((group.Chance < 1f) ? L10n.T(L10n.N(group.Chance * 100f) + "% 概率:", L10n.N(group.Chance * 100f) + "% chance: ", L10n.N(group.Chance * 100f) + "% の確率:") : "") + string.Join(L10n.T(";", "; ", "、"), group.Effects.Select((FoodEffect e) => e.Describe())); } internal static string Special(FoodEffectPlan p) { List<string> list = new List<string>(); foreach (FoodEffectGroup group in p.Groups) { if (group.Chance < 1f) { list.Add(Group(group)); continue; } list.AddRange(group.Effects.Select((FoodEffect e) => e.Describe())); } if (p.SpecialLost) { list.Add(L10n.Color(L10n.T("烧焦:特殊效果已失效", "Charred: special effects disabled", "焦げ:特殊効果は無効"), "A040E8")); } if (p.Choices.Count > 0) { list.Add(L10n.T("随机效果(其一):", "Random effect (one):", "ランダム効果(いずれか):")); foreach (FoodEffectGroup choice in p.Choices) { list.Add("· " + Group(choice) + " (" + L10n.N(100f / (float)p.Choices.Count) + "%)"); } } return string.Join("\n", list); } internal static List<string> Delta(float hunger, float nextHunger, float stamina, float nextStamina, FoodEffectPlan current, FoodEffectPlan next) { List<string> list = new List<string>(); float num = nextHunger - hunger; float num2 = nextStamina - stamina; if (Math.Abs(num) > 0.001f) { list.Add(L10n.Change(FoodEffectKind.Hunger, Math.Abs(num), num > 0f)); } if (Math.Abs(num2) > 0.001f) { list.Add(L10n.Change(FoodEffectKind.Stamina, Math.Abs(num2), num2 < 0f)); } foreach (FoodEffectGroup group in next.Groups) { FoodEffect[] effects = group.Effects; foreach (FoodEffect effect in effects) { FoodEffect foodEffect = current.Groups.Where((FoodEffectGroup g) => g.Chance == group.Chance).SelectMany((FoodEffectGroup g) => g.Effects).FirstOrDefault((FoodEffect e) => e.Kind == effect.Kind && e.Key == effect.Key); if (foodEffect == null || foodEffect.Amount != effect.Amount || foodEffect.Seconds != effect.Seconds) { if (foodEffect != null && foodEffect.Seconds == effect.Seconds && effect.Kind <= FoodEffectKind.Stamina) { float num3 = effect.Amount - foodEffect.Amount; string text = ((group.Chance < 1f) ? (L10n.N(group.Chance * 100f) + "% ") : ""); string text2 = L10n.Status((effect.Kind == FoodEffectKind.Heal) ? FoodEffectKind.Injury : effect.Kind); string text3 = ((num3 > 0f) ? "+" : "−") + L10n.N(Math.Abs(num3)); list.Add(text + L10n.T("食用效果变化:", "Change on consumption: ", "食べた時の変化:") + L10n.Color(text2 + " " + text3, L10n.StatusColor(effect.Kind)) + ((effect.Seconds > 0f) ? L10n.T("(" + L10n.N(effect.Seconds) + " 秒累计)", " (over " + L10n.N(effect.Seconds) + "s)", "(" + L10n.N(effect.Seconds) + " 秒間の合計)") : "")); } else { list.Add(L10n.T("食用时:", "On consumption: ", "食べた時:") + Group(new FoodEffectGroup(group.Chance, effect))); } } } } foreach (FoodEffectGroup group2 in current.Groups) { FoodEffect[] effects = group2.Effects; foreach (FoodEffect effect2 in effects) { if (!next.Groups.Any((FoodEffectGroup g) => g.Chance == group2.Chance && g.Effects.Any((FoodEffect e) => e.Kind == effect2.Kind && e.Key == effect2.Key))) { list.Add(L10n.T("不再提供:", "No longer applies: ", "適用されなくなる効果:") + Group(new FoodEffectGroup(group2.Chance, effect2))); } } } if (current.Choices.Count > 0 && next.Choices.Count == 0) { list.Add(L10n.T("随机特殊效果失效", "Random special effect disabled", "ランダム特殊効果が無効")); } return list; } internal static string Render(float hunger, float bonus, float nextHunger, float nextBonus, float weight, int stage, int wreck, int uses, int remaining, FoodEffectPlan current, FoodEffectPlan next) { if (stage >= wreck) { return L10n.Color(L10n.T("已烧毁,无法食用", "Burnt: cannot be consumed", "燃え尽き:食べられない"), "A040E8"); } StringBuilder stringBuilder = new StringBuilder(); if (hunger > 0f) { stringBuilder.AppendLine(L10n.Change(FoodEffectKind.Hunger, hunger, remove: true)); } if (bonus > 0f) { stringBuilder.AppendLine(L10n.Change(FoodEffectKind.Stamina, bonus, remove: false)); } string text = Special(current); if (text.Length > 0) { stringBuilder.AppendLine(text); } if (uses > 1) { stringBuilder.AppendLine(L10n.T($"剩余 {remaining}/{uses} 次(每次效果)", $"{remaining}/{uses} uses left (effects per use)", $"残り {remaining}/{uses} 回(1回あたりの効果)")); } stringBuilder.AppendLine(); stringBuilder.AppendLine(L10n.Color(L10n.T(L10n.N(weight) + " 重量", L10n.N(weight) + " weight", "重量 " + L10n.N(weight)), "B87838")); stringBuilder.AppendLine(); string text2 = ((stage == 0) ? L10n.T("可以烹饪", "Cookable", "調理可能") : L10n.T($"已烹饪 {stage} 次", $"Cooked {stage} time(s)", $"調理済み {stage} 回")); if (stage + 1 >= wreck) { stringBuilder.Append(text2 + "\n" + L10n.Color(L10n.T("下次烹饪:烧毁,无法食用", "Next cook: burnt and inedible", "次の調理:燃え尽きて食べられない"), "A040E8")); } else { List<string> list = Delta(hunger, nextHunger, bonus, nextBonus, current, next); if (list.Count == 0) { stringBuilder.Append(text2 + "\n" + L10n.Color(L10n.T("下次烹饪:没有效果", "Next cook: no effect change", "次の調理:効果の変化なし"), "6550B8")); } else { stringBuilder.AppendLine(text2 + " " + L10n.T("下次烹饪增量:", "Next cook changes:", "次の調理による変化:")); foreach (string item in list) { stringBuilder.AppendLine("· " + item); } } } return stringBuilder.ToString().TrimEnd(); } } internal static class L10n { internal static string Language = "zh-CN"; private static readonly Dictionary<string, string[]> Names = new Dictionary<string, string[]> { { "apple", new string[2] { "Apple", "リンゴ" } }, { "baked_potato", new string[2] { "Baked Potato", "ベイクドポテト" } }, { "beef", new string[2] { "Raw Beef", "生の牛肉" } }, { "cooked_beef", new string[2] { "Steak", "ステーキ" } }, { "beetroot", new string[2] { "Beetroot", "ビートルート" } }, { "beetroot_soup", new string[2] { "Beetroot Soup", "ビートルートスープ" } }, { "bread", new string[2] { "Bread", "パン" } }, { "cake", new string[2] { "Cake", "ケーキ" } }, { "carrot", new string[2] { "Carrot", "ニンジン" } }, { "chicken", new string[2] { "Raw Chicken", "生の鶏肉" } }, { "cooked_chicken", new string[2] { "Cooked Chicken", "焼き鳥" } }, { "chorus_fruit", new string[2] { "Chorus Fruit", "コーラスフルーツ" } }, { "cod", new string[2] { "Raw Cod", "生鱈" } }, { "cooked_cod", new string[2] { "Cooked Cod", "焼き鱈" } }, { "cookie", new string[2] { "Cookie", "クッキー" } }, { "enchanted_golden_apple", new string[2] { "Enchanted Golden Apple", "エンチャントされた金のリンゴ" } }, { "glow_berries", new string[2] { "Glow Berries", "グロウベリー" } }, { "golden_apple", new string[2] { "Golden Apple", "金のリンゴ" } }, { "golden_carrot", new string[2] { "Golden Carrot", "金のニンジン" } }, { "honey_bottle", new string[2] { "Honey Bottle", "ハチミツ入りの瓶" } }, { "melon_slice", new string[2] { "Melon Slice", "スイカの薄切り" } }, { "milk_bucket", new string[2] { "Milk Bucket", "ミルク入りバケツ" } }, { "mushroom_stew", new string[2] { "Mushroom Stew", "キノコシチュー" } }, { "mutton", new string[2] { "Raw Mutton", "生の羊肉" } }, { "cooked_mutton", new string[2] { "Cooked Mutton", "焼き羊肉" } }, { "poisonous_potato", new string[2] { "Poisonous Potato", "青くなったジャガイモ" } }, { "porkchop", new string[2] { "Raw Porkchop", "生の豚肉" } }, { "cooked_porkchop", new string[2] { "Cooked Porkchop", "焼き豚" } }, { "potato", new string[2] { "Potato", "ジャガイモ" } }, { "pufferfish", new string[2] { "Pufferfish", "フグ" } }, { "pumpkin_pie", new string[2] { "Pumpkin Pie", "パンプキンパイ" } }, { "rabbit", new string[2] { "Raw Rabbit", "生の兎肉" } }, { "cooked_rabbit", new string[2] { "Cooked Rabbit", "焼き兎肉" } }, { "rabbit_stew", new string[2] { "Rabbit Stew", "ウサギシチュー" } }, { "rotten_flesh", new string[2] { "Rotten Flesh", "腐った肉" } }, { "salmon", new string[2] { "Raw Salmon", "生鮭" } }, { "cooked_salmon", new string[2] { "Cooked Salmon", "焼き鮭" } }, { "spider_eye", new string[2] { "Spider Eye", "クモの目" } }, { "suspicious_stew", new string[2] { "Suspicious Stew", "怪しげなシチュー" } }, { "sweet_berries", new string[2] { "Sweet Berries", "スイートベリー" } }, { "tropical_fish", new string[2] { "Tropical Fish", "熱帯魚" } } }; internal static string Resolve(string preference, string client) { if (preference != "Auto") { return preference; } switch (client) { case "Japanese": return "ja"; case "SimplifiedChinese": case "TraditionalChinese": return "zh-CN"; default: return "en"; } } internal static string T(string zh, string en, string ja) { if (!(Language == "ja")) { if (!(Language == "zh-CN")) { return en; } return zh; } return ja; } internal static string N(float n) { return n.ToString("0.#", CultureInfo.InvariantCulture); } internal static string Color(string text, string hex) { return "<color=#" + hex + ">" + text + "</color>"; } internal static string Status(FoodEffectKind kind) { return kind switch { FoodEffectKind.Stamina => T("额外体力", "extra stamina", "追加スタミナ"), FoodEffectKind.Drowsy => T("睡意", "drowsiness", "眠気"), FoodEffectKind.Hunger => T("饥饿值", "hunger", "空腹度"), FoodEffectKind.Poison => T("中毒", "poison", "毒"), _ => T("受伤", "injury", "負傷"), }; } internal static string StatusColor(FoodEffectKind kind) { return kind switch { FoodEffectKind.Drowsy => "CB65BC", FoodEffectKind.Poison => "A040E8", FoodEffectKind.Stamina => "BCEB00", FoodEffectKind.Hunger => "FFB600", _ => "F07831", }; } internal static string Change(FoodEffectKind kind, float amount, bool remove, float seconds = 0f) { string text = Color(T(N(amount) + " 点 " + Status(kind), N(amount) + " " + Status(kind), Status(kind) + " " + N(amount) + " ポイント"), StatusColor(kind)); string text2 = (remove ? T("移除 ", "Remove ", "") : T("获得 ", "Gain ", "")); string text3 = T(text2 + text, text2 + text, text + (remove ? "を減少" : "を獲得")); if (!(seconds <= 0f)) { return T(N(seconds) + " 秒内:" + text3, "Over " + N(seconds) + "s: " + text3, N(seconds) + " 秒間で:" + text3); } return text3; } internal static string FoodName(string id, string chinese) { if (!(Language == "zh-CN")) { if (!Names.TryGetValue(id, out var value)) { return id; } return value[(Language == "ja") ? 1u : 0u]; } return chinese; } } internal sealed class LootChoice { internal string Id; internal string Tier; internal double Weight; internal LootChoice(string id, string tier, double weight) { Id = id; Tier = tier; Weight = weight; } } internal static class LootWeights { internal static Dictionary<string, double> Normalize(IEnumerable<LootChoice> choices, Dictionary<string, double> tiers) { double value; LootChoice[] array = choices.Where((LootChoice x) => x.Weight > 0.0 && !double.IsInfinity(x.Weight) && !double.IsNaN(x.Weight) && tiers.TryGetValue(x.Tier, out value) && value > 0.0 && !double.IsNaN(value) && !double.IsInfinity(value)).ToArray(); Dictionary<string, double> dictionary = (from x in array group x by x.Tier).ToDictionary((IGrouping<string, LootChoice> g) => g.Key, (IGrouping<string, LootChoice> g) => g.Sum((LootChoice x) => x.Weight)); double num = dictionary.Keys.Sum((string t) => tiers[t]); Dictionary<string, double> dictionary2 = new Dictionary<string, double>(); if (num <= 0.0) { return dictionary2; } LootChoice[] array2 = array; foreach (LootChoice lootChoice in array2) { dictionary2[lootChoice.Id] = tiers[lootChoice.Tier] / num * lootChoice.Weight / dictionary[lootChoice.Tier]; } return dictionary2; } } internal static class ModSettings { internal static ConfigFile File; internal static ConfigEntry<string> Language; internal static readonly Dictionary<string, ConfigEntry<float>[]> Tiers = new Dictionary<string, ConfigEntry<float>[]>(); internal static readonly Dictionary<string, ConfigEntry<float>> FoodWeights = new Dictionary<string, ConfigEntry<float>>(); internal static readonly string[] Pools = new string[3] { "Ordinary", "Cursed", "Clown" }; internal static readonly string[] TierNames = new string[4] { "common", "uncommon", "rare", "special" }; internal static void Open(string root, string legacy) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown string text = Path.Combine(root, "settings.cfg"); if (!System.IO.File.Exists(text) && System.IO.File.Exists(legacy)) { System.IO.File.Copy(legacy, text); } File = new ConfigFile(text, true); File.SaveOnConfigSet = false; Language = Bind("UI", "Language", "Auto", "语言:Auto 跟随游戏;zh-CN 中文、en 英语、ja 日语。其他游戏语言回退英语。", "Language: Auto follows the game; zh-CN, en, ja override it. Other game languages fall back to English.", "言語:Auto はゲームに従う。zh-CN/en/ja で固定。他言語は英語。", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[4] { "Auto", "zh-CN", "en", "ja" })); float[][] array = new float[3][] { new float[4] { 60f, 25f, 12f, 3f }, new float[4] { 35f, 25f, 30f, 10f }, new float[4] { 45f, 30f, 18f, 7f } }; for (int i = 0; i < Pools.Length; i++) { string text2 = Pools[i]; ConfigEntry<float>[] array2 = new ConfigEntry<float>[4]; for (int j = 0; j < 4; j++) { array2[j] = Bind("Tiers." + text2, TierNames[j], array[i][j], "该箱子内本模组食物的稀有度相对权重。0 禁用该档;其余非空档自动归一化。仅房主决定后续掉落。", "Relative tier weight within mod loot in this chest. 0 disables the tier; nonempty tiers are normalized. Host controls future loot.", "この箱のMOD食品内のレア度重み。0で無効。他の有効な区分で正規化。今後のドロップはホスト設定。", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1000f)); } Tiers[text2] = array2; } } internal static ConfigEntry<T> Bind<T>(string section, string key, T value, string zh, string en, string ja, AcceptableValueBase range = null) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown return File.Bind<T>(section, key, value, new ConfigDescription(zh + "\n" + en + "\n" + ja, range, Array.Empty<object>())); } internal static void BindFoods(IEnumerable<FoodDefinition> foods) { string[] pools = Pools; foreach (string text in pools) { foreach (FoodDefinition food in foods) { FoodWeights[text + "/" + food.id] = Bind("FoodWeights." + text, food.id, 1f, food.name + ":档内基础权重倍率,1 保持默认,0 禁用,2 表示基础权重加倍(不是最终概率加倍)。仅房主影响后续掉落。", "Within-tier multiplier for " + food.id + ". 1 = default, 0 = disabled, 2 = twice the base weight, not twice the final chance. Host affects future loot.", food.id + ":区分内の重み倍率。1は既定、0は無効、2は基礎重みの2倍(最終確率の2倍ではない)。ホストが今後のドロップに適用。", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f)); } } File.Save(); } internal static string Pool(string name) { if (!(name == "LuggageCursed")) { if (!(name == "LuggageClown")) { return "Ordinary"; } return "Clown"; } return "Cursed"; } internal static double Weight(string pool, string id) { ConfigEntry<float> value; return FoodWeights.TryGetValue(pool + "/" + id, out value) ? value.Value : 1f; } internal static Dictionary<string, double> TierWeights(string pool) { Dictionary<string, double> dictionary = new Dictionary<string, double>(); for (int i = 0; i < 4; i++) { dictionary[TierNames[i]] = Tiers[pool][i].Value; } return dictionary; } internal static string Help(ConfigEntryBase entry) { string[] array = entry.Description.Description.Split('\n'); int num = ((!(L10n.Language == "zh-CN")) ? ((!(L10n.Language == "ja")) ? 1 : 2) : 0); if (array.Length <= num) { return entry.Description.Description; } return array[num]; } } [HarmonyPatch(typeof(Item), "GetName")] internal static class NamePatch { private static bool Prefix(Item __instance, ref string __result) { FoodMarker component = ((Component)__instance).GetComponent<FoodMarker>(); if (!Object.op_Implicit((Object)(object)component) || component.Definition == null) { return true; } __result = component.Definition.NameAt(component.Stage); return false; } } [HarmonyPatch(typeof(Item), "GetItemName")] internal static class CookedNamePatch { private static bool Prefix(Item __instance, ItemInstanceData data, ref string __result) { FoodMarker component = ((Component)__instance).GetComponent<FoodMarker>(); if (!Object.op_Implicit((Object)(object)component) || component.Definition == null) { return true; } __result = component.Definition.NameAt((data == null) ? component.Stage : FoodMarker.ReadStage(data)); return false; } } [HarmonyPatch(typeof(InventoryItemUI), "SetItem")] internal static class SlotPatch { private static void Prefix(InventoryItemUI __instance, ItemSlot slot) { if (Object.op_Implicit((Object)(object)((slot != null) ? slot.prefab : null)) && Object.op_Implicit((Object)(object)((Component)slot.prefab).GetComponent<FoodMarker>())) { __instance._itemData = slot.data; } } private static void Postfix(InventoryItemUI __instance, ItemSlot slot) { if (slot != null && Object.op_Implicit((Object)(object)slot.prefab)) { Apply(__instance, slot.prefab, slot.data); } } internal static void Apply(InventoryItemUI ui, Item prefab, ItemInstanceData data) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) FoodMarker foodMarker = (Object.op_Implicit((Object)(object)prefab) ? ((Component)prefab).GetComponent<FoodMarker>() : null); if (Object.op_Implicit((Object)(object)foodMarker) && foodMarker.Definition != null) { int stage = FoodMarker.ReadStage(data); ui.icon.texture = (Texture)(object)Visuals.IconFor(foodMarker.Definition.TextureAt(stage)); ((Graphic)ui.icon).color = foodMarker.Definition.TintAt(stage); if (Object.op_Implicit((Object)(object)ui.nameText)) { ((TMP_Text)ui.nameText).text = foodMarker.Definition.NameAt(stage); } } } } [HarmonyPatch(typeof(InventoryItemUI), "UpdateCookedAmount")] internal static class SlotCookingPatch { private static void Postfix(InventoryItemUI __instance, Item ____itemPrefab) { SlotPatch.Apply(__instance, ____itemPrefab, __instance._itemData); } } [HarmonyPatch(typeof(ItemCooking), "UpdateCookedBehavior")] internal static class CookingPatch { private static bool Prefix(ItemCooking __instance) { FoodMarker component = ((Component)__instance).GetComponent<FoodMarker>(); if (!Object.op_Implicit((Object)(object)component) || component.Definition == null) { return true; } ((Component)__instance).GetComponent<Item>().GetData<IntItemData>((DataEntryKey)1); component.Refresh(); if (component.Stage >= component.Definition.wreck && Object.op_Implicit((Object)(object)((Component)__instance).GetComponent<FoodEatAction>())) { __instance.Wreck(); } return false; } } [HarmonyPatch(typeof(CharacterAfflictions), "AddStatus")] internal static class StatusPatch { private static readonly FieldInfo Invincible = AccessTools.Field(typeof(CharacterData), "isInvincible"); private static void Prefix(CharacterAfflictions __instance, STATUSTYPE statusType, ref float amount, bool fromRPC, bool ignoreInvincibility) { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Invalid comparison between Unknown and I4 //IL_0093: Unknown result type (might be due to invalid IL or missing references) Character character = __instance.character; if (!(!Object.op_Implicit((Object)(object)character) || !character.IsLocal || fromRPC) && !character.statusesLocked && !character.data.dead && !character.isZombie && !character.isScoutmaster && !character.data.isSkeleton && !FoodPlayerState.InAirport(__instance) && (!(bool)Invincible.GetValue(character.data) || ignoreInvincibility) && ((int)statusType != 1 || __instance.canGetHungry)) { FoodPlayerState component = ((Component)character).GetComponent<FoodPlayerState>(); if (Object.op_Implicit((Object)(object)component)) { component.FilterStatus(statusType, ref amount); } } } } [HarmonyPatch(typeof(CharacterAfflictions), "SubtractStatus")] internal static class CurePatch { private static void Postfix(CharacterAfflictions __instance, STATUSTYPE statusType, float amount, bool fromRPC, bool decreasedNaturally) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 if (!((int)statusType != 3 || amount <= 0f || fromRPC || decreasedNaturally) && Object.op_Implicit((Object)(object)__instance.character) && __instance.character.IsLocal && !__instance.character.statusesLocked) { FoodPlayerState component = ((Component)__instance.character).GetComponent<FoodPlayerState>(); if (Object.op_Implicit((Object)(object)component)) { component.RemoveFoodPoisonTimers(); } } } } [HarmonyPatch(typeof(LootData), "PopulateLootData")] internal static class LootPatch { private static void Postfix() { //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: 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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) if (Plugin.Registered.Count == 0 || LootData.AllSpawnWeightData == null) { return; } Dictionary<ushort, FoodDefinition> dictionary = Plugin.Registered.ToDictionary((Item x) => x.itemID, (Item x) => ((Component)x).GetComponent<FoodMarker>().Definition); foreach (KeyValuePair<SpawnPool, Dictionary<ushort, int>> allSpawnWeightDatum in LootData.AllSpawnWeightData) { if (!((object)allSpawnWeightDatum.Key/*cast due to .constrained prefix*/).ToString().StartsWith("Luggage", StringComparison.Ordinal)) { continue; } double num = ((((object)allSpawnWeightDatum.Key/*cast due to .constrained prefix*/).ToString() == "LuggageCursed") ? Plugin.CursedLootShare.Value : ((((object)allSpawnWeightDatum.Key/*cast due to .constrained prefix*/).ToString() == "LuggageClown") ? Plugin.ClownLootShare.Value : Plugin.LootShare.Value)); foreach (ushort key2 in dictionary.Keys) { allSpawnWeightDatum.Value.Remove(key2); } if (num <= 0.0) { continue; } string poolName = ((object)allSpawnWeightDatum.Key/*cast due to .constrained prefix*/).ToString(); string configPool = ModSettings.Pool(poolName); Dictionary<string, double> dictionary2 = LootWeights.Normalize(dictionary.Values.Select((FoodDefinition f) => new LootChoice(f.id, LootTier(f, poolName), (double)f.weight * ModSettings.Weight(configPool, f.id))), ModSettings.TierWeights(configPool)); if (dictionary2.Count == 0) { Plugin.Log.LogWarning((object)(poolName + ": all mod food weights disabled; retaining vanilla loot.")); continue; } double num2 = allSpawnWeightDatum.Value.Values.Sum((int x) => Math.Max(0.0, x)); if (num2 <= 0.0) { num = 1.0; } ushort[] array = allSpawnWeightDatum.Value.Keys.ToArray(); foreach (ushort key in array) { if (num >= 1.0 || allSpawnWeightDatum.Value[key] <= 0) { allSpawnWeightDatum.Value.Remove(key); } else { allSpawnWeightDatum.Value[key] = Math.Max(1, (int)Math.Round((double)allSpawnWeightDatum.Value[key] / num2 * (1.0 - num) * 1000000.0)); } } foreach (KeyValuePair<ushort, FoodDefinition> item in dictionary) { if (dictionary2.TryGetValue(item.Value.id, out var value)) { allSpawnWeightDatum.Value[item.Key] = Math.Max(1, (int)Math.Round(num * 1000000.0 * value)); } } } } internal static string LootTier(FoodDefinition food, string poolName) { if (food.id == "golden_apple" || food.id == "enchanted_golden_apple" || food.id == "chorus_fruit") { return "special"; } if (poolName == "LuggageCursed" && food.id == "rotten_flesh") { return "uncommon"; } if (!string.IsNullOrEmpty(food.rarity)) { return food.rarity.ToLowerInvariant(); } return "common"; } } [BepInPlugin("codex.peak.minecraftfoods", "Minecraft Foods", "1.26.0")] [BepInDependency("com.github.PEAKModding.PEAKLib.Items", "1.6.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency("me.loaforc.soundapi", "2.0.13")] public sealed class Plugin : BaseUnityPlugin { public const string Id = "codex.peak.minecraftfoods"; internal static Plugin Instance; internal static ManualLogSource Log; internal static string Root; internal static readonly Dictionary<string, FoodDefinition> Foods = new Dictionary<string, FoodDefinition>(StringComparer.Ordinal); internal static readonly List<Item> Registered = new List<Item>(); internal static ConfigEntry<float> LootShare; internal static ConfigEntry<float> CursedLootShare; internal static ConfigEntry<float> ClownLootShare; internal static ConfigEntry<bool> AirportEffects; internal static ConfigEntry<bool> AppleAftereffects; internal static ConfigEntry<string> GripTemplate; internal static ConfigEntry<bool> ShowInfo; internal static ConfigEntry<bool> DetailedInfo; internal static ConfigEntry<bool> ShowEffectTimers; private Harmony harmony; private bool ready; private bool failed; private bool externalInfo; private GameObject templates; private GUIStyle infoStyle; private Vector2 infoScroll; private SettingsWindow settingsWindow; private void Awake() { //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_0348: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; Root = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); ModSettings.Open(Root, ((BaseUnityPlugin)this).Config.ConfigFilePath); AcceptableValueRange<float> range = new AcceptableValueRange<float>(0f, 1f); LootShare = ModSettings.Bind("Loot", "MinecraftShare", 0.25f, "普通箱本模组食物占比:0 禁用,0.25=25%,1=仅本模组食品。不是每箱必出概率;仅房主影响后续生成。", "Ordinary chest mod-food share: 0=off, 0.25=25%, 1=mod foods only. Not a per-chest guarantee. Host controls future generation.", "通常の箱の食品比率:0=無効、0.25=25%、1=MOD食品のみ。箱ごとの保証ではなく、ホストが今後の生成に適用。", (AcceptableValueBase)(object)range); CursedLootShare = ModSettings.Bind("Loot", "CursedLuggageMinecraftShare", 0.35f, "诅咒箱占比,0~1;0.35=35%。仅房主影响后续生成。", "Cursed chest share, 0..1; 0.35=35%. Host affects future generation.", "呪いの箱の比率、0~1。0.35=35%。ホストが今後の生成に適用。", (AcceptableValueBase)(object)range); ClownLootShare = ModSettings.Bind("Loot", "ClownLuggageMinecraftShare", 0.3f, "小丑箱占比,0~1;0.30=30%。仅房主影响后续生成。", "Clown chest share, 0..1; 0.30=30%. Host affects future generation.", "ピエロの箱の比率、0~1。0.30=30%。ホストが今後の生成に適用。", (AcceptableValueBase)(object)range); AirportEffects = ModSettings.Bind("Effects", "AllowFoodEffectsInAirport", value: true, "在机场启用本模组食品状态效果,方便测试。", "Allow this mod's food status effects in the airport for testing.", "テスト用に空港内でも本MODの食品効果を有効化。"); AppleAftereffects = ModSettings.Bind("Effects", "GoldenAppleAftereffects", value: true, "金苹果无敌后睡意在6秒内逐渐升满,附魔为12秒;实际入睡后再维持6/12秒。关闭取消待触发或进行中的后遗症。", "After invincibility, drowsiness rises to maximum over 6s / 12s, then sleep lasts 6s / 12s from actual unconsciousness. Disabling cancels pending/active ramps.", "無敵終了後、6秒/12秒かけて眠気が最大まで上昇し、入眠後6秒/12秒維持。無効化で保留中・進行中の反動を中止。"); GripTemplate = ModSettings.Bind("Visuals", "GripTemplate", "TrailMix", "握持模板:TrailMix 混合坚果,SmallEgg 小煎蛋;修改后需重启游戏。", "Grip: TrailMix or SmallEgg. Restart the game after changing.", "持ち方:TrailMix または SmallEgg。変更後は再起動。", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[2] { "TrailMix", "SmallEgg" })); ShowInfo = ModSettings.Bind("UI", "ShowFoodInformation", value: true, "显示手持食品效果、重量和烹饪增量。", "Show held-food effects, weight and next-cook deltas.", "手持ち食品の効果・重量・次回調理の変化を表示。"); DetailedInfo = ModSettings.Bind("UI", "DetailedFoodInformation", value: false, "额外显示烧焦和烧毁次数。随机效果列表始终显示。", "Also show charring/destruction thresholds. Random effect lists are always shown.", "焦げ・燃え尽きの回数も表示。ランダム効果の一覧は常に表示。"); ShowEffectTimers = ModSettings.Bind("UI", "ShowEffectTimers", value: true, "显示本模组临时效果倒计时及剩余护盾。", "Show mod effect timers and remaining shield points.", "MOD効果の残り時間と残りシールドを表示。"); L10n.Language = L10n.Resolve(ModSettings.Language.Value, ((object)Unsafe.As<Language, Language>(ref LocalizedText.CURRENT_LANGUAGE)/*cast due to .constrained prefix*/).ToString()); try { Catalogue catalogue = JsonConvert.DeserializeObject<Catalogue>(File.ReadAllText(Path.Combine(Root, "catalogue.json"))); if (catalogue?.foods == null || catalogue.foods.Length == 0) { throw new InvalidDataException("catalogue.json contains no foods"); } foreach (FoodDefinition item in catalogue.foods.OrderBy<FoodDefinition, string>((FoodDefinition x) => x.id, StringComparer.Ordinal)) { if (string.IsNullOrEmpty(item.id) || Foods.ContainsKey(item.id) || item.scorch < 1 || item.wreck <= item.scorch || item.wreck > 12 || item.weight <= 0 || item.uses < 1) { throw new InvalidDataException("Invalid food definition: " + item.id); } Foods.Add(item.id, item); Visuals.TextureFor(item.texture); if (item.HasCooked) { Visuals.TextureFor(item.cookedTexture); } } ModSettings.BindFoods(Foods.Values); ValidateSettings(); settingsWindow = ((Component)this).gameObject.AddComponent<SettingsWindow>(); harmony = new Harmony("codex.peak.minecraftfoods"); harmony.PatchAll(); } catch (Exception ex) { failed = true; Log.LogError((object)("Minecraft Foods initialization failed: " + ex)); if (Environment.GetCommandLineArgs().Contains("--mcfoods-audit")) { Application.Quit(2); } } } private void Update() { RefreshLanguage(); if (ready || failed) { return; } ItemDatabase instance = SingletonAsset<ItemDatabase>.Instance; if ((Object)(object)instance == (Object)null || instance.itemLookup.Count < 50 || LocalizedText.mainTable == null) { return; } bool flag = Environment.GetCommandLineArgs().Contains("--mcfoods-audit"); try { Register(instance); ready = true; if (flag) { RuntimeAudit.Run(); } } catch (Exception ex) { failed = true; Log.LogError((object)("Food registration failed; fix before entering a multiplayer game: " + ex)); } finally { if (flag) { Application.Quit(failed ? 2 : 0); } } } private void Register(ItemDatabase db) { //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Expected O, but got Unknown //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0107: 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_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0589: Unknown result type (might be due to invalid IL or missing references) //IL_05bc: Unknown result type (might be due to invalid IL or missing references) //IL_05da: Unknown result type (might be due to invalid IL or missing references) //IL_06ca: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_0316: Unknown result type (might be due to invalid IL or missing references) //IL_031d: Unknown result type (might be due to invalid IL or missing references) //IL_0324: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Expected O, but got Unknown //IL_03fb: Unknown result type (might be due to invalid IL or missing references) //IL_03fc: Unknown result type (might be due to invalid IL or missing references) //IL_0409: Unknown result type (might be due to invalid IL or missing references) //IL_040e: Unknown result type (might be due to invalid IL or missing references) //IL_043b: Unknown result type (might be due to invalid IL or missing references) string wanted = ((GripTemplate.Value == "SmallEgg") ? "NestEgg_Raven" : "TrailMix"); Item val = ((IEnumerable<Item>)db.itemLookup.Values).FirstOrDefault((Func<Item, bool>)((Item x) => ((Object)x).name == wanted)) ?? ((IEnumerable<Item>)db.itemLookup.Values).FirstOrDefault((Func<Item, bool>)((Item x) => ((Object)x).name == "NestEgg_Raven")); if (!Object.op_Implicit((Object)(object)val)) { throw new InvalidOperationException("Neither TrailMix nor Small Egg template was found."); } templates = new GameObject("MinecraftFoods_PrefabStorage"); templates.SetActive(false); Object.DontDestroyOnLoad((Object)(object)templates); ModDefinition orCreate = ModDefinition.GetOrCreate(((BaseUnityPlugin)this).Info); SpawnPool val2 = (SpawnPool)0; foreach (SpawnPool value3 in Enum.GetValues(typeof(SpawnPool))) { if (((object)value3/*cast due to .constrained prefix*/).ToString().StartsWith("Luggage", StringComparison.Ordinal)) { val2 = (SpawnPool)(val2 | value3); } } foreach (FoodDefinition value4 in Foods.Values) { GameObject val4 = Object.Instantiate<GameObject>(((Component)val).gameObject, templates.transform, false); val4.SetActive(false); ((Object)val4).name = "MCFood_" + value4.id; ItemActionBase[] componentsInChildren = val4.GetComponentsInChildren<ItemActionBase>(true); for (int num = 0; num < componentsInChildren.Length; num++) { Object.DestroyImmediate((Object)(object)componentsInChildren[num]); } ItemComponent[] components = val4.GetComponents<ItemComponent>(); foreach (ItemComponent val5 in components) { if (!(val5 is ItemCooking)) { Object.DestroyImmediate((Object)(object)val5); } } Animator[] componentsInChildren2 = val4.GetComponentsInChildren<Animator>(true); for (int num = 0; num < componentsInChildren2.Length; num++) { Object.DestroyImmediate((Object)(object)componentsInChildren2[num]); } Item component = val4.GetComponent<Item>(); component.totalUses = ((value4.uses > 1) ? value4.uses : (-1)); component.data = null; component.isSecretlyOtherItemPrefab = null; component.canUseOnFriend = true; component.mustUseOnFriend = true; component.rightHandOnly = val.rightHandOnly; component.gliderHold = false; component.usingTimePrimary = ((value4.id == "honey_bottle") ? 2f : 1.6f); ItemUseFeedback component2 = val4.GetComponent<ItemUseFeedback>(); if (Object.op_Implicit((Object)(object)component2)) { component2.sfxUsed = null; } val4.AddComponent<FoodAudio>(); component.itemTags = (ItemTags)2; component.UIData = new ItemUIData { itemName = value4.name, icon = Visuals.IconFor(value4.texture), mainInteractPrompt = ((value4.id == "milk_bucket" || value4.id == "honey_bottle") ? "饮用" : "吃"), secondaryInteractPrompt = "喂食", hasSecondInteract = true, hideSecondInteract = false, hideFuel = (value4.uses == 1) }; LocalizeItem(component, value4); FoodMarker foodMarker = val4.AddComponent<FoodMarker>(); foodMarker.foodId = value4.id; Visuals.Build(component, foodMarker); ItemCooking val6 = val4.GetComponent<ItemCooking>() ?? val4.AddComponent<ItemCooking>(); val6.preCooked = 0; val6.wreckWhenCooked = false; val6.ignoreDefaultCookBehavior = true; val6.ignoreDefaultPoisonBehavior = true; val6.additionalCookingBehaviors = (AdditionalCookingBehavior[])(object)new AdditionalCookingBehavior[0]; AccessTools.Field(typeof(ItemCooking), "disableCooking").SetValue(val6, false); ((ItemAction)val4.AddComponent<FoodEatAction>()).OnCastFinished = true; if (value4.uses > 1) { val4.AddComponent<Action_ReduceUses>().consumeOnFullyUsed = true; } LootData obj = val4.GetComponent<LootData>() ?? val4.AddComponent<LootData>(); obj.spawnLocations = val2; obj.Rarity = RarityFor(value4.rarity); obj.banInSolo = false; obj.excludeBasedOnCustomRunSetting = false; obj.excludeFromCustomRunSelection = false; obj.useOtherItemForSpawningValidity = null; obj.rarityOverrides = new List<ItemRarityOverride>(); new ItemContent(component).Register(orCreate); if (!db.itemLookup.TryGetValue(component.itemID, out var value) || (Object)(object)value != (Object)(object)component) { throw new InvalidOperationException("PEAKLib did not register " + value4.id); } Registered.Add(component); } LootData.PopulateLootData(); InstallInfoIntegration(); Log.LogInfo((object)$"REGISTERED {Registered.Count} independent Minecraft foods; template={((Object)val).name}; no PeakCustomItemMod dependency."); List<string> list = new List<string> { "Minecraft Foods 1.26.0", "Grip template: " + ((Object)val).name, "Config: " + ModSettings.File.ConfigFilePath }; foreach (Item item in Registered) { FoodMarker component3 = ((Component)item).GetComponent<FoodMarker>(); object[] obj2 = new object[6] { component3.foodId, item.itemID, null, null, null, null }; Transform obj3 = item.transform.Find("Hand_L"); obj2[2] = ((obj3 != null) ? new Vector3?(obj3.localPosition) : ((Vector3?)null)); Transform obj4 = item.transform.Find("Hand_R"); obj2[3] = ((obj4 != null) ? new Vector3?(obj4.localPosition) : ((Vector3?)null)); obj2[4] = ((Component)component3.visual).transform.localPosition; obj2[5] = component3.meshSize; list.Add(string.Format("{0} ID={1} L={2} R={3} model={4} size={5:F3}", obj2)); } foreach (KeyValuePair<SpawnPool, Dictionary<ushort, int>> pool in LootData.AllSpawnWeightData.Where((KeyValuePair<SpawnPool, Dictionary<ushort, int>> x) => ((object)x.Key/*cast due to .constrained prefix*/).ToString().StartsWith("Luggage"))) { double num2 = ((IEnumerable<int>)pool.Value.Values).Sum((Func<int, double>)((int x) => x)); int value2; double num3 = Registered.Sum((Item i) => (!pool.Value.TryGetValue(i.itemID, out value2)) ? 0.0 : ((double)value2)); list.Add($"{pool.Key}: Minecraft {num3}/{num2} ({((num2 > 0.0) ? (num3 / num2) : 0.0):P2})"); foreach (IGrouping<string, Item> item2 in from i in Registered group i by LootPatch.LootTier(((Component)i).GetComponent<FoodMarker>().Definition, ((object)pool.Key/*cast due to .constrained prefix*/).ToString())) { double num4 = item2.Sum((Item i) => (!pool.Value.TryGetValue(i.itemID, out value2)) ? 0.0 : ((double)value2)); list.Add($" {item2.Key}: {num4} ({((num3 > 0.0) ? (num4 / num3) : 0.0):P2} within Minecraft foods)"); } } File.WriteAllLines(Path.Combine(Paths.BepInExRootPath, "MinecraftFoods-diagnostics.txt"), list); } private void ValidateSettings() { foreach (KeyValuePair<ConfigDefinition, ConfigEntryBase> item in ModSettings.File) { if (item.Value.BoxedValue is float f && (float.IsNaN(f) || float.IsInfinity(f))) { item.Value.BoxedValue = item.Value.DefaultValue; Log.LogWarning((object)("Reset non-finite setting: " + (object)item.Key)); } } } internal void ApplySettings() { ValidateSettings(); RefreshLanguage(); if (ready && SettingsWindow.Host) { LootData.PopulateLootData(); Log.LogInfo((object)"Loot settings rebuilt for future generation. Existing contents are unchanged."); } } internal static void LocalizeItem(Item item, FoodDefinition f) { item.UIData.itemName = L10n.FoodName(f.id, f.name); item.UIData.mainInteractPrompt = ((f.id == "milk_bucket" || f.id == "honey_bottle") ? L10n.T("饮用", "Drink", "飲む") : L10n.T("吃", "Eat", "食べる")); item.UIData.secondaryInteractPrompt = L10n.T("喂食", "Feed", "食べさせる"); } private void RefreshLanguage() { if (ModSettings.Language == null) { return; } string text = L10n.Resolve(ModSettings.Language.Value, ((object)Unsafe.As<Language, Language>(ref LocalizedText.CURRENT_LANGUAGE)/*cast due to .constrained prefix*/).ToString()); if (text == L10n.Language) { return; } L10n.Language = text; foreach (Item item in Registered) { LocalizeItem(item, ((Component)item).GetComponent<FoodMarker>().Definition); } FoodMarker[] array = Object.FindObjectsByType<FoodMarker>((FindObjectsSortMode)0); foreach (FoodMarker foodMarker in array) { if (foodMarker.Definition != null) { LocalizeItem(((Component)foodMarker).GetComponent<Item>(), foodMarker.Definition); } } InventoryItemUI[] array2 = Object.FindObjectsByType<InventoryItemUI>((FindObjectsSortMode)0); for (int i = 0; i < array2.Length; i++) { array2[i].UpdateNameText(); } } private static Rarity RarityFor(string rarity) { return (Rarity)(rarity switch { "uncommon" => 1, "rare" => 2, "epic" => 5, _ => 0, }); } private void InstallInfoIntegration() { //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Expected O, but got Unknown Type type = AccessTools.TypeByName("ItemInfoDisplay.Plugin"); MethodInfo methodInfo = ((type == null) ? null : AccessTools.Method(type, "ProcessItemGameObject", new Type[1] { typeof(Item) }, (Type[])null)); FieldInfo fieldInfo = ((type == null) ? null : AccessTools.Field(type, "itemInfoDisplayTextMesh")); if (!(methodInfo == null) && !(fieldInfo == null) && fieldInfo.IsStatic) { PropertyInfo propertyInfo = AccessTools.Property(fieldInfo.FieldType, "text"); if ((object)propertyInfo != null && propertyInfo.CanWrite) { harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(Plugin), "AfterExternalInfo", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); externalInfo = true; } } } private static bool AfterExternalInfo(Item __0) { FoodMarker foodMarker = (Object.op_Implicit((Object)(object)__0) ? ((Component)__0).GetComponent<FoodMarker>() : null); if (!Object.op_Implicit((Object)(object)foodMarker) || !ShowInfo.Value) { return true; } object obj = AccessTools.Field(AccessTools.TypeByName("ItemInfoDisplay.Plugin"), "itemInfoDisplayTextMesh")?.GetValue(null); if (obj == null) { Instance.externalInfo = false; return true; } Instance.externalInfo = true; AccessTools.Property(obj.GetType(), "text")?.SetValue(obj, Describe(foodMarker)); return false; } internal static string Describe(FoodMarker m) { return FoodInformation.Describe(m); } private void OnGUI() { //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Expected O, but got Unknown //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Expected O, but got Unknown //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Expected O, but got Unknown //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_022f: 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_024a: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) if (!ready || (Object.op_Implicit((Object)(object)settingsWindow) && ((MenuWindow)settingsWindow).isOpen)) { return; } Character localCharacter = Character.localCharacter; FoodMarker foodMarker = ((Object.op_Implicit((Object)(object)localCharacter) && Object.op_Implicit((Object)(object)localCharacter.data.currentItem)) ? ((Component)localCharacter.data.currentItem).GetComponent<FoodMarker>() : null); if (!Object.op_Implicit((Object)(object)localCharacter) || localCharacter.data.dead) { return; } if (infoStyle == null) { GUIStyle val = new GUIStyle(GUI.skin.label); val.richText = true; val.wordWrap = true; val.font = Font.CreateDynamicFontFromOSFont(new string[3] { "Microsoft YaHei", "Yu Gothic UI", "Arial" }, 18); val.normal.textColor = new Color(1f, 0.96f, 0.8f); infoStyle = val; } infoStyle.fontSize = Mathf.Clamp(Mathf.RoundToInt((float)Screen.height / 65f), 12, 25); if (ShowEffectTimers.Value) { FoodPlayerState component = ((Component)localCharacter).GetComponent<FoodPlayerState>(); string text = (Object.op_Implicit((Object)(object)component) ? component.CountdownText() : ""); if (text.Length > 0) { float num = (float)Screen.width * 0.29f; float num2 = infoStyle.CalcHeight(new GUIContent(text), num); GUI.Label(new Rect((float)Screen.width * 0.025f, (float)Screen.height * 0.16f, num, num2), text, infoStyle); } } if (Object.op_Implicit((Object)(object)foodMarker) && ShowInfo.Value && !externalInfo) { string text2 = Describe(foodMarker); float num3 = (float)Screen.width * 0.25f; float num4 = infoStyle.CalcHeight(new GUIContent(text2), num3 - 24f); float num5 = Mathf.Min(num4, (float)Screen.height * 0.52f); Rect val2 = default(Rect); ((Rect)(ref val2))..ctor((float)Screen.width * 0.64f, Mathf.Max(20f, (float)Screen.height * 0.78f - num5), num3, num5); if (num4 > num5) { infoScroll = GUI.BeginScrollView(val2, infoScroll, new Rect(0f, 0f, num3 - 24f, num4)); GUI.Label(new Rect(0f, 0f, num3 - 24f, num4), text2, infoStyle); GUI.EndScrollView(); } else { infoScroll = Vector2.zero; GUI.Label(val2, text2, infoStyle); } } } } internal static class RuntimeAudit { internal static void Run() { //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0566: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Invalid comparison between Unknown and I4 //IL_05b1: Unknown result type (might be due to invalid IL or missing references) //IL_05b6: Unknown result type (might be due to invalid IL or missing references) //IL_069c: Unknown result type (might be due to invalid IL or missing references) //IL_06a1: Unknown result type (might be due to invalid IL or missing references) //IL_086f: Unknown result type (might be due to invalid IL or missing references) //IL_0874: Unknown result type (might be due to invalid IL or missing references) //IL_07a0: Unknown result type (might be due to invalid IL or missing references) //IL_07a5: Unknown result type (might be due to invalid IL or missing references) //IL_07d2: Unknown result type (might be due to invalid IL or missing references) List<string> list = new List<string>(); int checks = 0; Check(Plugin.Registered.Count == 34, "34 registered foods"); foreach (Item item in Plugin.Registered) { FoodMarker component = ((Component)item).GetComponent<FoodMarker>(); FoodDefinition definition = component.Definition; Check((Object)(object)((Component)item).GetComponent<FoodEatAction>() != (Object)null, definition.id + " consume action"); Check(((Component)item).GetComponents<ItemActionBase>().All((ItemActionBase x) => x is FoodEatAction || x is Action_ReduceUses), definition.id + " no inherited effects"); Check(((Component)item).GetComponentsInChildren<MeshRenderer>(true).Length == 1, definition.id + " only Minecraft mesh"); Check(((Component)item).GetComponentsInChildren<Collider>(true).Length == 1, definition.id + " one matching collider"); Check(Vector3.Angle(((Component)component.visual).transform.localRotation * Vector3.forward, Vector3.forward) < 0.01f, definition.id + " front facing root"); Check(Mathf.Abs(item.transform.Find("Hand_R").localPosition.x - item.transform.Find("Hand_L").localPosition.x) < 0.5f, definition.id + " narrow grip"); Check(NetworkPrefabExists(item), definition.id + " network prefab"); for (int num = 0; num <= 12; num++) { Check(!definition.NameAt(num).Contains("LOC:") && !definition.NameAt(num).Contains("NAME_"), definition.id + " localized name"); Check(definition.HungerAt(num) >= 0f && definition.HungerAt(num) <= 100f && definition.BonusAt(num) >= 0f && definition.BonusAt(num) <= 100f, definition.id + " valid nutrition"); Check(Visuals.MeshFor(definition.TextureAt(num)).vertexCount > 0, definition.id + " mesh"); Check((int)((Texture)Visuals.TextureFor(definition.TextureAt(num))).filterMode == 0, definition.id + " sharp texture"); Check(num < definition.wreck || definition.HungerAt(num) == 0f, definition.id + " wreck nutrition"); Check(num < definition.wreck || !definition.EffectsAt(num).AllEffects.Any(), definition.id + " wreck effects disabled"); foreach (FoodEffect allEffect in definition.EffectsAt(num).AllEffects) { Check(!string.IsNullOrEmpty(allEffect.Describe()), definition.id + " effect description"); } if (definition.HasCooked && num == 1) { Check(definition.NameAt(num) == L10n.FoodName(definition.cookedTexture, definition.cookedName), definition.id + " cooked name"); } } GameObject val = Object.Instantiate<GameObject>(((Component)item).gameObject); val.SetActive(false); Item component2 = val.GetComponent<Item>(); ItemCooking component3 = val.GetComponent<ItemCooking>(); ((ItemComponent)component3).item = component2; for (int num2 = 0; num2 <= 12; num2++) { component2.GetData<IntItemData>((DataEntryKey)1).Value = num2; component3.UpdateCookedBehavior(); Check(component2.GetItemName((ItemInstanceData)null) == definition.NameAt(num2), definition.id + " patched cooked name"); Check(num2 < definition.wreck || !component2.CanUsePrimary(), definition.id + " native wreck disables use"); } Object.Destroy((Object)(object)val); list.Add("PASS " + definition.id + " stages 0..12, hand anchors, mesh, texture, network registration, native burn-disable"); } LootData.PopulateLootData(); Dictionary<SpawnPool, Dictionary<ushort, int>> dictionary = LootData.AllSpawnWeightData.ToDictionary((KeyValuePair<SpawnPool, Dictionary<ushort, int>> p) => p.Key, (KeyValuePair<SpawnPool, Dictionary<ushort, int>> p) => p.Value.ToDictionary((KeyValuePair<ushort, int> x) => x.Key, (KeyValuePair<ushort, int> x) => x.Value)); LootData.PopulateLootData(); Check(dictionary.Count == LootData.AllSpawnWeightData.Count, "repeat initialization pool count"); foreach (