using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Jotunn; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("LoxMilkMod")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("LoxMilkMod")] [assembly: AssemblyCopyright("Copyright © 2025")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("9b8b76d8-a423-44e1-80d0-104d6058d5d1")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace LoxMilkMod; [HarmonyPatch(typeof(Fermenter), "AddItem")] public static class BlockCheeseBaseInFermenterPatch { private static bool Prefix(Fermenter __instance, ItemData item) { if ((Object)(object)__instance == (Object)null || item == null || (Object)(object)item.m_dropPrefab == (Object)null) { return true; } if (((Object)__instance).name != "fermenter(Clone)") { return true; } string text = ((Object)item.m_dropPrefab).name ?? string.Empty; bool flag = text.StartsWith("CheeseBase_", StringComparison.Ordinal); return !flag; } } public sealed class ButterChurnAnimator : MonoBehaviour { public string RotorTag = "churnrotor"; public string PlungerTag = "plunger"; public float RotorSpeed = 90f; public float PlungerAmplitude = 0.1f; public float PlungerSpeed = 1.5f; private Transform _rotor; private Transform _plunger; private Vector3 _plungerStartPosition; private Fermenter _fermenter; private ZNetView _networkView; private void Awake() { _fermenter = ((Component)this).GetComponent(); _networkView = ((Component)this).GetComponent(); FindAnimatedParts(); } private void FindAnimatedParts() { //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) Transform[] componentsInChildren = ((Component)this).GetComponentsInChildren(true); foreach (Transform val in componentsInChildren) { string text = ((Object)val).name.ToLowerInvariant(); if ((Object)(object)_rotor == (Object)null && text.Contains(RotorTag.ToLowerInvariant())) { _rotor = val; } if ((Object)(object)_plunger == (Object)null && text.Contains(PlungerTag.ToLowerInvariant())) { _plunger = val; } } if ((Object)(object)_plunger != (Object)null) { _plungerStartPosition = _plunger.localPosition; } } private void Update() { //IL_0031: 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_0077: 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) if (IsWorking()) { float deltaTime = Time.deltaTime; if ((Object)(object)_rotor != (Object)null) { _rotor.Rotate(Vector3.right, RotorSpeed * deltaTime, (Space)1); } if ((Object)(object)_plunger != (Object)null) { float num = Mathf.Sin(Time.time * PlungerSpeed) * PlungerAmplitude; Vector3 plungerStartPosition = _plungerStartPosition; plungerStartPosition.y += num; _plunger.localPosition = plungerStartPosition; } } } private bool IsWorking() { if ((Object)(object)_fermenter == (Object)null || (Object)(object)_networkView == (Object)null || !_networkView.IsValid()) { return false; } ZDO zDO = _networkView.GetZDO(); if (zDO == null) { return false; } string value = zDO.GetString("Content", string.Empty); return !string.IsNullOrEmpty(value); } } public sealed class ButtermilkTankRotorAnimator : MonoBehaviour { public string LeftGearTag = "gearleft"; public string RightGearTag = "gearright"; public string RotorNameContains = "rotor"; public Vector3 RotationAxis = Vector3.up; public float RotationSpeed = 120f; public float GearSpeed = 180f; private Transform _leftGear; private Transform _rightGear; private Transform _rotor; private Fermenter _fermenter; private ZNetView _networkView; private void Awake() { _fermenter = ((Component)this).GetComponent(); _networkView = ((Component)this).GetComponent(); FindAnimatedParts(); } private void FindAnimatedParts() { string value = LeftGearTag.ToLowerInvariant(); string value2 = RightGearTag.ToLowerInvariant(); string value3 = RotorNameContains.ToLowerInvariant(); Transform[] componentsInChildren = ((Component)this).GetComponentsInChildren(true); foreach (Transform val in componentsInChildren) { string text = ((Object)val).name.ToLowerInvariant(); if ((Object)(object)_leftGear == (Object)null && text.Contains(value)) { _leftGear = val; } if ((Object)(object)_rightGear == (Object)null && text.Contains(value2)) { _rightGear = val; } if ((Object)(object)_rotor == (Object)null && text.Contains(value3)) { _rotor = val; } } } private void Update() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_005e: 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) if (IsWorking()) { float deltaTime = Time.deltaTime; if ((Object)(object)_rotor != (Object)null) { _rotor.Rotate(RotationAxis, RotationSpeed * deltaTime, (Space)1); } if ((Object)(object)_leftGear != (Object)null) { _leftGear.Rotate(Vector3.forward, GearSpeed * deltaTime, (Space)1); } if ((Object)(object)_rightGear != (Object)null) { _rightGear.Rotate(Vector3.forward, (0f - GearSpeed) * deltaTime, (Space)1); } } } private bool IsWorking() { if ((Object)(object)_fermenter == (Object)null || (Object)(object)_networkView == (Object)null || !_networkView.IsValid()) { return false; } ZDO zDO = _networkView.GetZDO(); if (zDO == null) { return false; } string value = zDO.GetString("Content", string.Empty); return !string.IsNullOrEmpty(value); } } [HarmonyPatch(typeof(Player), "EatFood")] public static class CheeseExtendPatch { private static void Postfix(Player __instance, ItemData item) { if ((Object)(object)__instance == (Object)null || item == null) { return; } SEMan sEMan = ((Character)__instance).GetSEMan(); if (sEMan == null) { return; } int stableHashCode = StringExtensionMethods.GetStableHashCode("SE_SatiatedVisual"); if (sEMan.HaveStatusEffect(stableHashCode)) { return; } float cheeseBonus = GetCheeseBonus(item); if (cheeseBonus <= 0f) { return; } foreach (Food food in __instance.GetFoods()) { if (food != null && food.m_item != null && !((Object)(object)food.m_item.m_dropPrefab == (Object)(object)item.m_dropPrefab)) { food.m_time += cheeseBonus; } } Sprite icon = null; if (item.m_shared != null && item.m_shared.m_icons != null && item.m_shared.m_icons.Length != 0) { icon = item.m_shared.m_icons[0]; } CheeseSatiatedEffect.Apply(__instance, icon, cheeseBonus); } private static float GetCheeseBonus(ItemData item) { if (item == null || (Object)(object)item.m_dropPrefab == (Object)null) { return 0f; } return (((Object)item.m_dropPrefab).name ?? string.Empty) switch { "TwarogItem" => 300f, "GoudaCheese" => 600f, "LazurCheese" => 900f, "SerTopionyItem" => 1200f, _ => 0f, }; } } public static class CheeseSatiatedEffect { public const string EffectName = "SE_SatiatedVisual"; public static void Apply(Player player, Sprite icon, float duration) { if (!((Object)(object)player == (Object)null)) { SEMan sEMan = ((Character)player).GetSEMan(); if (sEMan != null) { SE_Stats val = ScriptableObject.CreateInstance(); ((Object)val).name = "SE_SatiatedVisual"; ((StatusEffect)val).m_name = "Stuffed"; ((StatusEffect)val).m_tooltip = "You will feel full longer."; ((StatusEffect)val).m_ttl = duration; ((StatusEffect)val).m_icon = icon; sEMan.AddStatusEffect((StatusEffect)(object)val, false, 0, 0f); } } } } public sealed class ConversionRegistrar { private const string CheeseMachinePieceName = "CheeseMachine"; private const string ButterChurnPieceName = "piece_butterchurn"; private const string ButtermilkTankPieceName = "piece_buttermilktank"; private const string OvenPieceName = "piece_oven"; public void RegisterAll() { RegisterCheeseMachineConversions(); RegisterButterChurnConversion(); RegisterDairyCauldronConversions(); RegisterMilkBreadOvenConversion(); Logger.LogInfo((object)"[LoxMilkMod] Conversion registration completed."); } private static void RegisterCheeseMachineConversions() { AddFermenterConversion("CheeseBase_Lazur", "LazurCheese", "CheeseMachine", 3); AddFermenterConversion("CheeseBase_SerTopiony", "SerTopionyItem", "CheeseMachine", 3); AddFermenterConversion("CheeseBase_Twarog", "TwarogItem", "CheeseMachine", 3); AddFermenterConversion("CheeseBase_Gouda", "GoudaCheese", "CheeseMachine", 3); } private static void RegisterButterChurnConversion() { AddFermenterConversion("LoxMilkItem", "ButterItem", "piece_butterchurn", 3); } private static void RegisterDairyCauldronConversions() { AddFermenterConversion("LoxMilkItem", "ButtermilkItem", "piece_buttermilktank", 3); AddFermenterConversion("CheeseBase_Skyr", "skyrItem", "piece_buttermilktank", 3); } private static void RegisterMilkBreadOvenConversion() { //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) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown CookingConversionConfig val = new CookingConversionConfig { FromItem = "LoxMilkBreadDough", ToItem = "LoxMilkBread", Station = "piece_oven", CookTime = 40f }; ItemManager.Instance.AddItemConversion(new CustomItemConversion((ConversionConfig)(object)val)); Logger.LogInfo((object)"[LoxMilkMod] Added conversion: LoxMilkBreadDough -> LoxMilkBread."); } private static void AddFermenterConversion(string fromItem, string toItem, string station, int producedItems) { //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) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown FermenterConversionConfig val = new FermenterConversionConfig { FromItem = fromItem, ToItem = toItem, Station = station, ProducedItems = producedItems }; ItemManager.Instance.AddItemConversion(new CustomItemConversion((ConversionConfig)(object)val)); Logger.LogInfo((object)("[LoxMilkMod] Added conversion: " + fromItem + " -> " + toItem + ", station: " + station + ".")); } } public sealed class DecorRegistrar { private const string DecorDescription = "Dairy decoration."; private readonly ModAssets _assets; public DecorRegistrar(ModAssets assets) { _assets = assets; } public void RegisterAll() { if (_assets == null) { Logger.LogError((object)"[LoxMilkMod] DecorRegistrar: ModAssets is null."); return; } if (!_assets.IsLoaded) { Logger.LogError((object)"[LoxMilkMod] DecorRegistrar: AssetBundle isn't loaded."); return; } RegisterMilkCrate(); RegisterButtermilkCrate(); RegisterButterBucket(); RegisterGoudaDecorations(); RegisterLazurDecorations(); RegisterTwarogDecorations(); Logger.LogInfo((object)"[LoxMilkMod] decoration registration has been completed."); } private void RegisterMilkCrate() { //IL_0039: 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) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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_006f: Expected O, but got Unknown RegisterDecorPiece("piece_loxmilk_crate", "Crate of lox milk", _assets.MilkCrateModel, _assets.MilkStackIcon, 1.2f, 0f, 0.45f, new RequirementConfig { Item = "LoxMilkItem", Amount = 4 }, new RequirementConfig { Item = "Wood", Amount = 2 }); } private void RegisterButtermilkCrate() { //IL_0039: 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) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_0056: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown RegisterDecorPiece("piece_buttermilk_crate", "Crate of lox buttermilk", _assets.ButtermilkCrateModel, _assets.ButtermilkStackIcon, 1f, 0f, 0.25f, new RequirementConfig { Item = "ButtermilkItem", Amount = 9 }, new RequirementConfig { Item = "Wood", Amount = 2 }); } private void RegisterButterBucket() { //IL_0039: 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) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_0056: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown RegisterDecorPiece("piece_butter_bucket", "Bucket of butter", _assets.ButterBucketModel, _assets.ButterStackIcon, 1.6f, 0f, 0.5f, new RequirementConfig { Item = "ButterItem", Amount = 10 }, new RequirementConfig { Item = "Wood", Amount = 2 }); } private void RegisterGoudaDecorations() { //IL_0039: 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) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown //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_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected O, but got Unknown //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Expected O, but got Unknown RegisterDecorPiece("piece_gouda_single", "Gouda cheese", _assets.GoudaDecorModel, _assets.GoudaDecor1Icon, 2.3f, -0.01f, 0.3f, new RequirementConfig { Item = "GoudaCheese", Amount = 1 }); RegisterDecorPiece("piece_gouda_double1", "Two gouda cheeses", _assets.GoudaDecor2Model, _assets.GoudaDecor2Icon, 2f, -0.01f, 0.48f, new RequirementConfig { Item = "GoudaCheese", Amount = 2 }); RegisterDecorPiece("piece_gouda_double2", "Two gouda cheeses", _assets.GoudaDecor3Model, _assets.GoudaDecor3Icon, 2f, -0.01f, 0.55f, new RequirementConfig { Item = "GoudaCheese", Amount = 2 }); } private void RegisterLazurDecorations() { //IL_0039: 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) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown //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_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected O, but got Unknown //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Expected O, but got Unknown RegisterDecorPiece("piece_lazur_single", "Blue cheese", _assets.LazurDecorModel, _assets.LazurDecor1Icon, 2f, 0f, 0.3f, new RequirementConfig { Item = "LazurCheese", Amount = 1 }); RegisterDecorPiece("piece_lazur_double1", "Two blue cheeses", _assets.LazurDecor2Model, _assets.LazurDecor2Icon, 2f, 0f, 0.5f, new RequirementConfig { Item = "LazurCheese", Amount = 2 }); RegisterDecorPiece("piece_lazur_double2", "Two blue cheeses", _assets.LazurDecor3Model, _assets.LazurDecor3Icon, 2f, 0f, 0.6f, new RequirementConfig { Item = "LazurCheese", Amount = 2 }); } private void RegisterTwarogDecorations() { //IL_0039: 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) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown //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_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Expected O, but got Unknown //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_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Expected O, but got Unknown RegisterDecorPiece("piece_twarog_bowl1", "Small bowl of cottage cheese", _assets.TwarogBowl1Model, _assets.TwarogDecor1Icon, 2f, -0.01f, 0.22f, new RequirementConfig { Item = "TwarogItem", Amount = 1 }); RegisterDecorPiece("piece_twarog_bowl2", "Medium bowl of cottage cheese", _assets.TwarogBowl2Model, _assets.TwarogDecor2Icon, 1.3f, -0.02f, 0.15f, new RequirementConfig { Item = "TwarogItem", Amount = 10 }); RegisterDecorPiece("piece_twarog_bowl3", "Large bowl of cottage cheese", _assets.TwarogBowl3Model, _assets.TwarogDecor3Icon, 1.7f, 0.28f, 0.4f, new RequirementConfig { Item = "TwarogItem", Amount = 20 }); } private void RegisterDecorPiece(string pieceName, string displayName, GameObject model, Sprite icon, float scale, float yOffset, float boxHeight, params RequirementConfig[] requirements) { //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Expected O, but got Unknown GameObject prefab = PrefabManager.Instance.GetPrefab("piece_chair"); if ((Object)(object)prefab == (Object)null) { Logger.LogError((object)"[LoxMilkMod] prefab not found piece_chair."); return; } GameObject val = PrefabManager.Instance.CreateClonedPrefab(pieceName, prefab); if ((Object)(object)val == (Object)null) { Logger.LogError((object)("[LoxMilkMod] failed to create decoration: " + pieceName + ".")); return; } DisableOriginalVisuals(val); RemoveOriginalColliders(val); RemoveChairComponent(val); ConfigureWearAndTear(val); Piece val2 = ConfigurePiece(val); AddDecorationVisual(val, model, scale, yOffset); AddDecorationCollider(val, boxHeight); val2.m_name = displayName; val2.m_description = "Dairy decoration."; PieceConfig val3 = CreatePieceConfig(displayName, icon, requirements); CustomPiece val4 = new CustomPiece(val, false, val3); PieceManager.Instance.AddPiece(val4); Logger.LogInfo((object)("[LoxMilkMod] decoration added: " + displayName)); } private static void DisableOriginalVisuals(GameObject piece) { MeshRenderer[] componentsInChildren = piece.GetComponentsInChildren(true); MeshRenderer[] array = componentsInChildren; foreach (MeshRenderer val in array) { ((Renderer)val).enabled = false; } } private static void RemoveOriginalColliders(GameObject piece) { Collider[] componentsInChildren = piece.GetComponentsInChildren(true); Collider[] array = componentsInChildren; foreach (Collider val in array) { Object.DestroyImmediate((Object)(object)val); } } private static void RemoveChairComponent(GameObject piece) { Chair component = piece.GetComponent(); if ((Object)(object)component != (Object)null) { Object.DestroyImmediate((Object)(object)component); } } private static void ConfigureWearAndTear(GameObject piece) { WearNTear component = piece.GetComponent(); if (!((Object)(object)component == (Object)null)) { component.m_health = 50f; component.m_noRoofWear = true; component.m_noSupportWear = true; } } private static Piece ConfigurePiece(GameObject piece) { Piece val = piece.GetComponent(); if ((Object)(object)val == (Object)null) { val = piece.AddComponent(); } val.m_groundOnly = false; val.m_groundPiece = false; val.m_clipEverything = false; val.m_canBeRemoved = true; val.m_blockRadius = 0f; return val; } private static void AddDecorationVisual(GameObject piece, GameObject model, float scale, float yOffset) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_007f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)model == (Object)null) { Logger.LogWarning((object)("[LoxMilkMod] no model for decoration: " + ((Object)piece).name + ".")); return; } GameObject val = Object.Instantiate(model, piece.transform); ((Object)val).name = "LoxMilkMod_Visual"; val.transform.localPosition = new Vector3(0f, yOffset, 0f); val.transform.localRotation = Quaternion.identity; val.transform.localScale = Vector3.one * scale; Collider[] componentsInChildren = val.GetComponentsInChildren(true); Collider[] array = componentsInChildren; foreach (Collider val2 in array) { Object.DestroyImmediate((Object)(object)val2); } MeshRenderer[] componentsInChildren2 = val.GetComponentsInChildren(true); MeshRenderer[] array2 = componentsInChildren2; foreach (MeshRenderer val3 in array2) { ((Renderer)val3).enabled = true; } } private static void AddDecorationCollider(GameObject piece, float boxHeight) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) BoxCollider val = piece.AddComponent(); val.size = new Vector3(1f, boxHeight, 1f); val.center = new Vector3(0f, boxHeight / 2f, 0f); ((Collider)val).isTrigger = false; } private static PieceConfig CreatePieceConfig(string displayName, Sprite icon, RequirementConfig[] requirements) { //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) //IL_0012: 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_0026: 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_003b: Expected O, but got Unknown PieceConfig val = new PieceConfig { PieceTable = "Hammer", Name = displayName, Description = "Dairy decoration.", Category = "Misc", Icon = icon }; if (requirements == null) { return val; } foreach (RequirementConfig val2 in requirements) { if (val2 != null) { val.AddRequirement(val2.Item, val2.Amount, true); } } return val; } } public static class FeasterRegistrar { private sealed class FoodRegistration { public CustomItem Item; public string Category; } private const string FeasterPieceTableName = "Feaster"; private static readonly List Registrations = new List(); public static void RegisterFood(CustomItem item, string category) { //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Expected O, but got Unknown if (item == null) { Logger.LogError((object)"[LoxMilkMod] FeasterRegistrar: CustomItem is null."); return; } if ((Object)(object)item.ItemPrefab == (Object)null) { Logger.LogError((object)"[LoxMilkMod] FeasterRegistrar: ItemPrefab is null."); return; } if ((Object)(object)item.ItemDrop == (Object)null) { Logger.LogError((object)("[LoxMilkMod] FeasterRegistrar: " + ((Object)item.ItemPrefab).name + " don't have ItemDrop.")); return; } Piece component = item.ItemPrefab.GetComponent(); if ((Object)(object)component == (Object)null) { Logger.LogError((object)("[LoxMilkMod] FeasterRegistrar: " + ((Object)item.ItemPrefab).name + " don't haave Piece component.")); return; } SharedData val = item.ItemDrop.m_itemData?.m_shared; if (val == null) { Logger.LogError((object)("[LoxMilkMod] FeasterRegistrar: " + ((Object)item.ItemPrefab).name + " don't have SharedData.")); return; } if (string.IsNullOrEmpty(category)) { category = PieceCategories.Food; } component.m_name = val.m_name; component.m_description = val.m_description; if (val.m_icons != null && val.m_icons.Length != 0 && (Object)(object)val.m_icons[0] != (Object)null) { component.m_icon = val.m_icons[0]; } component.m_resources = (Requirement[])(object)new Requirement[1] { new Requirement { m_resItem = item.ItemDrop, m_amount = 1, m_recover = true } }; component.m_canBeRemoved = true; AddOrUpdateRegistration(item, category); Logger.LogInfo((object)("[LoxMilkMod] prepared for Serving Tray: " + ((Object)item.ItemPrefab).name + ", category: " + category + ".")); } public static void RegisterPendingFoods() { PieceTable pieceTable = PieceManager.Instance.GetPieceTable("Feaster"); if ((Object)(object)pieceTable == (Object)null) { Logger.LogError((object)"[LoxMilkMod] FeasterRegistrar: tab Feaster still not found."); return; } foreach (FoodRegistration registration in Registrations) { if (registration != null && registration.Item != null && !((Object)(object)registration.Item.ItemPrefab == (Object)null)) { GameObject itemPrefab = registration.Item.ItemPrefab; if (!pieceTable.m_pieces.Contains(itemPrefab)) { PieceManager.Instance.RegisterPieceInPieceTable(itemPrefab, "Feaster", registration.Category); Logger.LogInfo((object)("[LoxMilkMod] added to Serving Tray: " + ((Object)itemPrefab).name + ", category: " + registration.Category + ".")); } } } } public static void RegisterFood(CustomItem item) { RegisterFood(item, PieceCategories.Food); } public static void RegisterMead(CustomItem item) { RegisterFood(item, PieceCategories.Mead); } public static void RegisterFeast(CustomItem item) { RegisterFood(item, PieceCategories.Feasts); } private static void AddOrUpdateRegistration(CustomItem item, string category) { string name = ((Object)item.ItemPrefab).name; foreach (FoodRegistration registration in Registrations) { object obj; if (registration == null) { obj = null; } else { CustomItem item2 = registration.Item; obj = ((item2 != null) ? item2.ItemPrefab : null); } if ((Object)obj == (Object)null || ((Object)registration.Item.ItemPrefab).name != name) { continue; } registration.Item = item; registration.Category = category; return; } Registrations.Add(new FoodRegistration { Item = item, Category = category }); } } public static class FermenterDurationController { private const string CheeseMachinePrefab = "CheeseMachine"; private const string CheeseMachineDisplayName = "Cheese machine"; private const string DairyCauldronPrefab = "piece_buttermilktank"; private const string DairyCauldronDisplayName = "Dairy cauldron"; private const string ButterChurnPrefab = "piece_butterchurn"; private const string ButterChurnDisplayName = "Butter churn"; private const string SkyrBasePrefab = "CheeseBase_Skyr"; private const string LoxMilkPrefab = "LoxMilkItem"; public static void Apply(Fermenter fermenter, string contentPrefabName) { if ((Object)(object)fermenter == (Object)null || !ModConfig.IsInitialized) { return; } float num; if (IsCheeseMachine(fermenter)) { num = ModConfig.CheeseFermentationSeconds; } else if (IsButterChurn(fermenter)) { num = ModConfig.ButterFermentationSeconds; } else { if (!IsDairyCauldron(fermenter)) { return; } if (ContainsPrefabName(contentPrefabName, "CheeseBase_Skyr")) { num = ModConfig.SkyrFermentationSeconds; } else { if (!ContainsPrefabName(contentPrefabName, "LoxMilkItem")) { return; } num = ModConfig.ButtermilkFermentationSeconds; } } if (!(Math.Abs(fermenter.m_fermentationDuration - num) < 0.01f)) { fermenter.m_fermentationDuration = num; } } private static bool IsCheeseMachine(Fermenter fermenter) { string cleanObjectName = GetCleanObjectName(fermenter); string a = fermenter.m_name ?? string.Empty; return string.Equals(cleanObjectName, "CheeseMachine", StringComparison.OrdinalIgnoreCase) || string.Equals(a, "Cheese machine", StringComparison.OrdinalIgnoreCase); } private static bool IsButterChurn(Fermenter fermenter) { string cleanObjectName = GetCleanObjectName(fermenter); string a = fermenter.m_name ?? string.Empty; return string.Equals(cleanObjectName, "piece_butterchurn", StringComparison.OrdinalIgnoreCase) || string.Equals(a, "Butter churn", StringComparison.OrdinalIgnoreCase); } private static bool IsDairyCauldron(Fermenter fermenter) { string cleanObjectName = GetCleanObjectName(fermenter); string a = fermenter.m_name ?? string.Empty; return string.Equals(cleanObjectName, "piece_buttermilktank", StringComparison.OrdinalIgnoreCase) || string.Equals(a, "Dairy cauldron", StringComparison.OrdinalIgnoreCase); } private static bool ContainsPrefabName(string actualName, string expectedName) { if (string.IsNullOrEmpty(actualName)) { return false; } return actualName.IndexOf(expectedName, StringComparison.OrdinalIgnoreCase) >= 0; } private static string GetCleanObjectName(Fermenter fermenter) { if ((Object)(object)fermenter == (Object)null || (Object)(object)((Component)fermenter).gameObject == (Object)null) { return string.Empty; } string text = ((Object)((Component)fermenter).gameObject).name ?? string.Empty; return text.Replace("(Clone)", string.Empty).Trim(); } } [HarmonyPatch(typeof(Fermenter), "RPC_AddItem", new Type[] { typeof(long), typeof(string) })] public static class FermenterRpcAddItemDurationPatch { private static void Prefix(Fermenter __instance, string __1) { FermenterDurationController.Apply(__instance, __1); } } [HarmonyPatch(typeof(Fermenter), "GetStatus")] public static class FermenterGetStatusDurationPatch { private static void Prefix(Fermenter __instance) { if ((Object)(object)__instance == (Object)null) { return; } ZNetView component = ((Component)__instance).GetComponent(); if (!((Object)(object)component == (Object)null) && component.IsValid()) { ZDO zDO = component.GetZDO(); if (zDO != null) { string contentPrefabName = zDO.GetString("Content", string.Empty); FermenterDurationController.Apply(__instance, contentPrefabName); } } } } public sealed class ItemRegistrar { private readonly ModAssets _assets; public ItemRegistrar(ModAssets assets) { _assets = assets; } public void RegisterAll() { if (_assets == null) { Logger.LogError((object)"[LoxMilkMod] ItemRegistrar: ModAssets is null."); return; } if (!_assets.IsLoaded) { Logger.LogError((object)"[LoxMilkMod] ItemRegistrar: AssetBundle is not loaded."); return; } RegisterLoxMilk(); RegisterMilkSoup(); RegisterMilkBread(); RegisterGouda(); RegisterLazur(); RegisterCheesecake(); RegisterMeltedCheese(); RegisterTwarog(); RegisterRennet(); RegisterCheeseBases(); RegisterButter(); RegisterButtermilk(); RegisterSkyr(); RegisterBearSoup(); RegisterFulingDelicacy(); RegisterCheesePlate(); FixRegisteredIcons(); Logger.LogInfo((object)"[LoxMilkMod] Item registration completed."); } private void RegisterLoxMilk() { //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) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0057: Unknown result type (might be due to invalid IL or missing references) ItemConfig val = new ItemConfig { Name = "Lox milk", Description = "Fresh milk from a lox.", Enabled = true }; CustomItem val2 = new CustomItem("LoxMilkItem", "QueensJam", val); ItemManager.Instance.AddItem(val2); SharedData shared = val2.ItemDrop.m_itemData.m_shared; shared.m_itemType = (ItemType)2; shared.m_maxStackSize = 20; shared.m_food = 10f; shared.m_foodStamina = 80f; shared.m_foodBurnTime = 1800f; shared.m_foodRegen = 1f; SetIcon(shared, _assets.LoxMilkIcon); if ((Object)(object)_assets.MilkBottleModel != (Object)null) { ItemVisuals.OverrideDropModel(((Component)val2.ItemDrop).gameObject, _assets.MilkBottleModel); ItemVisuals.FixDropScale(((Component)val2.ItemDrop).gameObject, 1.1f); ItemVisuals.FixDropCollider(((Component)val2.ItemDrop).gameObject, 0.25f); } FeasterRegistrar.RegisterFood(val2); } private void RegisterMilkSoup() { //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) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Expected O, but got Unknown //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Expected O, but got Unknown //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Expected O, but got Unknown //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Expected O, but got Unknown //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Expected O, but got Unknown ItemConfig val = new ItemConfig { Name = "Lox milk soup", Description = "Creamy soup made with lox milk.", Enabled = true }; CustomItem val2 = new CustomItem("LoxMilkSoup", "TurnipStew", val); ItemManager.Instance.AddItem(val2); if ((Object)(object)_assets.MilkSoupModel != (Object)null) { ItemVisuals.OverrideDropModel(((Component)val2.ItemDrop).gameObject, _assets.MilkSoupModel); ItemVisuals.FixDropScale(((Component)val2.ItemDrop).gameObject, 1.3f); } SharedData shared = val2.ItemDrop.m_itemData.m_shared; shared.m_food = 40f; shared.m_foodStamina = 75f; shared.m_foodBurnTime = 2100f; shared.m_foodRegen = 2f; SetIcon(shared, _assets.MilkSoupIcon); ItemVisuals.FixDropCollider(((Component)val2.ItemDrop).gameObject, 0.3f); RecipeConfig val3 = new RecipeConfig(); val3.Name = "Recipe_LoxMilkSoup"; val3.Item = "LoxMilkSoup"; val3.Amount = 1; val3.CraftingStation = "piece_cauldron"; val3.Requirements = (RequirementConfig[])(object)new RequirementConfig[4] { new RequirementConfig { Item = "LoxMilkItem", Amount = 1 }, new RequirementConfig { Item = "BarleyFlour", Amount = 1 }, new RequirementConfig { Item = "ChickenEgg", Amount = 2 }, new RequirementConfig { Item = "Honey", Amount = 1 } }; RecipeConfig recipe = val3; AddRecipe(recipe); FeasterRegistrar.RegisterFood(val2); } private void RegisterMilkBread() { RegisterMilkBreadDough(); RegisterFinishedMilkBread(); } private void RegisterMilkBreadDough() { //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) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Expected O, but got Unknown //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Expected O, but got Unknown ItemConfig val = new ItemConfig { Name = "Milk bread dough", Description = "Dough for fluffy bread made with lox milk.", Enabled = true }; CustomItem val2 = new CustomItem("LoxMilkBreadDough", "BreadDough", val); ItemManager.Instance.AddItem(val2); if ((Object)(object)_assets.MilkBreadDoughModel != (Object)null) { ItemVisuals.OverrideDropModel(((Component)val2.ItemDrop).gameObject, _assets.MilkBreadDoughModel); } SharedData shared = val2.ItemDrop.m_itemData.m_shared; ClearFoodValues(shared); SetIcon(shared, _assets.MilkBreadDoughIcon); RecipeConfig val3 = new RecipeConfig(); val3.Name = "Recipe_LoxMilkBreadDough"; val3.Item = "LoxMilkBreadDough"; val3.Amount = 1; val3.CraftingStation = "piece_preptable"; val3.MinStationLevel = 1; val3.Requirements = (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig { Item = "LoxMilkItem", Amount = 1 }, new RequirementConfig { Item = "BarleyFlour", Amount = 10 } }; RecipeConfig recipe = val3; AddRecipe(recipe); } private void RegisterFinishedMilkBread() { //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) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown ItemConfig val = new ItemConfig { Name = "Milk bread", Description = "Soft and fluffy milk bread.", Enabled = true }; CustomItem val2 = new CustomItem("LoxMilkBread", "Bread", val); ItemManager.Instance.AddItem(val2); if ((Object)(object)_assets.MilkBreadModel != (Object)null) { ItemVisuals.OverrideDropModel(((Component)val2.ItemDrop).gameObject, _assets.MilkBreadModel); } SharedData shared = val2.ItemDrop.m_itemData.m_shared; shared.m_food = 25f; shared.m_foodStamina = 60f; shared.m_foodBurnTime = 1200f; shared.m_foodRegen = 3f; SetIcon(shared, _assets.MilkBreadIcon); ItemVisuals.RemoveSteamEffect(val2.ItemPrefab); FeasterRegistrar.RegisterFood(val2); } private void RegisterGouda() { //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) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown ItemConfig val = new ItemConfig { Name = "Gouda cheese", Description = "Cheese made from lox milk. Consuming it applies the Stuffed effect, extending the duration of previously eaten foods (except cheeses) by 10 minutes.", Enabled = true }; CustomItem val2 = new CustomItem("GoudaCheese", "TurnipStew", val); ItemManager.Instance.AddItem(val2); if ((Object)(object)_assets.GoudaModel != (Object)null) { ItemVisuals.OverrideDropModel(((Component)val2.ItemDrop).gameObject, _assets.GoudaModel); ItemVisuals.FixDropScale(((Component)val2.ItemDrop).gameObject, 1.3f); } SharedData shared = val2.ItemDrop.m_itemData.m_shared; shared.m_food = 60f; shared.m_foodStamina = 20f; shared.m_foodBurnTime = 900f; shared.m_foodRegen = 2f; SetIcon(shared, _assets.GoudaIcon); ItemVisuals.FixDropCollider(((Component)val2.ItemDrop).gameObject, 0.18f); ItemVisuals.RemoveSteamEffect(val2.ItemPrefab); FeasterRegistrar.RegisterFood(val2); } private void RegisterLazur() { //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) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown ItemConfig val = new ItemConfig { Name = "Blue cheese", Description = "Cheese made from lox milk. Consuming it applies the Stuffed effect, extending the duration of previously eaten foods (except cheeses) by 15 minutes.", Enabled = true }; CustomItem val2 = new CustomItem("LazurCheese", "TurnipStew", val); ItemManager.Instance.AddItem(val2); if ((Object)(object)_assets.LazurModel != (Object)null) { ItemVisuals.OverrideDropModel(((Component)val2.ItemDrop).gameObject, _assets.LazurModel); ItemVisuals.FixDropScale(((Component)val2.ItemDrop).gameObject, 1.3f); } SharedData shared = val2.ItemDrop.m_itemData.m_shared; shared.m_food = 13f; shared.m_foodStamina = 13f; shared.m_foodEitr = 90f; shared.m_foodBurnTime = 600f; shared.m_foodRegen = 2f; SetIcon(shared, _assets.LazurIcon); ItemVisuals.FixDropCollider(((Component)val2.ItemDrop).gameObject, 0.18f); ItemVisuals.RemoveSteamEffect(val2.ItemPrefab); FeasterRegistrar.RegisterFood(val2); } private void RegisterCheesecake() { //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) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Expected O, but got Unknown //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Expected O, but got Unknown //IL_0125: 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_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Expected O, but got Unknown //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Expected O, but got Unknown ItemConfig val = new ItemConfig { Name = "Nordic cheesecake", Description = "A sweet cheesecake made from lox milk.", Enabled = true }; CustomItem val2 = new CustomItem("SernikItem", "LoxPie", val); ItemManager.Instance.AddItem(val2); if ((Object)(object)_assets.CheesecakeModel != (Object)null) { ItemVisuals.OverrideDropModel(((Component)val2.ItemDrop).gameObject, _assets.CheesecakeModel); } SharedData shared = val2.ItemDrop.m_itemData.m_shared; shared.m_food = 48f; shared.m_foodStamina = 48f; shared.m_foodBurnTime = 1500f; shared.m_foodRegen = 3f; SetIcon(shared, _assets.CheesecakeIcon); RecipeConfig val3 = new RecipeConfig(); val3.Name = "Recipe_SernikItem"; val3.Item = "SernikItem"; val3.Amount = 1; val3.CraftingStation = "piece_cauldron"; val3.Requirements = (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig { Item = "LoxMilkItem", Amount = 1 }, new RequirementConfig { Item = "Cloudberry", Amount = 2 }, new RequirementConfig { Item = "ChickenEgg", Amount = 2 } }; RecipeConfig recipe = val3; AddRecipe(recipe); ItemVisuals.RemoveSteamEffect(val2.ItemPrefab); FeasterRegistrar.RegisterFood(val2); } private void RegisterMeltedCheese() { //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) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown ItemConfig val = new ItemConfig { Name = "Melted cheese", Description = "Cheese made from lox milk. Consuming it applies the Stuffed effect, extending the duration of previously eaten foods (except cheeses) by 20 minutes.", Enabled = true }; CustomItem val2 = new CustomItem("SerTopionyItem", "TurnipStew", val); ItemManager.Instance.AddItem(val2); if ((Object)(object)_assets.MeltCheeseModel != (Object)null) { ItemVisuals.OverrideDropModel(((Component)val2.ItemDrop).gameObject, _assets.MeltCheeseModel); ItemVisuals.FixDropScale(((Component)val2.ItemDrop).gameObject, 1.5f); ItemVisuals.FixDropCollider(((Component)val2.ItemDrop).gameObject, 0.25f); } SharedData shared = val2.ItemDrop.m_itemData.m_shared; shared.m_food = 80f; shared.m_foodStamina = 35f; shared.m_foodBurnTime = 1800f; shared.m_foodRegen = 4f; SetIcon(shared, _assets.MeltCheeseIcon); FeasterRegistrar.RegisterFood(val2); } private void RegisterTwarog() { //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) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown ItemConfig val = new ItemConfig { Name = "White cheese", Description = "Cheese made from lox milk. Consuming it applies the Stuffed effect, extending the duration of previously eaten foods (except cheeses) by 5 minutes.", Enabled = true }; CustomItem val2 = new CustomItem("TwarogItem", "TurnipStew", val); ItemManager.Instance.AddItem(val2); if ((Object)(object)_assets.TwarogModel != (Object)null) { ItemVisuals.OverrideDropModel(((Component)val2.ItemDrop).gameObject, _assets.TwarogModel); ItemVisuals.FixDropScale(((Component)val2.ItemDrop).gameObject, 0.8f); ItemVisuals.FixDropCollider(((Component)val2.ItemDrop).gameObject, 0.25f); } SharedData shared = val2.ItemDrop.m_itemData.m_shared; shared.m_food = 20f; shared.m_foodStamina = 60f; shared.m_foodBurnTime = 600f; shared.m_foodRegen = 2f; SetIcon(shared, _assets.WhiteCheeseIcon); ItemVisuals.RemoveSteamEffect(val2.ItemPrefab); FeasterRegistrar.RegisterFood(val2); } private void RegisterCheeseBases() { RegisterTwarogBase(); RegisterMeltedCheeseBase(); RegisterGoudaBase(); RegisterLazurBase(); RegisterSkyrBase(); } private void RegisterTwarogBase() { //IL_0044: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown //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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown CreateCheeseBase("CheeseBase_Twarog", "Cheese base: White cheese", "Requires fermentation in a cheese maker.", _assets.BaseTwarogModel, _assets.BaseTwarogIcon, 1f, 0.2f); AddCheeseBaseRecipe("CheeseBase_Twarog", new RequirementConfig { Item = "RennetItem", Amount = 1 }, new RequirementConfig { Item = "LoxMilkItem", Amount = 2 }, new RequirementConfig { Item = "Onion", Amount = 1 }); } private void RegisterMeltedCheeseBase() { //IL_0044: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown //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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown CreateCheeseBase("CheeseBase_SerTopiony", "Cheese base: Melted cheese", "Requires fermentation in a cheese maker.", _assets.BaseMeltCheeseModel, _assets.BaseMeltCheeseIcon, 1f, 0.2f); AddCheeseBaseRecipe("CheeseBase_SerTopiony", new RequirementConfig { Item = "RennetItem", Amount = 1 }, new RequirementConfig { Item = "LoxMilkItem", Amount = 2 }, new RequirementConfig { Item = "SpiceMistlands", Amount = 1 }); } private void RegisterGoudaBase() { //IL_0044: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown //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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown CreateCheeseBase("CheeseBase_Gouda", "Cheese base: Gouda cheese", "Requires fermentation in a cheese maker.", _assets.BaseGoudaModel, _assets.BaseGoudaIcon, 1f, 0.2f); AddCheeseBaseRecipe("CheeseBase_Gouda", new RequirementConfig { Item = "RennetItem", Amount = 1 }, new RequirementConfig { Item = "LoxMilkItem", Amount = 2 }, new RequirementConfig { Item = "FragrantBundle", Amount = 1 }); } private void RegisterLazurBase() { //IL_0044: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown //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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown CreateCheeseBase("CheeseBase_Lazur", "Cheese base: Blue cheese", "Requires fermentation in a cheese maker.", _assets.BaseLazurModel, _assets.BaseLazurIcon, 1f, 0.25f); AddCheeseBaseRecipe("CheeseBase_Lazur", new RequirementConfig { Item = "RennetItem", Amount = 1 }, new RequirementConfig { Item = "LoxMilkItem", Amount = 2 }, new RequirementConfig { Item = "MushroomMagecap", Amount = 1 }); } private void RegisterSkyrBase() { //IL_0044: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown //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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown CreateCheeseBase("CheeseBase_Skyr", "Fermentation base: Skyr", "Base used to produce skyr.", _assets.BaseSkyrModel, _assets.BaseSkyrIcon, 1f, 0.2f); AddCheeseBaseRecipe("CheeseBase_Skyr", new RequirementConfig { Item = "LoxMilkItem", Amount = 1 }, new RequirementConfig { Item = "Honey", Amount = 2 }); } private CustomItem CreateCheeseBase(string prefabName, string displayName, string description, GameObject model, Sprite icon, float modelScale, float colliderHeight) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown CustomItem val = new CustomItem(prefabName, "MeadBaseHealthMedium", new ItemConfig { Name = displayName, Description = description }); ItemManager.Instance.AddItem(val); SharedData shared = val.ItemDrop.m_itemData.m_shared; ClearFoodValues(shared); shared.m_description = description; SetIcon(shared, icon); if ((Object)(object)model != (Object)null) { ItemVisuals.ReplaceDropVisual(((Component)val.ItemDrop).gameObject, model, modelScale); ItemVisuals.FixDropCollider(((Component)val.ItemDrop).gameObject, colliderHeight); } return val; } private static void AddCheeseBaseRecipe(string itemName, params RequirementConfig[] requirements) { //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) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown RecipeConfig recipe = new RecipeConfig { Name = "Recipe_" + itemName, Item = itemName, Amount = 1, CraftingStation = "piece_MeadCauldron", Requirements = requirements }; AddRecipe(recipe); } private void RegisterRennet() { //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) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Expected O, but got Unknown //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Expected O, but got Unknown //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Expected O, but got Unknown ItemConfig val = new ItemConfig { Name = "Rennet", Description = "Special ingredient used in cheese making.", Enabled = true }; CustomItem val2 = new CustomItem("RennetItem", "Amber", val); ItemManager.Instance.AddItem(val2); ItemDrop itemDrop = val2.ItemDrop; if ((Object)(object)itemDrop == (Object)null) { Logger.LogError((object)"[LoxMilkMod] RennetItem nie ma ItemDrop."); return; } SharedData shared = itemDrop.m_itemData.m_shared; ClearFoodValues(shared); SetIcon(shared, _assets.RennetIcon); if ((Object)(object)_assets.RennetModel != (Object)null) { ItemVisuals.OverrideDropModel(((Component)itemDrop).gameObject, _assets.RennetModel); ItemVisuals.FixDropScale(((Component)itemDrop).gameObject, 1.5f); ItemVisuals.FixDropCollider(((Component)itemDrop).gameObject, 0.25f); } else { Logger.LogWarning((object)"[LoxMilkMod] Rennet model not found replaced by model Amber."); } RecipeConfig val3 = new RecipeConfig(); val3.Name = "Recipe_RennetItem"; val3.Item = "RennetItem"; val3.Amount = 3; val3.CraftingStation = "piece_preptable"; val3.Requirements = (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig { Item = "RottenMeat", Amount = 1 }, new RequirementConfig { Item = "LeatherScraps", Amount = 1 } }; RecipeConfig recipe = val3; AddRecipe(recipe); Logger.LogInfo((object)"[LoxMilkMod] Rennet recepie added."); } private void RegisterButter() { //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) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown ItemConfig val = new ItemConfig { Name = "Butter", Description = "Butter churned from lox milk.", Enabled = true }; CustomItem val2 = new CustomItem("ButterItem", "Amber", val); ItemManager.Instance.AddItem(val2); if ((Object)(object)_assets.ButterModel != (Object)null) { ItemVisuals.OverrideDropModel(((Component)val2.ItemDrop).gameObject, _assets.ButterModel); ItemVisuals.FixDropScale(((Component)val2.ItemDrop).gameObject, 2f); } SharedData shared = val2.ItemDrop.m_itemData.m_shared; ClearFoodValues(shared); SetIcon(shared, _assets.ButterIcon); ItemVisuals.FixDropCollider(((Component)val2.ItemDrop).gameObject, 0.18f); } private void RegisterButtermilk() { //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) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown ItemConfig val = new ItemConfig { Name = "Buttermilk", Description = "Refreshing buttermilk from lox milk. Good for your bones.", Enabled = true }; CustomItem val2 = new CustomItem("ButtermilkItem", "QueensJam", val); ItemManager.Instance.AddItem(val2); ConfigureTallContainerModel(val2, _assets.ButtermilkModel, 0.95f); SharedData shared = val2.ItemDrop.m_itemData.m_shared; ClearConsumableValues(shared); SetIcon(shared, _assets.ButtermilkIcon); SE_StrongBones sE_StrongBones = ScriptableObject.CreateInstance(); ((Object)sE_StrongBones).name = "SE_StrongBones"; ((StatusEffect)sE_StrongBones).m_name = "Strong bones"; ((StatusEffect)sE_StrongBones).m_tooltip = "You take 50% less fall damage."; ((StatusEffect)sE_StrongBones).m_ttl = 600f; ((StatusEffect)sE_StrongBones).m_icon = _assets.ButtermilkIcon; shared.m_consumeStatusEffect = (StatusEffect)(object)sE_StrongBones; FeasterRegistrar.RegisterMead(val2); } private void RegisterSkyr() { //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) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown ItemConfig val = new ItemConfig { Name = "Skyr", Description = "Tastes like home...", Enabled = true }; CustomItem val2 = new CustomItem("skyrItem", "QueensJam", val); ItemManager.Instance.AddItem(val2); ConfigureTallContainerModel(val2, _assets.SkyrModel, 1.2f); SharedData shared = val2.ItemDrop.m_itemData.m_shared; ClearConsumableValues(shared); SetIcon(shared, _assets.SkyrIcon); SE_Skyr sE_Skyr = ScriptableObject.CreateInstance(); ((Object)sE_Skyr).name = "SE_Skyr"; ((StatusEffect)sE_Skyr).m_name = "Skyr"; ((StatusEffect)sE_Skyr).m_tooltip = "You regain the rest effect for a short time."; ((StatusEffect)sE_Skyr).m_ttl = 600f; ((StatusEffect)sE_Skyr).m_icon = _assets.SkyrIcon; shared.m_consumeStatusEffect = (StatusEffect)(object)sE_Skyr; FeasterRegistrar.RegisterMead(val2); } private static void ConfigureTallContainerModel(CustomItem item, GameObject model, float scale) { if (item != null && !((Object)(object)item.ItemDrop == (Object)null) && !((Object)(object)model == (Object)null)) { GameObject gameObject = ((Component)item.ItemDrop).gameObject; ItemVisuals.OverrideDropModel(gameObject, model); ItemVisuals.FixDropScale(gameObject, scale); ItemVisuals.FixDropCollider(gameObject, 0.55f); Rigidbody component = gameObject.GetComponent(); if ((Object)(object)component != (Object)null) { component.mass = 5f; component.drag = 5f; component.angularDrag = 999f; component.constraints = (RigidbodyConstraints)112; } } } private void RegisterBearSoup() { //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) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Expected O, but got Unknown //IL_0138: 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) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Expected O, but got Unknown //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Expected O, but got Unknown //IL_0170: 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_0181: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Expected O, but got Unknown //IL_0086: Unknown result type (might be due to invalid IL or missing references) ItemConfig val = new ItemConfig { Name = "Bear soup", Description = "Thick soup made from bear meat and butter.", Enabled = true }; CustomItem val2 = new CustomItem("BearSoup", "MeatPlatter", val); ItemManager.Instance.AddItem(val2); if ((Object)(object)_assets.BearSoupModel != (Object)null) { ItemVisuals.ReplaceDropVisual(((Component)val2.ItemDrop).gameObject, _assets.BearSoupModel, 1.3f, new Vector3(0f, -0.04f, 0f)); } SharedData shared = val2.ItemDrop.m_itemData.m_shared; shared.m_food = 80f; shared.m_foodStamina = 26f; shared.m_foodBurnTime = 1800f; shared.m_foodRegen = 5f; SetIcon(shared, _assets.BearSoupIcon); ItemVisuals.FixDropCollider(((Component)val2.ItemDrop).gameObject, 0.2f); RecipeConfig val3 = new RecipeConfig(); val3.Name = "Recipe_BearSoup"; val3.Item = "BearSoup"; val3.Amount = 1; val3.CraftingStation = "piece_cauldron"; val3.Requirements = (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig { Item = "ButterItem", Amount = 1 }, new RequirementConfig { Item = "CookedBjornMeat", Amount = 1 }, new RequirementConfig { Item = "Turnip", Amount = 1 } }; RecipeConfig recipe = val3; AddRecipe(recipe); FeasterRegistrar.RegisterFood(val2); } private void RegisterFulingDelicacy() { //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) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Expected O, but got Unknown //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Expected O, but got Unknown //IL_0145: 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_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Expected O, but got Unknown //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Expected O, but got Unknown //IL_0077: Unknown result type (might be due to invalid IL or missing references) ItemConfig val = new ItemConfig { Name = "Fuling delicacy", Description = "A gourmet dish made with fish and butter.", Enabled = true }; CustomItem val2 = new CustomItem("FulingDelicacy", "FishWraps", val); ItemManager.Instance.AddItem(val2); if ((Object)(object)_assets.FulingDelicacyModel != (Object)null) { ItemVisuals.ReplaceDropVisualCentered(((Component)val2.ItemDrop).gameObject, _assets.FulingDelicacyModel, 2f, Vector3.zero); } SharedData shared = val2.ItemDrop.m_itemData.m_shared; shared.m_food = 80f; shared.m_foodStamina = 26f; shared.m_foodBurnTime = 1800f; shared.m_foodRegen = 3f; SetIcon(shared, _assets.FulingDelicacyIcon); ItemVisuals.FixDropCollider(((Component)val2.ItemDrop).gameObject, 0.18f); RecipeConfig val3 = new RecipeConfig(); val3.Name = "Recipe_FulingDelicacy"; val3.Item = "FulingDelicacy"; val3.Amount = 1; val3.CraftingStation = "piece_cauldron"; val3.Requirements = (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig { Item = "Needle", Amount = 2 }, new RequirementConfig { Item = "FishCooked", Amount = 1 }, new RequirementConfig { Item = "ButterItem", Amount = 1 } }; RecipeConfig recipe = val3; AddRecipe(recipe); FeasterRegistrar.RegisterFood(val2); } private void RegisterCheesePlate() { //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) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Expected O, but got Unknown //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Expected O, but got Unknown //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Expected O, but got Unknown //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Expected O, but got Unknown ItemConfig val = new ItemConfig { Name = "Cheese plate", Description = "Rich platter of cheeses made from lox milk.", Enabled = true }; CustomItem val2 = new CustomItem("CheesePlateItem", "MeatPlatter", val); ItemManager.Instance.AddItem(val2); if ((Object)(object)_assets.CheesePlateModel != (Object)null) { ItemVisuals.OverrideDropModel(((Component)val2.ItemDrop).gameObject, _assets.CheesePlateModel); ItemVisuals.FixDropScale(((Component)val2.ItemDrop).gameObject, 1.5f); ItemVisuals.FixDropCollider(((Component)val2.ItemDrop).gameObject, 0.25f); } SharedData shared = val2.ItemDrop.m_itemData.m_shared; shared.m_food = 100f; shared.m_foodStamina = 100f; shared.m_foodEitr = 100f; shared.m_foodBurnTime = 1800f; shared.m_foodRegen = 5f; SetIcon(shared, _assets.CheesePlateIcon); RecipeConfig val3 = new RecipeConfig(); val3.Name = "Recipe_CheesePlate"; val3.Item = "CheesePlateItem"; val3.Amount = 1; val3.CraftingStation = "piece_preptable"; val3.Requirements = (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig { Item = "LazurCheese", Amount = 1 }, new RequirementConfig { Item = "GoudaCheese", Amount = 1 }, new RequirementConfig { Item = "TwarogItem", Amount = 1 } }; RecipeConfig recipe = val3; AddRecipe(recipe); ItemVisuals.RemoveSteamEffect(val2.ItemPrefab); FeasterRegistrar.RegisterFeast(val2); } private void FixRegisteredIcons() { ItemVisuals.FixItemIcon("RennetItem", _assets.RennetIcon); } private static void AddRecipe(RecipeConfig recipe) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown ItemManager.Instance.AddRecipe(new CustomRecipe(recipe)); } private static void SetIcon(SharedData data, Sprite icon) { if (data != null && !((Object)(object)icon == (Object)null)) { data.m_icons = (Sprite[])(object)new Sprite[1] { icon }; } } private static void ClearFoodValues(SharedData data) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) if (data != null) { data.m_consumeStatusEffect = null; data.m_itemType = (ItemType)1; data.m_food = 0f; data.m_foodStamina = 0f; data.m_foodEitr = 0f; data.m_foodBurnTime = 0f; data.m_foodRegen = 0f; } } private static void ClearConsumableValues(SharedData data) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) if (data != null) { data.m_consumeStatusEffect = null; data.m_itemType = (ItemType)2; data.m_food = 0f; data.m_foodStamina = 0f; data.m_foodEitr = 0f; data.m_foodBurnTime = 0f; data.m_foodRegen = 0f; } } } public static class ItemVisuals { public static void RemoveSteamEffect(GameObject itemPrefab) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)itemPrefab == (Object)null) { return; } ParticleSystem[] componentsInChildren = itemPrefab.GetComponentsInChildren(true); ParticleSystem[] array = componentsInChildren; foreach (ParticleSystem val in array) { if (!((Object)(object)val == (Object)null)) { val.Stop(true, (ParticleSystemStopBehavior)0); EmissionModule emission = val.emission; ((EmissionModule)(ref emission)).enabled = false; ParticleSystemRenderer component = ((Component)val).GetComponent(); if ((Object)(object)component != (Object)null) { ((Renderer)component).enabled = false; } ((Component)val).gameObject.SetActive(false); } } } public static void ReplaceDropVisualCentered(GameObject dropObject, GameObject modelPrefab, float scale, Vector3 extraOffset) { //IL_00cd: 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_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)dropObject == (Object)null || (Object)(object)modelPrefab == (Object)null) { return; } Transform val = dropObject.transform.Find("LoxMilkMod_Visual"); if ((Object)(object)val != (Object)null) { Object.DestroyImmediate((Object)(object)((Component)val).gameObject); } MeshRenderer[] componentsInChildren = dropObject.GetComponentsInChildren(true); MeshRenderer[] array = componentsInChildren; foreach (MeshRenderer val2 in array) { ((Renderer)val2).enabled = false; } SkinnedMeshRenderer[] componentsInChildren2 = dropObject.GetComponentsInChildren(true); SkinnedMeshRenderer[] array2 = componentsInChildren2; foreach (SkinnedMeshRenderer val3 in array2) { ((Renderer)val3).enabled = false; } GameObject val4 = Object.Instantiate(modelPrefab, dropObject.transform); ((Object)val4).name = "LoxMilkMod_Visual"; val4.transform.localPosition = Vector3.zero; val4.transform.localRotation = Quaternion.identity; val4.transform.localScale = Vector3.one * scale; Collider[] componentsInChildren3 = val4.GetComponentsInChildren(true); Collider[] array3 = componentsInChildren3; foreach (Collider val5 in array3) { Object.DestroyImmediate((Object)(object)val5); } Renderer[] componentsInChildren4 = val4.GetComponentsInChildren(true); if (componentsInChildren4.Length == 0) { Logger.LogWarning((object)("[LoxMilkMod] ReplaceDropVisualCentered: model don't have Renderers: " + ((Object)modelPrefab).name)); return; } Renderer[] array4 = componentsInChildren4; foreach (Renderer val6 in array4) { val6.enabled = true; } Bounds bounds = componentsInChildren4[0].bounds; for (int m = 1; m < componentsInChildren4.Length; m++) { ((Bounds)(ref bounds)).Encapsulate(componentsInChildren4[m].bounds); } Vector3 val7 = dropObject.transform.InverseTransformPoint(((Bounds)(ref bounds)).center); Vector3 val8 = default(Vector3); ((Vector3)(ref val8))..ctor(0f - val7.x, 0f, 0f - val7.z); val4.transform.localPosition = val8 + extraOffset; } public static void FixDropCollider(GameObject dropObject, float height) { //IL_0055: 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) if (!((Object)(object)dropObject == (Object)null)) { Collider[] componentsInChildren = dropObject.GetComponentsInChildren(true); Collider[] array = componentsInChildren; foreach (Collider val in array) { Object.DestroyImmediate((Object)(object)val); } BoxCollider val2 = dropObject.AddComponent(); val2.size = new Vector3(0.35f, height, 0.35f); val2.center = new Vector3(0f, height / 2f, 0f); ((Collider)val2).isTrigger = false; Rigidbody component = dropObject.GetComponent(); if ((Object)(object)component != (Object)null) { component.constraints = (RigidbodyConstraints)112; component.drag = 5f; component.angularDrag = 999f; } } } public static void OverrideDropModel(GameObject targetPrefab, GameObject sourcePrefab) { if (!((Object)(object)targetPrefab == (Object)null) && !((Object)(object)sourcePrefab == (Object)null)) { MeshFilter componentInChildren = sourcePrefab.GetComponentInChildren(true); MeshRenderer componentInChildren2 = sourcePrefab.GetComponentInChildren(true); MeshFilter componentInChildren3 = targetPrefab.GetComponentInChildren(true); MeshRenderer componentInChildren4 = targetPrefab.GetComponentInChildren(true); if ((Object)(object)componentInChildren != (Object)null && (Object)(object)componentInChildren3 != (Object)null) { componentInChildren3.sharedMesh = componentInChildren.sharedMesh; } else { Logger.LogWarning((object)"[LoxMilkMod] OverrideDropModel: MeshFilter is not found."); } if ((Object)(object)componentInChildren2 != (Object)null && (Object)(object)componentInChildren4 != (Object)null) { ((Renderer)componentInChildren4).sharedMaterials = ((Renderer)componentInChildren2).sharedMaterials; } else { Logger.LogWarning((object)"[LoxMilkMod] OverrideDropModel: MeshRenderer is not found."); } } } public static GameObject ReplaceDropVisual(GameObject dropObject, GameObject modelPrefab, float scale) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) return ReplaceDropVisual(dropObject, modelPrefab, scale, Vector3.zero); } public static GameObject ReplaceDropVisual(GameObject dropObject, GameObject modelPrefab, float scale, Vector3 localPosition) { //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: 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) if ((Object)(object)dropObject == (Object)null || (Object)(object)modelPrefab == (Object)null) { return null; } Transform val = dropObject.transform.Find("LoxMilkMod_Visual"); if ((Object)(object)val != (Object)null) { Object.DestroyImmediate((Object)(object)((Component)val).gameObject); } MeshRenderer[] componentsInChildren = dropObject.GetComponentsInChildren(true); MeshRenderer[] array = componentsInChildren; foreach (MeshRenderer val2 in array) { ((Renderer)val2).enabled = false; } SkinnedMeshRenderer[] componentsInChildren2 = dropObject.GetComponentsInChildren(true); SkinnedMeshRenderer[] array2 = componentsInChildren2; foreach (SkinnedMeshRenderer val3 in array2) { ((Renderer)val3).enabled = false; } GameObject val4 = Object.Instantiate(modelPrefab, dropObject.transform); ((Object)val4).name = "LoxMilkMod_Visual"; val4.transform.localPosition = localPosition; val4.transform.localRotation = Quaternion.identity; val4.transform.localScale = Vector3.one * scale; Collider[] componentsInChildren3 = val4.GetComponentsInChildren(true); Collider[] array3 = componentsInChildren3; foreach (Collider val5 in array3) { Object.DestroyImmediate((Object)(object)val5); } MeshRenderer[] componentsInChildren4 = val4.GetComponentsInChildren(true); MeshRenderer[] array4 = componentsInChildren4; foreach (MeshRenderer val6 in array4) { ((Renderer)val6).enabled = true; } SkinnedMeshRenderer[] componentsInChildren5 = val4.GetComponentsInChildren(true); SkinnedMeshRenderer[] array5 = componentsInChildren5; foreach (SkinnedMeshRenderer val7 in array5) { ((Renderer)val7).enabled = true; } return val4; } public static void FixDropScale(GameObject dropObject, float scale) { //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) if (!((Object)(object)dropObject == (Object)null)) { MeshFilter componentInChildren = dropObject.GetComponentInChildren(true); if ((Object)(object)componentInChildren == (Object)null) { Logger.LogWarning((object)("[LoxMilkMod] FixDropScale: MeshFilter is not found " + ((Object)dropObject).name + ".")); } else { ((Component)componentInChildren).transform.localScale = Vector3.one * scale; } } } public static void EnsureItemHasIcon(ItemDrop itemDrop, Sprite fallbackIcon) { if ((Object)(object)itemDrop == (Object)null) { return; } SharedData val = itemDrop.m_itemData?.m_shared; if (val != null && (val.m_icons == null || val.m_icons.Length == 0 || !((Object)(object)val.m_icons[0] != (Object)null))) { if ((Object)(object)fallbackIcon != (Object)null) { val.m_icons = (Sprite[])(object)new Sprite[1] { fallbackIcon }; Logger.LogInfo((object)("[LoxMilkMod] Added backup icon: " + ((Object)itemDrop).name)); } else { Logger.LogWarning((object)("[LoxMilkMod] No backup icon for: " + ((Object)itemDrop).name)); } } } public static void FixItemIcon(string itemName, Sprite fallbackIcon) { if ((Object)(object)ObjectDB.instance == (Object)null) { Logger.LogWarning((object)"[LoxMilkMod] FixItemIcon: ObjectDB is not ready."); return; } GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(itemName); if ((Object)(object)itemPrefab == (Object)null) { Logger.LogWarning((object)("[LoxMilkMod] FixItemIcon: prefab is not found " + itemName + ".")); return; } ItemDrop component = itemPrefab.GetComponent(); if ((Object)(object)component == (Object)null) { Logger.LogWarning((object)("[LoxMilkMod] FixItemIcon: " + itemName + " ItemDrop component not found.")); } else { EnsureItemHasIcon(component, fallbackIcon); } } } [HarmonyPatch(typeof(Character), "GetHoverText")] public static class LoxMilkHoverPatch { private const float MilkerDistance = 5f; private static void Postfix(Character __instance, ref string __result) { //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance == (Object)null) { return; } string text = __instance.m_name ?? string.Empty; string text2 = (((Object)(object)((Component)__instance).gameObject != (Object)null) ? ((Object)((Component)__instance).gameObject).name : string.Empty); if (!text.ToLowerInvariant().Contains("lox") && !text2.ToLowerInvariant().Contains("lox")) { return; } Tameable component = ((Component)__instance).GetComponent(); if ((Object)(object)component == (Object)null || !component.IsTamed()) { return; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } bool flag = false; foreach (MobileLoxWorkbench instance in MobileLoxWorkbench.Instances) { if (!((Object)(object)instance == (Object)null)) { float num = Vector3.Distance(((Component)localPlayer).transform.position, ((Component)instance).transform.position); if (num <= 5f) { flag = true; break; } } } if (flag && (string.IsNullOrEmpty(__result) || !__result.Contains("[Ctrl+C] Milking lox"))) { __result += "\n[Ctrl+C] Milking lox"; } } } public sealed class LoxMilkingController : MonoBehaviour { private const float MilkerDistance = 5f; private const float LoxLookDistance = 8f; private const float LookSphereRadius = 0.5f; private const string MilkPrefabName = "LoxMilkItem"; private readonly Dictionary _loxNextMilkTime = new Dictionary(); private static float MilkCooldown => ModConfig.IsInitialized ? ModConfig.LoxMilkingCooldownSeconds : 1260f; private static int MilkPerLox => ModConfig.IsInitialized ? ModConfig.MilkPerMilking.Value : 5; private void Update() { Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null)) { bool key = Input.GetKey((KeyCode)306); bool keyDown = Input.GetKeyDown((KeyCode)99); if (key && keyDown) { TryMilkNearbyLox(localPlayer); } } } private void TryMilkNearbyLox(Player player) { if ((Object)(object)player == (Object)null) { return; } if (!PlayerIsNearMobileWorkbench(player)) { ShowMessage(player, "You must stand near the Milker to milk a lox."); return; } Character lookedAtLox = GetLookedAtLox(player, 8f); if ((Object)(object)lookedAtLox == (Object)null) { ShowMessage(player, "Look at a tamed lox."); return; } Tameable component = ((Component)lookedAtLox).GetComponent(); if ((Object)(object)component == (Object)null || !component.IsTamed()) { ShowMessage(player, "The lox must be tamed."); return; } if (!CanMilkLox(lookedAtLox, out var remainingSeconds)) { ShowMessage(player, $"Lox needs to rest ({remainingSeconds}s)."); return; } if ((Object)(object)ObjectDB.instance == (Object)null) { ShowMessage(player, "Error: ObjectDB is not ready."); Logger.LogError((object)"[LoxMilkMod] Can't milk lox: ObjectDB.instance is null."); return; } GameObject itemPrefab = ObjectDB.instance.GetItemPrefab("LoxMilkItem"); if ((Object)(object)itemPrefab == (Object)null) { ShowMessage(player, "Error: lox milk prefab not found."); Logger.LogError((object)"[LoxMilkMod] prefabu is not foundLoxMilkItem."); return; } bool flag = TryPutMilkIntoNearestCart(player, itemPrefab, MilkPerLox); StartLoxCooldown(lookedAtLox); PlayLoxPetEffects(lookedAtLox); if (flag) { ShowMessage(player, "You milked the lox - milk was placed in the Milker."); return; } Inventory inventory = ((Humanoid)player).GetInventory(); if (inventory == null) { ShowMessage(player, "You milked the lox, but no inventory was found."); Logger.LogError((object)"[LoxMilkMod] Player.GetInventory() is null."); } else if (inventory.AddItem(itemPrefab, MilkPerLox)) { ShowMessage(player, "You milked the lox - milk was added to your inventory because the Milker is full."); } else { ShowMessage(player, "You milked the lox, but both inventories are full."); Logger.LogWarning((object)"[LoxMilkMod] Could not add milk neither to Milker nor to the player's inventory."); } } private bool CanMilkLox(Character lox, out int remainingSeconds) { remainingSeconds = 0; if ((Object)(object)lox == (Object)null) { return false; } int instanceID = ((Object)lox).GetInstanceID(); float time = Time.time; if (!_loxNextMilkTime.TryGetValue(instanceID, out var value)) { return true; } if (time >= value) { _loxNextMilkTime.Remove(instanceID); return true; } float num = value - time; remainingSeconds = Mathf.CeilToInt(num); return false; } private void StartLoxCooldown(Character lox) { if (!((Object)(object)lox == (Object)null)) { int instanceID = ((Object)lox).GetInstanceID(); _loxNextMilkTime[instanceID] = Time.time + MilkCooldown; } } private MobileLoxWorkbench GetNearestMobileWorkbench(Player player, float maxDistance) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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) if ((Object)(object)player == (Object)null) { return null; } List instances = MobileLoxWorkbench.Instances; if (instances == null || instances.Count == 0) { return null; } Vector3 position = ((Component)player).transform.position; MobileLoxWorkbench result = null; float num = maxDistance; foreach (MobileLoxWorkbench item in instances) { if (!((Object)(object)item == (Object)null)) { float num2 = Vector3.Distance(position, ((Component)item).transform.position); if (num2 <= num) { num = num2; result = item; } } } return result; } private bool PlayerIsNearMobileWorkbench(Player player, float maxDistance = 5f) { return (Object)(object)GetNearestMobileWorkbench(player, maxDistance) != (Object)null; } private bool TryPutMilkIntoNearestCart(Player player, GameObject milkPrefab, int amount) { if ((Object)(object)player == (Object)null || (Object)(object)milkPrefab == (Object)null || amount <= 0) { return false; } MobileLoxWorkbench nearestMobileWorkbench = GetNearestMobileWorkbench(player, 5f); if ((Object)(object)nearestMobileWorkbench == (Object)null) { return false; } Container componentInChildren = ((Component)nearestMobileWorkbench).GetComponentInChildren(true); if ((Object)(object)componentInChildren == (Object)null) { Logger.LogWarning((object)"[LoxMilkMod] Nearest Milkerhas no Container component."); return false; } Inventory inventory = componentInChildren.GetInventory(); if (inventory == null) { Logger.LogWarning((object)"[LoxMilkMod] Container Milker no equipment."); return false; } return inventory.AddItem(milkPrefab, amount); } private static bool IsLox(Character character) { if ((Object)(object)character == (Object)null) { return false; } string text = ((Object)((Component)character).gameObject).name ?? string.Empty; string text2 = character.m_name ?? string.Empty; return text.IndexOf("lox", StringComparison.OrdinalIgnoreCase) >= 0 || text2.IndexOf("lox", StringComparison.OrdinalIgnoreCase) >= 0; } private static Character GetLookedAtLox(Player player, float maxDistance) { //IL_0044: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null) { return null; } Camera main = Camera.main; if ((Object)(object)main == (Object)null) { Logger.LogWarning((object)"[LoxMilkMod] Camera.main is null."); return null; } Vector3 position = ((Component)main).transform.position; Vector3 forward = ((Component)main).transform.forward; int num = -1; RaycastHit[] array = Physics.SphereCastAll(position, 0.5f, forward, maxDistance, num, (QueryTriggerInteraction)1); if (array == null || array.Length == 0) { return null; } Array.Sort(array, (RaycastHit first, RaycastHit second) => ((RaycastHit)(ref first)).distance.CompareTo(((RaycastHit)(ref second)).distance)); RaycastHit[] array2 = array; for (int num2 = 0; num2 < array2.Length; num2++) { RaycastHit val = array2[num2]; if (!((Object)(object)((RaycastHit)(ref val)).collider == (Object)null)) { Character componentInParent = ((Component)((RaycastHit)(ref val)).collider).GetComponentInParent(); if (!((Object)(object)componentInParent == (Object)null) && !((Object)(object)componentInParent == (Object)(object)player) && IsLox(componentInParent)) { return componentInParent; } } } return null; } private static void PlayLoxPetEffects(Character lox) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)lox == (Object)null)) { Tameable component = ((Component)lox).GetComponent(); if (!((Object)(object)component == (Object)null) && component.m_petEffect != null) { component.m_petEffect.Create(((Component)lox).transform.position, Quaternion.identity, ((Component)lox).transform, 1f, -1); } } } private static void ShowMessage(Player player, string message) { if (!((Object)(object)player == (Object)null) && !string.IsNullOrEmpty(message)) { ((Character)player).Message((MessageType)2, message, 0, (Sprite)null); } } } [BepInPlugin("Jax.LoxMilkMod", "Lox Milk Mod", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class LoxMilkMod : BaseUnityPlugin { public class RequireNearbyPiece : MonoBehaviour { public string RequiredPieceName; public float RequiredDistance = 5f; private Piece _piece; private void Awake() { _piece = ((Component)this).GetComponent(); if (!IsRequiredPieceNearby()) { ZNetView component = ((Component)this).GetComponent(); if ((Object)(object)component != (Object)null && component.IsValid()) { component.Destroy(); } else { Object.Destroy((Object)(object)((Component)this).gameObject); } } } private bool IsRequiredPieceNearby() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) Vector3 position = ((Component)this).transform.position; Piece[] array = Object.FindObjectsOfType(); foreach (Piece val in array) { if (!((Object)(object)val == (Object)null) && ((Object)val).name == RequiredPieceName && Vector3.Distance(position, ((Component)val).transform.position) <= RequiredDistance) { return true; } } return false; } } public const string ModGUID = "Jax.LoxMilkMod"; public const string ModName = "Lox Milk Mod"; public const string Version = "1.0.0"; public static LoxMilkMod Instance; private ModAssets _assets; private Harmony _harmony; private void Awake() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown ModConfig.Bind(((BaseUnityPlugin)this).Config); _harmony = new Harmony("Jax.LoxMilkMod"); _harmony.PatchAll(); _assets = new ModAssets(); _assets.Load(); if ((Object)(object)((Component)this).GetComponent() == (Object)null) { ((Component)this).gameObject.AddComponent(); } PrefabManager.OnVanillaPrefabsAvailable += OnVanillaPrefabsAvailable; PieceManager.OnPiecesRegistered += FeasterRegistrar.RegisterPendingFoods; Logger.LogInfo((object)"[LoxMilkMod] Start"); Instance = this; } private void OnVanillaPrefabsAvailable() { PieceRegistrar pieceRegistrar = new PieceRegistrar(_assets); pieceRegistrar.RegisterAll(); ItemRegistrar itemRegistrar = new ItemRegistrar(_assets); itemRegistrar.RegisterAll(); ConversionRegistrar conversionRegistrar = new ConversionRegistrar(); conversionRegistrar.RegisterAll(); DecorRegistrar decorRegistrar = new DecorRegistrar(_assets); decorRegistrar.RegisterAll(); } private void OnDestroy() { PrefabManager.OnVanillaPrefabsAvailable -= OnVanillaPrefabsAvailable; PieceManager.OnPiecesRegistered -= FeasterRegistrar.RegisterPendingFoods; } private string GetRelativePath(Transform root, Transform target) { List list = new List(); while ((Object)(object)target != (Object)(object)root) { list.Insert(0, ((Object)target).name); target = target.parent; } return string.Join("/", list); } } public sealed class LoxWheelAnimator : MonoBehaviour { public string LeftWheelName = "WheelLeft"; public string RightWheelName = "WheelRight"; public string LeftGearName = "GearLeft"; public string RightGearName = "GearRight"; public float WheelRadius = 0.5f; public float GearSpeed = 80f; private Transform _leftWheel; private Transform _rightWheel; private Transform _leftGear; private Transform _rightGear; private Rigidbody _body; private void Awake() { _body = ((Component)this).GetComponent(); if ((Object)(object)_body == (Object)null) { _body = ((Component)this).GetComponentInParent(); } Transform[] componentsInChildren = ((Component)this).GetComponentsInChildren(true); foreach (Transform val in componentsInChildren) { if (((Object)val).name == LeftWheelName) { _leftWheel = val; } else if (((Object)val).name == RightWheelName) { _rightWheel = val; } else if (((Object)val).name == LeftGearName) { _leftGear = val; } else if (((Object)val).name == RightGearName) { _rightGear = val; } } } private void Update() { float deltaTime = Time.deltaTime; AnimateWheels(deltaTime); AnimateGears(deltaTime); } private void AnimateWheels(float deltaTime) { //IL_0031: 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_0037: 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) if (!((Object)(object)_body == (Object)null) && !(WheelRadius <= 0f)) { Vector3 velocity = _body.velocity; float num = Vector3.Dot(velocity, ((Component)this).transform.forward); if (!(Mathf.Abs(num) < 0.01f)) { float num2 = num * deltaTime; float angleDegrees = num2 / ((float)Math.PI * 2f * WheelRadius) * 360f; RotateWheel(_leftWheel, angleDegrees); RotateWheel(_rightWheel, angleDegrees); } } } private void AnimateGears(float deltaTime) { if ((Object)(object)_leftGear != (Object)null) { _leftGear.Rotate(GearSpeed * deltaTime, 0f, 0f, (Space)1); } if ((Object)(object)_rightGear != (Object)null) { _rightGear.Rotate((0f - GearSpeed) * deltaTime, 0f, 0f, (Space)1); } } private static void RotateWheel(Transform wheel, float angleDegrees) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)wheel == (Object)null)) { wheel.Rotate(Vector3.right, angleDegrees, (Space)1); } } } public sealed class MobileLoxWorkbench : MonoBehaviour { public static readonly List Instances = new List(); private void OnEnable() { if (!Instances.Contains(this)) { Instances.Add(this); } } private void OnDisable() { Instances.Remove(this); } private void OnDestroy() { Instances.Remove(this); } } public sealed class ModAssets { private const string BundleFileName = "loxmilkitem"; public AssetBundle Bundle { get; private set; } public bool IsLoaded => (Object)(object)Bundle != (Object)null; public GameObject SkyrModel { get; private set; } public GameObject CheesePlateModel { get; private set; } public GameObject MilkBottleModel { get; private set; } public GameObject MilkSoupModel { get; private set; } public GameObject MilkBreadDoughModel { get; private set; } public GameObject MilkBreadModel { get; private set; } public GameObject GoudaModel { get; private set; } public GameObject LazurModel { get; private set; } public GameObject CheesecakeModel { get; private set; } public GameObject MeltCheeseModel { get; private set; } public GameObject TwarogModel { get; private set; } public GameObject MilkerModel { get; private set; } public GameObject ButterChurnModel { get; private set; } public GameObject ButterModel { get; private set; } public GameObject ButtermilkModel { get; private set; } public GameObject BearSoupModel { get; private set; } public GameObject FulingDelicacyModel { get; private set; } public GameObject RennetModel { get; private set; } public GameObject ButtermilkTankModel { get; private set; } public GameObject CheeseMachineModel { get; private set; } public GameObject MilkCrateModel { get; private set; } public GameObject ButtermilkCrateModel { get; private set; } public GameObject ButterBucketModel { get; private set; } public GameObject GoudaDecorModel { get; private set; } public GameObject GoudaDecor2Model { get; private set; } public GameObject GoudaDecor3Model { get; private set; } public GameObject LazurDecorModel { get; private set; } public GameObject LazurDecor2Model { get; private set; } public GameObject LazurDecor3Model { get; private set; } public GameObject TwarogBowl1Model { get; private set; } public GameObject TwarogBowl2Model { get; private set; } public GameObject TwarogBowl3Model { get; private set; } public GameObject BaseTwarogModel { get; private set; } public GameObject BaseSkyrModel { get; private set; } public GameObject BaseMeltCheeseModel { get; private set; } public GameObject BaseGoudaModel { get; private set; } public GameObject BaseLazurModel { get; private set; } public Sprite SkyrIcon { get; private set; } public Sprite CheesePlateIcon { get; private set; } public Sprite ButterIcon { get; private set; } public Sprite ButtermilkIcon { get; private set; } public Sprite BearSoupIcon { get; private set; } public Sprite FulingDelicacyIcon { get; private set; } public Sprite MilkerIcon { get; private set; } public Sprite WhiteCheeseIcon { get; private set; } public Sprite MeltCheeseIcon { get; private set; } public Sprite CheesecakeIcon { get; private set; } public Sprite LazurIcon { get; private set; } public Sprite GoudaIcon { get; private set; } public Sprite MilkBreadIcon { get; private set; } public Sprite MilkBreadDoughIcon { get; private set; } public Sprite MilkSoupIcon { get; private set; } public Sprite LoxMilkIcon { get; private set; } public Sprite RennetIcon { get; private set; } public Sprite ButterChurnIcon { get; private set; } public Sprite ButtermilkTankIcon { get; private set; } public Sprite CheeseMachineIcon { get; private set; } public Sprite ButterStackIcon { get; private set; } public Sprite MilkStackIcon { get; private set; } public Sprite ButtermilkStackIcon { get; private set; } public Sprite GoudaDecor1Icon { get; private set; } public Sprite GoudaDecor2Icon { get; private set; } public Sprite GoudaDecor3Icon { get; private set; } public Sprite LazurDecor1Icon { get; private set; } public Sprite LazurDecor2Icon { get; private set; } public Sprite LazurDecor3Icon { get; private set; } public Sprite TwarogDecor1Icon { get; private set; } public Sprite TwarogDecor2Icon { get; private set; } public Sprite TwarogDecor3Icon { get; private set; } public Sprite BaseSkyrIcon { get; private set; } public Sprite BaseTwarogIcon { get; private set; } public Sprite BaseMeltCheeseIcon { get; private set; } public Sprite BaseGoudaIcon { get; private set; } public Sprite BaseLazurIcon { get; private set; } public void Load() { if ((Object)(object)Bundle != (Object)null) { Logger.LogWarning((object)"[LoxMilkMod] AssetBundle loaded."); return; } string location = typeof(LoxMilkMod).Assembly.Location; string directoryName = Path.GetDirectoryName(location); if (string.IsNullOrEmpty(directoryName)) { Logger.LogError((object)"[LoxMilkMod] Could not locate mod DLL folder."); return; } string text = Path.Combine(directoryName, "loxmilkitem"); Logger.LogInfo((object)("[LoxMilkMod] DLL path: " + location)); Logger.LogInfo((object)("[LoxMilkMod] Attempting to load AssetBundle: " + text)); if (!File.Exists(text)) { Logger.LogError((object)("[LoxMilkMod] Could not locate AssetBundle in folder with DLL file: " + text)); return; } long length = new FileInfo(text).Length; Logger.LogInfo((object)("[LoxMilkMod] AssetBundle size: " + length + " bajtów.")); if (length == 0) { Logger.LogError((object)"[LoxMilkMod] Plik AssetBundle is empty."); return; } Bundle = AssetBundle.LoadFromFile(text); if ((Object)(object)Bundle == (Object)null) { Logger.LogError((object)("[LoxMilkMod] Unity could not open AssetBundle: " + text)); return; } LoadModels(); LoadIcons(); Logger.LogInfo((object)"[LoxMilkMod] Finished loading models and icons."); } private void LoadModels() { SkyrModel = LoadPrefab("skyrModel"); CheesePlateModel = LoadPrefab("cheeseplateModel"); MilkBottleModel = LoadPrefab("LoxMilkBottleModel"); MilkSoupModel = LoadPrefab("zupa mleczna"); MilkBreadDoughModel = LoadPrefab("LoxMilkBreadDoughModel"); MilkBreadModel = LoadPrefab("LoxMilkBreadModel"); GoudaModel = LoadPrefab("GoudaModel"); LazurModel = LoadPrefab("LazurModel"); CheesecakeModel = LoadPrefab("SernikModel"); MeltCheeseModel = LoadPrefab("SerTopionyModel"); TwarogModel = LoadPrefab("TwarogModel"); MilkerModel = LoadPrefab("LoxMilkerModel"); ButterChurnModel = LoadPrefab("MaselnicaModel"); ButterModel = LoadPrefab("MasloModel"); ButtermilkModel = LoadPrefab("MaslankaModel"); BearSoupModel = LoadPrefab("BearSoupModel"); FulingDelicacyModel = LoadPrefab("FulingDelicacyModel"); RennetModel = LoadPrefab("PodpuszczkaModel"); ButtermilkTankModel = LoadPrefab("ZbiornikModel"); CheeseMachineModel = LoadPrefab("serowarModel"); MilkCrateModel = LoadPrefab("milkCrateModel"); ButtermilkCrateModel = LoadPrefab("buttermilkCrateModel"); ButterBucketModel = LoadPrefab("butterBucketModel"); GoudaDecorModel = LoadPrefab("goudaDecorModel"); GoudaDecor2Model = LoadPrefab("goudaDecor2Model"); GoudaDecor3Model = LoadPrefab("goudaDecor3Model"); LazurDecorModel = LoadPrefab("lazurDecorModel"); LazurDecor2Model = LoadPrefab("lazurDecor2Model"); LazurDecor3Model = LoadPrefab("lazurDecor3Model"); TwarogBowl1Model = LoadPrefab("twarogBowl1Model"); TwarogBowl2Model = LoadPrefab("twarogBowl2Model"); TwarogBowl3Model = LoadPrefab("twarogBowl3Model"); BaseTwarogModel = LoadPrefab("bazatwarogModel"); BaseMeltCheeseModel = LoadPrefab("bazatopionyModel"); BaseLazurModel = LoadPrefab("bazalazurModel"); BaseGoudaModel = LoadPrefab("bazagoudaModel"); BaseSkyrModel = LoadPrefab("BaseSkyrModel"); } private void LoadIcons() { SkyrIcon = LoadSprite("icon_skyr"); CheesePlateIcon = LoadSprite("icon_cheeseplate"); ButterIcon = LoadSprite("icon_butter"); ButtermilkIcon = LoadSprite("icon_buttermilk"); BearSoupIcon = LoadSprite("icon_bearsoup"); FulingDelicacyIcon = LoadSprite("icon_fulingdelicacy"); CheesecakeIcon = LoadSprite("icon_cheesecake"); GoudaIcon = LoadSprite("icon_gouda"); LazurIcon = LoadSprite("icon_lazur"); MeltCheeseIcon = LoadSprite("icon_meltcheese"); LoxMilkIcon = LoadSprite("icon_loxmilk"); MilkerIcon = LoadSprite("icon_milker"); MilkSoupIcon = LoadSprite("icon_milksoup"); WhiteCheeseIcon = LoadSprite("icon_whitecheese"); MilkBreadDoughIcon = LoadSprite("icon_milkbreaddough"); MilkBreadIcon = LoadSprite("icon_milkbread"); RennetIcon = LoadSprite("icon_rennet"); ButterChurnIcon = LoadSprite("icon_maselnica"); ButtermilkTankIcon = LoadSprite("icon_zbiornik"); CheeseMachineIcon = LoadSprite("icon_serowar"); ButterStackIcon = LoadSprite("icon_maslostack"); MilkStackIcon = LoadSprite("icon_mlekostack"); ButtermilkStackIcon = LoadSprite("icon_maslankastack"); GoudaDecor1Icon = LoadSprite("icon_gouda1"); GoudaDecor2Icon = LoadSprite("icon_gouda2"); GoudaDecor3Icon = LoadSprite("icon_gouda3"); LazurDecor1Icon = LoadSprite("icon_lazur1"); LazurDecor2Icon = LoadSprite("icon_lazur2"); LazurDecor3Icon = LoadSprite("icon_lazur3"); TwarogDecor1Icon = LoadSprite("icon_twarog1"); TwarogDecor2Icon = LoadSprite("icon_twarog2"); TwarogDecor3Icon = LoadSprite("icon_twarog3"); BaseTwarogIcon = LoadSprite("icon_bazatwarog"); BaseGoudaIcon = LoadSprite("icon_bazagouda"); BaseSkyrIcon = LoadSprite("icon_bazaskyr"); BaseLazurIcon = LoadSprite("icon_bazalazur"); BaseMeltCheeseIcon = LoadSprite("icon_bazatopiony"); } private GameObject LoadPrefab(string prefabName) { if ((Object)(object)Bundle == (Object)null) { Logger.LogError((object)("[LoxMilkMod] Unable to load prefab " + prefabName + ", because AssetBundle is empty.")); return null; } GameObject val = Bundle.LoadAsset(prefabName); if ((Object)(object)val == (Object)null) { Logger.LogWarning((object)("[LoxMilkMod] prefabu is not found: " + prefabName)); } else { Logger.LogInfo((object)("[LoxMilkMod] prefab loaded: " + prefabName)); } return val; } private Sprite LoadSprite(string spriteName) { if ((Object)(object)Bundle == (Object)null) { Logger.LogError((object)("[LoxMilkMod] Unable to load icon " + spriteName + ", because AssetBundle is empty.")); return null; } Sprite val = Bundle.LoadAsset(spriteName); if ((Object)(object)val == (Object)null) { Logger.LogWarning((object)("[LoxMilkMod] icon not found: " + spriteName)); } return val; } } public static class ModConfig { public static ConfigEntry CheeseFermentationMinutes { get; private set; } public static ConfigEntry SkyrFermentationMinutes { get; private set; } public static ConfigEntry ButtermilkFermentationMinutes { get; private set; } public static ConfigEntry ButterFermentationMinutes { get; private set; } public static ConfigEntry LoxMilkingCooldownMinutes { get; private set; } public static ConfigEntry MilkPerMilking { get; private set; } public static bool IsInitialized => CheeseFermentationMinutes != null && SkyrFermentationMinutes != null && ButtermilkFermentationMinutes != null && ButterFermentationMinutes != null && LoxMilkingCooldownMinutes != null && MilkPerMilking != null; public static float CheeseFermentationSeconds => Math.Max(0.1f, CheeseFermentationMinutes.Value) * 60f; public static float SkyrFermentationSeconds => Math.Max(0.1f, SkyrFermentationMinutes.Value) * 60f; public static float ButtermilkFermentationSeconds => Math.Max(0.1f, ButtermilkFermentationMinutes.Value) * 60f; public static float ButterFermentationSeconds => Math.Max(0.1f, ButterFermentationMinutes.Value) * 60f; public static float LoxMilkingCooldownSeconds => Math.Max(0.1f, LoxMilkingCooldownMinutes.Value) * 60f; public static void Bind(ConfigFile config) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Expected O, but got Unknown //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Expected O, but got Unknown //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Expected O, but got Unknown //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Expected O, but got Unknown //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Expected O, but got Unknown if (config == null) { Logger.LogError((object)"[LoxMilkMod] ModConfig.Bind: ConfigFile jest null."); } else if (!IsInitialized) { CheeseFermentationMinutes = config.Bind("Fermentation", "Cheese fermentation time (minutes)", 40f, new ConfigDescription("Time required to ferment all cheeses in the Cheese Machine.", (AcceptableValueBase)(object)new AcceptableValueRange(0.1f, 240f), Array.Empty())); SkyrFermentationMinutes = config.Bind("Fermentation", "Skyr fermentation time (minutes)", 40f, new ConfigDescription("Time required to ferment skyr in the Dairy Cauldron.", (AcceptableValueBase)(object)new AcceptableValueRange(0.1f, 240f), Array.Empty())); ButtermilkFermentationMinutes = config.Bind("Fermentation", "Buttermilk fermentation time (minutes)", 40f, new ConfigDescription("Time required to ferment buttermilk in the Dairy Cauldron.", (AcceptableValueBase)(object)new AcceptableValueRange(0.1f, 240f), Array.Empty())); ButterFermentationMinutes = config.Bind("Fermentation", "Butter churning time (minutes)", 40f, new ConfigDescription("Time required to churn butter in the Butter Churn.", (AcceptableValueBase)(object)new AcceptableValueRange(0.1f, 240f), Array.Empty())); LoxMilkingCooldownMinutes = config.Bind("Milking", "Lox milking cooldown (minutes)", 21f, new ConfigDescription("How long a lox must rest before it can be milked again.", (AcceptableValueBase)(object)new AcceptableValueRange(0.1f, 240f), Array.Empty())); MilkPerMilking = config.Bind("Milking", "Milk gained per milking", 5, new ConfigDescription("Number of Lox milk items received from one successful milking.", (AcceptableValueBase)(object)new AcceptableValueRange(1, 100), Array.Empty())); Logger.LogInfo((object)"[LoxMilkMod] Configuration entries created."); } } } public sealed class PieceRegistrar { private const string MobileWorkbenchPieceName = "piece_mobile_loxworkbench"; private const string CheeseMachinePieceName = "CheeseMachine"; private const string ButterChurnPieceName = "piece_butterchurn"; private const string ButtermilkTankPieceName = "piece_buttermilktank"; private readonly ModAssets _assets; public PieceRegistrar(ModAssets assets) { _assets = assets; } public void RegisterAll() { if (_assets == null) { Logger.LogError((object)"[LoxMilkMod] PieceRegistrar: ModAssets is null."); return; } if (!_assets.IsLoaded) { Logger.LogError((object)"[LoxMilkMod] PieceRegistrar: AssetBundle loaded."); return; } CreateCheeseMachine(); CreateButterChurn(); CreateButtermilkTank(); CreateMobileWorkbenchCart(); Logger.LogInfo((object)"[LoxMilkMod] Construction registration completed."); } private void CreateMobileWorkbenchCart() { //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: 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_0112: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Expected O, but got Unknown //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Expected O, but got Unknown GameObject prefab = PrefabManager.Instance.GetPrefab("Cart"); if ((Object)(object)prefab == (Object)null) { Logger.LogWarning((object)"[LoxMilkMod] Cart prefab not found. Milker is not created."); return; } GameObject val = PrefabManager.Instance.CreateClonedPrefab("piece_mobile_loxworkbench", prefab); if ((Object)(object)val == (Object)null) { Logger.LogWarning((object)"[LoxMilkMod] Cart is not cloned."); return; } ConfigureMilkerVisual(val); ConfigureMilkerName(val); Piece orAddPiece = GetOrAddPiece(val); orAddPiece.m_name = "Milker"; orAddPiece.m_description = "A combination of a cart and a workbench. Can be pulled like a cart."; if ((Object)(object)_assets.MilkerIcon != (Object)null) { orAddPiece.m_icon = _assets.MilkerIcon; } HoverText component = val.GetComponent(); if ((Object)(object)component != (Object)null) { component.m_text = "Milker"; } PieceConfig val2 = new PieceConfig { PieceTable = "Hammer", Name = "Milker", Description = "A combination of a cart and a workbench. Can be pulled like a cart.", Category = "Misc", AllowedInDungeons = false, CraftingStation = "piece_artisanstation", Icon = _assets.MilkerIcon }; val2.AddRequirement("BlackMetal", 10, true); val2.AddRequirement("Iron", 5, true); val2.AddRequirement("SurtlingCore", 2, true); val2.AddRequirement("FineWood", 20, true); CustomPiece val3 = new CustomPiece(val, false, val2); PieceManager.Instance.AddPiece(val3); if ((Object)(object)_assets.MilkerIcon != (Object)null && (Object)(object)val3.PiecePrefab != (Object)null) { Piece component2 = val3.PiecePrefab.GetComponent(); if ((Object)(object)component2 != (Object)null) { component2.m_icon = _assets.MilkerIcon; } } SetupMobileCartAsWorkbench(val3.PiecePrefab); Logger.LogInfo((object)"[LoxMilkMod] construction added: Milker."); } private void ConfigureMilkerVisual(GameObject clonedCart) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_0083: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_assets.MilkerModel == (Object)null) { Logger.LogWarning((object)"[LoxMilkMod] Milker model is not found. replaced by vanilla cart model."); return; } DisableRenderers(clonedCart); GameObject val = Object.Instantiate(_assets.MilkerModel, clonedCart.transform); ((Object)val).name = "LoxMilkMod_MilkerVisual"; val.transform.localPosition = Vector3.zero; val.transform.localRotation = Quaternion.identity; val.transform.localScale = Vector3.one * 0.75f; LoxWheelAnimator loxWheelAnimator = clonedCart.GetComponent(); if ((Object)(object)loxWheelAnimator == (Object)null) { loxWheelAnimator = clonedCart.AddComponent(); } loxWheelAnimator.WheelRadius = 0.5f; } private static void ConfigureMilkerName(GameObject clonedCart) { Component component = clonedCart.GetComponent("Cart"); if (!((Object)(object)component == (Object)null)) { FieldInfo field = ((object)component).GetType().GetField("m_name", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { field.SetValue(component, "Milker"); } } } private static void SetupMobileCartAsWorkbench(GameObject cartObject) { if ((Object)(object)cartObject == (Object)null) { Logger.LogWarning((object)"[LoxMilkMod] SetupMobileCartAsWorkbench: cartObject is null."); return; } GameObject prefab = PrefabManager.Instance.GetPrefab("piece_workbench"); if ((Object)(object)prefab == (Object)null) { Logger.LogWarning((object)"[LoxMilkMod] piece_workbench not found."); return; } CraftingStation component = prefab.GetComponent(); if ((Object)(object)component == (Object)null) { Logger.LogWarning((object)"[LoxMilkMod] piece_workbench do not have component CraftingStation."); return; } CraftingStation val = cartObject.GetComponent(); if ((Object)(object)val == (Object)null) { val = cartObject.AddComponent(); } val.m_name = component.m_name; val.m_icon = component.m_icon; val.m_rangeBuild = component.m_rangeBuild; val.m_craftRequireRoof = component.m_craftRequireRoof; val.m_craftRequireFire = component.m_craftRequireFire; if ((Object)(object)cartObject.GetComponent() == (Object)null) { cartObject.AddComponent(); } } private void CreateCheeseMachine() { //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: 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_00f1: 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_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Expected O, but got Unknown //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Expected O, but got Unknown GameObject prefab = PrefabManager.Instance.GetPrefab("fermenter"); if ((Object)(object)prefab == (Object)null) { Logger.LogWarning((object)"[LoxMilkMod] cannot found prefab fermenter. cheese machine is not created."); return; } GameObject val = PrefabManager.Instance.CreateClonedPrefab("CheeseMachine", prefab); if ((Object)(object)val == (Object)null) { Logger.LogError((object)"[LoxMilkMod] cannot created cheese machine."); return; } Fermenter component = val.GetComponent(); if ((Object)(object)component != (Object)null) { component.m_name = "Cheese machine"; component.m_fermentationDuration = ModConfig.CheeseFermentationSeconds; } ReplacePieceVisual(val, _assets.CheeseMachineModel, Vector3.zero, Quaternion.identity, 1f); Piece orAddPiece = GetOrAddPiece(val); orAddPiece.m_name = "Cheese machine"; orAddPiece.m_description = "Machine used for cheese production."; PieceConfig val2 = new PieceConfig { PieceTable = "Hammer", Name = "Cheese machine", Description = "Machine used for cheese production.", Category = "Crafting", AllowedInDungeons = false, CraftingStation = "piece_artisanstation", Icon = _assets.CheeseMachineIcon }; val2.AddRequirement("FineWood", 20, true); val2.AddRequirement("Iron", 15, true); val2.AddRequirement("IronNails", 10, true); val2.AddRequirement("Crystal", 20, true); PieceManager.Instance.AddPiece(new CustomPiece(val, false, val2)); Logger.LogInfo((object)"[LoxMilkMod] Coionstruction added: Cheese machine."); } private void CreateButterChurn() { //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: 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_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Expected O, but got Unknown //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Expected O, but got Unknown GameObject prefab = PrefabManager.Instance.GetPrefab("fermenter"); if ((Object)(object)prefab == (Object)null) { Logger.LogWarning((object)"[LoxMilkMod] cannot found prefab fermenter. butter churn is not created."); return; } GameObject val = PrefabManager.Instance.CreateClonedPrefab("piece_butterchurn", prefab); if ((Object)(object)val == (Object)null) { Logger.LogError((object)"[LoxMilkMod] cannot create butter churn."); return; } Fermenter component = val.GetComponent(); if ((Object)(object)component != (Object)null) { component.m_name = "Butter churn"; component.m_fermentationDuration = ModConfig.ButterFermentationSeconds; } DisableParticleSystems(val); ReplacePieceVisual(val, _assets.ButterChurnModel, Vector3.zero, Quaternion.Euler(0f, 180f, 0f), 1f); if ((Object)(object)val.GetComponent() == (Object)null) { val.AddComponent(); } Piece orAddPiece = GetOrAddPiece(val); orAddPiece.m_name = "Butter churn"; orAddPiece.m_description = "Used to churn butter from lox milk."; PieceConfig val2 = new PieceConfig { PieceTable = "Hammer", Name = "Butter churn", Description = "Used to churn butter from lox milk.", Category = "Crafting", AllowedInDungeons = false, CraftingStation = "piece_artisanstation", Icon = _assets.ButterChurnIcon }; val2.AddRequirement("FineWood", 15, true); val2.AddRequirement("Iron", 10, true); val2.AddRequirement("Copper", 10, true); PieceManager.Instance.AddPiece(new CustomPiece(val, false, val2)); Logger.LogInfo((object)"[LoxMilkMod] Construction added: Butter churn."); } private void CreateButtermilkTank() { //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //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_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Expected O, but got Unknown //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Expected O, but got Unknown GameObject prefab = PrefabManager.Instance.GetPrefab("fermenter"); if ((Object)(object)prefab == (Object)null) { Logger.LogError((object)"[LoxMilkMod] prefab fermenter not found. dairy couldron not created."); return; } if ((Object)(object)_assets.ButtermilkTankModel == (Object)null) { Logger.LogError((object)"[LoxMilkMod] model is not found dairy couldron."); return; } GameObject val = PrefabManager.Instance.CreateClonedPrefab("piece_buttermilktank", prefab); if ((Object)(object)val == (Object)null) { Logger.LogError((object)"[LoxMilkMod] cannot create dairy couldron."); return; } RemoveUnwantedTankComponents(val); Fermenter component = val.GetComponent(); if ((Object)(object)component != (Object)null) { component.m_name = "Dairy cauldron"; component.m_fermentationDuration = ModConfig.ButtermilkFermentationSeconds; } DisableParticleSystems(val); DisableRenderers(val); GameObject val2 = Object.Instantiate(_assets.ButtermilkTankModel, val.transform); ((Object)val2).name = "LoxMilkMod_ButtermilkTankVisual"; val2.transform.localPosition = new Vector3(0f, -0.35f, 0f); val2.transform.localRotation = Quaternion.Euler(0f, 180f, 0f); val2.transform.localScale = Vector3.one; Piece orAddPiece = GetOrAddPiece(val); orAddPiece.m_name = "Dairy cauldron"; orAddPiece.m_description = "Allows you to make lox milk-based potions."; HoverText component2 = val.GetComponent(); if ((Object)(object)component2 != (Object)null) { component2.m_text = "Dairy cauldron"; } RemoveTankCollidersAndTriggers(val); AddTankCollider(val); AddTankAnimator(val); PieceConfig val3 = new PieceConfig { PieceTable = "Hammer", Name = "Dairy cauldron", Description = "Allows you to make lox milk-based potions.", Category = "Crafting", AllowedInDungeons = false, CraftingStation = "piece_artisanstation", Icon = _assets.ButtermilkTankIcon }; if ((Object)(object)_assets.ButtermilkTankIcon == (Object)null) { Logger.LogWarning((object)"[LoxMilkMod] dairy couldron icon is null."); } val3.AddRequirement("FineWood", 10, true); val3.AddRequirement("Iron", 20, true); val3.AddRequirement("IronNails", 10, true); val3.AddRequirement("Crystal", 20, true); PieceManager.Instance.AddPiece(new CustomPiece(val, false, val3)); Logger.LogInfo((object)"[LoxMilkMod] construction added: Dairy cauldron."); } private static void RemoveUnwantedTankComponents(GameObject tank) { CraftingStation component = tank.GetComponent(); if ((Object)(object)component != (Object)null) { Object.DestroyImmediate((Object)(object)component); } Smelter component2 = tank.GetComponent(); if ((Object)(object)component2 != (Object)null) { Object.DestroyImmediate((Object)(object)component2); } EffectArea[] componentsInChildren = tank.GetComponentsInChildren(true); EffectArea[] array = componentsInChildren; foreach (EffectArea val in array) { Object.DestroyImmediate((Object)(object)val); } CraftingStation[] componentsInChildren2 = tank.GetComponentsInChildren(true); CraftingStation[] array2 = componentsInChildren2; foreach (CraftingStation val2 in array2) { if ((Object)(object)val2 != (Object)null) { Object.DestroyImmediate((Object)(object)val2); } } } private static void RemoveTankCollidersAndTriggers(GameObject tank) { Collider[] componentsInChildren = tank.GetComponentsInChildren(true); Collider[] array = componentsInChildren; foreach (Collider val in array) { Object.DestroyImmediate((Object)(object)val); } MonoBehaviour[] componentsInChildren2 = tank.GetComponentsInChildren(true); MonoBehaviour[] array2 = componentsInChildren2; foreach (MonoBehaviour val2 in array2) { if (!((Object)(object)val2 == (Object)null)) { string name = ((object)val2).GetType().Name; if (name.Contains("Character") || name.Contains("Trigger") || name.Contains("PlayerBase")) { Object.DestroyImmediate((Object)(object)val2); } } } } private static void AddTankCollider(GameObject tank) { //IL_0018: 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) BoxCollider val = tank.AddComponent(); val.size = new Vector3(0.9f, 1.5f, 0.9f); val.center = new Vector3(0f, 0.52f, 0f); ((Collider)val).isTrigger = false; } private static void AddTankAnimator(GameObject tank) { //IL_001d: 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) ButtermilkTankRotorAnimator buttermilkTankRotorAnimator = tank.GetComponent(); if ((Object)(object)buttermilkTankRotorAnimator == (Object)null) { buttermilkTankRotorAnimator = tank.AddComponent(); } buttermilkTankRotorAnimator.RotationAxis = Vector3.left; buttermilkTankRotorAnimator.RotationSpeed = 90f; } private static Piece GetOrAddPiece(GameObject gameObject) { Piece val = gameObject.GetComponent(); if ((Object)(object)val == (Object)null) { val = gameObject.AddComponent(); } return val; } private static void DisableRenderers(GameObject gameObject) { MeshRenderer[] componentsInChildren = gameObject.GetComponentsInChildren(true); MeshRenderer[] array = componentsInChildren; foreach (MeshRenderer val in array) { ((Renderer)val).enabled = false; } } private static void DisableParticleSystems(GameObject gameObject) { ParticleSystem[] componentsInChildren = gameObject.GetComponentsInChildren(true); ParticleSystem[] array = componentsInChildren; foreach (ParticleSystem val in array) { ((Component)val).gameObject.SetActive(false); } } private static void ReplacePieceVisual(GameObject parent, GameObject model, Vector3 localPosition, Quaternion localRotation, float scale) { //IL_0053: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)model == (Object)null) { Logger.LogWarning((object)("[LoxMilkMod] model is null for construcion: " + ((Object)parent).name + ". replaced by vanilla.")); return; } DisableRenderers(parent); GameObject val = Object.Instantiate(model, parent.transform); ((Object)val).name = "LoxMilkMod_Visual"; val.transform.localPosition = localPosition; val.transform.localRotation = localRotation; val.transform.localScale = Vector3.one * scale; Collider[] componentsInChildren = val.GetComponentsInChildren(true); Collider[] array = componentsInChildren; foreach (Collider val2 in array) { Object.DestroyImmediate((Object)(object)val2); } MeshRenderer[] componentsInChildren2 = val.GetComponentsInChildren(true); MeshRenderer[] array2 = componentsInChildren2; foreach (MeshRenderer val3 in array2) { ((Renderer)val3).enabled = true; } } } [HarmonyPatch(typeof(Player), "UpdateFood")] public static class RemoveSatiatedWhenNoFoodPatch { private static void Postfix(Player __instance) { if (!((Object)(object)__instance == (Object)null) && __instance.GetFoods().Count <= 0) { SEMan sEMan = ((Character)__instance).GetSEMan(); if (sEMan != null) { int stableHashCode = StringExtensionMethods.GetStableHashCode("SE_SatiatedVisual"); sEMan.RemoveStatusEffect(stableHashCode, false); } } } } public sealed class SE_Skyr : StatusEffect { private const float CheckInterval = 1f; private const float RestedDuration = 120f; private float _checkTimer; public override void UpdateStatusEffect(float deltaTime) { ((StatusEffect)this).UpdateStatusEffect(deltaTime); _checkTimer += deltaTime; if (_checkTimer < 1f) { return; } _checkTimer = 0f; Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } SEMan sEMan = ((Character)localPlayer).GetSEMan(); if (sEMan == null) { return; } int stableHashCode = StringExtensionMethods.GetStableHashCode("Rested"); if (!sEMan.HaveStatusEffect(stableHashCode)) { StatusEffect val = sEMan.AddStatusEffect(stableHashCode, false, 0, 0f); if ((Object)(object)val != (Object)null) { val.m_ttl = 120f; } } } } public sealed class SE_StrongBones : StatusEffect { public override void UpdateStatusEffect(float deltaTime) { ((StatusEffect)this).UpdateStatusEffect(deltaTime); } } [HarmonyPatch(typeof(Character), "Damage")] public static class StrongBonesFallReductionPatch { private static void Prefix(Character __instance, ref HitData hit) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Invalid comparison between Unknown and I4 Player val = (Player)(object)((__instance is Player) ? __instance : null); if ((Object)(object)val == (Object)null || hit == null) { return; } SEMan sEMan = ((Character)val).GetSEMan(); if (sEMan != null) { int stableHashCode = StringExtensionMethods.GetStableHashCode("SE_StrongBones"); if (sEMan.HaveStatusEffect(stableHashCode) && (int)hit.m_hitType == 3) { hit.m_damage.m_damage *= 0.5f; } } } }