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 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.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.25.0.0")]
[assembly: AssemblyInformationalVersion("1.25.0+590e738a0498231fa64584299702b4e020338601")]
[assembly: AssemblyProduct("MinecraftFoods")]
[assembly: AssemblyTitle("MinecraftFoods")]
[assembly: AssemblyVersion("1.25.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_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Expected O, but got Unknown
Character val = (Object.op_Implicit((Object)(object)item) ? item.trueHolderCharacter : null);
int num;
if (Object.op_Implicit((Object)(object)val) && val.IsLocal && !item.finishedCast && !item.consuming)
{
if (!item.isUsingPrimary)
{
num = (item.isUsingSecondary ? 1 : 0);
if (num == 0)
{
goto IL_0160;
}
}
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_0160;
IL_0160:
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 = (Cooked(stage) ? cookedName : name);
if (stage >= wreck)
{
return text + "(烧毁,不能食用)";
}
if (stage >= scorch)
{
return text + "(烧焦)";
}
if (stage <= 0 || HasCooked)
{
return text;
}
return text + "(加热" + 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.3f * (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;
}
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);
}
}
}
}
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 && Object.op_Implicit((Object)(object)component) && !((ItemActionBase)this).item.consuming && !(Time.time - lastUse < 0.3f) && component.Stage < component.Definition.wreck && (((ItemActionBase)this).item.totalUses <= 0 || ((ItemActionBase)this).item.GetData<OptionableIntItemData>((DataEntryKey)2).Value > 0))
{
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 float remaining;
internal float rate;
internal bool healing;
}
internal float Shield;
private float shieldUntil;
private float resistUntil;
private float fireUntil;
private float afterAt;
private float afterAmount;
private float nextTeleport;
private Character character;
private readonly Dictionary<string, TimedStatus> timers = new Dictionary<string, TimedStatus>();
private float tick;
private static readonly FieldInfo Airport = AccessTools.Field(typeof(CharacterAfflictions), "m_inAirport");
internal static bool InAirport(CharacterAfflictions a)
{
return (bool)Airport.GetValue(a);
}
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);
bool flag = stage < f.scorch;
switch (f.id)
{
case "pufferfish":
Apply((STATUSTYPE)3, 0.3f + 0.025f * (float)stage);
Timed("puffer-poison", (STATUSTYPE)3, 60f, 0.35f + 0.05f * (float)stage);
Timed("puffer-hunger", (STATUSTYPE)1, 15f, 0.15f);
Apply((STATUSTYPE)6, 0.1f);
Timed("puffer-nausea", (STATUSTYPE)6, 15f, 0.1f);
break;
case "rotten_flesh":
if (Random.value < 0.8f)
{
Timed("rotten-hunger", (STATUSTYPE)1, 30f, 0.2f);
}
if (stage > 0)
{
Apply((STATUSTYPE)3, Mathf.Min(0.5f, 0.05f * (float)stage));
}
break;
case "spider_eye":
Apply((STATUSTYPE)3, 0.05f + 0.025f * (float)stage);
Timed("spider-poison", (STATUSTYPE)3, 4f, 0.05f + 0.025f * (float)stage);
break;
case "poisonous_potato":
if (Random.value < 0.6f)
{
Apply((STATUSTYPE)3, 0.05f + 0.025f * (float)stage);
Timed("potato-poison", (STATUSTYPE)3, 5f, 0.05f + 0.025f * (float)stage);
}
break;
case "chicken":
if (stage == 0 && Random.value < 0.3f)
{
Apply((STATUSTYPE)3, 0.12f);
}
break;
case "mutton":
case "rabbit":
case "beef":
case "porkchop":
if (stage == 0 && Random.value < 0.15f)
{
Apply((STATUSTYPE)3, 0.08f);
}
break;
case "salmon":
case "cod":
case "tropical_fish":
if (stage == 0 && Random.value < 0.2f)
{
Apply((STATUSTYPE)3, 0.1f);
}
break;
case "honey_bottle":
if (flag)
{
ClearPoison();
}
break;
case "milk_bucket":
if (flag)
{
Milk();
}
break;
case "golden_apple":
if (flag)
{
Golden(enchanted: false);
}
break;
case "enchanted_golden_apple":
if (flag)
{
Golden(enchanted: true);
}
break;
case "chorus_fruit":
if (flag)
{
Teleport();
}
break;
case "suspicious_stew":
if (flag)
{
Stew();
}
break;
}
if (f.BurnPoisonAt(stage) > 0f)
{
Apply((STATUSTYPE)3, f.BurnPoisonAt(stage));
}
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_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
float num = total / seconds;
if (timers.TryGetValue(key, out var value))
{
seconds = Mathf.Max(seconds, value.remaining);
num = Mathf.Max(num, value.rate);
}
timers[key] = new TimedStatus
{
status = status,
remaining = seconds,
rate = num,
healing = heal
};
}
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 Golden(bool enchanted)
{
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Expected O, but got Unknown
float num = (enchanted ? 12 : 5);
CharacterAfflictions afflictions = character.refs.afflictions;
Affliction val = default(Affliction);
if (!afflictions.HasAfflictionType((AfflictionType)16, ref val) || val.totalTime - val.timeElapsed < num)
{
afflictions.AddAffliction((Affliction)new Affliction_Invincibility
{
totalTime = num
}, false);
}
else
{
num = val.totalTime - val.timeElapsed;
}
Shield = Mathf.Max(Shield, enchanted ? 0.8f : 0.2f);
shieldUntil = Time.time + 60f;
Timed("regeneration", (STATUSTYPE)0, enchanted ? 20 : 5, enchanted ? 0.8f : 0.2f, heal: true);
if (enchanted)
{
resistUntil = Time.time + 60f;
fireUntil = Time.time + 60f;
}
if (Plugin.AppleAftereffects.Value)
{
afterAmount = Mathf.Max((afterAt > Time.time) ? afterAmount : 0f, enchanted ? 6f : 3f);
afterAt = Mathf.Max(afterAt, Time.time + num);
}
}
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()
{
timers.Clear();
Shield = 0f;
shieldUntil = (resistUntil = (fireUntil = (afterAt = (afterAmount = 0f))));
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 Stew()
{
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Expected O, but got Unknown
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Expected O, but got Unknown
switch (Random.Range(0, 8))
{
case 0:
Timed("regeneration", (STATUSTYPE)0, 8f, 0.15f, heal: true);
break;
case 1:
character.AddExtraStamina(0.2f);
break;
case 2:
character.refs.afflictions.AddAffliction((Affliction)new Affliction_LowGravity(1, 6f), false);
break;
case 3:
fireUntil = Mathf.Max(fireUntil, Time.time + 4f);
break;
case 4:
character.refs.afflictions.AddAffliction((Affliction)new Affliction_Blind
{
totalTime = 8f
}, false);
break;
case 5:
Apply((STATUSTYPE)3, 0.05f);
Timed("stew-poison", (STATUSTYPE)3, 12f, 0.15f);
break;
case 6:
Apply((STATUSTYPE)6, 0.1f);
break;
case 7:
Timed("stew-wither", (STATUSTYPE)0, 8f, 0.15f);
break;
}
}
private unsafe void Teleport()
{
//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_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: 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_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: 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_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: 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_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_0128: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: Unknown result type (might be due to invalid IL or missing references)
//IL_0140: Unknown result type (might be due to invalid IL or missing references)
//IL_014a: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Unknown result type (might be due to invalid IL or missing references)
//IL_022c: 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 * 8f;
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 });
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 *= 0.8f;
}
if (Time.time < shieldUntil)
{
float num = Mathf.Min(Shield, amount);
Shield -= num;
amount -= num;
}
}
}
private void Update()
{
//IL_019e: Unknown result type (might be due to invalid IL or missing references)
//IL_0183: 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)
{
timers.Clear();
Shield = 0f;
afterAt = (resistUntil = (fireUntil = (shieldUntil = 0f)));
return;
}
if (Time.time >= shieldUntil)
{
Shield = 0f;
}
Affliction val = default(Affliction);
if (afterAt > 0f && Time.time >= afterAt && !character.refs.afflictions.HasAfflictionType((AfflictionType)16, ref val))
{
afterAt = 0f;
((MonoBehaviourPun)character).photonView.RPC("RPCA_Fall", (RpcTarget)0, new object[2] { afterAmount, 0f });
}
tick += Time.deltaTime;
if (tick < 0.25f)
{
return;
}
float num = tick;
tick = 0f;
string[] array = timers.Keys.ToArray();
foreach (string key in array)
{
TimedStatus timedStatus = timers[key];
float num2 = Mathf.Min(num, timedStatus.remaining);
if (timedStatus.healing)
{
character.refs.afflictions.SubtractStatus(timedStatus.status, timedStatus.rate * num2, false, false);
}
else
{
Apply(timedStatus.status, timedStatus.rate * num2);
}
timedStatus.remaining -= num2;
if (timedStatus.remaining <= 0f)
{
timers.Remove(key);
}
}
}
}
internal static class FoodInformation
{
private static string Good(string s)
{
return "<color=#9CDF62>" + s + "</color>";
}
private static string Bad(string s)
{
return "<color=#BF68E6>" + s + "</color>";
}
private static string Special(FoodDefinition f, int s)
{
if (s >= f.wreck)
{
return "";
}
switch (f.id)
{
case "pufferfish":
return Bad($"获得 {30f + 2.5f * (float)s:0.#} 点中毒;60 秒内再累积 {35 + 5 * s} 点中毒\n15 秒内增加 15 点饥饿、20 点嗜睡(其中 10 点立即生效)");
case "rotten_flesh":
return Bad("80% 概率在 30 秒内增加 20 点饥饿" + ((s > 0) ? $";增加 {Mathf.Min(50, 5 * s)} 点中毒" : ""));
case "spider_eye":
return Bad($"立即增加 {5f + 2.5f * (float)s:0.#} 点中毒,4 秒内再增加 {5f + 2.5f * (float)s:0.#} 点");
case "poisonous_potato":
return Bad($"60% 概率立即增加 {5f + 2.5f * (float)s:0.#} 点中毒,5 秒内再增加 {5f + 2.5f * (float)s:0.#} 点");
case "chicken":
if (s != 0)
{
return "";
}
return Bad("30% 概率增加 12 点中毒;烤熟消除生食风险");
case "mutton":
case "rabbit":
case "beef":
case "porkchop":
if (s != 0)
{
return "";
}
return Bad("15% 概率增加 8 点中毒;烤熟消除生食风险");
case "salmon":
case "cod":
if (s != 0)
{
return "";
}
return Bad("20% 概率增加 10 点中毒;烤熟消除生食风险");
case "tropical_fish":
if (s != 0)
{
return "";
}
return Bad("20% 概率增加 10 点中毒;加热消除生食风险");
default:
if (s >= f.scorch)
{
if (!(f.id == "golden_apple") && !(f.id == "enchanted_golden_apple") && !(f.id == "milk_bucket") && !(f.id == "honey_bottle") && !(f.id == "chorus_fruit") && !(f.id == "suspicious_stew"))
{
return "";
}
return Bad("烧焦:特殊效果已失效");
}
return f.id switch
{
"golden_apple" => Good("获得 5 秒无敌;5 秒内移除 20 点受伤\n获得 20 点受伤吸收盾,持续 60 秒") + (Plugin.AppleAftereffects.Value ? ("\n" + Bad("无敌结束后:彻底眩晕、倒地失控 3 秒")) : ""),
"enchanted_golden_apple" => Good("获得 12 秒无敌;20 秒内移除 80 点受伤\n获得 80 点受伤吸收盾,持续 60 秒\n60 秒内受伤减少 20%,免疫炎热增长") + (Plugin.AppleAftereffects.Value ? ("\n" + Bad("无敌结束后:彻底眩晕、倒地失控 6 秒")) : ""),
"honey_bottle" => Good("移除全部中毒及本模组持续中毒;同时清除孢子"),
"milk_bucket" => Good("清除临时效果、全部中毒与嗜睡") + "\n" + Bad("同时移除无敌、吸收盾等正面效果"),
"chorus_fruit" => Good("随机传送至水平 8 米内安全落脚点;无落脚点则留在原地"),
"suspicious_stew" => "随机获得以下之一(每项 12.5%):\n" + Good("8 秒恢复 15 点受伤/20 点额外体力/6 秒低重力/4 秒免疫炎热增长") + "\n" + Bad("8 秒失明/5 点中毒并在 12 秒内再增加 15 点/10 点嗜睡/8 秒内增加 15 点受伤"),
_ => "",
};
}
}
internal static string Describe(FoodMarker m)
{
FoodDefinition definition = m.Definition;
if (definition == null)
{
return "";
}
int stage = m.Stage;
StringBuilder stringBuilder = new StringBuilder();
if (stage >= definition.wreck)
{
return Bad("已烧毁,无法食用") + "\n" + definition.description;
}
stringBuilder.AppendLine(Good($"移除 {definition.HungerAt(stage):0.#} 点饥饿值"));
if (definition.BonusAt(stage) > 0f)
{
stringBuilder.AppendLine(Good($"获得 {definition.BonusAt(stage):0.#} 点额外体力"));
}
string text = Special(definition, stage);
if (text.Length > 0)
{
stringBuilder.AppendLine(text);
}
if (definition.BurnPoisonAt(stage) > 0f)
{
stringBuilder.AppendLine(Bad($"烧焦额外增加 {definition.BurnPoisonAt(stage) * 100f:0.#} 点中毒"));
}
Item component = ((Component)m).GetComponent<Item>();
stringBuilder.AppendLine($"<color=#B87838>{(float)component.CarryWeight * 2.5f:0.#} 重量</color>");
stringBuilder.AppendLine($"已烹饪 {stage} 次;{definition.scorch} 次起烧焦,{definition.wreck} 次烧毁");
if (stage + 1 >= definition.wreck)
{
stringBuilder.AppendLine(Bad("下次烹饪:烧毁,无法食用"));
}
else
{
stringBuilder.AppendLine("下次烹饪:" + definition.NameAt(stage + 1));
stringBuilder.AppendLine(Good($"· 移除 {definition.HungerAt(stage + 1):0.#} 点饥饿;获得 {definition.BonusAt(stage + 1):0.#} 点额外体力"));
if (definition.BurnPoisonAt(stage + 1) > 0f)
{
stringBuilder.AppendLine(Bad($"· 烧焦附加 {definition.BurnPoisonAt(stage + 1) * 100f:0.#} 点中毒"));
}
if (definition.id == "pufferfish" || definition.id == "rotten_flesh" || definition.id == "spider_eye" || definition.id == "poisonous_potato")
{
stringBuilder.AppendLine(Bad("· 有毒食物加热后毒性继续增加"));
}
}
if (definition.uses > 1)
{
stringBuilder.AppendLine($"可食用 {definition.uses} 次,以上为每次效果");
}
return stringBuilder.ToString().TrimEnd();
}
}
[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_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
if (Plugin.Registered.Count == 0 || LootData.AllSpawnWeightData == null)
{
return;
}
double num = Plugin.LootShare.Value;
Dictionary<ushort, int> dictionary = Plugin.Registered.ToDictionary((Item x) => x.itemID, (Item x) => ((Component)x).GetComponent<FoodMarker>().Definition.weight);
double num2 = dictionary.Values.Sum();
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;
}
foreach (ushort key2 in dictionary.Keys)
{
allSpawnWeightDatum.Value.Remove(key2);
}
if (num <= 0.0)
{
continue;
}
ushort[] array = allSpawnWeightDatum.Value.Keys.ToArray();
foreach (ushort key in array)
{
allSpawnWeightDatum.Value[key] *= 128;
}
double num4 = ((IEnumerable<int>)allSpawnWeightDatum.Value.Values).Sum((Func<int, double>)((int x) => x));
double num5 = num4 * num / (1.0 - num);
if (num4 == 0.0)
{
num5 = num2;
}
foreach (KeyValuePair<ushort, int> item in dictionary)
{
allSpawnWeightDatum.Value[item.Key] = Math.Max(1, (int)Math.Round(num5 * (double)item.Value / num2));
}
}
}
}
[BepInPlugin("codex.peak.minecraftfoods", "Minecraft Foods", "1.25.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<bool> AirportEffects;
internal static ConfigEntry<bool> AppleAftereffects;
internal static ConfigEntry<string> GripTemplate;
internal static ConfigEntry<bool> ShowInfo;
private Harmony harmony;
private bool ready;
private bool failed;
private bool externalInfo;
private GameObject templates;
private GUIStyle infoStyle;
private void Awake()
{
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Expected O, but got Unknown
//IL_0219: Unknown result type (might be due to invalid IL or missing references)
//IL_0223: Expected O, but got Unknown
Instance = this;
Log = ((BaseUnityPlugin)this).Logger;
Root = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
LootShare = ((BaseUnityPlugin)this).Config.Bind<float>("Loot", "MinecraftShare", 0.25f, new ConfigDescription("Minecraft food share per ordinary luggage slot. Host setting; restart for changes.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 0.8f), Array.Empty<object>()));
AirportEffects = ((BaseUnityPlugin)this).Config.Bind<bool>("Effects", "AllowFoodEffectsInAirport", true, "Allow only this mod's food effects in the airport, for testing. Does not unlock environmental damage.");
AppleAftereffects = ((BaseUnityPlugin)this).Config.Bind<bool>("Effects", "GoldenAppleAftereffects", true, "Golden/enchanted apple: 3/6 seconds of complete knockdown after invulnerability ends.");
GripTemplate = ((BaseUnityPlugin)this).Config.Bind<string>("Visuals", "GripTemplate", "TrailMix", "TrailMix (recommended) or SmallEgg. Restart after changing.");
ShowInfo = ((BaseUnityPlugin)this).Config.Bind<bool>("UI", "ShowFoodInformation", true, "Show names, nutrition, effects and cooking thresholds; independent of other personal mods.");
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);
}
}
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()
{
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_0581: Unknown result type (might be due to invalid IL or missing references)
//IL_05b4: Unknown result type (might be due to invalid IL or missing references)
//IL_05d2: Unknown result type (might be due to invalid IL or missing references)
//IL_06c2: 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_03f2: Unknown result type (might be due to invalid IL or missing references)
//IL_03f3: Unknown result type (might be due to invalid IL or missing references)
//IL_0400: Unknown result type (might be due to invalid IL or missing references)
//IL_0405: Unknown result type (might be due to invalid IL or missing references)
//IL_0432: 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)
};
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.25.0",
"Grip template: " + ((Object)val).name,
"Config: " + ((BaseUnityPlugin)this).Config.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})");
}
File.WriteAllLines(Path.Combine(Paths.BepInExRootPath, "MinecraftFoods-diagnostics.txt"), list);
}
private static Rarity RarityFor(string rarity)
{
return (Rarity)(rarity switch
{
"uncommon" => 1,
"rare" => 2,
"epic" => 5,
_ => 0,
});
}
private void InstallInfoIntegration()
{
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: 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));
if (!(methodInfo == null))
{
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)
{
return 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_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: Expected O, but got Unknown
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: 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_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Expected O, but got Unknown
if (!ready || !ShowInfo.Value || externalInfo)
{
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)foodMarker))
{
if (infoStyle == null)
{
GUIStyle val = new GUIStyle(GUI.skin.label)
{
richText = true,
wordWrap = true,
font = Font.CreateDynamicFontFromOSFont("Microsoft YaHei", 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);
string text = Describe(foodMarker);
float num = (float)Screen.width * 0.31f;
float num2 = infoStyle.CalcHeight(new GUIContent(text), num);
GUI.Label(new Rect((float)Screen.width * 0.67f, Mathf.Max(20f, (float)Screen.height * 0.8f - num2), num, num2), text, 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_04f8: Unknown result type (might be due to invalid IL or missing references)
//IL_04fd: Unknown result type (might be due to invalid IL or missing references)
//IL_052a: 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
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");
if (definition.HasCooked && num == 1)
{
Check(definition.NameAt(num) == 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();
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 num3 = ((IEnumerable<int>)pool.Value.Values).Sum((Func<int, double>)((int x) => x));
int value;
double num4 = Plugin.Registered.Sum((Item x) => (!pool.Value.TryGetValue(x.itemID, out value)) ? 0.0 : ((double)value));
Check(Math.Abs(num4 / num3 - (double)Plugin.LootShare.Value) < 0.002, ((object)pool.Key/*cast due to .constrained prefix*/).ToString() + " loot fraction");
list.Add($"PASS {pool.Key}: {num4 / num3:P4} Minecraft share");
}
list.Add($"PASS {checks} runtime assertions. No player/world gameplay was exercised.");
File.WriteAllLines(Path.Combine(Paths.BepInExRootPath, "MinecraftFoods-audit.txt"), list);
Plugin.Log.LogInfo((object)list.Last());
void Check(bool condition, string label)
{
checks++;
if (!condition)
{
throw new InvalidOperationException("AUDIT FAIL: " + label);
}
}
}
private static bool NetworkPrefabExists(Item item)
{
return NetworkPrefabManager.HasNetworkPrefab("0_Items/" + ((Object)item).name);
}
}
internal static class Visuals
{
private static readonly Dictionary<string, Texture2D> textures = new Dictionary<string, Texture2D>();
private static readonly Dictionary<string, Mesh> meshes = new Dictionary<string, Mesh>();
private static readonly Dictionary<string, Material> materials = new Dictionary<string, Material>();
internal static Texture2D TextureFor(string id)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Expected O, but got Unknown
if (textures.TryGetValue(id, out var value))
{
return value;
}
Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false, false)
{
name = "MC_" + id
};
if (!ImageConversion.LoadImage(val, File.ReadAllBytes(Path.Combine(Plugin.Root, "textures", id + ".png")), false))
{
throw new InvalidDataException(id);
}
((Texture)val).filterMode = (FilterMode)0;
((Texture)val).wrapMode = (TextureWrapMode)1;
((Texture)val).anisoLevel = 0;
textures[id] = val;
return val;
}
internal static Texture2D IconFor(string id)
{
return TextureFor(id);
}
internal static Material MaterialFor(string id, Color tint)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Expected O, but got Unknown
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
string text = id + ColorUtility.ToHtmlStringRGBA(tint);
if (materials.TryGetValue(text, out var value))
{
return value;
}
Shader obj = Shader.Find("Universal Render Pipeline/Unlit") ?? Shader.Find("Unlit/Texture");
if (!Object.op_Implicit((Object)(object)obj))
{
throw new InvalidOperationException("No unlit item shader available.");
}
value = new Material(obj)
{
name = "MC_" + text,
mainTexture = (Texture)(object)TextureFor(id)
};
if (value.HasProperty("_BaseMap"))
{
value.SetTexture("_BaseMap", (Texture)(object)TextureFor(id));
}
if (value.HasProperty("_BaseColor"))
{
value.SetColor("_BaseColor", tint);
}
if (value.HasProperty("_Color"))
{
value.SetColor("_Color", tint);
}
if (value.HasProperty("_Surface"))
{
value.SetFloat("_Surface", 0f);
}
if (value.HasProperty("_Cull"))
{
value.SetFloat("_Cull", 0f);
}
value.renderQueue = 2000;
materials[text] = value;
return value;
}
internal static void Build(Item item, FoodMarker marker)
{
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: 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_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0121: Unknown result type (might be due to invalid IL or missing references)
//IL_0128: Expected O, but got Unknown
//IL_014f: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: Unknown result type (might be due to invalid IL or missing references)
//IL_0164: Unknown result type (might be due to invalid IL or missing references)
//IL_0175: Unknown result type (might be due to invalid IL or missing references)
//IL_0186: Unknown result type (might be due to invalid IL or missing references)
//IL_018d: Unknown result type (might be due to invalid IL or missing references)
//IL_01ea: 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_01f3: Unknown result type (might be due to invalid IL or missing references)
//IL_0208: Unknown result type (might be due to invalid IL or missing references)
//IL_020d: Unknown result type (might be due to invalid IL or missing references)
//IL_0211: Unknown result type (might be due to invalid IL or missing references)
//IL_0226: 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)
//IL_022f: Unknown result type (might be due to invalid IL or missing references)
//IL_023e: Unknown result type (might be due to invalid IL or missing references)
Transform transform = item.transform;
Transform val = transform.Find("Hand_L");
Transform val2 = transform.Find("Hand_R");
if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val2))
{
throw new InvalidOperationException("Native hand anchors missing: " + ((Object)item).name);
}
Vector3 val3 = (val.localPosition + val2.localPosition) * 0.5f;
float num = Mathf.Clamp(Mathf.Abs(val2.localPosition.x - val.localPosition.x) + 0.065f, 0.18f, 0.52f);
Renderer[] componentsInChildren = ((Component)transform).GetComponentsInChildren<Renderer>(true);
foreach (Renderer val4 in componentsInChildren)
{
if (val4 is MeshRenderer || val4 is SkinnedMeshRenderer)
{
Object.DestroyImmediate((Object)(object)val4);
}
}
MeshFilter[] componentsInChildren2 = ((Component)transform).GetComponentsInChildren<MeshFilter>(true);
for (int i = 0; i < componentsInChildren2.Length; i++)
{
Object.DestroyImmediate((Object)(object)componentsInChildren2[i]);
}
Collider[] componentsInChildren3 = ((Component)transform).GetComponentsInChildren<Collider>(true);
for (int i = 0; i < componentsInChildren3.Length; i++)
{
Object.DestroyImmediate((Object)(object)componentsInChildren3[i]);
}
GameObject val5 = new GameObject("MinecraftFoodVisual");
val5.layer = ((Component)item).gameObject.layer;
val5.transform.SetParent(transform, false);
val5.transform.localPosition = val3 + new Vector3(0f, 0.015f, 0.035f);
val5.transform.localRotation = Quaternion.identity;
val5.transform.localScale = Vector3.one * num;
marker.mesh = val5.AddComponent<MeshFilter>();
marker.visual = val5.AddComponent<MeshRenderer>();
marker.meshSize = num;
((Renderer)marker.visual).shadowCastingMode = (ShadowCastingMode)0;
((Renderer)marker.visual).receiveShadows = false;
marker.Refresh();
BoxCollider obj = val5.AddComponent<BoxCollider>();
Bounds bounds = marker.mesh.sharedMesh.bounds;
obj.center = ((Bounds)(ref bounds)).center;
bounds = marker.mesh.sharedMesh.bounds;
float x = ((Bounds)(ref bounds)).size.x;
bounds = marker.mesh.sharedMesh.bounds;
obj.size = new Vector3(x, ((Bounds)(ref bounds)).size.y, 0.09f);
item.mainRenderer = (Renderer)(object)marker.visual;
item.addtlRenderers = (Renderer[])(object)new Renderer[0];
item.offsetLuggageSpawn = false;
item.forceScale = true;
}
internal static Mesh MeshFor(string id)
{
//IL_0359: Unknown result type (might be due to invalid IL or missing references)
//IL_035e: Unknown result type (might be due to invalid IL or missing references)
//IL_0370: Expected O, but got Unknown
//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
//IL_01e6: 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_0200: 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_0216: Unknown result type (might be due to invalid IL or missing references)
//IL_021b: Unknown result type (might be due to invalid IL or missing references)
//IL_0239: Unknown result type (might be due to invalid IL or missing references)
//IL_0244: Unknown result type (might be due to invalid IL or missing references)
//IL_0250: Unknown result type (might be due to invalid IL or missing references)
//IL_025c: Unknown result type (might be due to invalid IL or missing references)
//IL_0261: Unknown result type (might be due to invalid IL or missing references)
//IL_0280: Unknown result type (might be due to invalid IL or missing references)
//IL_028c: Unknown result type (might be due to invalid IL or missing references)
//IL_0297: Unknown result type (might be due to invalid IL or missing references)
//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
//IL_030c: Unknown result type (might be due to invalid IL or missing references)
//IL_0317: Unknown result type (might be due to invalid IL or missing references)
//IL_0322: Unknown result type (might be due to invalid IL or missing references)
//IL_032e: Unknown result type (might be due to invalid IL or missing references)
//IL_0333: Unknown result type (might be due to invalid IL or missing references)
if (meshes.TryGetValue(id, out var value))
{
return value;
}
Texture2D t = TextureFor(id);
Color32[] pixels = t.GetPixels32();
int num = ((Texture)t).width;
int num2 = -1;
int num3 = ((Texture)t).height;
int num4 = -1;
for (int i = 0; i < ((Texture)t).height; i++)
{
for (int j = 0; j < ((Texture)t).width; j++)
{
if (pixels[i * ((Texture)t).width + j].a > 127)
{
num = Math.Min(num, j);
num2 = Math.Max(num2, j);
num3 = Math.Min(num3, i);
num4 = Math.Max(num4, i);
}
}
}
if (num2 < num)
{
throw new InvalidDataException("Empty texture: " + id);
}
List<Vector3> vertices = new List<Vector3>();
List<Vector2> uv = new List<Vector2>();
List<int> indices = new List<int>();
float num5 = 1f / (float)(num2 - num + 1);
float num6 = (float)(num + num2 + 1) * 0.5f;
float num7 = (float)(num3 + num4 + 1) * 0.5f;
float num8 = num5 * 0.5f;
Vector2 p = default(Vector2);
for (int k = num3; k <= num4; k++)
{
for (int l = num; l <= num2; l++)
{
if (Solid(l, k))
{
float num9 = ((float)l - num6) * num5;
float num10 = num9 + num5;
float num11 = ((float)k - num7) * num5;
float num12 = num11 + num5;
((Vector2)(ref p))..ctor(((float)l + 0.5f) / (float)((Texture)t).width, ((float)k + 0.5f) / (float)((Texture)t).height);
Face(new Vector3(num9, num11, 0f - num8), new Vector3(num9, num12, 0f - num8), new Vector3(num10, num12, 0f - num8), new Vector3(num10, num11, 0f - num8), p);
Face(new Vector3(num10, num11, num8), new Vector3(num10, num12, num8), new Vector3(num9, num12, num8), new Vector3(num9, num11, num8), p);
if (!Solid(l - 1, k))
{
Face(new Vector3(num9, num11, num8), new Vector3(num9, num12, num8), new Vector3(num9, num12, 0f - num8), new Vector3(num9, num11, 0f - num8), p);
}
if (!Solid(l + 1, k))
{
Face(new Vector3(num10, num11, 0f - num8), new Vector3(num10, num12, 0f - num8), new Vector3(num10, num12, num8), new Vector3(num10, num11, num8), p);
}
if (!Solid(l, k - 1))
{
Face(new Vector3(num9, num11, num8), new Vector3(num9, num11, 0f - num8), new Vector3(num10, num11, 0f - num8), new Vector3(num10, num11, num8), p);
}
if (!Solid(l, k + 1))
{
Face(new Vector3(num9, num12, 0f - num8), new Vector3(num9, num12, num8), new Vector3(num10, num12, num8), new Vector3(num10, num12, 0f - num8), p);
}
}
}
}
value = new Mesh
{
name = "MC_generated_" + id
};
value.SetVertices(vertices);
value.SetUVs(0, uv);
value.SetTriangles(indices, 0);
value.RecalculateNormals();
value.RecalculateBounds();
meshes[id] = value;
return value;
void Face(Vector3 a, Vector3 b, Vector3 c, Vector3 d, Vector2 item)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
int count = vertices.Count;
vertices.Add(a);
vertices.Add(b);
vertices.Add(c);
vertices.Add(d);
uv.Add(item);
uv.Add(item);
uv.Add(item);
uv.Add(item);
indices.Add(count);
indices.Add(count + 1);
indices.Add(count + 2);
indices.Add(count);
indices.Add(count + 2);
indices.Add(count + 3);
}
bool Solid(int x, int y)
{
if (x >= 0 && y >= 0 && x < ((Texture)t).width && y < ((Texture)t).height)
{
return pixels[y * ((Texture)t).width + x].a > 127;
}
return false;
}
}
}
}