using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using 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 Photon.Realtime;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
using Zorro.Core;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.github.drifter-handbook.PeakCooking")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0+74b31fe18286ab5b15acdc7a2d6e9c737fea38c9")]
[assembly: AssemblyProduct("com.github.drifter-handbook.PeakCooking")]
[assembly: AssemblyTitle("PeakCooking")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.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 BepInEx
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class BepInAutoPluginAttribute : Attribute
{
public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace BepInEx.Preloader.Core.Patching
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class PatcherAutoPluginAttribute : Attribute
{
public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace PeakCooking
{
public class Action_CookingPotConsume : ItemAction
{
public override void RunAction()
{
CookingPot component = ((Component)((ItemActionBase)this).item).GetComponent<CookingPot>();
if ((Object)(object)component != (Object)null)
{
component.RemoveRandomItem();
}
}
}
public class CookingPot : ModItemComponent
{
public class DummyItem
{
public ushort ID;
public GameObject Object;
public DummyItem(ushort ID, GameObject Object)
{
this.ID = ID;
this.Object = Object;
}
}
[Serializable]
public class PotItem
{
public ushort ID;
public int CookedAmount;
public int Uses;
}
private GameObject? _soup;
private Vector3 soupScale;
private List<DummyItem> dummyItems = new List<DummyItem>();
private float dummyItemRadius = 0.85f;
private float dummyItemScale = 0.35f;
private float dummyItemHeight = 0.03f;
private CookingPotEffects CurrentEffects = new CookingPotEffects();
private GameObject soup
{
get
{
return Utils.NonNullGet<GameObject>(_soup);
}
set
{
Utils.NonNullSet(ref _soup, value);
}
}
public override void Awake()
{
//IL_0044: 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_0054: Unknown result type (might be due to invalid IL or missing references)
((ItemComponent)this).Awake();
soup = ((Component)((Component)this).transform.Find("Model").Find("Soup")).gameObject;
soupScale = soup.transform.Find("Cylinder").localScale * dummyItemRadius;
if (!((ItemComponent)this).HasData((DataEntryKey)2))
{
OptionableIntItemData data = ((ItemComponent)this).GetData<OptionableIntItemData>((DataEntryKey)2);
data.HasData = true;
data.Value = 0;
((ItemComponent)this).item.SetUseRemainingPercentage(0f);
}
}
private void Start()
{
((ItemComponent)this).OnInstanceDataSet();
List<PotItem> data = GetData();
Plugin.Log.LogInfo((object)$"Cooking Pot State: {CurrentEffects}");
Plugin.Log.LogInfo((object)("Cooking Pot Items: " + JsonConvert.SerializeObject((object)data)));
}
public void Update()
{
}
public void AddDummyItemToPot(Item item)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_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)
//IL_0097: 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_00bb: 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_00cf: 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_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)_soup == (Object)null))
{
Bounds bounds;
GameObject val = Utils.CloneItemMeshesOnly(((Component)item).gameObject, out bounds);
float num = Mathf.Max(((Bounds)(ref bounds)).extents.x, ((Bounds)(ref bounds)).extents.z) * dummyItemScale;
Vector2 val2 = default(Vector2);
((Vector2)(ref val2))..ctor(Mathf.Max(0f, soupScale.x * 0.5f - num), Mathf.Max(new float[1] { soupScale.z * 0.5f - num }));
Vector2 val3 = Random.insideUnitCircle * val2;
val.transform.parent = soup.transform;
val.transform.localPosition = new Vector3(val3.x, dummyItemHeight, val3.y);
val.transform.localRotation = Quaternion.identity;
val.transform.localScale = Vector3.one * dummyItemScale;
dummyItems.Add(new DummyItem(item.itemID, val));
}
}
public void AddToPot(Item item)
{
int num = Mathf.Max(1, item.GetData<OptionableIntItemData>((DataEntryKey)2).Value);
int value = item.GetData<IntItemData>((DataEntryKey)1).Value;
Plugin.Log.LogInfo((object)("Item " + item.GetItemName((ItemInstanceData)null) + " placed in Cooking Pot!"));
((ItemComponent)this).photonView.RPC("AddToPotRPC", (RpcTarget)0, new object[3]
{
(int)item.itemID,
value,
num
});
}
[PunRPC]
public void AddToPotRPC(int ID, int cookedAmount, int uses)
{
AddItemToData((ushort)ID, cookedAmount, uses);
((ItemComponent)this).OnInstanceDataSet();
List<PotItem> data = GetData();
Plugin.Log.LogInfo((object)$"Cooking Pot State: {CurrentEffects}");
Plugin.Log.LogInfo((object)("Cooking Pot Items: " + JsonConvert.SerializeObject((object)data)));
}
public void ClearPot()
{
((ItemComponent)this).photonView.RPC("ClearPotRPC", (RpcTarget)0, Array.Empty<object>());
}
[PunRPC]
public void ClearPotRPC()
{
ClearItemsFromData();
((ItemComponent)this).OnInstanceDataSet();
List<PotItem> data = GetData();
Plugin.Log.LogInfo((object)$"Cooking Pot State: {CurrentEffects}");
Plugin.Log.LogInfo((object)("Cooking Pot Items: " + JsonConvert.SerializeObject((object)data)));
}
public void RemoveRandomItem()
{
List<PotItem> data = GetData();
int num = Random.Range(0, data.Sum((PotItem x) => x.Uses));
((ItemComponent)this).photonView.RPC("RemoveItemRPC", (RpcTarget)0, new object[1] { num });
}
[PunRPC]
public void RemoveItemRPC(int useIndex)
{
List<PotItem> data = GetData();
List<PotItem> list = new List<PotItem>();
foreach (PotItem item in data)
{
for (int i = 0; i < item.Uses; i++)
{
list.Add(item);
}
}
PotItem potItem = list[Mathf.Max(0, Mathf.Min(useIndex, list.Count - 1))];
potItem.Uses--;
for (int j = 0; j < data.Count; j++)
{
if (data[j].Uses <= 0)
{
Plugin.Log.LogInfo((object)("Item " + data[j].Item().GetItemName((ItemInstanceData)null) + " removed from Cooking Pot!"));
data.RemoveAt(j);
j--;
}
}
OptionableIntItemData data2 = ((ItemComponent)this).item.GetData<OptionableIntItemData>((DataEntryKey)2);
if (data2.HasData && data2.Value == 0)
{
data.Clear();
}
((ModItemComponent)this).SetModItemDataFromJson((object)data);
((ItemComponent)this).OnInstanceDataSet();
Plugin.Log.LogInfo((object)$"Cooking Pot State: {CurrentEffects}");
Plugin.Log.LogInfo((object)("Cooking Pot Items: " + JsonConvert.SerializeObject((object)data)));
}
public override void OnInstanceDataSet()
{
List<PotItem> data = GetData();
Dictionary<ushort, int> dictionary = new Dictionary<ushort, int>();
foreach (PotItem item in data)
{
if (item != null)
{
if (!dictionary.ContainsKey(item.ID))
{
dictionary[item.ID] = 0;
}
dictionary[item.ID]++;
}
}
foreach (DummyItem dummyItem in dummyItems)
{
if (!dictionary.ContainsKey(dummyItem.ID))
{
dictionary[dummyItem.ID] = 0;
}
dictionary[dummyItem.ID]--;
}
Item val = default(Item);
foreach (ushort item2 in new List<ushort>(dictionary.Keys))
{
if (dictionary[item2] > 0)
{
for (int i = 0; i < dictionary[item2]; i++)
{
ItemDatabase.TryGetItem(item2, ref val);
if ((Object)(object)val != (Object)null)
{
AddDummyItemToPot(val);
}
}
}
else
{
if (dictionary[item2] >= 0)
{
continue;
}
for (int j = 0; j < dummyItems.Count; j++)
{
if (dictionary[item2] >= 0)
{
break;
}
if (dummyItems[j].ID == item2)
{
Object.Destroy((Object)(object)dummyItems[j].Object);
dummyItems.RemoveAt(j);
j--;
dictionary[item2]++;
}
}
}
}
CurrentEffects.FromCookingPotItems(data, data.Sum((PotItem x) => x.Uses));
CurrentEffects.UpdateGenerated(((Component)this).gameObject);
}
private void ClearItemsFromData()
{
((ModItemComponent)this).SetModItemDataFromJson((object)new List<PotItem>());
}
private void AddItemToData(ushort ID, int cookedAmount, int uses)
{
List<PotItem> data = GetData();
IncreaseUses(uses);
data.Add(new PotItem
{
ID = ID,
CookedAmount = cookedAmount,
Uses = uses
});
((ModItemComponent)this).SetModItemDataFromJson((object)data);
}
private void IncreaseUses(int amount)
{
OptionableIntItemData data = ((ItemComponent)this).item.GetData<OptionableIntItemData>((DataEntryKey)2);
if (data.HasData)
{
int value = Mathf.Min(data.Value + amount, ((ItemComponent)this).item.totalUses);
data.Value = value;
if (((ItemComponent)this).item.totalUses > 0)
{
((ItemComponent)this).item.SetUseRemainingPercentage((float)data.Value / (float)((ItemComponent)this).item.totalUses);
}
}
}
private List<PotItem> GetData()
{
List<PotItem> list = default(List<PotItem>);
if (!((ModItemComponent)this).TryGetModItemDataFromJson<List<PotItem>>(ref list))
{
((ModItemComponent)this).SetModItemDataFromJson((object)new List<PotItem>());
}
bool flag = ((ModItemComponent)this).TryGetModItemDataFromJson<List<PotItem>>(ref list);
if (list == null || !flag)
{
throw new NullReferenceException("Failed to read item data.");
}
return list;
}
[PunRPC]
private void UpdateInstanceDataRPC()
{
((ItemComponent)this).OnInstanceDataSet();
}
}
public class CookingPotEffects
{
public Dictionary<AfflictionType, Affliction> Afflictions = new Dictionary<AfflictionType, Affliction>();
public Dictionary<STATUSTYPE, float> Statuses = new Dictionary<STATUSTYPE, float>();
private List<MonoBehaviour> generated = new List<MonoBehaviour>();
public override string ToString()
{
//IL_0029: 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_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Invalid comparison between Unknown and I4
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00fd: 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_00c7: Unknown result type (might be due to invalid IL or missing references)
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.Append("{ ");
foreach (STATUSTYPE key in Statuses.Keys)
{
stringBuilder.Append($"{key}={Statuses[key]}, ");
}
foreach (AfflictionType key2 in Afflictions.Keys)
{
if ((int)key2 == 10)
{
Affliction obj = Afflictions[key2];
Affliction_AddBonusStamina val = (Affliction_AddBonusStamina)(object)((obj is Affliction_AddBonusStamina) ? obj : null);
if (val != null)
{
stringBuilder.Append($"{key2}={val.staminaAmount}, ");
}
}
else
{
stringBuilder.Append($"{key2}={Afflictions[key2].totalTime}, ");
}
}
stringBuilder.Append("}");
return stringBuilder.ToString();
}
private static Affliction? CopyAffliction(Affliction obj)
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Expected O, but got Unknown
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Expected O, but got Unknown
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Expected O, but got Unknown
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Expected O, but got Unknown
//IL_0196: Unknown result type (might be due to invalid IL or missing references)
//IL_019d: Expected O, but got Unknown
//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
//IL_01db: Expected O, but got Unknown
//IL_023c: Unknown result type (might be due to invalid IL or missing references)
//IL_0243: Expected O, but got Unknown
//IL_0247: Unknown result type (might be due to invalid IL or missing references)
//IL_024c: Unknown result type (might be due to invalid IL or missing references)
//IL_0288: Unknown result type (might be due to invalid IL or missing references)
//IL_028f: Expected O, but got Unknown
//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
//IL_02cd: Expected O, but got Unknown
//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
//IL_02fd: Expected O, but got Unknown
//IL_0334: Unknown result type (might be due to invalid IL or missing references)
//IL_033b: Expected O, but got Unknown
//IL_0372: Unknown result type (might be due to invalid IL or missing references)
//IL_0379: Expected O, but got Unknown
Affliction val = null;
if (obj is Affliction_PoisonOverTime)
{
Affliction_PoisonOverTime val2 = (Affliction_PoisonOverTime)(object)((obj is Affliction_PoisonOverTime) ? obj : null);
if (val2 != null)
{
Affliction_PoisonOverTime val3 = new Affliction_PoisonOverTime();
val3.delayBeforeEffect = val2.delayBeforeEffect;
val3.statusPerSecond = val2.statusPerSecond;
val = (Affliction)(object)val3;
}
}
if (obj is Affliction_InfiniteStamina)
{
Affliction_InfiniteStamina val4 = (Affliction_InfiniteStamina)(object)((obj is Affliction_InfiniteStamina) ? obj : null);
if (val4 != null)
{
Affliction_InfiniteStamina val5 = new Affliction_InfiniteStamina();
val5.drowsyAffliction = CopyAffliction(val4.drowsyAffliction);
val5.climbDelay = val4.climbDelay;
val = (Affliction)(object)val5;
}
}
if (obj is Affliction_FasterBoi)
{
Affliction_FasterBoi val6 = (Affliction_FasterBoi)(object)((obj is Affliction_FasterBoi) ? obj : null);
if (val6 != null)
{
Affliction_FasterBoi val7 = new Affliction_FasterBoi();
val7.moveSpeedMod = val6.moveSpeedMod;
val7.climbSpeedMod = val6.climbSpeedMod;
val7.drowsyOnEnd = val6.drowsyOnEnd;
val7.cachedDrowsy = val6.cachedDrowsy;
val7.climbDelay = val6.climbDelay;
val = (Affliction)(object)val7;
}
}
if (obj is Affliction_Exhaustion)
{
Affliction_Exhaustion val8 = (Affliction_Exhaustion)(object)((obj is Affliction_Exhaustion) ? obj : null);
if (val8 != null)
{
Affliction_Exhaustion val9 = new Affliction_Exhaustion();
val9.drainAmount = val8.drainAmount;
val = (Affliction)(object)val9;
}
}
if (obj is Affliction_Glowing)
{
Affliction_Glowing val10 = (Affliction_Glowing)(object)((obj is Affliction_Glowing) ? obj : null);
if (val10 == null)
{
}
}
if (obj is Affliction_AdjustColdOverTime)
{
Affliction_AdjustColdOverTime val11 = (Affliction_AdjustColdOverTime)(object)((obj is Affliction_AdjustColdOverTime) ? obj : null);
if (val11 != null)
{
Affliction_AdjustColdOverTime val12 = new Affliction_AdjustColdOverTime();
val12.statusPerSecond = val11.statusPerSecond;
val = (Affliction)(object)val12;
}
}
if (obj is Affliction_Chaos)
{
Affliction_Chaos val13 = (Affliction_Chaos)(object)((obj is Affliction_Chaos) ? obj : null);
if (val13 != null)
{
Affliction_Chaos val14 = new Affliction_Chaos();
val14.statusAmountAverage = val13.statusAmountAverage;
val14.statusAmountStandardDeviation = val13.statusAmountStandardDeviation;
val14.averageBonusStamina = val13.averageBonusStamina;
val14.standardDeviationBonusStamina = val13.standardDeviationBonusStamina;
val = (Affliction)(object)val14;
}
}
if (obj is Affliction_AdjustStatus)
{
Affliction_AdjustStatus val15 = (Affliction_AdjustStatus)(object)((obj is Affliction_AdjustStatus) ? obj : null);
if (val15 != null)
{
Affliction_AdjustStatus val16 = new Affliction_AdjustStatus();
val16.statusType = val15.statusType;
val16.statusAmount = val15.statusAmount;
val = (Affliction)(object)val16;
}
}
if (obj is Affliction_ClearAllStatus)
{
Affliction_ClearAllStatus val17 = (Affliction_ClearAllStatus)(object)((obj is Affliction_ClearAllStatus) ? obj : null);
if (val17 != null)
{
Affliction_ClearAllStatus val18 = new Affliction_ClearAllStatus();
val18.excludeCurse = val17.excludeCurse;
val = (Affliction)(object)val18;
}
}
if (obj is Affliction_PreventPoisonHealing)
{
Affliction_PreventPoisonHealing val19 = (Affliction_PreventPoisonHealing)(object)((obj is Affliction_PreventPoisonHealing) ? obj : null);
if (val19 != null)
{
Affliction_PreventPoisonHealing val20 = new Affliction_PreventPoisonHealing();
val = (Affliction)(object)val20;
}
}
if (obj is Affliction_AddBonusStamina)
{
Affliction_AddBonusStamina val21 = (Affliction_AddBonusStamina)(object)((obj is Affliction_AddBonusStamina) ? obj : null);
if (val21 != null)
{
Affliction_AddBonusStamina val22 = new Affliction_AddBonusStamina();
val22.staminaAmount = val21.staminaAmount;
val = (Affliction)(object)val22;
}
}
if (obj is Affliction_AdjustDrowsyOverTime)
{
Affliction_AdjustDrowsyOverTime val23 = (Affliction_AdjustDrowsyOverTime)(object)((obj is Affliction_AdjustDrowsyOverTime) ? obj : null);
if (val23 != null)
{
Affliction_AdjustDrowsyOverTime val24 = new Affliction_AdjustDrowsyOverTime();
val24.statusPerSecond = val23.statusPerSecond;
val = (Affliction)(object)val24;
}
}
if (obj is Affliction_AdjustStatusOverTime)
{
Affliction_AdjustStatusOverTime val25 = (Affliction_AdjustStatusOverTime)(object)((obj is Affliction_AdjustStatusOverTime) ? obj : null);
if (val25 != null)
{
Affliction_AdjustStatusOverTime val26 = new Affliction_AdjustStatusOverTime();
val26.statusPerSecond = val25.statusPerSecond;
val = (Affliction)(object)val26;
}
}
if (val != null)
{
val.timeElapsed = obj.timeElapsed;
val.bonusTime = obj.bonusTime;
val.totalTime = obj.totalTime;
}
return val;
}
private static Affliction AddMultiplyAffliction(Affliction? accumulator, float mult, Affliction scale)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
Affliction val = CopyAffliction(scale);
if (val == null)
{
return scale;
}
Affliction val2 = ((accumulator != null && val.GetAfflictionType() == accumulator.GetAfflictionType() && ((object)val).GetType() == ((object)accumulator).GetType()) ? accumulator : null);
Affliction_InfiniteStamina val3 = (Affliction_InfiniteStamina)(object)((val is Affliction_InfiniteStamina) ? val : null);
Affliction_InfiniteStamina val4 = (Affliction_InfiniteStamina)(object)((val2 is Affliction_InfiniteStamina) ? val2 : null);
Affliction_FasterBoi val5 = (Affliction_FasterBoi)(object)((val is Affliction_FasterBoi) ? val : null);
Affliction_FasterBoi val6 = (Affliction_FasterBoi)(object)((val2 is Affliction_FasterBoi) ? val2 : null);
Affliction_AddBonusStamina val7 = (Affliction_AddBonusStamina)(object)((val is Affliction_AddBonusStamina) ? val : null);
Affliction_AddBonusStamina val8 = (Affliction_AddBonusStamina)(object)((val2 is Affliction_AddBonusStamina) ? val2 : null);
if (val3 != null)
{
((Affliction)val3).totalTime = ((Affliction)val3).totalTime * mult;
if (val4 != null)
{
((Affliction)val3).totalTime = ((Affliction)val3).totalTime + ((Affliction)val4).totalTime;
}
if (val3.drowsyAffliction != null)
{
Affliction drowsyAffliction = val3.drowsyAffliction;
drowsyAffliction.totalTime *= mult;
if (val4?.drowsyAffliction != null)
{
Affliction drowsyAffliction2 = val3.drowsyAffliction;
drowsyAffliction2.totalTime += val4.drowsyAffliction.totalTime;
}
}
}
else if (val5 != null)
{
((Affliction)val5).totalTime = ((Affliction)val5).totalTime * mult;
val5.drowsyOnEnd *= mult;
if (val6 != null)
{
((Affliction)val5).totalTime = ((Affliction)val5).totalTime + ((Affliction)val6).totalTime;
val5.drowsyOnEnd += val6.drowsyOnEnd;
}
}
else if (val7 != null)
{
((Affliction)val7).totalTime = ((Affliction)val7).totalTime * mult;
val7.staminaAmount *= mult;
if (val8 != null)
{
((Affliction)val7).totalTime = ((Affliction)val7).totalTime + ((Affliction)val8).totalTime;
val7.staminaAmount += val8.staminaAmount;
}
}
else
{
val.totalTime *= mult;
if (val2 != null)
{
val.totalTime += val2.totalTime;
}
}
return val;
}
private void ClearGenerated()
{
foreach (MonoBehaviour item in generated)
{
Object.Destroy((Object)(object)item);
}
generated.Clear();
}
public void UpdateGenerated(GameObject go)
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: 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_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
ClearGenerated();
foreach (STATUSTYPE key in Statuses.Keys)
{
Action_ModifyStatus val = go.AddComponent<Action_ModifyStatus>();
val.statusType = key;
val.changeAmount = Statuses[key];
((ItemAction)val).OnCastFinished = true;
generated.Add((MonoBehaviour)(object)val);
}
foreach (AfflictionType key2 in Afflictions.Keys)
{
Action_ApplyAffliction val2 = go.AddComponent<Action_ApplyAffliction>();
val2.affliction = Afflictions[key2];
((ItemAction)val2).OnCastFinished = true;
generated.Add((MonoBehaviour)(object)val2);
}
}
public void FromCookingPotItems(List<CookingPot.PotItem> items, int uses)
{
//IL_04b4: Unknown result type (might be due to invalid IL or missing references)
//IL_04b9: Unknown result type (might be due to invalid IL or missing references)
//IL_04c2: Unknown result type (might be due to invalid IL or missing references)
//IL_04ca: Unknown result type (might be due to invalid IL or missing references)
//IL_0511: Unknown result type (might be due to invalid IL or missing references)
//IL_0516: Unknown result type (might be due to invalid IL or missing references)
//IL_051f: Unknown result type (might be due to invalid IL or missing references)
//IL_0530: Unknown result type (might be due to invalid IL or missing references)
//IL_01de: Unknown result type (might be due to invalid IL or missing references)
//IL_01e5: Expected O, but got Unknown
//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
//IL_02f9: 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_03ae: Unknown result type (might be due to invalid IL or missing references)
//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
//IL_03d0: Unknown result type (might be due to invalid IL or missing references)
//IL_0408: Unknown result type (might be due to invalid IL or missing references)
//IL_0410: Unknown result type (might be due to invalid IL or missing references)
//IL_03e7: Unknown result type (might be due to invalid IL or missing references)
Statuses.Clear();
Afflictions.Clear();
Item val = default(Item);
foreach (CookingPot.PotItem item in items)
{
ItemDatabase.TryGetItem(item.ID, ref val);
if ((Object)(object)val != (Object)null)
{
Action_RestoreHunger[] components = ((Component)val).gameObject.GetComponents<Action_RestoreHunger>();
foreach (Action_RestoreHunger val2 in components)
{
if ((((ItemAction)val2).OnCastFinished || ((ItemAction)val2).OnConsumed) && ((Behaviour)val2).enabled)
{
if (!Statuses.ContainsKey((STATUSTYPE)1))
{
Statuses[(STATUSTYPE)1] = 0f;
}
Statuses[(STATUSTYPE)1] -= val2.restorationAmount;
}
}
Action_InflictPoison[] components2 = ((Component)val).gameObject.GetComponents<Action_InflictPoison>();
foreach (Action_InflictPoison val3 in components2)
{
if ((((ItemAction)val3).OnCastFinished || ((ItemAction)val3).OnConsumed) && ((Behaviour)val3).enabled)
{
if (!Statuses.ContainsKey((STATUSTYPE)3))
{
Statuses[(STATUSTYPE)3] = 0f;
}
Statuses[(STATUSTYPE)3] += val3.inflictionTime * val3.poisonPerSecond;
}
}
Action_GiveExtraStamina[] components3 = ((Component)val).gameObject.GetComponents<Action_GiveExtraStamina>();
foreach (Action_GiveExtraStamina val4 in components3)
{
if ((((ItemAction)val4).OnCastFinished || ((ItemAction)val4).OnConsumed) && ((Behaviour)val4).enabled)
{
Affliction_AddBonusStamina val5 = new Affliction_AddBonusStamina();
val5.staminaAmount = val4.amount;
if (!Afflictions.ContainsKey((AfflictionType)10))
{
Afflictions[(AfflictionType)10] = AddMultiplyAffliction(null, item.Uses, (Affliction)(object)val5);
}
else
{
Afflictions[(AfflictionType)10] = AddMultiplyAffliction(Afflictions[(AfflictionType)10], item.Uses, (Affliction)(object)val5);
}
}
}
Action_ModifyStatus[] components4 = ((Component)val).gameObject.GetComponents<Action_ModifyStatus>();
foreach (Action_ModifyStatus val6 in components4)
{
if ((((ItemAction)val6).OnCastFinished || ((ItemAction)val6).OnConsumed) && ((Behaviour)val6).enabled)
{
if (!Statuses.ContainsKey(val6.statusType))
{
Statuses[val6.statusType] = 0f;
}
Statuses[val6.statusType] += val6.changeAmount * (float)item.Uses;
}
}
Action_ApplyAffliction[] components5 = ((Component)val).gameObject.GetComponents<Action_ApplyAffliction>();
foreach (Action_ApplyAffliction val7 in components5)
{
if ((!((ItemAction)val7).OnCastFinished && !((ItemAction)val7).OnConsumed) || !((Behaviour)val7).enabled)
{
continue;
}
foreach (Affliction item2 in new List<Affliction> { val7.affliction }.Concat(val7.extraAfflictions.ToArray()))
{
AfflictionType afflictionType = item2.GetAfflictionType();
Affliction val8 = CopyAffliction(item2);
if (val8 != null)
{
if (!Afflictions.ContainsKey(afflictionType))
{
Afflictions[afflictionType] = AddMultiplyAffliction(null, item.Uses, val8);
}
else
{
Afflictions[afflictionType] = AddMultiplyAffliction(Afflictions[afflictionType], item.Uses, val8);
}
}
}
}
continue;
}
throw new PeakCookingException($"ID {item.ID} is not valid.");
}
foreach (STATUSTYPE item3 in new List<STATUSTYPE>(Statuses.Keys))
{
Statuses[item3] /= (float)uses;
}
foreach (AfflictionType item4 in new List<AfflictionType>(Afflictions.Keys))
{
Afflictions[item4] = AddMultiplyAffliction(null, 1f / (float)uses, Afflictions[item4]);
}
}
}
public class CookingPotPatches
{
[HarmonyPatch(typeof(Interaction))]
public class InteractionPatcher
{
public class InteractionExtraFields
{
public Item? bestCookingPot;
public bool hasValidTarget => (Object)(object)bestCookingPot != (Object)null;
}
public static Dictionary<Interaction, InteractionExtraFields> Fields = new Dictionary<Interaction, InteractionExtraFields>();
public static InteractionExtraFields GetExtraFields(Interaction interaction)
{
if (!Fields.ContainsKey(interaction))
{
Fields[interaction] = new InteractionExtraFields();
}
foreach (Interaction item in new List<Interaction>(Fields.Keys))
{
if ((Object)(object)item == (Object)null && item != null)
{
Fields.Remove(item);
}
}
InteractionExtraFields interactionExtraFields = Fields[interaction];
if (interactionExtraFields == null)
{
throw new PeakCookingException("Extra Field patch logic gave null, this should never happen");
}
return interactionExtraFields;
}
[HarmonyPostfix]
[HarmonyPatch("LateUpdate")]
private static void LateUpdatePatch(ref Interaction __instance)
{
IInteractible bestInteractable = __instance.bestInteractable;
Item val = (Item)(object)((bestInteractable is Item) ? bestInteractable : null);
if ((Object)(object)val != (Object)null && ItemPatcher.GetExtraFields(val).IsCookingPot)
{
ref Item? bestCookingPot = ref GetExtraFields(__instance).bestCookingPot;
IInteractible bestInteractable2 = __instance.bestInteractable;
bestCookingPot = (Item?)(object)((bestInteractable2 is Item) ? bestInteractable2 : null);
}
else
{
GetExtraFields(__instance).bestCookingPot = null;
}
}
}
[HarmonyPatch(typeof(Item))]
public class ItemPatcher
{
public class ItemExtraFields
{
public CookingPot? script;
public bool IsCookingPot => (Object)(object)script != (Object)null;
}
public static Dictionary<Item, ItemExtraFields> Fields = new Dictionary<Item, ItemExtraFields>();
public static ItemExtraFields GetExtraFields(Item item)
{
if (!Fields.ContainsKey(item))
{
Fields[item] = new ItemExtraFields();
}
foreach (Item item2 in new List<Item>(Fields.Keys))
{
if ((Object)(object)item2 == (Object)null && item2 != null)
{
Fields.Remove(item2);
}
}
ItemExtraFields itemExtraFields = Fields[item];
if (itemExtraFields == null)
{
throw new PeakCookingException("Extra Field patch logic gave null, this should never happen");
}
return itemExtraFields;
}
[HarmonyPostfix]
[HarmonyPatch("Start")]
private static void StartPatch(ref Item __instance)
{
GetExtraFields(__instance).script = ((Component)__instance).GetComponent<CookingPot>();
}
public static void FeedItem(ref Item? __instance, Item item)
{
if ((Object)(object)__instance != (Object)null)
{
CookingPot script = GetExtraFields(__instance).script;
if (!((Object)(object)script != (Object)null))
{
throw new PeakCookingException("CookingPot behavior not found, this should never happen");
}
script.AddToPot(item);
if ((Object)(object)item != (Object)null)
{
((MonoBehaviour)item).StartCoroutine(item.ConsumeDelayed(true));
}
}
}
[HarmonyPostfix]
[HarmonyPatch("IsInteractible")]
private static void IsInteractiblePatch(ref Item __instance, ref bool __result, Character interactor)
{
__result = __result || IsSecondaryInteractible(ref __instance, interactor);
}
public static bool IsSecondaryInteractible(ref Item __instance, Character interactor)
{
if (HasItemCanUseOnFriend())
{
return true;
}
return false;
}
public static string GetSecondaryInteractionText(ref Item __instance)
{
if (HasItemCanUseOnFriend())
{
return GetItemPrompt(ref __instance, Character.localCharacter.data.currentItem);
}
return "";
}
public static string GetItemPrompt(ref Item __instance, Item item)
{
return item.UIData.secondaryInteractPrompt.Replace("#targetChar", __instance.GetName());
}
private static bool HasItemCanUseOnFriend()
{
if (Object.op_Implicit((Object)(object)Character.localCharacter.data.currentItem))
{
return Character.localCharacter.data.currentItem.canUseOnFriend;
}
return false;
}
[HarmonyPostfix]
[HarmonyPatch("CanUseSecondary")]
private static void CanUseSecondaryPatch(ref Item __instance, ref bool __result)
{
__result = __result || (__instance.canUseOnFriend && InteractionPatcher.GetExtraFields(Interaction.instance).hasValidTarget);
}
[HarmonyPostfix]
[HarmonyPatch("StartUseSecondary")]
private static void StartUseSecondaryPatch(ref Item __instance)
{
if (!__instance.isUsingPrimary && !__instance.isUsingSecondary && Object.op_Implicit((Object)(object)__instance.holderCharacter) && __instance.canUseOnFriend && InteractionPatcher.GetExtraFields(Interaction.instance).hasValidTarget)
{
GameUtils.instance.StartFeed(((MonoBehaviourPun)__instance.holderCharacter).photonView.ViewID, ((MonoBehaviourPun)__instance.holderCharacter).photonView.ViewID, __instance.itemID, __instance.totalSecondaryUsingTime);
}
}
[HarmonyPostfix]
[HarmonyPatch("FinishCastSecondary")]
private static void FinishCastSecondaryPatch(ref Item __instance)
{
if (__instance.canUseOnFriend && InteractionPatcher.GetExtraFields(Interaction.instance).hasValidTarget)
{
FeedItem(ref InteractionPatcher.GetExtraFields(Interaction.instance).bestCookingPot, __instance);
((MonoBehaviourPun)__instance).photonView.RPC("RemoveFeedDataRPC", (RpcTarget)0, new object[1] { ((MonoBehaviourPun)__instance.holderCharacter).photonView.ViewID });
}
}
}
[HarmonyPatch(typeof(GUIManager))]
public class GUIManagerPatcher
{
[HarmonyPostfix]
[HarmonyPatch("RefreshInteractablePrompt")]
private static void RefreshInteractablePromptPatch(ref GUIManager __instance)
{
if (!ClassExtensionsMethods.UnityObjectExists<IInteractible>(__instance.currentInteractable))
{
return;
}
IInteractible currentInteractable = __instance.currentInteractable;
Item __instance2 = (Item)(object)((currentInteractable is Item) ? currentInteractable : null);
if ((Object)(object)__instance2 != (Object)null && ItemPatcher.GetExtraFields(__instance2).IsCookingPot)
{
__instance.interactName.SetActive(false);
if (ItemPatcher.IsSecondaryInteractible(ref __instance2, Character.localCharacter))
{
__instance.interactPromptSecondary.SetActive(true);
((TMP_Text)__instance.secondaryInteractPromptText).text = ItemPatcher.GetSecondaryInteractionText(ref __instance2);
}
}
}
}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("com.github.drifter-handbook.PeakCooking", "PeakCooking", "0.1.0")]
public class Plugin : BaseUnityPlugin
{
private ConfigEntry<bool>? _placeAtSpawn;
private bool _gameStarted = false;
private const int POT_AMOUNT = 1;
private const float SPAWN_DELAY = 2f;
public static GameObject? CookingPotPrefab;
public const string Id = "com.github.drifter-handbook.PeakCooking";
public static Plugin Instance { get; private set; }
internal static ManualLogSource Log { get; private set; }
internal static Harmony? Harmony { get; set; }
internal static AssetBundle Bundle { get; set; }
internal static ModDefinition Definition { get; set; }
public static string Name => "PeakCooking";
public static string Version => "0.1.0";
private void Awake()
{
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
Instance = this;
Log = ((BaseUnityPlugin)this).Logger;
Definition = ModDefinition.GetOrCreate(((BaseUnityPlugin)this).Info.Metadata);
string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "peak_cooking");
Bundle = AssetBundle.LoadFromFile(text);
CookingPotPrefab = Bundle.LoadAsset<GameObject>("CookingPot.prefab");
CookingPotPrefab.AddComponent<CookingPot>();
new ItemContent(CookingPotPrefab.GetComponent<Item>()).Register(Definition);
Action_CookingPotConsume action_CookingPotConsume = CookingPotPrefab.AddComponent<Action_CookingPotConsume>();
((ItemAction)action_CookingPotConsume).OnCastFinished = true;
_placeAtSpawn = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "SpawnCookingPot", true, "Enable or disable automatic cooking pot placed at spawn");
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), Definition.Id);
Log.LogInfo((object)("Plugin " + Name + " is loaded!"));
}
private void Start()
{
SceneManager.sceneLoaded += OnSceneLoaded;
((MonoBehaviour)this).StartCoroutine(MonitorGameState());
}
private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
_gameStarted = false;
((BaseUnityPlugin)this).Logger.LogInfo((object)("Scene changed to: " + ((Scene)(ref scene)).name + " - mod state reset"));
}
private IEnumerator MonitorGameState()
{
while (true)
{
if (!(_placeAtSpawn?.Value ?? false))
{
yield return (object)new WaitForSeconds(1f);
continue;
}
if (!IsInValidGameLevel())
{
yield return (object)new WaitForSeconds(1f);
continue;
}
if (PhotonNetwork.IsConnected && PhotonNetwork.InRoom)
{
if (!_gameStarted)
{
_gameStarted = true;
ManualLogSource logger = ((BaseUnityPlugin)this).Logger;
Scene activeScene = SceneManager.GetActiveScene();
logger.LogInfo((object)("Game started in level: " + ((Scene)(ref activeScene)).name + " - spawning cooking pot"));
yield return (object)new WaitForSeconds(2f);
SpawnCookingPots();
}
}
else if (_gameStarted)
{
_gameStarted = false;
((BaseUnityPlugin)this).Logger.LogInfo((object)"Game session ended - resetting cooking pot tracking");
}
yield return (object)new WaitForSeconds(1f);
}
}
private bool IsInValidGameLevel()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
Scene activeScene = SceneManager.GetActiveScene();
string name = ((Scene)(ref activeScene)).name;
if (name.StartsWith("Level_"))
{
string s = name.Substring(6);
if (int.TryParse(s, out var _))
{
return true;
}
}
return false;
}
private void SpawnCookingPots()
{
if (!PhotonNetwork.IsConnected || !PhotonNetwork.IsMasterClient)
{
return;
}
((BaseUnityPlugin)this).Logger.LogInfo((object)"Automatically spawning cooking pot for host...");
Player[] playerList = PhotonNetwork.PlayerList;
foreach (Player val in playerList)
{
if (val.IsMasterClient)
{
((MonoBehaviour)this).StartCoroutine(SpawnCookingPotForPlayerCoroutine(val));
}
}
}
private IEnumerator SpawnCookingPotForPlayerCoroutine(Player player)
{
SpawnCookingPotForPlayer(player);
yield return (object)new WaitForSeconds(0.1f);
}
private void SpawnCookingPotForPlayer(Player player)
{
try
{
Character playerCharacter = GetPlayerCharacter(player);
if (!((Object)(object)playerCharacter == (Object)null))
{
Player playerComponent = GetPlayerComponent(player);
if (!((Object)(object)playerComponent == (Object)null))
{
SpawnCookingPotNearPlayer(playerCharacter);
((BaseUnityPlugin)this).Logger.LogInfo((object)("Cooking Pot spawned near player: " + player.NickName));
}
}
}
catch (Exception ex)
{
((BaseUnityPlugin)this).Logger.LogError((object)("Error spawning pot for " + player.NickName + ": " + ex.Message));
}
}
private Character? GetPlayerCharacter(Player player)
{
foreach (Character allCharacter in Character.AllCharacters)
{
if ((Object)(object)allCharacter != (Object)null && ((MonoBehaviourPun)allCharacter).photonView.Owner == player)
{
return allCharacter;
}
}
return null;
}
private Player? GetPlayerComponent(Player photonPlayer)
{
Player[] array = Object.FindObjectsByType<Player>((FindObjectsSortMode)0);
Player[] array2 = array;
foreach (Player val in array2)
{
if (((MonoBehaviourPun)val).photonView.Owner == photonPlayer)
{
return val;
}
}
return null;
}
private void SpawnCookingPotNearPlayer(Character character)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
try
{
Vector3 val = character.Center + Vector3.up * 1f + Random.insideUnitSphere * 1.5f;
val.y = Mathf.Max(val.y, character.Center.y);
if (!((Object)(object)CookingPotPrefab == (Object)null))
{
PhotonNetwork.InstantiateItemRoom(((Object)CookingPotPrefab).name, val, Quaternion.identity);
}
}
catch (Exception ex)
{
((BaseUnityPlugin)this).Logger.LogError((object)("Error spawning pot near player: " + ex.Message));
}
}
private void OnDestroy()
{
SceneManager.sceneLoaded -= OnSceneLoaded;
}
}
public class PeakCookingException : Exception
{
public PeakCookingException(string message)
: base(message)
{
}
}
public static class Utils
{
public static class ColliderUtils
{
public static Bounds GetCollidersBounds(GameObject gameObject)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
List<Collider> colliders = new List<Collider>();
FindCollidersRecursive(gameObject.transform, colliders);
return CalculateCollidersBounds(colliders);
}
private static void FindCollidersRecursive(Transform transform, List<Collider> colliders)
{
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Expected O, but got Unknown
Collider[] components = ((Component)transform).GetComponents<Collider>();
Collider[] array = components;
foreach (Collider val in array)
{
if (val.enabled)
{
colliders.Add(val);
}
}
foreach (Transform item in transform)
{
Transform transform2 = item;
FindCollidersRecursive(transform2, colliders);
}
}
private static Bounds CalculateCollidersBounds(List<Collider> colliders)
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_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)
if (colliders.Count == 0)
{
Debug.LogWarning((object)"No colliders found to calculate center point");
return default(Bounds);
}
Bounds bounds = colliders[0].bounds;
for (int i = 1; i < colliders.Count; i++)
{
((Bounds)(ref bounds)).Encapsulate(colliders[i].bounds);
}
return bounds;
}
}
public static T NonNullGet<T>(T? obj)
{
if (obj == null)
{
throw new PeakCookingException("NonNullGet: Field not initialized.");
}
return obj;
}
public static void NonNullSet<T>(ref T obj, T? value)
{
if (value == null)
{
throw new PeakCookingException("NonNullSet: Value is null.");
}
obj = value;
}
public static Item Item(this CookingPot.PotItem cookingPotItem)
{
Item result = default(Item);
ItemDatabase.TryGetItem(cookingPotItem.ID, ref result);
return result;
}
public static GameObject CloneItemMeshesOnly(GameObject prefab, out Bounds bounds)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: 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_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)
GameObject val = new GameObject("DummyItem");
GameObject val2 = new GameObject("Adjust");
val2.transform.parent = val.transform;
bool hasMesh;
GameObject val3 = CloneItemMeshesHelper(prefab, out hasMesh);
val3.transform.parent = val2.transform;
string[] array = new string[2] { "Hand_L", "Hand_R" };
string[] array2 = array;
foreach (string text in array2)
{
Transform obj = val3.transform.Find(text);
GameObject val4 = ((obj != null) ? ((Component)obj).gameObject : null);
if ((Object)(object)val4 != (Object)null)
{
Object.Destroy((Object)(object)val4);
}
}
bounds = ColliderUtils.GetCollidersBounds(prefab);
val2.transform.localPosition = -(((Bounds)(ref bounds)).center - prefab.transform.position);
return val;
}
private static GameObject CloneItemMeshesHelper(GameObject obj, out bool hasMesh)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Expected O, but got Unknown
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
hasMesh = false;
GameObject val = new GameObject(((Object)obj).name);
foreach (Transform item in obj.transform)
{
Transform val2 = item;
if (((Component)val2).gameObject.activeSelf)
{
bool hasMesh2;
GameObject val3 = CloneItemMeshesHelper(((Component)val2).gameObject, out hasMesh2);
if (hasMesh2)
{
hasMesh = true;
val3.transform.parent = val.transform;
val3.transform.localPosition = val2.localPosition;
val3.transform.localRotation = val2.localRotation;
val3.transform.localScale = val2.localScale;
}
else
{
Object.Destroy((Object)(object)val3);
}
}
}
MeshFilter component = obj.GetComponent<MeshFilter>();
if ((Object)(object)component != (Object)null)
{
MeshFilter val4 = val.AddComponent<MeshFilter>();
val4.mesh = component.mesh;
}
MeshRenderer component2 = obj.GetComponent<MeshRenderer>();
if ((Object)(object)component2 != (Object)null)
{
MeshRenderer val5 = val.AddComponent<MeshRenderer>();
((Renderer)val5).materials = ((Renderer)component2).materials;
((Renderer)val5).shadowCastingMode = ((Renderer)component2).shadowCastingMode;
}
hasMesh = hasMesh || ((Object)(object)component != (Object)null && (Object)(object)component2 != (Object)null);
return val;
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}