using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using TobaccoPotAndCigar.Compatibility; using TobaccoPotAndCigar.Prefabs; using TobaccoPotAndCigar.Runtime; using TobaccoPotAndCigar.Shops; using TobaccoPotAndCigar.Smoking; using UnityEngine; using UnityEngine.PostProcessing; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")] [assembly: AssemblyCompany("TobaccoPotAndCigar")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.2.7.0")] [assembly: AssemblyInformationalVersion("1.2.7")] [assembly: AssemblyProduct("TobaccoPotAndCigar")] [assembly: AssemblyTitle("TobaccoPotAndCigar")] [assembly: AssemblyVersion("1.2.7.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace TobaccoPotAndCigar { [BepInPlugin("DogEggz.Cigar", "Tobacco pot and cigar", "1.2.7")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { public const string PluginGuid = "DogEggz.Cigar"; public const string PluginName = "Tobacco pot and cigar"; public const string PluginVersion = "1.2.7"; internal const int PointerMask = -67713029; private Harmony harmony; internal static ManualLogSource LogSource { get; private set; } internal static string PluginDirectory { get; private set; } private void Awake() { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown LogSource = ((BaseUnityPlugin)this).Logger; PluginDirectory = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location) ?? string.Empty; RuntimeDiagnostics.InfoSink = delegate(string message) { ((BaseUnityPlugin)this).Logger.LogInfo((object)message); }; RuntimeDiagnostics.ErrorSink = delegate(string message) { ((BaseUnityPlugin)this).Logger.LogError((object)message); }; try { CigarAssetBundle.Load(PluginDirectory); harmony = new Harmony("DogEggz.Cigar"); harmony.PatchAll(typeof(Plugin).Assembly); RadSingleClickSmoking.Install(harmony); ShopPlacement.ResetDiagnostics(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Tobacco pot and cigar 1.2.7 loaded."); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Cigar initialization failed: " + ex)); throw; } } private void OnDestroy() { Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } CigarEffectService.Reset(); RadRefinementsCompatibility.Reset(); CigarPrefabRegistrar.Reset(); CigarAssetBundle.Unload(); ShopPlacement.ResetDiagnostics(); RuntimeDiagnostics.Reset(); PluginDirectory = null; LogSource = null; } } } namespace TobaccoPotAndCigar.Shops { internal static class ShopPlacement { private const string GoldRockScene = "island 1 A Gold Rock"; private const string DragonCliffsScene = "island 9 E Dragon Cliffs"; private const string SageHillsScene = "island 13 E (Sage Hills)"; private const string FortAestrinScene = "island 15 M (Fort)"; private const string NeverdinScene = "island 3 A Neverdin"; private const string SirenSongScene = "island 21 M (siren song)"; private const string CrabBeachScene = "island 11 E (Crab Beach)"; private const string OasisScene = "island 20 A (Oasis)"; private const string EastwindScene = "island 19 M (Eastwind)"; private const string PonderingPeakScene = "island 39 (onsen)"; private const string ChronosScene = "island 25 (chronos)"; private static readonly HashSet LoggedIdentityFailures = new HashSet(); private static readonly FieldInfo StockItem = typeof(ShopItemSpawner).GetField("item", BindingFlags.Instance | BindingFlags.NonPublic); private static readonly FieldInfo ItemShopArea = typeof(ShipItem).GetField("shopArea", BindingFlags.Instance | BindingFlags.NonPublic); internal static void ResetDiagnostics() { LoggedIdentityFailures.Clear(); } internal static void ConfigureSpawnerBeforeStart(ShopItemSpawner spawner) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0032: 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) StorageShopPlacement.Configure(spawner); if (!CigarPrefabRegistrar.IsReady || (Object)(object)spawner == (Object)null) { return; } Scene scene = ((Component)spawner).gameObject.scene; if (!((Scene)(ref scene)).IsValid()) { return; } scene = ((Component)spawner).gameObject.scene; string name = ((Scene)(ref scene)).name; string name2 = ((Object)((Component)spawner).gameObject).name; if ((name == "island 1 A Gold Rock" && (name2 == "shop item (171)" || name2 == "shop item (173)")) || (name == "island 9 E Dragon Cliffs" && name2 == "shop item spawner (184)")) { if (!IsUniqueSpawner(spawner)) { LogIdentityFailure(name + "/" + name2); } else { spawner.itemPrefab = CigarAssetBundle.GetPrefab(614); } } } internal static void AddRelativeDisplaysAfterStart(ShopItemSpawner anchor) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Unknown result type (might be due to invalid IL or missing references) //IL_033b: Unknown result type (might be due to invalid IL or missing references) //IL_0379: Unknown result type (might be due to invalid IL or missing references) //IL_03b7: Unknown result type (might be due to invalid IL or missing references) //IL_03f5: Unknown result type (might be due to invalid IL or missing references) //IL_0433: Unknown result type (might be due to invalid IL or missing references) //IL_0447: Unknown result type (might be due to invalid IL or missing references) //IL_0485: Unknown result type (might be due to invalid IL or missing references) //IL_0499: Unknown result type (might be due to invalid IL or missing references) //IL_04d7: Unknown result type (might be due to invalid IL or missing references) //IL_04eb: Unknown result type (might be due to invalid IL or missing references) //IL_0529: Unknown result type (might be due to invalid IL or missing references) //IL_053d: Unknown result type (might be due to invalid IL or missing references) if (!CigarPrefabRegistrar.IsReady || (Object)(object)anchor == (Object)null) { return; } Scene scene = ((Component)anchor).gameObject.scene; if (!((Scene)(ref scene)).IsValid()) { return; } scene = ((Component)anchor).gameObject.scene; string name = ((Scene)(ref scene)).name; string name2 = ((Object)((Component)anchor).gameObject).name; if ((IsWrapperDisplay(anchor) || (name == "island 15 M (Fort)" && name2 == "shop item (24)") || (name == "island 3 A Neverdin" && name2 == "shop item (32)") || (name == "island 21 M (siren song)" && name2 == "shop item (77)") || (name == "island 11 E (Crab Beach)" && name2 == "shop spawner crab cakes (50)") || (name == "island 20 A (Oasis)" && name2 == "shop item (65)") || (name == "island 19 M (Eastwind)" && name2 == "shop item (42)") || (name == "island 39 (onsen)" && name2 == "shop item (80)") || (name == "island 25 (chronos)" && name2 == "shop item (136)")) && IsUniqueSpawner(anchor)) { if (name == "island 9 E Dragon Cliffs" && name2 == "shop item spawner (184)") { AlignWrapper(anchor); CreateRelativeSpawner(anchor, "DogEggz.Cigar.DriedLeaf.DragonCliffs.2", new Vector3(0f, 0f, -0.29f), Vector3.zero, 614); } else if (name == "island 15 M (Fort)" && name2 == "shop item (24)") { CreateRelativeSpawner(anchor, "DogEggz.Cigar.DriedLeaf.Fort.1", new Vector3(-0.734f, 0f, 0f), new Vector3(90f, 0f, 0f), 614); CreateRelativeSpawner(anchor, "DogEggz.Cigar.DriedLeaf.Fort.2", new Vector3(-0.734f, 0f, -0.367f), new Vector3(90f, 0f, 0f), 614); CreateRelativeSpawner(anchor, "DogEggz.Cigar.DriedLeaf.Fort.3", new Vector3(-0.734f, 0f, -0.734f), new Vector3(90f, 0f, 0f), 614); } if (IsWrapperDisplay(anchor)) { AlignWrapper(anchor); ReconcileWrapperStock(anchor); } if (name == "island 1 A Gold Rock" && name2 == "shop item (171)") { CreateRelativeSpawner(anchor, "DogEggz.Cigar.Ashtray.AlAnkh", new Vector3(0.024026f, -0.062822f, -2.044131f), new Vector3(0.159581f, 0.015844f, 11.33965f), 618); } if (name == "island 9 E Dragon Cliffs" && name2 == "shop item spawner (184)") { CreateRelativeSpawner(anchor, "DogEggz.Cigar.Ashtray.Emerald", new Vector3(-0.03281f, -0.082593f, 0.246239f), new Vector3(359.5197f, 0.031987f, 352.3793f), 620); } if (name == "island 15 M (Fort)" && name2 == "shop item (24)") { CreateRelativeSpawner(anchor, "DogEggz.Cigar.Ashtray.Aestrin", new Vector3(-0.749037f, -0.127f, -0.995985f), Vector3.zero, 619); } if (name == "island 3 A Neverdin" && name2 == "shop item (32)") { CreateTavernAshtray(anchor, "Neverdin", new Vector3(0.749442f, -0.032372f, -0.702033f), 615); } if (name == "island 21 M (siren song)" && name2 == "shop item (77)") { CreateTavernAshtray(anchor, "SirenSong", new Vector3(0.089528f, -0.031021f, -0.304271f), 616); } if (name == "island 11 E (Crab Beach)" && name2 == "shop spawner crab cakes (50)") { CreateTavernAshtray(anchor, "CrabBeach", new Vector3(-0.226775f, -0.114298f, 0.099208f), 617); } if (name == "island 20 A (Oasis)" && name2 == "shop item (65)") { CreateRelativeSpawner(anchor, "DogEggz.Cigar.Ashtray.Oasis", new Vector3(-0.2249f, -0.223426f, -4.4E-05f), new Vector3(359.7922f, 358.0053f, 0.11785f), 623); } if (name == "island 19 M (Eastwind)" && name2 == "shop item (42)") { CreateRelativeSpawner(anchor, "DogEggz.Cigar.Ashtray.Eastwind", new Vector3(0.069258f, -0.080073f, 0.195737f), new Vector3(0.171237f, 291.8018f, 359.9076f), 621); } if (name == "island 39 (onsen)" && name2 == "shop item (80)") { CreateRelativeSpawner(anchor, "DogEggz.Cigar.Ashtray.PonderingPeak", new Vector3(-0.154666f, -0.120439f, -0.173347f), new Vector3(359.2273f, 311.1519f, 359.3744f), 622); } if (name == "island 25 (chronos)" && name2 == "shop item (136)") { CreateRelativeSpawner(anchor, "DogEggz.Cigar.Ashtray.Chronos", new Vector3(-0.095731f, -0.085555f, 0.224801f), new Vector3(359.0469f, 68.82883f, 0.145291f), 624); } } } private static void CreateTavernAshtray(ShopItemSpawner anchor, string town, Vector3 offset, int prefabIndex) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0013: 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_001d: 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) string hostName = "DogEggz.Cigar.Ashtray." + town; Quaternion val = Quaternion.Inverse(((Component)anchor).transform.rotation); CreateRelativeSpawner(anchor, hostName, offset, ((Quaternion)(ref val)).eulerAngles, prefabIndex); } internal static bool IsWrapperDisplay(ShopItemSpawner spawner) { //IL_000f: 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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)spawner == (Object)null)) { Scene scene = ((Component)spawner).gameObject.scene; if (((Scene)(ref scene)).IsValid()) { scene = ((Component)spawner).gameObject.scene; string name = ((Scene)(ref scene)).name; string name2 = ((Object)((Component)spawner).gameObject).name; if ((!(name == "island 1 A Gold Rock") || (!(name2 == "shop item (171)") && !(name2 == "shop item (173)"))) && (!(name == "island 9 E Dragon Cliffs") || (!(name2 == "shop item spawner (184)") && !(name2 == "DogEggz.Cigar.DriedLeaf.DragonCliffs.2")))) { if (name == "island 15 M (Fort)") { if (!(name2 == "DogEggz.Cigar.DriedLeaf.Fort.1") && !(name2 == "DogEggz.Cigar.DriedLeaf.Fort.2")) { return name2 == "DogEggz.Cigar.DriedLeaf.Fort.3"; } return true; } return false; } return true; } } return false; } internal static void PrepareWrapperRestock(ShopItemSpawner spawner) { if (CigarPrefabRegistrar.IsReady && IsWrapperDisplay(spawner)) { spawner.itemPrefab = CigarAssetBundle.GetPrefab(614); AlignWrapper(spawner); } } private static void AlignWrapper(ShopItemSpawner spawner) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00de: 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_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_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) Scene scene = ((Component)spawner).gameObject.scene; if (((Scene)(ref scene)).name == "island 9 E Dragon Cliffs") { Quaternion val = Quaternion.Euler(0f, 317.992f, 0f); ((Component)spawner).transform.localPosition = new Vector3(-34.694f, 3.453f, -557.039f) + val * new Vector3(0f, 0f, (((Object)spawner).name == "shop item spawner (184)") ? (-0.08f) : (-0.37f)); ((Component)spawner).transform.localRotation = val; return; } scene = ((Component)spawner).gameObject.scene; if (((Scene)(ref scene)).name == "island 1 A Gold Rock") { ((Component)spawner).transform.localPosition = ((((Object)spawner).name == "shop item (171)") ? new Vector3(1568.4852f, 7.368f, -399.9322f) : new Vector3(1568.1798f, 7.368f, -399.5058f)); ((Component)spawner).transform.localEulerAngles = new Vector3(0f, 145.594f, 0f); } else { ((Component)spawner).transform.rotation = Quaternion.FromToRotation(((Component)spawner).transform.up, Vector3.up) * ((Component)spawner).transform.rotation; } } private static void ReconcileWrapperStock(ShopItemSpawner spawner) { //IL_005d: 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) object? value = StockItem.GetValue(spawner); ShipItem val = (ShipItem)((value is ShipItem) ? value : null); if ((Object)(object)val == (Object)null || val.sold) { return; } SaveablePrefab component = ((Component)val).GetComponent(); if ((Object)(object)component == (Object)null || component.prefabIndex != 613) { return; } GameObject prefab = CigarAssetBundle.GetPrefab(614); if (!((Object)(object)prefab == (Object)null)) { ShipItem component2 = Object.Instantiate(prefab, ((Component)spawner).transform.position, ((Component)spawner).transform.rotation).GetComponent(); ((Component)component2).transform.SetParent(((Component)spawner).transform, true); object? value2 = ItemShopArea.GetValue(val); ShopArea val2 = (ShopArea)((value2 is ShopArea) ? value2 : null); if ((Object)(object)val2 != (Object)null) { val2.itemsForSale.Remove(val); component2.AddToShop(val2); } ((Component)component2).gameObject.SetActive(((Component)val).gameObject.activeSelf); StockItem.SetValue(spawner, component2); ((Component)val).gameObject.SetActive(false); Object.Destroy((Object)(object)((Component)val).gameObject); } } internal static void AddSageHillsPotAfterStart(Shopkeeper shopkeeper) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: 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_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00df: 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_0104: 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_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: 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_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) if (!CigarPrefabRegistrar.IsReady || (Object)(object)shopkeeper == (Object)null) { return; } Scene scene = ((Component)shopkeeper).gameObject.scene; if (!((Scene)(ref scene)).IsValid()) { return; } scene = ((Component)shopkeeper).gameObject.scene; if (((Scene)(ref scene)).name != "island 13 E (Sage Hills)" || ((Object)((Component)shopkeeper).gameObject).name != "shopkeeper (2)" || !IsUniqueShopkeeper(shopkeeper)) { return; } Transform parent = ((Component)shopkeeper).transform.parent; Transform val = FindDirectChild(parent, "shop area (3)"); if ((Object)(object)val == (Object)null || (Object)(object)((Component)val).GetComponent() == (Object)null) { LogIdentityFailure("island 13 E (Sage Hills)/shopkeeper (2)+shop area (3)"); return; } Transform val2 = FindDirectChild(parent, "east_market_stall 1 (1)"); if ((Object)(object)val2 == (Object)null) { LogIdentityFailure("island 13 E (Sage Hills)/east_market_stall 1 (1)"); return; } Vector3 val3 = Vector3.ProjectOnPlane(-val2.up, Vector3.up); Vector3 val4 = ((Vector3)(ref val3)).normalized; if (Vector3.Dot(val4, ((Component)shopkeeper).transform.forward) < 0f) { val4 = -val4; } Vector3 val5 = ((Component)shopkeeper).transform.InverseTransformVector(val4 * 0.72f); Quaternion val6 = Quaternion.Inverse(((Component)shopkeeper).transform.rotation) * Quaternion.LookRotation(val4, Vector3.up); Vector3 eulerAngles = ((Quaternion)(ref val6)).eulerAngles; for (int i = 0; i < 3; i++) { CreateRelativeSpawner(((Component)shopkeeper).transform, availableAtNight: false, 1f, "DogEggz.Cigar.TobaccoPot.SageHills" + ((i == 0) ? "" : ("." + (i + 1))), new Vector3(-2.175f, 0.6f, 3.931f) + val5 * (float)i, eulerAngles, 610); } } private static void CreateRelativeSpawner(ShopItemSpawner anchor, string hostName, Vector3 localPosition, Vector3 localEuler, int prefabIndex) { //IL_0013: 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) CreateRelativeSpawner(((Component)anchor).transform, anchor.availableAtNight, anchor.priceMult, hostName, localPosition, localEuler, prefabIndex); } private static void CreateRelativeSpawner(Transform anchor, bool availableAtNight, float priceMultiplier, string hostName, Vector3 localPosition, Vector3 localEuler, int prefabIndex) { //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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) Transform parent = anchor.parent; if ((Object)(object)parent == (Object)null) { return; } Transform val = FindDirectChild(parent, hostName); if ((Object)(object)val != (Object)null) { ShopItemSpawner component = ((Component)val).GetComponent(); if (prefabIndex == 614 && (Object)(object)component != (Object)null) { component.itemPrefab = CigarAssetBundle.GetPrefab(prefabIndex); AlignWrapper(component); ReconcileWrapperStock(component); } return; } GameObject val2 = new GameObject(hostName) { layer = ((Component)anchor).gameObject.layer }; val2.transform.SetParent(parent, true); val2.transform.position = anchor.TransformPoint(localPosition); val2.transform.rotation = anchor.rotation * Quaternion.Euler(localEuler); val2.transform.localScale = Vector3.one; val2.AddComponent(); val2.AddComponent(); ShopItemSpawner val3 = val2.AddComponent(); val3.itemPrefab = CigarAssetBundle.GetPrefab(prefabIndex); val3.availableAtNight = availableAtNight; val3.priceMult = priceMultiplier; if (prefabIndex == 614) { AlignWrapper(val3); } ManualLogSource logSource = Plugin.LogSource; if (logSource != null) { string[] obj = new string[5] { "Added shop display ", hostName, " in ", null, null }; Scene scene = ((Component)anchor).gameObject.scene; obj[3] = ((Scene)(ref scene)).name; obj[4] = "."; logSource.LogInfo((object)string.Concat(obj)); } } private static bool IsUniqueSpawner(ShopItemSpawner target) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) int num = 0; ShopItemSpawner[] array = Resources.FindObjectsOfTypeAll(); for (int i = 0; i < array.Length; i++) { if (!((Object)(object)array[i] != (Object)null)) { continue; } Scene scene = ((Component)array[i]).gameObject.scene; if (((Scene)(ref scene)).IsValid()) { scene = ((Component)array[i]).gameObject.scene; int handle = ((Scene)(ref scene)).handle; scene = ((Component)target).gameObject.scene; if (handle == ((Scene)(ref scene)).handle && ((Object)((Component)array[i]).gameObject).name == ((Object)((Component)target).gameObject).name) { num++; } } } return num == 1; } private static bool IsUniqueShopkeeper(Shopkeeper target) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) int num = 0; Shopkeeper[] array = Resources.FindObjectsOfTypeAll(); for (int i = 0; i < array.Length; i++) { if (!((Object)(object)array[i] != (Object)null)) { continue; } Scene scene = ((Component)array[i]).gameObject.scene; if (((Scene)(ref scene)).IsValid()) { scene = ((Component)array[i]).gameObject.scene; int handle = ((Scene)(ref scene)).handle; scene = ((Component)target).gameObject.scene; if (handle == ((Scene)(ref scene)).handle && ((Object)((Component)array[i]).gameObject).name == ((Object)((Component)target).gameObject).name) { num++; } } } return num == 1; } private static Transform FindDirectChild(Transform parent, string name) { if ((Object)(object)parent == (Object)null) { return null; } for (int i = 0; i < parent.childCount; i++) { Transform child = parent.GetChild(i); if (((Object)child).name == name) { return child; } } return null; } private static void LogIdentityFailure(string identity) { if (LoggedIdentityFailures.Add(identity)) { ManualLogSource logSource = Plugin.LogSource; if (logSource != null) { logSource.LogError((object)("Shop placement identity did not resolve exactly once: " + identity + ". That display was skipped.")); } } } } internal static class StorageShopPlacement { private static readonly StorageShopMarker[] Configured = new StorageShopMarker[3]; internal static void Configure(ShopItemSpawner first) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0090: 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_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_0169: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: 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_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_0360: Unknown result type (might be due to invalid IL or missing references) //IL_0371: Unknown result type (might be due to invalid IL or missing references) //IL_0376: Unknown result type (might be due to invalid IL or missing references) //IL_038a: Unknown result type (might be due to invalid IL or missing references) //IL_039e: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: Unknown result type (might be due to invalid IL or missing references) //IL_03b4: Unknown result type (might be due to invalid IL or missing references) //IL_03c5: Unknown result type (might be due to invalid IL or missing references) //IL_03ca: Unknown result type (might be due to invalid IL or missing references) //IL_03de: Unknown result type (might be due to invalid IL or missing references) //IL_0412: Unknown result type (might be due to invalid IL or missing references) //IL_0423: Unknown result type (might be due to invalid IL or missing references) //IL_0428: Unknown result type (might be due to invalid IL or missing references) //IL_042d: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_0309: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_032b: Unknown result type (might be due to invalid IL or missing references) //IL_0330: Unknown result type (might be due to invalid IL or missing references) //IL_0344: Unknown result type (might be due to invalid IL or missing references) //IL_0454: Unknown result type (might be due to invalid IL or missing references) //IL_0456: Unknown result type (might be due to invalid IL or missing references) //IL_045b: Unknown result type (might be due to invalid IL or missing references) //IL_0460: Unknown result type (might be due to invalid IL or missing references) //IL_047a: Unknown result type (might be due to invalid IL or missing references) //IL_047f: Unknown result type (might be due to invalid IL or missing references) //IL_0497: Unknown result type (might be due to invalid IL or missing references) //IL_049d: Unknown result type (might be due to invalid IL or missing references) //IL_04ab: Unknown result type (might be due to invalid IL or missing references) //IL_04ad: Unknown result type (might be due to invalid IL or missing references) if (!CigarPrefabRegistrar.IsReady || (Object)(object)first == (Object)null) { return; } Scene home = ((Component)first).gameObject.scene; if (!((Scene)(ref home)).IsValid()) { return; } int num = ((Scene)(ref home)).name switch { "island 9 E Dragon Cliffs" => 2, "island 15 M (Fort)" => 1, "island 1 A Gold Rock" => 0, _ => -1, }; if (num < 0) { return; } StorageShopMarker storageShopMarker = Configured[num]; if ((Object)(object)storageShopMarker != (Object)null && ((Component)storageShopMarker).gameObject.scene == home) { return; } string anchorName = num switch { 1 => "shop item (24)", 0 => "shop item (171)", _ => "shop item spawner (184)", }; ShopItemSpawner[] all = (from s in Resources.FindObjectsOfTypeAll() where ((Component)s).gameObject.scene == home select s).ToArray(); ShopItemSpawner val = ((IEnumerable)all).SingleOrDefault((Func)((ShopItemSpawner s) => ((Object)s).name == anchorName)); if ((Object)(object)val == (Object)null) { return; } Configured[num] = ((Component)val).GetComponent(); if ((Object)(object)Configured[num] != (Object)null) { return; } Configured[num] = ((Component)val).gameObject.AddComponent(); Vector3 position = ((Component)val).transform.position; position.y = 0f; switch (num) { case 0: Replace(all, "shop item (176)", 627, position + new Vector3(-0.68553f, 3.6329f, 0.85053f), Quaternion.Euler(348.659f, 236.368f, 0f) * Quaternion.Euler(0f, 180f, 0f)); Create(val, 630, position + new Vector3(-66.07019f, 3.31741f, -4.52365f), Quaternion.Euler(0f, 161.34f, 0f), tavern: true); return; case 1: { Vector3 val2 = position + new Vector3(0.04406f, 3.064f, 0.35797f); Quaternion val3 = Quaternion.Euler(0f, 179.065f, 0f); Create(val, 625, val2, val3, tavern: false); Quaternion val4 = Quaternion.Euler(0f, 359.065f, 0f); BoxCollider component = CigarAssetBundle.GetPrefab(625).GetComponent(); BoxCollider component2 = CigarAssetBundle.GetPrefab(626).GetComponent(); Vector3 position2 = val2 + val3 * (component.center + Vector3.right * 0.48f) - val4 * component2.center; position2.y = val2.y + component.center.y - component.size.y * 0.5f - component2.center.y + component2.size.y * 0.5f; Create(val, 626, position2, val4, tavern: false); Create(val, 629, position + new Vector3(-38.75871f, 3.03934f, -12.07408f), Quaternion.Euler(0f, 179.5f, 0f), tavern: true); return; } } Replace(all, "shop item spawner (188)", 628, position + new Vector3(0.77688f, 3.32881f, -0.54858f), Quaternion.Euler(0f, 321.609f, 352.364f) * Quaternion.Euler(0f, 180f, 0f)); Create(val, 631, position + new Vector3(-35.08951f, 3.39949f, 22.71332f), Quaternion.Euler(0f, 135.68f, 0f), tavern: true); ShopItemSpawner[] array = new int[3] { 185, 186, 187 }.Select((int n) => all.Single((ShopItemSpawner s) => ((Object)s).name == "shop item spawner (" + n + ")")).ToArray(); Vector3 val5 = position + new Vector3(0.95999f, 3.48246f, -1.14672f); Vector3 val6 = default(Vector3); ((Vector3)(ref val6))..ctor(0.027805f, 0.26464f, 0.02203f); for (int num2 = 0; num2 < 3; num2++) { ((Component)array[num2]).transform.position = val5 + val6 * (float)num2; } GameObject val7 = new GameObject("DogEggz.Cigar.TobaccoStockStack"); val7.transform.SetParent(((Component)val).transform.parent, false); val7.transform.position = val5; val7.AddComponent().Configure(array, val5, val6); } private static void Replace(ShopItemSpawner[] all, string name, int id, Vector3 position, Quaternion rotation) { //IL_0030: 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) ShopItemSpawner obj = all.Single((ShopItemSpawner s) => ((Object)s).name == name); obj.itemPrefab = CigarAssetBundle.GetPrefab(id); ((Component)obj).transform.SetPositionAndRotation(position, rotation); } private static void Create(ShopItemSpawner anchor, int id, Vector3 position, Quaternion rotation, bool tavern) { //IL_0011: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("DogEggz.Cigar.Storage." + id); val.transform.SetParent(((Component)anchor).transform.parent, false); val.transform.SetPositionAndRotation(position, rotation); val.AddComponent(); val.AddComponent(); ShopItemSpawner obj = val.AddComponent(); obj.itemPrefab = CigarAssetBundle.GetPrefab(id); obj.priceMult = 1f; obj.availableAtNight = tavern || anchor.availableAtNight; } } public sealed class StorageShopMarker : MonoBehaviour { } public sealed class StorageStockStack : MonoBehaviour { private ShopItemSpawner[] spawners; private Vector3 baseLocal; private Vector3 stepLocal; private float nextCheck; private static readonly FieldInfo Stock = typeof(ShopItemSpawner).GetField("item", BindingFlags.Instance | BindingFlags.NonPublic); private static readonly FieldInfo ReturnPosition = typeof(ShipItem).GetField("shopPos", BindingFlags.Instance | BindingFlags.NonPublic); private static readonly FieldInfo Shop = typeof(ShipItem).GetField("shopArea", BindingFlags.Instance | BindingFlags.NonPublic); public void Configure(ShopItemSpawner[] values, Vector3 bottom, Vector3 step) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: 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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) spawners = values; baseLocal = ((Component)this).transform.InverseTransformPoint(bottom); stepLocal = ((Component)this).transform.InverseTransformVector(step); } private void LateUpdate() { if (!(Time.unscaledTime < nextCheck) && spawners != null) { nextCheck = Time.unscaledTime + 0.2f; Reconcile(); } } public void Reconcile() { //IL_004c: 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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) int num = 0; for (int i = 0; i < spawners.Length; i++) { object? value = Stock.GetValue(spawners[i]); ShipItem val = (ShipItem)((value is ShipItem) ? value : null); bool num2 = (Object)(object)val != (Object)null && !val.sold; Vector3 val2 = (((Object)(object)val != (Object)null) ? ((Component)val).transform.position : Vector3.zero); Vector3 val3 = ((Component)this).transform.TransformPoint(baseLocal + stepLocal * (float)num); ((Component)spawners[i]).transform.position = val3; if (num2) { ((Component)val).transform.position = (((Object)(object)((PickupableItem)val).held == (Object)null) ? val3 : val2); object? value2 = Shop.GetValue(val); ShopArea val4 = (ShopArea)((value2 is ShopArea) ? value2 : null); if ((Object)(object)val4 != (Object)null) { ReturnPosition.SetValue(val, ((Component)val4).transform.InverseTransformPoint(val3)); } num++; } } } } } namespace TobaccoPotAndCigar.Compatibility { internal struct BlueEffectProfile { internal float ImmediateSleepChange; internal float GreenVisualChargeRate; internal static BlueEffectProfile VanillaGreen => new BlueEffectProfile { ImmediateSleepChange = -0.11f, GreenVisualChargeRate = 2f }; internal static BlueEffectProfile RadEnhanced(int multiplier) { multiplier = Math.Max(0, multiplier); return new BlueEffectProfile { ImmediateSleepChange = -0.11f * (float)multiplier, GreenVisualChargeRate = 2f * (float)multiplier * 0.33f }; } } internal static class RadRefinementsCompatibility { internal const string PluginGuid = "com.raddude.radrefinements"; private static ConfigEntry enableBlueTobacco; private static ConfigEntry bluePotencyMult; private static bool warnedAboutIncompatibleVersion; internal static BlueEffectProfile GetBlueEffectProfile() { if (!Chainloader.PluginInfos.TryGetValue("com.raddude.radrefinements", out var value)) { return BlueEffectProfile.VanillaGreen; } if ((enableBlueTobacco == null || bluePotencyMult == null) && (warnedAboutIncompatibleVersion || !TryBindConfigEntries(((object)value.Instance).GetType().Assembly))) { WarnOnce(); return BlueEffectProfile.VanillaGreen; } if (!enableBlueTobacco.Value) { return BlueEffectProfile.VanillaGreen; } return BlueEffectProfile.RadEnhanced(bluePotencyMult.Value); } internal static void Reset() { enableBlueTobacco = null; bluePotencyMult = null; warnedAboutIncompatibleVersion = false; } private static bool TryBindConfigEntries(Assembly assembly) { Type type = assembly.GetType("RadRefinements.Configs", throwOnError: false); if (type == null) { return false; } FieldInfo field = type.GetField("enableBlueTobacco", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); FieldInfo field2 = type.GetField("bluePotencyMult", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); enableBlueTobacco = ((field == null) ? null : (field.GetValue(null) as ConfigEntry)); bluePotencyMult = ((field2 == null) ? null : (field2.GetValue(null) as ConfigEntry)); if (enableBlueTobacco != null) { return bluePotencyMult != null; } return false; } private static void WarnOnce() { if (!warnedAboutIncompatibleVersion) { warnedAboutIncompatibleVersion = true; ManualLogSource logSource = Plugin.LogSource; if (logSource != null) { logSource.LogWarning((object)"Rad Refinements was detected but its blue-tobacco settings could not be read. Cigar blue tobacco will use vanilla green effects."); } } } } internal static class RadSingleClickSmoking { private static readonly FieldInfo Amount = AccessTools.Field(typeof(ShipItem), "amount"); private static readonly MethodInfo ReadAmount = AccessTools.Method(typeof(RadSingleClickSmoking), "GetRadSmokingAmount", (Type[])null, (Type[])null); private static bool warned; private static string detectedVersion; internal static void Install(Harmony harmony) { //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Expected O, but got Unknown if (!Chainloader.PluginInfos.TryGetValue("com.raddude.radrefinements", out var value)) { return; } warned = false; detectedVersion = value.Metadata.Version.ToString(); try { Type type = ((object)value.Instance).GetType().Assembly.GetType("RadRefinements.PipePatches+ShipItemPatches", throwOnError: false); MethodInfo methodInfo = ((type == null) ? null : AccessTools.Method(type, "MovePipe", new Type[1] { typeof(ShipItemPipe) }, (Type[])null)); MethodInfo methodInfo2 = ((methodInfo == null) ? null : AccessTools.EnumeratorMoveNext((MethodBase)methodInfo)); if (methodInfo2 == null) { WarnOnce("the expected smoking iterator was not found"); return; } harmony.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(RadSingleClickSmoking), "Transpiler", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null); if (!warned) { ManualLogSource logSource = Plugin.LogSource; if (logSource != null) { logSource.LogInfo((object)("RadRefinements " + detectedVersion + " single-click cigar smoking compatibility enabled.")); } } } catch (Exception ex) { WarnOnce("patch installation failed: " + ex); } } private static IEnumerable Transpiler(IEnumerable instructions) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown List list = new List(instructions); if (!HasExpectedChecks(list)) { WarnOnce("the smoking iterator IL changed; no amount reads were replaced"); return list; } List list2 = new List(list.Count); foreach (CodeInstruction item in list) { CodeInstruction val = new CodeInstruction(item); if (CodeInstructionExtensions.LoadsField(val, Amount, false)) { val.opcode = OpCodes.Call; val.operand = ReadAmount; } list2.Add(val); } return list2; } private static bool HasExpectedChecks(List instructions) { int num = 0; int num2 = 0; int num3 = 0; for (int i = 0; i < instructions.Count; i++) { if (!CodeInstructionExtensions.LoadsField(instructions[i], Amount, false)) { continue; } num3++; if (i + 2 >= instructions.Count || instructions[i + 1].opcode != OpCodes.Ldc_R4 || !object.Equals(instructions[i + 1].operand, 0f)) { return false; } if (instructions[i + 2].opcode == OpCodes.Cgt) { num++; continue; } if (i + 4 < instructions.Count && instructions[i + 2].opcode == OpCodes.Cgt_Un && instructions[i + 3].opcode == OpCodes.Ldc_I4_0 && instructions[i + 4].opcode == OpCodes.Ceq) { num2++; continue; } return false; } if (num3 == 2 && num == 1) { return num2 == 1; } return false; } private static float GetRadSmokingAmount(ShipItemPipe pipe) { if (((ShipItem)pipe).amount < 0f && ((ShipItem)pipe).health > 0f) { CigarRuntimeState component = ((Component)pipe).GetComponent(); if ((Object)(object)component != (Object)null && component.TryGetRecipe(out var _)) { return 1f; } } return ((ShipItem)pipe).amount; } private static void WarnOnce(string reason) { if (!warned) { warned = true; ManualLogSource logSource = Plugin.LogSource; if (logSource != null) { logSource.LogWarning((object)("RadRefinements " + detectedVersion + " single-click cigar smoking compatibility unavailable: " + reason + ".")); } } } } } namespace TobaccoPotAndCigar.Smoking { internal static class CigarEffectService { private sealed class DoseChannel { internal CigarTobaccoType Type; internal float Charge; } private sealed class DoseGroup { internal readonly List Channels = new List(3); } private static readonly Dictionary Doses = new Dictionary(); private static readonly List RemovalBuffer = new List(); internal static void ApplyInhale(CigarRuntimeState source, TobaccoBlend blend, float deltaTime) { if (!((Object)(object)source == (Object)null) && !(deltaTime <= 0f)) { DoseGroup orCreateDose = GetOrCreateDose(source, blend); BlueEffectProfile blueEffectProfile = RadRefinementsCompatibility.GetBlueEffectProfile(); CigarEffectTotals cigarEffectTotals = CigarEffectMath.Calculate(blend, blueEffectProfile.ImmediateSleepChange, blueEffectProfile.GreenVisualChargeRate); PlayerNeeds.sleep += deltaTime * cigarEffectTotals.ImmediateSleepPerSecond; for (int i = 0; i < orCreateDose.Channels.Count; i++) { DoseChannel doseChannel = orCreateDose.Channels[i]; float num = ((doseChannel.Type == CigarTobaccoType.Blue) ? blueEffectProfile.GreenVisualChargeRate : 2f); doseChannel.Charge += deltaTime * num; } } } internal static void TickAndCompose(PlayerTobacco vanilla, float deltaTime) { //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)vanilla == (Object)null || Doses.Count == 0 || deltaTime <= 0f) { return; } float num = vanilla.white; float num2 = vanilla.green; float num3 = vanilla.black; RemovalBuffer.Clear(); foreach (KeyValuePair dose in Doses) { bool flag = false; List channels = dose.Value.Channels; for (int i = 0; i < channels.Count; i++) { DoseChannel doseChannel = channels[i]; if (!(doseChannel.Charge <= 0f)) { flag = true; doseChannel.Charge = Mathf.Max(0f, doseChannel.Charge - deltaTime * 0.5f); switch (doseChannel.Type) { case CigarTobaccoType.White: num += doseChannel.Charge; PlayerNeeds.sleep -= deltaTime * 0.165f; break; case CigarTobaccoType.Green: num2 += doseChannel.Charge; PlayerNeeds.sleep -= deltaTime * 0.055f; break; case CigarTobaccoType.Blue: num2 += doseChannel.Charge; PlayerNeeds.sleep -= deltaTime * 0.055f; break; case CigarTobaccoType.Black: num3 += doseChannel.Charge; PlayerNeeds.sleep -= deltaTime * 0.3f; break; case CigarTobaccoType.Brown: PlayerNeeds.sleep -= deltaTime * 0.2f; break; } } } if (!flag) { RemovalBuffer.Add(dose.Key); } } for (int j = 0; j < RemovalBuffer.Count; j++) { Doses.Remove(RemovalBuffer[j]); } PlayerTobacco.saturationOverride = 1f + (num2 - num) / 100f; if ((Object)(object)vanilla.postProcessing != (Object)null) { Settings settings = vanilla.postProcessing.bloom.settings; settings.bloom.intensity = Mathf.Lerp(0.66f * Settings.bloomIntensity, 0f, Mathf.Clamp01(num3 / 100f)); vanilla.postProcessing.bloom.settings = settings; } } internal static void Reset() { Doses.Clear(); RemovalBuffer.Clear(); CigarSmokeContext.Current = null; } private static DoseGroup GetOrCreateDose(CigarRuntimeState source, TobaccoBlend blend) { int instanceID = ((Object)source).GetInstanceID(); if (Doses.TryGetValue(instanceID, out var value)) { return value; } value = new DoseGroup(); AddChannels(value, CigarTobaccoType.White, blend.White); AddChannels(value, CigarTobaccoType.Green, blend.Green); AddChannels(value, CigarTobaccoType.Black, blend.Black); AddChannels(value, CigarTobaccoType.Brown, blend.Brown); AddChannels(value, CigarTobaccoType.Blue, blend.Blue); Doses.Add(instanceID, value); return value; } private static void AddChannels(DoseGroup group, CigarTobaccoType type, int count) { for (int i = 0; i < count; i++) { group.Channels.Add(new DoseChannel { Type = type }); } } } internal static class CigarSmokeContext { internal static CigarRuntimeState Current; } } namespace TobaccoPotAndCigar.Prefabs { internal static class VanillaPipeSmokeProfile { internal const float EmissionRate = 120f; internal const float MaximumLifetime = 12f; internal const int MaximumParticles = 1536; internal static void ApplyRequired(GameObject prefab, int prefabIndex) { if ((Object)(object)prefab == (Object)null) { throw new InvalidOperationException("Vanilla pipe prefab " + prefabIndex + " is missing."); } SaveablePrefab component = prefab.GetComponent(); ShipItemPipe component2 = prefab.GetComponent(); if ((Object)(object)component == (Object)null || component.prefabIndex != prefabIndex || (Object)(object)component2 == (Object)null || !Apply(component2)) { throw new InvalidOperationException("Vanilla pipe prefab " + prefabIndex + " does not expose its expected smoke profile."); } } internal static bool ApplyIfVanilla(ShipItemPipe pipe) { if ((Object)(object)pipe == (Object)null) { return false; } SaveablePrefab component = ((Component)pipe).GetComponent(); if ((Object)(object)component == (Object)null || component.prefabIndex < 300 || component.prefabIndex > 302) { return false; } return Apply(pipe); } private static bool Apply(ShipItemPipe pipe) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) ParticleSystem componentInChildren = ((Component)pipe).GetComponentInChildren(true); if ((Object)(object)componentInChildren == (Object)null) { return false; } pipe.maxLifetime = 12f; pipe.maxEmission = 120f; MainModule main = componentInChildren.main; ((MainModule)(ref main)).maxParticles = 1536; EmissionModule emission = componentInChildren.emission; ((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(120f); return true; } } internal static class CigarAssetBundle { internal const string BundleName = "dogeggz.cigar.assets"; private static readonly Dictionary Prefabs = new Dictionary(); private static AssetBundle bundle; internal static bool IsLoaded { get { if ((Object)(object)bundle != (Object)null) { return Prefabs.Count == 22; } return false; } } internal static void Load(string pluginDirectory) { if (IsLoaded) { return; } string text = Path.Combine(pluginDirectory, "assets", "dogeggz.cigar.assets"); if (!File.Exists(text)) { throw new FileNotFoundException("Cigar AssetBundle is missing.", text); } bundle = AssetBundle.LoadFromFile(text); if ((Object)(object)bundle == (Object)null) { throw new InvalidOperationException("Unity could not load " + text); } CigarWrapperVisual.BindBundleData(bundle.LoadAsset("assets/cigar/generated/modelpreview/wrappervisualdata.asset")); Prefabs.Clear(); GameObject[] array = bundle.LoadAllAssets(); for (int i = 0; i < array.Length; i++) { SaveablePrefab component = array[i].GetComponent(); if ((Object)(object)component == (Object)null) { continue; } int prefabIndex = component.prefabIndex; if (prefabIndex >= 610 && prefabIndex <= 631) { if (Prefabs.ContainsKey(prefabIndex)) { throw new InvalidOperationException("AssetBundle contains duplicate prefab index " + prefabIndex + "."); } Prefabs.Add(prefabIndex, array[i]); } } for (int j = 610; j <= 631; j++) { if (!Prefabs.ContainsKey(j)) { throw new InvalidOperationException("AssetBundle is missing prefab index " + j + "."); } } } internal static GameObject GetPrefab(int index) { if (!Prefabs.TryGetValue(index, out var value)) { return null; } return value; } internal static void Unload() { CigarWrapperVisual.ClearBundleData(); Prefabs.Clear(); if ((Object)(object)bundle != (Object)null) { bundle.Unload(false); } bundle = null; } } internal static class CigarPrefabRegistrar { private const int RequiredDirectoryLength = 632; private static bool registered; internal static bool IsReady => registered; internal static void EnsureRegistered(PrefabsDirectory directory) { if (registered) { return; } if ((Object)(object)directory == (Object)null || directory.directory == null) { throw new InvalidOperationException("PrefabsDirectory is unavailable."); } if (!CigarAssetBundle.IsLoaded) { throw new InvalidOperationException("Cigar AssetBundle is not loaded."); } GameObject[] array = directory.directory; if (array.Length < 632) { Array.Resize(ref array, 632); } for (int i = 610; i <= 631; i++) { GameObject prefab = CigarAssetBundle.GetPrefab(i); GameObject val = array[i]; if ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)prefab) { throw new InvalidOperationException("Prefab index " + i + " is already occupied by " + ((Object)val).name + "; registration aborted without overwriting it."); } ValidateBundledPrefab(i, prefab); } directory.directory = array; for (int j = 610; j <= 631; j++) { GameObject prefab2 = CigarAssetBundle.GetPrefab(j); directory.directory[j] = prefab2; PrefabReplacement.RegisterCustomPrefab(j, prefab2); } registered = true; } internal static void ValidateAndConfigure(PrefabsDirectory directory) { if (!registered || (Object)(object)directory == (Object)null || directory.shipItems == null || directory.shipItems.Length < 632) { throw new InvalidOperationException("PrefabsDirectory ship-item cache was not populated for indices 610-631."); } for (int i = 610; i <= 631; i++) { if ((Object)(object)directory.directory[i] != (Object)(object)CigarAssetBundle.GetPrefab(i) || (Object)(object)directory.shipItems[i] == (Object)null) { throw new InvalidOperationException("Runtime prefab cache validation failed at index " + i + "."); } } for (int j = 300; j <= 302; j++) { VanillaPipeSmokeProfile.ApplyRequired(directory.directory[j], j); } ConfigureTobaccoHint(directory.directory[310], 310); ConfigureTobaccoHint(directory.directory[312], 312); ConfigureTobaccoHint(directory.directory[314], 314); ConfigureTobaccoHint(directory.directory[316], 316); ConfigureTobaccoHint(directory.directory[318], 318); ConfigureVanillaDrying(directory.directory[312], 310); ConfigureVanillaDrying(directory.directory[310], 316); ConfigureVanillaDrying(directory.directory[316], 314); ManualLogSource logSource = Plugin.LogSource; if (logSource != null) { logSource.LogInfo((object)"Registered bundled prefabs 610-631 and rack-only tobacco drying."); } } internal static void Reset() { registered = false; PrefabReplacement.ClearCustomPrefabs(); } private static void ConfigureVanillaDrying(GameObject prefab, int resultPrefabIndex) { if ((Object)(object)prefab == (Object)null) { throw new InvalidOperationException("Vanilla drying source for result " + resultPrefabIndex + " is missing."); } RackOnlyDrying rackOnlyDrying = prefab.GetComponent(); if ((Object)(object)rackOnlyDrying == (Object)null) { rackOnlyDrying = prefab.AddComponent(); } rackOnlyDrying.ConfigureResultPrefab(resultPrefabIndex); } private static void ConfigureTobaccoHint(GameObject prefab, int prefabIndex) { ShipItemTobacco val = (((Object)(object)prefab != (Object)null) ? prefab.GetComponent() : null); if ((Object)(object)val == (Object)null || string.IsNullOrEmpty(((ShipItem)val).name)) { throw new InvalidOperationException("Tobacco prefab " + prefabIndex + " cannot provide its pointer hint name."); } ((GoPointerButton)val).description = ((ShipItem)val).name; } private static void ValidateBundledPrefab(int index, GameObject prefab) { if ((Object)(object)prefab == (Object)null || (Object)(object)prefab.GetComponent() == (Object)null || (Object)(object)prefab.GetComponent() == (Object)null) { throw new InvalidOperationException("Bundled prefab " + index + " is missing its item/save contract."); } int num; if (index != 610) { if (index != 611) { if (index != 612) { if (index != 613) { if (index != 614) { num = (((index <= 624) ? ((Object)(object)prefab.GetComponent() != (Object)null) : ((index <= 628) ? ((Object)(object)prefab.GetComponent() != (Object)null) : ((Object)(object)prefab.GetComponent() != (Object)null))) ? 1 : 0); } else { if (!((Object)(object)prefab.GetComponent() != (Object)null)) { goto IL_0114; } num = (((Object)(object)prefab.GetComponent() != (Object)null) ? 1 : 0); } } else { num = (((Object)(object)prefab.GetComponent() != (Object)null) ? 1 : 0); } } else { num = (((Object)(object)prefab.GetComponent() != (Object)null) ? 1 : 0); } } else { if (!((Object)(object)prefab.GetComponent() != (Object)null)) { goto IL_0114; } num = (((Object)(object)prefab.GetComponent() != (Object)null) ? 1 : 0); } } else { num = (((Object)(object)prefab.GetComponent() != (Object)null) ? 1 : 0); } if (num != 0) { if (index == 614 && !prefab.GetComponent().IsConfigured(out var error)) { throw new InvalidOperationException("Bundled wrapper filling is invalid: " + error); } return; } goto IL_0114; IL_0114: throw new InvalidOperationException("Bundled prefab " + index + " does not contain its authored runtime component."); } } } namespace TobaccoPotAndCigar.Patches { [HarmonyPatch(typeof(ShipItemPipe), "OnItemClick")] internal static class CigarRefillBlockPatch { [HarmonyPrefix] private static bool Prefix(ShipItemPipe __instance, ref bool __result) { if ((Object)(object)((Component)__instance).GetComponent() == (Object)null) { return true; } __result = false; return false; } } [HarmonyPatch(typeof(ShipItemPipe), "ExtraLateUpdate")] internal static class CigarPipeContextPatch { [HarmonyPrefix] private static void Prefix(ShipItemPipe __instance, bool ___drinking, ref bool ___wasDrinking, float ___initialHoldDistance, out CigarRuntimeState __state) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) __state = ((Component)__instance).GetComponent(); CigarSmokeContext.Current = __state; if ((Object)(object)__state != (Object)null && (Object)(object)((PickupableItem)__instance).held != (Object)null && ___initialHoldDistance != 0f) { Transform transform = ((Component)__instance).transform; transform.rotation *= Quaternion.Euler(0f - ((PickupableItem)__instance).heldRotationOffset, 0f, 0f); } if (((Object)(object)__state != (Object)null && !___drinking) & ___wasDrinking) { ___wasDrinking = false; ((PickupableItem)__instance).heldRotationOffset = 77f; } } [HarmonyPostfix] private static void Postfix(CigarRuntimeState __state, float ___currentHeat, bool ___inhaling) { if ((Object)(object)__state != (Object)null && !__state.TryDestroyIfConsumed()) { __state.SyncVisuals(snap: false, ___currentHeat / 100f, ___inhaling); } if ((Object)(object)CigarSmokeContext.Current == (Object)(object)__state) { CigarSmokeContext.Current = null; } } } [HarmonyPatch(typeof(ShipItemPipe), "OnLoad")] internal static class CigarPipeLoadPatch { [HarmonyPostfix] private static void Postfix(ShipItemPipe __instance) { VanillaPipeSmokeProfile.ApplyIfVanilla(__instance); RestingPipeState.Ensure(__instance); CigarRuntimeState component = ((Component)__instance).GetComponent(); if ((Object)(object)component != (Object)null && !component.TryDestroyIfConsumed()) { component.RefreshValue(); component.SyncVisuals(snap: true, 0f, inhaling: false); } } } [HarmonyPatch(typeof(ShipItemPipe), "Smoke")] internal static class PipeHeldSmokePatch { [HarmonyPrefix] private static bool Prefix(ShipItemPipe __instance) { if (((ShipItem)__instance).sold) { return (Object)(object)((PickupableItem)__instance).held != (Object)null; } return false; } } [HarmonyPatch(typeof(ShipItemPipe), "StopSmoking")] internal static class PipeIdleExhalePatch { [HarmonyPrefix] private static bool Prefix(ShipItemPipe __instance, bool ___inhaling) { if (!___inhaling) { return (Object)(object)((PickupableItem)__instance).held != (Object)null; } return true; } } [HarmonyPatch(typeof(PlayerTobacco), "Smoke")] internal static class CigarSmokeRecipePatch { [HarmonyPrefix] private static bool Prefix(int tobaccoType) { if (tobaccoType >= 0) { return true; } CigarRuntimeState current = CigarSmokeContext.Current; if ((Object)(object)current == (Object)null || !TobaccoBlendCodec.TryDecode(-tobaccoType, out var blend)) { RuntimeDiagnostics.Error("Rejected a cigar smoke call with no valid cigar recipe context."); return false; } CigarEffectService.ApplyInhale(current, blend, Time.deltaTime); return false; } } [HarmonyPatch(typeof(PlayerTobacco), "Update")] internal static class CigarEffectUpdatePatch { [HarmonyPostfix] private static void Postfix(PlayerTobacco __instance) { CigarEffectService.TickAndCompose(__instance, Time.deltaTime); } } [HarmonyPatch(typeof(CrateInventoryUI), "GetCrateDimensions")] internal static class RackJarDimensionsPatch { internal static bool IsJar(CrateInventory crate) { PipeRackState pipeRackState = (((Object)(object)crate != (Object)null) ? ((Component)crate).GetComponent() : null); if ((Object)(object)pipeRackState != (Object)null) { return pipeRackState.HasJar; } return false; } [HarmonyPrefix] private static bool Prefix(CrateInventoryUI __instance, ref Vector2 __result) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) if (!IsJar(__instance.currentCrate)) { return true; } __result = new Vector2(4f, 4f); return false; } } [HarmonyPatch(typeof(CrateInventory), "LateUpdate")] internal static class RackJarContentsPatch { [HarmonyPrefix] private static bool Prefix(CrateInventory __instance) { //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) if (!RackJarDimensionsPatch.IsJar(__instance)) { return true; } ShipItem component = ((Component)__instance).GetComponent(); SaveablePrefab component2 = ((Component)component).GetComponent(); bool flag = (Object)(object)CrateInventoryUI.instance != (Object)null && CrateInventoryUI.instance.showingUI && (Object)(object)CrateInventoryUI.instance.currentCrate == (Object)(object)__instance; foreach (ShipItem containedItem in __instance.containedItems) { if (!((Object)(object)containedItem == (Object)null) && !((Object)(object)containedItem.itemRigidbodyC == (Object)null)) { containedItem.currentActualBoat = component.currentActualBoat; containedItem.currentWalkCol = component.currentWalkCol; ((Component)containedItem).GetComponent().SetParentObject(component2.GetParentObject()); if (!flag) { ((Component)containedItem).transform.SetPositionAndRotation(((Component)component).transform.position, ((Component)component).transform.rotation); } if ((Object)(object)containedItem.currentActualBoat != (Object)null && (Object)(object)containedItem.currentWalkCol != (Object)null) { containedItem.itemRigidbodyC.ForceRigidbodyToWalkCol(); } } } return false; } } [HarmonyPatch(typeof(CrateInventoryUI), "RefreshButtons")] internal static class RackJarLayoutPatch { private static readonly FieldRef Tracker = AccessTools.FieldRefAccess("localPosTracker"); private static CrateInventoryUI scaledUI; private static Vector3 originalScale; [HarmonyPostfix] private static void Postfix(CrateInventoryUI __instance) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) if (!RackJarDimensionsPatch.IsJar(__instance.currentCrate)) { Restore(__instance); return; } if ((Object)(object)scaledUI != (Object)(object)__instance) { scaledUI = __instance; originalScale = ((Component)__instance).transform.localScale; } ((Component)__instance).transform.localScale = originalScale * 0.5f; for (int i = 0; i < __instance.buttons.Length; i++) { ((Component)__instance.buttons[i]).gameObject.SetActive(i < 16); if (i < 16) { ((Component)__instance.buttons[i]).transform.localPosition = new Vector3(0.75f - (float)(i % 4) * 0.5f, -0.75f + (float)(i / 4) * 0.5f, 0f); } } if (__instance.showingUI) { Position(__instance); } } internal static void Restore(CrateInventoryUI ui) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)scaledUI == (Object)(object)ui) { ((Component)ui).transform.localScale = originalScale; scaledUI = null; } } internal static void Position(CrateInventoryUI ui) { //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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_0050: 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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) if (RackJarDimensionsPatch.IsJar(ui.currentCrate) && !((Object)(object)Camera.main == (Object)null)) { Transform transform = ((Component)Camera.main).transform; Bounds bounds = ((Component)ui.currentCrate).GetComponent().bounds; Vector3 forward = transform.forward; float num = Vector3.Dot(((Bounds)(ref bounds)).extents, new Vector3(Mathf.Abs(forward.x), Mathf.Abs(forward.y), Mathf.Abs(forward.z))); float num2 = Mathf.Clamp(Vector3.Dot(((Bounds)(ref bounds)).center - transform.position, forward) - num - 0.12f, 0.3f, 0.65f); ((Component)ui).transform.localScale = originalScale * (0.5f * num2); ((Component)ui).transform.position = transform.position + forward * num2 + transform.up * (0.07f * num2); ((Component)ui).transform.LookAt(transform.position); Tracker.Invoke(ui).SetPositionAndRotation(((Component)ui).transform.position, ((Component)ui).transform.rotation); } } } [HarmonyPatch(typeof(CrateInventoryUI), "ShowInventory")] internal static class RackJarPositionPatch { [HarmonyPostfix] private static void Postfix(CrateInventoryUI __instance) { if (__instance.showingUI) { RackJarLayoutPatch.Position(__instance); } } } [HarmonyPatch(typeof(CrateInventoryUI), "HideInventory")] internal static class RackJarClosePatch { [HarmonyPostfix] private static void Postfix(CrateInventoryUI __instance) { RackJarLayoutPatch.Restore(__instance); } } [HarmonyPatch(typeof(CrateInventoryButton), "OnActivate")] internal static class RackJarInsertPatch { [HarmonyPrefix] private static bool Prefix(GoPointer activatingPointer) { if ((Object)(object)CrateInventoryUI.instance == (Object)null || !RackJarDimensionsPatch.IsJar(CrateInventoryUI.instance.currentCrate)) { return true; } PickupableItem heldItem = activatingPointer.GetHeldItem(); ShipItem val = (ShipItem)(object)((heldItem is ShipItem) ? heldItem : null); if ((Object)(object)val == (Object)null) { return true; } FreshTobaccoLeafState component = ((Component)val).GetComponent(); if (CrateInventoryUI.instance.currentCrate.containedItems.Count < 16) { if (!(val is ShipItemTobacco) && (!((Object)(object)component != (Object)null) || !component.IsFullyDry)) { return (Object)(object)((Component)val).GetComponent() != (Object)null; } return true; } return false; } } [HarmonyPatch(typeof(CrateInventory), "InsertItem")] internal static class RackJarItemScalePatch { [HarmonyPostfix] private static void Postfix(CrateInventory __instance, ShipItem item) { //IL_0018: 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) if (!((Object)(object)item == (Object)null) && RackJarDimensionsPatch.IsJar(__instance)) { ((Component)item).transform.localScale = Vector3.one * RackJarDisplay.ItemScale(item.inventoryScale); } } } [HarmonyPatch(typeof(ShipItem), "AddLODGroup")] internal static class CustomItemLodPatch { [HarmonyPrefix] private static bool Prefix(ShipItem __instance) { SaveablePrefab component = ((Component)__instance).GetComponent(); if ((Object)(object)component == (Object)null || component.prefabIndex < 610 || component.prefabIndex > 631 || component.prefabIndex == 614) { return true; } List list = new List(); MeshRenderer[] componentsInChildren = ((Component)__instance).GetComponentsInChildren(true); foreach (MeshRenderer val in componentsInChildren) { if ((Object)(object)((Renderer)val).sharedMaterial != (Object)null && ((Object)((Renderer)val).sharedMaterial).name == "InteractionOutlineProxy") { ((Renderer)val).enabled = false; } else { list.Add((Renderer)(object)val); } } LODGroup val2 = ((Component)__instance).GetComponent(); if ((Object)(object)val2 == (Object)null) { val2 = ((Component)__instance).gameObject.AddComponent(); } LOD[] array = (LOD[])RefsDirectory.instance.LODtemplateItems.GetLODs().Clone(); array[0].renderers = list.ToArray(); val2.SetLODs(array); val2.RecalculateBounds(); return false; } } [HarmonyPatch(typeof(ShipItem), "OnItemClick")] internal static class CustomItemClickPatch { private static readonly FieldRef ReadPointerHit = AccessTools.FieldRefAccess("hit"); [HarmonyPrefix] private static bool Prefix(ShipItem __instance, PickupableItem heldItem, ref bool __result) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: 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) DisplayStorageState component = ((Component)__instance).GetComponent(); if ((Object)(object)component != (Object)null) { __result = false; ShipItem val = (((Object)(object)heldItem != (Object)null) ? ((Component)heldItem).GetComponent() : null); if ((Object)(object)val != (Object)null && (Object)(object)((PickupableItem)val).held != (Object)null) { component.TryPlace(val, ((RaycastHit)(ref ReadPointerHit.Invoke(((PickupableItem)val).held))).point); } return false; } TobaccoPlantPotState component2 = ((Component)__instance).GetComponent(); if ((Object)(object)component2 != (Object)null) { __result = false; if ((Object)(object)heldItem != (Object)null) { component2.TryAcceptWater(((Component)heldItem).GetComponent()); } return false; } if ((Object)(object)((Component)__instance).GetComponent() != (Object)null) { __result = false; return false; } AshtrayState component3 = ((Component)__instance).GetComponent(); if ((Object)(object)component3 != (Object)null) { __result = false; CigarRuntimeState cigarRuntimeState = (((Object)(object)heldItem != (Object)null) ? ((Component)heldItem).GetComponent() : null); ShipItemPipe val2 = (((Object)(object)heldItem != (Object)null) ? ((Component)heldItem).GetComponent() : null); GoPointer val3 = (((Object)(object)val2 != (Object)null) ? ((PickupableItem)val2).held : null); if ((Object)(object)val3 != (Object)null && (Object)(object)val3.GetHeldItem() == (Object)(object)heldItem) { RaycastHit val4 = ReadPointerHit.Invoke(val3); if ((Object)(object)((RaycastHit)(ref val4)).collider != (Object)null && (Object)(object)((Component)((RaycastHit)(ref val4)).collider).GetComponentInParent() == (Object)(object)component3) { if ((Object)(object)cigarRuntimeState != (Object)null) { component3.TrySeatAt(cigarRuntimeState, ((RaycastHit)(ref val4)).point); } else { component3.TrySeatPipe(val2); } } } return false; } CigarWrapperState component4 = ((Component)__instance).GetComponent(); if ((Object)(object)component4 != (Object)null) { __result = false; if ((Object)(object)heldItem != (Object)null) { component4.TryInsert(((Component)heldItem).GetComponent()); } return false; } return true; } } [HarmonyPatch(typeof(ShipItem), "OnAltActivate")] internal static class CustomAltInteractionPatch { [HarmonyPrefix] private static bool Prefix(ShipItem __instance) { CigarBoxState component = ((Component)__instance).GetComponent(); if ((Object)(object)component != (Object)null && __instance.sold) { component.ToggleLid(); return false; } TobaccoPlantPotState component2 = ((Component)__instance).GetComponent(); if ((Object)(object)component2 != (Object)null && __instance.sold) { component2.TryHarvest(); return false; } CigarWrapperState component3 = ((Component)__instance).GetComponent(); if ((Object)(object)component3 != (Object)null && __instance.sold) { component3.TryRoll(); return false; } return true; } } [HarmonyPatch(typeof(ShipItemBottle), "AllowOnItemClick")] internal static class PotWaterTargetPatch { [HarmonyPostfix] private static void Postfix(ShipItemBottle __instance, GoPointerButton lookedAtButton, ref bool __result) { if (!__result && !((Object)(object)lookedAtButton == (Object)null) && ((ShipItem)__instance).sold) { TobaccoPlantPotState component = ((Component)lookedAtButton).GetComponent(); if ((Object)(object)component != (Object)null && component.StoredWater < 15f && (Object)(object)((Component)lookedAtButton).GetComponent() != (Object)null && ((Component)lookedAtButton).GetComponent().sold && ((ShipItem)__instance).amount == 1f && ((ShipItem)__instance).health > 0f) { __result = true; } } } } [HarmonyPatch(typeof(ShipItemTobacco), "AllowOnItemClick")] internal static class TobaccoTargetPatch { [HarmonyPostfix] private static void Postfix(ShipItemTobacco __instance, GoPointerButton lookedAtButton, ref bool __result) { if ((Object)(object)lookedAtButton == (Object)null) { return; } if ((Object)(object)((Component)lookedAtButton).GetComponent() != (Object)null) { __result = false; return; } if ((Object)(object)((Component)lookedAtButton).GetComponent() != (Object)null || (Object)(object)((Component)lookedAtButton).GetComponent() != (Object)null) { __result = false; return; } CigarWrapperState component = ((Component)lookedAtButton).GetComponent(); if ((Object)(object)component != (Object)null) { __result = component.CanInsert(__instance); } } } [HarmonyPatch(typeof(ShipItem), "AllowOnItemClick")] internal static class DryLeafCombineTargetPatch { [HarmonyPostfix] private static void Postfix(ShipItem __instance, GoPointerButton lookedAtButton, ref bool __result) { //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown //IL_00f7: 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) FreshTobaccoLeafState component = ((Component)__instance).GetComponent(); FreshTobaccoLeafState freshTobaccoLeafState = (((Object)(object)lookedAtButton != (Object)null) ? ((Component)lookedAtButton).GetComponent() : null); if ((Object)(object)component != (Object)null && (Object)(object)freshTobaccoLeafState != (Object)null) { __result = freshTobaccoLeafState.CanCombineWith(component); } CigarRuntimeState component2 = ((Component)__instance).GetComponent(); AshtrayState ashtrayState = (((Object)(object)lookedAtButton != (Object)null) ? ((Component)lookedAtButton).GetComponent() : null); if ((Object)(object)component2 != (Object)null && (Object)(object)ashtrayState != (Object)null) { __result = ashtrayState.CanUse(component2); } else if ((Object)(object)ashtrayState != (Object)null && __instance is ShipItemPipe) { __result = ashtrayState.CanSeatPipe((ShipItemPipe)__instance); } StoragePointerTarget storagePointerTarget = (((Object)(object)lookedAtButton != (Object)null) ? ((Component)lookedAtButton).GetComponent() : null); DisplayStorageState displayStorageState = (((Object)(object)storagePointerTarget != (Object)null) ? storagePointerTarget.Owner : (((Object)(object)lookedAtButton != (Object)null) ? ((Component)lookedAtButton).GetComponent() : null)); if ((Object)(object)displayStorageState != (Object)null) { __result = displayStorageState.Available && displayStorageState.NearestEmpty(__instance, ((Object)(object)storagePointerTarget != (Object)null) ? storagePointerTarget.Point : ((Component)displayStorageState).transform.position) >= 0; } } } [HarmonyPatch(typeof(GoPointerButton), "OnAltActivate", new Type[] { typeof(GoPointer) })] internal static class HeldCigarAndLeafAltPatch { [HarmonyPostfix] private static void Postfix(GoPointerButton __instance, GoPointer activatingPointer) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)activatingPointer == (Object)null || (Object)(object)activatingPointer.GetHeldItem() != (Object)(object)__instance || GameState.inCursorMenu || GameState.sleeping || Object.op_Implicit((Object)(object)GameState.inBed) || BoatCamera.on) { return; } AshtrayState component = ((Component)__instance).GetComponent(); if ((Object)(object)component != (Object)null) { component.BeginEmptying(); } else { RaycastHit val = default(RaycastHit); if (!Physics.Raycast(((Component)activatingPointer).transform.position, ((Component)activatingPointer).transform.forward, ref val, 1.8f, -67713029)) { return; } ShipItem component2 = ((Component)((RaycastHit)(ref val)).collider).GetComponent(); if (!((Object)(object)component2 == (Object)null) && component2.sold && !((GoPointerButton)component2).unclickable) { FreshTobaccoLeafState component3 = ((Component)__instance).GetComponent(); FreshTobaccoLeafState component4 = ((Component)component2).GetComponent(); if ((Object)(object)component3 != (Object)null && (Object)(object)component4 != (Object)null) { component4.TryCombineWith(component3); } CigarRuntimeState component5 = ((Component)__instance).GetComponent(); AshtrayState component6 = ((Component)component2).GetComponent(); if ((Object)(object)component5 != (Object)null && (Object)(object)component6 != (Object)null) { component6.TryClearAsh(component5); } } } } } [HarmonyPatch(typeof(ShipItemHammer), "CanNail")] internal static class AshtrayHammerPatch { [HarmonyPostfix] private static void Postfix(ShipItem item, ref bool __result) { if (!__result && !((Object)(object)item == (Object)null) && item.sold) { __result = (Object)(object)((Component)item).GetComponent() != (Object)null || (Object)(object)((Component)item).GetComponent() != (Object)null; } } } [HarmonyPatch(typeof(ShipItem), "OnPickup")] internal static class CigarLeaveRestPatch { [HarmonyPrefix] private static void Prefix(ShipItem __instance) { SecuredDisplayItem component = ((Component)__instance).GetComponent(); if ((Object)(object)component != (Object)null) { component.Detach(); } CigarRuntimeState component2 = ((Component)__instance).GetComponent(); if ((Object)(object)component2 != (Object)null) { component2.LeaveRest(); ((PickupableItem)component2.Pipe).heldRotationOffset = 77f; } RestingPipeState component3 = ((Component)__instance).GetComponent(); if ((Object)(object)component3 != (Object)null) { component3.LeaveRest(); } AshtrayState component4 = ((Component)__instance).GetComponent(); if ((Object)(object)component4 != (Object)null) { component4.PreparePickup(); } PipeRackState component5 = ((Component)__instance).GetComponent(); if ((Object)(object)component5 != (Object)null) { component5.PreparePickup(); } } } [HarmonyPatch(typeof(GoPointer), "DoRaycast")] internal static class SeatedCigarPointerPatch { private static readonly RaycastHit[] NearbyHits = (RaycastHit[])(object)new RaycastHit[16]; private static readonly FieldRef ReadPointerRay = AccessTools.FieldRefAccess("raycastRay"); [HarmonyTranspiler] private static IEnumerable Transpiler(IEnumerable instructions) { FieldInfo hitField = AccessTools.Field(typeof(GoPointer), "hit"); bool writesPointerHit = false; int replaced = 0; foreach (CodeInstruction instruction in instructions) { if (instruction.opcode == OpCodes.Ldflda && object.Equals(instruction.operand, hitField)) { writesPointerHit = true; } yield return instruction; MethodInfo methodInfo = instruction.operand as MethodInfo; if (writesPointerHit && !(instruction.opcode != OpCodes.Call) && !(methodInfo == null) && !(methodInfo.ReturnType != typeof(bool))) { ParameterInfo[] parameters = methodInfo.GetParameters(); if (parameters.Length == 4 && parameters[0].ParameterType == typeof(Ray) && parameters[1].ParameterType == typeof(RaycastHit).MakeByRefType() && parameters[2].ParameterType == typeof(float) && parameters[3].ParameterType == typeof(int)) { yield return new CodeInstruction(OpCodes.Ldarg_0, (object)null); yield return new CodeInstruction(OpCodes.Ldarg_0, (object)null); yield return new CodeInstruction(OpCodes.Ldflda, (object)hitField); yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(SeatedCigarPointerPatch), "PreferCigar", (Type[])null, (Type[])null)); replaced++; writesPointerHit = false; } } } if (replaced != 1) { throw new InvalidOperationException("Cannot locate native pointer raycast for seated cigar targeting."); } } private static bool PreferCigar(bool didHit, GoPointer pointer, ref RaycastHit hit) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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_00c8: 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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) if (!didHit) { return false; } if ((Object)(object)pointer.GetHeldItem() != (Object)null) { return StoragePointerPatch.SkipHeldCollider(pointer, ref hit); } AshtrayState component = ((Component)((RaycastHit)(ref hit)).collider).GetComponent(); if ((Object)(object)component == (Object)null) { return true; } Ray val = (pointer.debugEditorPointer ? Camera.main.ScreenPointToRay(Input.mousePosition) : ReadPointerRay.Invoke(pointer)); Collider val2 = TargetCollider(((Object)(object)component.Occupant != (Object)null) ? component.Occupant.Pipe : null); Collider val3 = TargetCollider(((Object)(object)component.PipeOccupant != (Object)null) ? component.PipeOccupant.Pipe : null); if ((Object)(object)val2 == (Object)null && (Object)(object)val3 == (Object)null) { return true; } bool flag = false; float num = 1.8f; RaycastHit val4 = default(RaycastHit); if ((Object)(object)val2 != (Object)null && val2.Raycast(val, ref val4, num)) { hit = val4; num = ((RaycastHit)(ref val4)).distance; flag = true; } if ((Object)(object)val3 != (Object)null && val3.Raycast(val, ref val4, num)) { hit = val4; flag = true; } if (flag) { return true; } int num2 = Physics.SphereCastNonAlloc(val, 0.012f, NearbyHits, 1.8f, -67713029); for (int i = 0; i < num2; i++) { if (((Object)(object)((RaycastHit)(ref NearbyHits[i])).collider == (Object)(object)val2 || (Object)(object)((RaycastHit)(ref NearbyHits[i])).collider == (Object)(object)val3) && ((RaycastHit)(ref NearbyHits[i])).distance < num) { hit = NearbyHits[i]; num = ((RaycastHit)(ref hit)).distance; } } return true; } private static Collider TargetCollider(ShipItemPipe item) { if (!((Object)(object)item != (Object)null) || ((GoPointerButton)item).unclickable || ((ShipItem)item).nailed) { return null; } return ((Component)item).GetComponent(); } } [HarmonyPatch(typeof(ShipItem), "ExtraFixedUpdate")] internal static class RestingCigarBoatPatch { [HarmonyPrefix] private static bool Prefix(ShipItem __instance) { ItemRigidbody itemRigidbodyC = __instance.itemRigidbodyC; if (itemRigidbodyC != null && itemRigidbodyC.GetCurrentBox() == null) { return true; } CigarRuntimeState component = ((Component)__instance).GetComponent(); RestingPipeState component2 = ((Component)__instance).GetComponent(); SecuredDisplayItem component3 = ((Component)__instance).GetComponent(); if (((Object)(object)component3 == (Object)null || (Object)(object)component3.Owner == (Object)null) && ((Object)(object)component == (Object)null || !component.IsResting)) { if (!((Object)(object)component2 == (Object)null)) { return !component2.IsResting; } return true; } return false; } } [HarmonyPatch(typeof(ShipItem), "OnEnterInventory")] internal static class AshtrayInventoryPatch { [HarmonyPrefix] private static void Prefix(ShipItem __instance) { SecuredDisplayItem component = ((Component)__instance).GetComponent(); if ((Object)(object)component != (Object)null) { component.Detach(); } PipeRackState component2 = ((Component)__instance).GetComponent(); if ((Object)(object)component2 != (Object)null) { component2.PreparePickup(); } AshtrayState component3 = ((Component)__instance).GetComponent(); if ((Object)(object)component3 != (Object)null) { component3.ReleaseOccupant(); } RestingPipeState component4 = ((Component)__instance).GetComponent(); if ((Object)(object)component4 != (Object)null) { component4.LeaveRest(); } } } [HarmonyPatch(typeof(GoPointer), "DoRaycast")] internal static class StoragePointerPatch { private static readonly RaycastHit[] SelfHits = (RaycastHit[])(object)new RaycastHit[64]; private static readonly FieldRef Hit = AccessTools.FieldRefAccess("hit"); private static readonly FieldRef Ray = AccessTools.FieldRefAccess("raycastRay"); private static readonly FieldRef Pointed = AccessTools.FieldRefAccess("pointedAtButton"); private static readonly FieldRef Distance = AccessTools.FieldRefAccess("currentLookDistance"); internal static bool SkipHeldCollider(GoPointer pointer, ref RaycastHit hit) { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) PickupableItem heldItem = pointer.GetHeldItem(); ShipItem val = (ShipItem)(object)((heldItem is ShipItem) ? heldItem : null); if ((Object)(object)val == (Object)null || (!(val is ShipItemPipe) && (Object)(object)((Component)val).GetComponent() == (Object)null)) { return true; } if (!IsHeld(((RaycastHit)(ref hit)).collider, val)) { return true; } int num = Physics.RaycastNonAlloc((pointer.debugEditorPointer && (Object)(object)Camera.main != (Object)null) ? Camera.main.ScreenPointToRay(Input.mousePosition) : Ray.Invoke(pointer), SelfHits, 1.8f, -67713029); float num2 = float.MaxValue; bool flag = false; for (int i = 0; i < num; i++) { if (!IsHeld(((RaycastHit)(ref SelfHits[i])).collider, val) && ((RaycastHit)(ref SelfHits[i])).distance < num2) { hit = SelfHits[i]; num2 = ((RaycastHit)(ref hit)).distance; flag = true; } } if (!flag) { hit = default(RaycastHit); } return flag; } private static bool IsHeld(Collider collider, ShipItem held) { if ((Object)(object)collider == (Object)null) { return false; } if (!((Component)collider).transform.IsChildOf(((Component)held).transform)) { if ((Object)(object)held.itemRigidbodyC != (Object)null) { return ((Component)collider).transform.IsChildOf(((Component)held.itemRigidbodyC).transform); } return false; } return true; } [HarmonyPostfix] private static void Postfix(GoPointer __instance) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_030c: Unknown result type (might be due to invalid IL or missing references) if (GameState.inCursorMenu || GameState.sleeping || Object.op_Implicit((Object)(object)GameState.inBed) || BoatCamera.on) { return; } RaycastHit val = Hit.Invoke(__instance); if ((Object)(object)((RaycastHit)(ref val)).collider == (Object)null) { return; } SecuredDisplayItem componentInParent = ((Component)((RaycastHit)(ref val)).collider).GetComponentInParent(); DisplayStorageState displayStorageState = (((Object)(object)componentInParent != (Object)null && (Object)(object)componentInParent.Owner != (Object)null) ? componentInParent.Owner : ((Component)((RaycastHit)(ref val)).collider).GetComponentInParent()); if ((Object)(object)displayStorageState == (Object)null || (Object)(object)((PickupableItem)displayStorageState.Item).held != (Object)null || ((GoPointerButton)displayStorageState.Item).unclickable) { return; } Ray val2 = ((__instance.debugEditorPointer && (Object)(object)Camera.main != (Object)null) ? Camera.main.ScreenPointToRay(Input.mousePosition) : Ray.Invoke(__instance)); ShipItem val3 = (((Object)(object)__instance.GetHeldItem() != (Object)null) ? ((Component)__instance.GetHeldItem()).GetComponent() : null); if (!displayStorageState.Item.sold || val3 is ShipItemHammer) { if ((Object)(object)val3 == (Object)null || ((GoPointerButton)val3).AllowOnItemClick((GoPointerButton)(object)displayStorageState.Item)) { Assign(__instance, (GoPointerButton)(object)displayStorageState.Item, ((RaycastHit)(ref val)).distance); } return; } CigarBoxState cigarBoxState = displayStorageState as CigarBoxState; if ((Object)(object)cigarBoxState != (Object)null) { if (cigarBoxState.ResolveInterior(val2, out var slot, out var point)) { Assign(__instance, (GoPointerButton)(object)cigarBoxState.Target(slot, point, __instance), Vector3.Distance(point, ((Ray)(ref val2)).origin)); } else { Assign(__instance, (GoPointerButton)(object)(displayStorageState.Item.nailed ? displayStorageState.Target(-3, ((RaycastHit)(ref val)).point, __instance) : ((StoragePointerTarget)(object)displayStorageState.Item)), ((RaycastHit)(ref val)).distance); } return; } PipeRackState pipeRackState = displayStorageState as PipeRackState; if ((Object)(object)pipeRackState == (Object)null) { return; } float num = 1.8f; SecuredDisplayItem securedDisplayItem = null; RaycastHit val4 = default(RaycastHit); for (int i = 0; i < pipeRackState.Capacity; i++) { SecuredDisplayItem content = pipeRackState.GetContent(i); if (!((Object)(object)content == (Object)null)) { Collider component = ((Component)content.Item).GetComponent(); if ((Object)(object)component != (Object)null && component.Raycast(val2, ref val4, num)) { num = ((RaycastHit)(ref val4)).distance; securedDisplayItem = content; } } } Vector3 point2; if ((Object)(object)securedDisplayItem != (Object)null && ((Object)(object)val3 == (Object)null || val3 is ShipItemTobacco || ((Object)(object)((Component)securedDisplayItem.Item).GetComponent() != (Object)null && val3 is ShipItemPipe))) { Assign(__instance, (GoPointerButton)(object)securedDisplayItem.Item, num); } else if ((Object)(object)val3 == (Object)null && pipeRackState.RayAtJar(val2, out point2)) { Assign(__instance, (GoPointerButton)(object)pipeRackState.Target(-2, point2, __instance), Vector3.Distance(point2, ((Ray)(ref val2)).origin)); } else if ((Object)(object)val3 != (Object)null && (val3 is ShipItemPipe || (Object)(object)((Component)val3).GetComponent() != (Object)null)) { Assign(__instance, (GoPointerButton)(object)pipeRackState.Target(-1, ((RaycastHit)(ref val)).point, __instance), ((RaycastHit)(ref val)).distance); } else if ((Object)(object)val3 == (Object)null && displayStorageState.Item.nailed) { Assign(__instance, (GoPointerButton)(object)pipeRackState.Target(-3, ((RaycastHit)(ref val)).point, __instance), ((RaycastHit)(ref val)).distance); } } private static void Assign(GoPointer pointer, GoPointerButton target, float distance) { GoPointerButton val = Pointed.Invoke(pointer); if ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)target) { val.ForceUnlook(); } StoragePointerTarget storagePointerTarget = target as StoragePointerTarget; if ((Object)(object)storagePointerTarget != (Object)null) { ((GoPointerButton)storagePointerTarget.Owner.Item).ForceUnlook(); } Pointed.Invoke(pointer) = target; Distance.Invoke(pointer) = distance; target.Look(pointer); } } [HarmonyPatch(typeof(GoPointer), "PickUpItem")] internal static class NailedStoragePickupPatch { [HarmonyPrefix] private static bool Prefix(PickupableItem item) { ShipItem val = (ShipItem)(object)((item is ShipItem) ? item : null); if (!((Object)(object)val == (Object)null) && val.nailed) { if ((Object)(object)((Component)val).GetComponent() == (Object)null) { return (Object)(object)((Component)val).GetComponent() == (Object)null; } return false; } return true; } } [HarmonyPatch(typeof(LookUI), "ShowLookText")] internal static class StorageLookTextPatch { private static readonly FieldRef Extra = AccessTools.FieldRefAccess("extraText"); [HarmonyPostfix] private static void Postfix(LookUI __instance, GoPointerButton button) { HideName(__instance, button); } internal static void HideName(LookUI ui, GoPointerButton button) { if (!((Object)(object)button == (Object)null)) { StoragePointerTarget storagePointerTarget = button as StoragePointerTarget; if ((Object)(object)(((Object)(object)storagePointerTarget != (Object)null) ? storagePointerTarget.Owner : ((Component)button).GetComponent()) != (Object)null) { Extra.Invoke(ui).text = string.Empty; } } } } [HarmonyPatch(typeof(LookUI), "ShowHoldText")] internal static class StorageHoldTextPatch { [HarmonyPostfix] private static void Postfix(LookUI __instance, PickupableItem item) { StorageLookTextPatch.HideName(__instance, (GoPointerButton)(object)item); } } [HarmonyPatch(typeof(GoPointer), "LateUpdate")] internal static class StoragePlacementPreviewPatch { private static readonly FieldRef Pointed = AccessTools.FieldRefAccess("pointedAtButton"); [HarmonyPostfix] private static void Postfix(GoPointer __instance) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) StoragePointerTarget storagePointerTarget = Pointed.Invoke(__instance) as StoragePointerTarget; PickupableItem heldItem = __instance.GetHeldItem(); ShipItem val = (ShipItem)(object)((heldItem is ShipItem) ? heldItem : null); DisplayStorageState displayStorageState = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent() : null); if ((Object)(object)displayStorageState != (Object)null && !((PickupableItem)val).big) { ((Component)val).transform.rotation = ((Component)__instance).transform.rotation * Quaternion.Euler(((PickupableItem)val).heldRotationOffset, 180f, 0f); displayStorageState.SyncContents(); } if ((Object)(object)storagePointerTarget == (Object)null || (Object)(object)val == (Object)null || !storagePointerTarget.Owner.Available) { return; } int num = storagePointerTarget.Owner.NearestEmpty(val, storagePointerTarget.Point); if (num >= 0) { MeshFilter component = ((Component)val).GetComponent(); if (!((Object)(object)component == (Object)null) && !((Object)(object)component.sharedMesh == (Object)null)) { storagePointerTarget.Owner.Pose(num, val, out var position, out var rotation); __instance.GetTargeter().DisplayTargeter(position, rotation, component.sharedMesh); } } } } [HarmonyPatch(typeof(PrefabsDirectory), "Start")] internal static class PrefabRegistrationPatches { [HarmonyPrefix] [HarmonyPriority(0)] private static void Prefix(PrefabsDirectory __instance) { CigarPrefabRegistrar.EnsureRegistered(__instance); } [HarmonyPostfix] [HarmonyPriority(0)] private static void Postfix(PrefabsDirectory __instance) { CigarPrefabRegistrar.ValidateAndConfigure(__instance); } } [HarmonyPatch(typeof(SaveLoadManager), "LoadGame")] internal static class LegacyLeafSaveMigrationPatch { [HarmonyTranspiler] private static IEnumerable Transpiler(IEnumerable instructions) { int hooks = 0; foreach (CodeInstruction instruction in instructions) { yield return instruction; if (instruction.opcode == OpCodes.Castclass && object.Equals(instruction.operand, typeof(SaveContainer))) { hooks++; yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(LegacyLeafMigration), "MigrateLoadedContainer", (Type[])null, (Type[])null)); } } if (hooks != 1) { throw new InvalidOperationException("Cannot safely locate the loaded Sailwind save container for leaf migration."); } } } [HarmonyPatch(typeof(SaveablePrefab), "Load")] internal static class SaveLoadSyncPatches { [HarmonyPostfix] private static void Postfix(SaveablePrefab __instance, SavePrefabData data) { TobaccoPlantPotState component = ((Component)__instance).GetComponent(); if ((Object)(object)component != (Object)null) { component.ReadRainSave(data); } CigarRuntimeState component2 = ((Component)__instance).GetComponent(); if ((Object)(object)component2 != (Object)null) { component2.ReadSave(data); } RestingPipeState restingPipeState = RestingPipeState.Ensure(((Component)__instance).GetComponent()); if ((Object)(object)restingPipeState != (Object)null) { restingPipeState.ReadSave(data); } CigarBoxState component3 = ((Component)__instance).GetComponent(); if ((Object)(object)component3 != (Object)null) { component3.ReadSave(data); } if (data.extraValue4 == 130f && (Object)(object)((Component)__instance).GetComponent() != (Object)null) { (((Component)__instance).GetComponent() ?? ((Component)__instance).gameObject.AddComponent()).ReadSave(data); } RuntimeStateSynchronizer.Sync(((Component)__instance).GetComponent(), snapCigar: true); } } [HarmonyPatch(typeof(SaveablePrefab), "PrepareSaveData")] internal static class CigarSavePatch { [HarmonyPrefix] private static void Prefix(SaveablePrefab __instance) { CigarRuntimeState component = ((Component)__instance).GetComponent(); if ((Object)(object)component != (Object)null) { component.SyncRestParent(); } RestingPipeState component2 = ((Component)__instance).GetComponent(); if ((Object)(object)component2 != (Object)null) { component2.SyncRestParent(); } SecuredDisplayItem component3 = ((Component)__instance).GetComponent(); if ((Object)(object)component3 != (Object)null) { component3.Sync(); } } [HarmonyPostfix] private static void Postfix(SaveablePrefab __instance, SavePrefabData __result) { TobaccoPlantPotState component = ((Component)__instance).GetComponent(); if ((Object)(object)component != (Object)null) { component.WriteRainSave(__result); } CigarRuntimeState component2 = ((Component)__instance).GetComponent(); if ((Object)(object)component2 != (Object)null) { component2.WriteSave(__result); } RestingPipeState component3 = ((Component)__instance).GetComponent(); if ((Object)(object)component3 != (Object)null) { component3.WriteSave(__result); } CigarBoxState component4 = ((Component)__instance).GetComponent(); if ((Object)(object)component4 != (Object)null) { component4.WriteSave(__result); } SecuredDisplayItem component5 = ((Component)__instance).GetComponent(); if ((Object)(object)component5 != (Object)null) { component5.WriteSave(__result); } } } [HarmonyPatch(typeof(ShopItemSpawner), "SpawnItem")] internal static class WrapperRestockPatch { [HarmonyPrefix] private static void Prefix(ShopItemSpawner __instance) { ShopPlacement.PrepareWrapperRestock(__instance); } } [HarmonyPatch(typeof(ShopItemSpawner), "Start")] internal static class ShopItemSpawnerPlacementPatch { [HarmonyPrefix] private static void Prefix(ShopItemSpawner __instance) { ShopPlacement.ConfigureSpawnerBeforeStart(__instance); } [HarmonyPostfix] private static void Postfix(ShopItemSpawner __instance) { ShopPlacement.AddRelativeDisplaysAfterStart(__instance); } } [HarmonyPatch(typeof(Shopkeeper), "Start")] internal static class SageHillsPotPlacementPatch { [HarmonyPostfix] private static void Postfix(Shopkeeper __instance) { ShopPlacement.AddSageHillsPotAfterStart(__instance); } } [HarmonyPatch(typeof(ShipItemKnife), "AllowOnItemClick")] internal static class TobaccoLeafKnifeTargetPatch { [HarmonyPostfix] private static void Postfix(ShipItemKnife __instance, GoPointerButton lookedAtButton, ref bool __result) { FreshTobaccoLeafState freshTobaccoLeafState = (((Object)(object)lookedAtButton != (Object)null) ? ((Component)lookedAtButton).GetComponent() : null); if ((Object)(object)freshTobaccoLeafState != (Object)null && freshTobaccoLeafState.IsFullyDry) { __result = false; } else if (!__result && ((ShipItem)__instance).sold && (Object)(object)lookedAtButton != (Object)null) { ShipItem component = ((Component)lookedAtButton).GetComponent(); __result = (Object)(object)component != (Object)null && component.sold && (Object)(object)((Component)component).GetComponent() != (Object)null; } } } [HarmonyPatch(typeof(ShipItemKnife), "OnAltActivate")] internal static class TobaccoLeafKnifePatch { private const int SliceCount = 3; [HarmonyPostfix] private static void Postfix(ShipItemKnife __instance, ref bool ___animating, ref float ___heldRotationOffset, ref float ___cutTimer) { //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) if (!((ShipItem)__instance).sold || (Object)(object)((PickupableItem)__instance).held == (Object)null) { return; } ShipItem pointedAtItem = ((PickupableItem)__instance).held.GetPointedAtItem(); if ((Object)(object)pointedAtItem == (Object)null || !pointedAtItem.sold || (Object)(object)((Component)pointedAtItem).GetComponent() == (Object)null || ((Component)pointedAtItem).GetComponent().IsFullyDry || !PrefabReplacement.CanTransform(pointedAtItem) || !PrefabReplacement.CanSpawn(312)) { return; } ___animating = true; ___heldRotationOffset = 0f; ___cutTimer = 0.25f; List list = new List(3); float num = -0.03f; for (int i = 0; i < 3; i++) { ShipItem val = PrefabReplacement.SpawnOwned(312, ((Component)pointedAtItem).transform.position + ((Component)pointedAtItem).transform.right * num, ((Component)pointedAtItem).transform.rotation * Quaternion.Euler(0f, 90f, 0f), pointedAtItem, 0f, 0f); if ((Object)(object)val != (Object)null) { list.Add(val); } num += 0.02f; } if (list.Count == 3) { PrefabReplacement.ConsumeOwned(pointedAtItem); return; } for (int j = 0; j < list.Count; j++) { list[j].DestroyItem(); } RuntimeDiagnostics.Error("Knife cut could not create all three green tobaccos; partial output was rolled back and the leaf was preserved."); } } [HarmonyPatch(typeof(GoPointer), "DropItem")] internal static class PotRainPlacementPatch { [HarmonyPrefix] private static void Prefix(GoPointer __instance, out TobaccoPlantPotState __state) { PickupableItem heldItem = __instance.GetHeldItem(); __state = (((Object)(object)heldItem != (Object)null) ? ((Component)heldItem).GetComponent() : null); } [HarmonyPostfix] private static void Postfix(TobaccoPlantPotState __state) { if ((Object)(object)__state != (Object)null) { __state.CheckRainExposureOnPlacement(); } } } [HarmonyPatch(typeof(ShipItem), "OnPickup")] internal static class PotRainPickupPatch { [HarmonyPostfix] private static void Postfix(ShipItem __instance) { TobaccoPlantPotState component = ((Component)__instance).GetComponent(); if ((Object)(object)component != (Object)null) { component.ClearRainExposure(); } } } [HarmonyPatch(typeof(ShipItem), "OnEnterInventory")] internal static class PotRainInventoryPatch { [HarmonyPostfix] private static void Postfix(ShipItem __instance) { TobaccoPlantPotState component = ((Component)__instance).GetComponent(); if ((Object)(object)component != (Object)null) { component.ClearRainExposure(); } } } } namespace TobaccoPotAndCigar.Runtime { public sealed class AshPileVisual : MonoBehaviour { private Mesh ownedMesh; private float lastFill = -1f; [SerializeField] private float[] floorHeights; public const int FloorGridSize = 65; public void ConfigureFloor(float[] heights) { floorHeights = heights; lastFill = -1f; } public void SetFill(float fill) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown fill = Mathf.Clamp01(fill); ((Component)this).gameObject.SetActive(fill > 1E-06f); if (!(fill <= 1E-06f) && fill != lastFill) { if ((Object)(object)ownedMesh == (Object)null) { ownedMesh = new Mesh { name = "Deposited Ash (instance)" }; } WriteMesh(ownedMesh, fill, floorHeights); ((Component)this).GetComponent().sharedMesh = ownedMesh; lastFill = fill; } } private void OnDestroy() { if (!((Object)(object)ownedMesh == (Object)null)) { if (Application.isPlaying) { Object.Destroy((Object)(object)ownedMesh); } else { Object.DestroyImmediate((Object)(object)ownedMesh); } } } public static Mesh CreateMesh(float fill, float[] floorHeights = null) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown //IL_001e: Expected O, but got Unknown Mesh val = new Mesh { name = "Deposited Ash" }; WriteMesh(val, Mathf.Clamp01(fill), floorHeights); return val; } private static void WriteMesh(Mesh mesh, float fill, float[] floorHeights) { int num = 97; Vector3[] array = (Vector3[])(object)new Vector3[num * 2]; Vector2[] uv = (Vector2[])(object)new Vector2[array.Length]; List list = new List(); float num2 = Mathf.Lerp(0.16f, 1f, Mathf.Sqrt(fill)); float num3 = 0.015f * Mathf.Pow(fill, 0.6f); SetVertex(array, uv, 0, num, 0.05f, 0f, num3, floorHeights); for (int i = 0; i < 3; i++) { for (int j = 0; j < 32; j++) { float num4 = (float)j * MathF.PI * 2f / 32f; float num5 = Mathf.Cos(num4); float num6 = Mathf.Sin(num4); float num7 = -0.05f * num5 + Mathf.Sqrt(0.011664f - 0.0025000002f * num6 * num6); if (num5 < 0f) { num7 = Mathf.Min(num7, -0.048f / num5); } num7 *= 0.982f + 0.012f * Mathf.Sin((float)j * 1.7f); float num8 = ((float)i + 1f) / 3f; float num9 = num7 * num2 * num8; float mound = num3 * Mathf.Pow(1f - num8 * num8, 1.25f) * (1f + 0.08f * Mathf.Sin((float)j * 2.3f + (float)i)); int num10 = 1 + i * 32 + j; int num11 = 1 + i * 32 + (j + 1) % 32; SetVertex(array, uv, num10, num, 0.05f + num5 * num9, num6 * num9, mound, floorHeights); if (i == 0) { AddFace(list, 0, num10, num11, num); } else { AddFace(list, num10 - 32, num10, num11, num); AddFace(list, num10 - 32, num11, num11 - 32, num); } if (i == 2) { list.AddRange(new int[6] { num10, num10 + num, num11, num11, num10 + num, num11 + num }); } } } mesh.Clear(); mesh.vertices = array; mesh.uv = uv; mesh.triangles = list.ToArray(); mesh.RecalculateNormals(); mesh.RecalculateBounds(); mesh.RecalculateTangents(); } private static void AddFace(List triangles, int a, int b, int c, int half) { triangles.AddRange(new int[6] { a, b, c, c + half, b + half, a + half }); } private static void SetVertex(Vector3[] vertices, Vector2[] uv, int i, int half, float x, float z, float mound, float[] floorHeights) { //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: 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_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Sqrt(x * x + z * z); float num2 = ((num <= 0.075f) ? 0.013f : ((num <= 0.098f) ? Mathf.Lerp(0.013f, 0.016f, (num - 0.075f) / 0.023f) : Mathf.Lerp(0.016f, 0.023f, (num - 0.098f) / 0.012f))); if (floorHeights != null && floorHeights.Length == 4225) { float num3 = Mathf.Clamp01(x / 0.11f) * 64f; float num4 = Mathf.Clamp01((z + 0.11f) / 0.22f) * 64f; int num5 = Mathf.Min((int)num3, 63); int num6 = Mathf.Min((int)num4, 63); float num7 = Mathf.Lerp(floorHeights[num6 * 65 + num5], floorHeights[num6 * 65 + num5 + 1], num3 - (float)num5); float num8 = Mathf.Lerp(floorHeights[(num6 + 1) * 65 + num5], floorHeights[(num6 + 1) * 65 + num5 + 1], num3 - (float)num5); num2 = Mathf.Lerp(num7, num8, num4 - (float)num6); } Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(0.9848077f * x - 0.17364818f * z, num2, -0.17364818f * x - 0.9848077f * z); vertices[i] = val + Vector3.up * (0.00065f + mound); vertices[i + half] = val + Vector3.up * 0.00035f; uv[i] = (uv[i + half] = new Vector2(0.225f + (x - 0.05f) * 1.3f, 0.21f + z * 1.3f)); } } public sealed class AshtrayState : MonoBehaviour { [SerializeField] private Transform[] rests; [SerializeField] private Transform ashPile; [SerializeField] private Transform[] pipeRests; [SerializeField] private Transform[] grooveTargets; private ShipItem item; private CigarRuntimeState occupant; private RestingPipeState pipeOccupant; private float emptyingTime = -1f; private float restingAngle; private GoPointer emptyingPointer; public ShipItem Item { get { if (!((Object)(object)item != (Object)null)) { return item = ((Component)this).GetComponent(); } return item; } } public CigarRuntimeState Occupant => occupant; public RestingPipeState PipeOccupant => pipeOccupant; public void Configure(Transform[] sockets, Transform pile) { rests = sockets; ashPile = pile; } public void ConfigurePipeRests(Transform[] sockets, Transform[] grooves) { pipeRests = sockets; grooveTargets = grooves; } private void Start() { SyncFromSavedState(); } public void SyncFromSavedState() { //IL_00ee: Unknown result type (might be due to invalid IL or missing references) Item.health = ((float.IsNaN(Item.health) || float.IsInfinity(Item.health)) ? 0f : Mathf.Clamp(Item.health, 0f, 100f)); if (!((Object)(object)ashPile == (Object)null)) { AshPileVisual component = ((Component)ashPile).GetComponent(); if ((Object)(object)component != (Object)null) { component.SetFill(Item.health / 100f); return; } ((Component)ashPile).gameObject.SetActive(Item.health > 0.0001f); float num = Item.health / 100f; float num2 = Mathf.Lerp(0.25f, 1f, Mathf.Sqrt(num)); ashPile.localScale = new Vector3(num2, Mathf.Lerp(0.15f, 1f, num), num2); } } public bool BeginEmptying() { if (emptyingTime >= 0f || !Item.sold || (Object)(object)((PickupableItem)Item).held == (Object)null) { return false; } emptyingPointer = ((PickupableItem)Item).held; restingAngle = ((PickupableItem)Item).heldRotationOffset; emptyingTime = 0f; return true; } private void AdvanceEmptying(float deltaTime) { if (emptyingTime < 0f) { return; } if ((Object)(object)((PickupableItem)Item).held != (Object)(object)emptyingPointer) { CancelEmptying(); return; } emptyingTime += deltaTime; float num = ((emptyingTime < 0.3f) ? Mathf.SmoothStep(0f, 1f, emptyingTime / 0.3f) : (1f - Mathf.SmoothStep(0f, 1f, (emptyingTime - 0.4f) / 0.3f))); ((PickupableItem)Item).heldRotationOffset = restingAngle - 150f * num; if (emptyingTime >= 0.3f && Item.health > 0f) { Item.health = 0f; SyncFromSavedState(); } if (emptyingTime >= 0.7f) { CancelEmptying(); } } private void CancelEmptying() { if (emptyingTime >= 0f && (Object)(object)Item != (Object)null) { ((PickupableItem)Item).heldRotationOffset = restingAngle; } emptyingTime = -1f; emptyingPointer = null; } public bool CanUse(CigarRuntimeState cigar) { if ((Object)(object)cigar != (Object)null && (Object)(object)cigar.Pipe != (Object)null && ((ShipItem)cigar.Pipe).sold && ((ShipItem)cigar.Pipe).health > 0f) { return IsAvailable(); } return false; } private bool IsAvailable() { SecuredDisplayItem component = ((Component)this).GetComponent(); bool flag = (Object)(object)component != (Object)null && (Object)(object)component.Owner != (Object)null && component.Owner.Available; if ((Object)(object)Item != (Object)null && Item.sold && !Object.op_Implicit((Object)(object)((PickupableItem)Item).held) && ((Component)this).gameObject.activeInHierarchy && ((Component)Item).GetComponent().currentCrateId == 0 && (Object)(object)Item.itemRigidbodyC != (Object)null && (Object)(object)Item.itemRigidbodyC.GetCurrentInventorySlot() == (Object)null) { return (Object)(object)Item.itemRigidbodyC.GetCurrentBox() == (Object)null || flag; } return false; } public bool CanSeatPipe(ShipItemPipe pipe) { int num = RestingPipeState.NativePipeSlot(pipe); if (num >= 0 && ((ShipItem)pipe).sold && !((ShipItem)pipe).nailed && IsAvailable() && pipeRests != null && pipeRests.Length == 3 && (Object)(object)pipeRests[num] != (Object)null) { if (!((Object)(object)pipeOccupant == (Object)null)) { return (Object)(object)pipeOccupant.Pipe == (Object)(object)pipe; } return true; } return false; } public bool TrySeatPipe(ShipItemPipe pipe) { if (!CanSeatPipe(pipe) || (Object)(object)((ShipItem)pipe).itemRigidbodyC == (Object)null) { return false; } RestingPipeState restingPipeState = RestingPipeState.Ensure(pipe); if ((Object)(object)((PickupableItem)pipe).held != (Object)null) { ((PickupableItem)pipe).held.DropItem(); } restingPipeState.RestOn(this, pipeRests[RestingPipeState.NativePipeSlot(pipe)]); pipeOccupant = restingPipeState; return true; } public void ReleasePipe(RestingPipeState pipe) { if ((Object)(object)pipeOccupant == (Object)(object)pipe) { pipeOccupant = null; } } public void PreparePickup() { //IL_0046: Unknown result type (might be due to invalid IL or missing references) CancelEmptying(); ReleaseOccupant(drop: true); ((PickupableItem)Item).heldRotationOffset = 0f; if ((Object)(object)((PickupableItem)Item).held != (Object)null) { ((Component)this).transform.rotation = ((Component)((PickupableItem)Item).held).transform.rotation; } } public bool TryClearAsh(CigarRuntimeState cigar) { if (!CanUse(cigar) || (Object)(object)((PickupableItem)cigar.Pipe).held == (Object)null) { return false; } float num = cigar.AccumulatedAsh01 * 100f; cigar.ClearAsh(); ShipItem obj = Item; obj.health += num; SyncFromSavedState(); return true; } public bool TrySeatAt(CigarRuntimeState cigar, Vector3 hitPoint) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: 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) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) if (rests == null || rests.Length != 2 || (Object)(object)rests[0] == (Object)null || (Object)(object)rests[1] == (Object)null) { return false; } Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(0f, -0.12f, 0.00058f); Vector3 val2 = rests[0].TransformPoint(val); Vector3 val3 = rests[1].TransformPoint(val); if (grooveTargets != null && grooveTargets.Length == 2 && (Object)(object)grooveTargets[0] != (Object)null && (Object)(object)grooveTargets[1] != (Object)null) { val2 = grooveTargets[0].position; val3 = grooveTargets[1].position; } Vector3 val4 = hitPoint - val2; float sqrMagnitude = ((Vector3)(ref val4)).sqrMagnitude; val4 = hitPoint - val3; int slot = ((!(sqrMagnitude <= ((Vector3)(ref val4)).sqrMagnitude)) ? 1 : 0); return TrySeat(cigar, slot); } public bool TrySeat(CigarRuntimeState cigar, int slot) { if (!CanUse(cigar) || ((Object)(object)occupant != (Object)null && (Object)(object)occupant != (Object)(object)cigar) || rests == null || rests.Length != 2 || slot < 0 || slot > 1 || (Object)(object)rests[slot] == (Object)null || (Object)(object)((ShipItem)cigar.Pipe).itemRigidbodyC == (Object)null) { return false; } if ((Object)(object)((PickupableItem)cigar.Pipe).held != (Object)null) { ((PickupableItem)cigar.Pipe).held.DropItem(); } cigar.RestOn(this, rests[slot], slot); occupant = cigar; return true; } public void Release(CigarRuntimeState cigar) { if ((Object)(object)occupant == (Object)(object)cigar) { occupant = null; } } public void ReleaseOccupant(bool drop = false) { if ((Object)(object)pipeOccupant != (Object)null) { pipeOccupant.LeaveRest(drop); } if ((Object)(object)occupant == (Object)null) { return; } CigarRuntimeState cigarRuntimeState = occupant; cigarRuntimeState.LeaveRest(); if (!drop || !((Object)(object)((ShipItem)cigarRuntimeState.Pipe).itemRigidbodyC != (Object)null)) { return; } Rigidbody body = ((ShipItem)cigarRuntimeState.Pipe).itemRigidbodyC.GetBody(); if ((Object)(object)body != (Object)null) { ((ShipItem)cigarRuntimeState.Pipe).ResetRigidbody(); if ((Object)(object)((ShipItem)cigarRuntimeState.Pipe).currentActualBoat != (Object)null && (Object)(object)((ShipItem)cigarRuntimeState.Pipe).currentWalkCol != (Object)null) { ((ShipItem)cigarRuntimeState.Pipe).itemRigidbodyC.ForceRigidbodyToWalkCol(); } body.isKinematic = false; body.WakeUp(); } } private void LateUpdate() { AdvanceEmptying(Time.deltaTime); if (((Object)(object)occupant != (Object)null || (Object)(object)pipeOccupant != (Object)null) && (Object)(object)((PickupableItem)Item).held != (Object)null) { ReleaseOccupant(drop: true); } if (((Object)(object)occupant != (Object)null || (Object)(object)pipeOccupant != (Object)null) && (((Component)Item).GetComponent().currentCrateId != 0 || ((Object)(object)Item.itemRigidbodyC != (Object)null && (Object)(object)Item.itemRigidbodyC.GetCurrentInventorySlot() != (Object)null))) { ReleaseOccupant(); } } private void OnDisable() { CancelEmptying(); ReleaseOccupant(); } } public sealed class RestingPipeState : MonoBehaviour { private ShipItemPipe pipe; private AshtrayState tray; private Transform socket; private int savedTrayId; private bool started; public ShipItemPipe Pipe { get { if (!((Object)(object)pipe != (Object)null)) { return pipe = ((Component)this).GetComponent(); } return pipe; } } public bool IsResting { get { if ((Object)(object)tray != (Object)null) { return (Object)(object)socket != (Object)null; } return false; } } public static int NativePipeSlot(ShipItemPipe item) { SaveablePrefab val = (((Object)(object)item != (Object)null) ? ((Component)item).GetComponent() : null); int num = (((Object)(object)val != (Object)null) ? val.prefabIndex : (-1)); if (num < 300 || num > 302) { return -1; } return num - 300; } public static RestingPipeState Ensure(ShipItemPipe item) { if (NativePipeSlot(item) < 0) { return null; } RestingPipeState component = ((Component)item).GetComponent(); if (!((Object)(object)component != (Object)null)) { return ((Component)item).gameObject.AddComponent(); } return component; } private void Start() { started = true; if (savedTrayId != 0) { ((MonoBehaviour)this).StartCoroutine(RestoreRest()); } } public void RestOn(AshtrayState target, Transform rest) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0053: 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) LeaveRest(); tray = target; socket = rest; ((Component)this).transform.SetPositionAndRotation(rest.position, rest.rotation); ((ShipItem)Pipe).ResetRigidbody(); ((ShipItem)Pipe).itemRigidbodyC.EnterBox(((Component)tray).transform, socket.localPosition, socket.localRotation); SyncRestParent(); } public void LeaveRest(bool drop = false) { savedTrayId = 0; if ((Object)(object)tray == (Object)null) { return; } if ((Object)(object)((ShipItem)Pipe).itemRigidbodyC != (Object)null && (Object)(object)((ShipItem)Pipe).itemRigidbodyC.GetCurrentBox() == (Object)(object)((Component)tray).transform) { ((ShipItem)Pipe).itemRigidbodyC.ExitBox(); } tray.ReleasePipe(this); tray = null; socket = null; if (!drop || !((Object)(object)((ShipItem)Pipe).itemRigidbodyC != (Object)null)) { return; } Rigidbody body = ((ShipItem)Pipe).itemRigidbodyC.GetBody(); if ((Object)(object)body != (Object)null) { ((ShipItem)Pipe).ResetRigidbody(); if ((Object)(object)((ShipItem)Pipe).currentActualBoat != (Object)null && (Object)(object)((ShipItem)Pipe).currentWalkCol != (Object)null) { ((ShipItem)Pipe).itemRigidbodyC.ForceRigidbodyToWalkCol(); } body.isKinematic = false; body.WakeUp(); } } public void SyncRestParent() { //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) if (!IsResting) { return; } ShipItem item = tray.Item; if ((Object)(object)((PickupableItem)Pipe).held != (Object)null || (Object)(object)((PickupableItem)item).held != (Object)null || ((Component)item).GetComponent().currentCrateId != 0 || ((Object)(object)item.itemRigidbodyC != (Object)null && (Object)(object)item.itemRigidbodyC.GetCurrentInventorySlot() != (Object)null)) { LeaveRest((Object)(object)((PickupableItem)item).held != (Object)null); return; } ((ShipItem)Pipe).currentActualBoat = item.currentActualBoat; ((ShipItem)Pipe).currentWalkCol = item.currentWalkCol; ((Component)this).GetComponent().SetParentObject(((Component)item).GetComponent().GetParentObject()); if ((Object)(object)((ShipItem)Pipe).itemRigidbodyC != (Object)null) { ((ShipItem)Pipe).itemRigidbodyC.EnterBox(((Component)tray).transform, socket.localPosition, socket.localRotation); } } private void LateUpdate() { if (IsResting) { SyncRestParent(); } } private void OnDisable() { LeaveRest(); } public void WriteSave(SavePrefabData data) { int num = (IsResting ? ((Component)tray).GetComponent().instanceId : savedTrayId); data.extraValue1 = num & 0xFFFF; data.extraValue2 = (num >> 16) & 0x7FFF; data.extraValue4 = 120f; } public void ReadSave(SavePrefabData data) { savedTrayId = 0; if (data.extraValue4 == 120f && data.inventorySlot < 0 && data.crateId == 0 && data.extraValue1 >= 0f && data.extraValue1 <= 65535f && data.extraValue1 % 1f == 0f && data.extraValue2 >= 0f && data.extraValue2 <= 32767f && data.extraValue2 % 1f == 0f) { savedTrayId = (int)data.extraValue1 | ((int)data.extraValue2 << 16); } if (started && savedTrayId != 0) { ((MonoBehaviour)this).StartCoroutine(RestoreRest()); } } private IEnumerator RestoreRest() { while (GameState.currentlyLoading) { yield return null; } for (int frame = 0; frame < 120; frame++) { if (savedTrayId == 0) { break; } if ((Object)(object)SaveLoadManager.instance != (Object)null) { foreach (SaveablePrefab currentPrefab in SaveLoadManager.instance.GetCurrentPrefabs()) { if ((Object)(object)currentPrefab != (Object)null && currentPrefab.instanceId == savedTrayId) { AshtrayState component = ((Component)currentPrefab).GetComponent(); if ((Object)(object)component != (Object)null && component.TrySeatPipe(Pipe)) { savedTrayId = 0; yield break; } } } } yield return null; } savedTrayId = 0; } } public struct CigarEffectTotals { public float ImmediateSleepPerSecond; public float LingeringSleepPerSecond; public float WhiteVisualInputPerSecond; public float GreenVisualInputPerSecond; public float BlackVisualInputPerSecond; } public static class CigarEffectMath { public static CigarEffectTotals Calculate(TobaccoBlend blend, float blueImmediateSleepPerSecond, float blueGreenVisualInputPerSecond) { return new CigarEffectTotals { ImmediateSleepPerSecond = (float)blend.White * 0.66f - (float)blend.Green * 0.11f + (float)blend.Blue * blueImmediateSleepPerSecond + (float)blend.Black * 1.2f + (float)blend.Brown * 0.8f, LingeringSleepPerSecond = (float)blend.White * -0.165f + (float)blend.Green * -0.055f + (float)blend.Blue * -0.055f + (float)blend.Black * -0.3f + (float)blend.Brown * -0.2f, WhiteVisualInputPerSecond = (float)blend.White * 2f, GreenVisualInputPerSecond = (float)blend.Green * 2f + (float)blend.Blue * blueGreenVisualInputPerSecond, BlackVisualInputPerSecond = (float)blend.Black * 2f }; } } public enum CigarEmberCoolingPhase { Dark, YellowToOrange, OrangeToRed, RedToDark } public static class CigarEmberMath { private const float BoundaryEpsilon = 0.0001f; public const float YellowToOrangeSeconds = 2f; public const float OrangeToRedSeconds = 12f; public const float RedToDarkSeconds = 36f; public const float FullHeatCoolingSeconds = 50f; public static CigarEmberCoolingPhase GetCoolingPhase(float currentHeat01, float coolingStartHeat01) { if (currentHeat01 <= 0f || coolingStartHeat01 <= 0f) { return CigarEmberCoolingPhase.Dark; } float profileSeconds = GetProfileSeconds(currentHeat01, coolingStartHeat01); if (profileSeconds + 0.0001f < 2f) { return CigarEmberCoolingPhase.YellowToOrange; } if (profileSeconds + 0.0001f < 14f) { return CigarEmberCoolingPhase.OrangeToRed; } return CigarEmberCoolingPhase.RedToDark; } public static float GetPhaseProgress(CigarEmberCoolingPhase phase, float currentHeat01, float coolingStartHeat01) { if (currentHeat01 <= 0f || coolingStartHeat01 <= 0f) { if (phase != CigarEmberCoolingPhase.RedToDark) { return 0f; } return 1f; } float profileSeconds = GetProfileSeconds(currentHeat01, coolingStartHeat01); return phase switch { CigarEmberCoolingPhase.YellowToOrange => Mathf.Clamp01(profileSeconds / 2f), CigarEmberCoolingPhase.OrangeToRed => Mathf.Clamp01((profileSeconds - 2f) / 12f), CigarEmberCoolingPhase.RedToDark => Mathf.Clamp01((profileSeconds - 2f - 12f) / 36f), _ => 0f, }; } public static float GetProfileSeconds(float currentHeat01, float coolingStartHeat01) { if (coolingStartHeat01 <= 0f) { return 50f; } float num = Mathf.Clamp01(currentHeat01 / coolingStartHeat01); return (1f - num) * 50f; } } public static class CigarHintText { public const string GreenHex = "3FAF45"; public const string BrownHex = "8B5A2B"; public const string BlueHex = "3F7FFF"; public const string BlackHex = "202020"; public static string Build(TobaccoRecipe recipe) { if (recipe.Count <= 0) { return "cigar"; } if (recipe.IsFullSingleType) { return "Full " + GetName(recipe.GetAt(0)) + " Cigar"; } string text = ""; for (int i = 0; i < recipe.Count; i++) { text += GetColoredLetter(recipe.GetAt(i)); } return text + " Cigar"; } private static string GetName(CigarTobaccoType tobaccoType) { return tobaccoType switch { CigarTobaccoType.White => "White", CigarTobaccoType.Green => "Green", CigarTobaccoType.Black => "Black", CigarTobaccoType.Brown => "Brown", CigarTobaccoType.Blue => "Blue", _ => "Unknown", }; } private static string GetColoredLetter(CigarTobaccoType tobaccoType) { return tobaccoType switch { CigarTobaccoType.White => "W", CigarTobaccoType.Green => Color("G", "3FAF45"), CigarTobaccoType.Brown => Color("B", "8B5A2B"), CigarTobaccoType.Blue => Color("B", "3F7FFF"), CigarTobaccoType.Black => Color("B", "202020"), _ => "?", }; } private static string Color(string letter, string hex) { return "" + letter + ""; } } public static class CigarValueMath { public const int WrapperValue = 200; public static int Calculate(TobaccoBlend blend, int whiteValue, int greenValue, int blackValue, int brownValue, int blueValue) { return 200 + blend.White * whiteValue + blend.Green * greenValue + blend.Black * blackValue + blend.Brown * brownValue + blend.Blue * blueValue; } public static int ScaleByRemainingHealth(int fullValue, float currentHealth, float initialHealth) { if (fullValue <= 0) { return 0; } if (initialHealth <= 0f || float.IsNaN(initialHealth)) { return fullValue; } if (currentHealth <= 0f || float.IsNaN(currentHealth)) { return 0; } if (currentHealth >= initialHealth) { return fullValue; } double value = (double)fullValue * (double)currentHealth / (double)initialHealth; return Math.Max(0, (int)Math.Round(value, MidpointRounding.AwayFromZero)); } } public enum CigarTobaccoType { White = 1, Green, Black, Brown, Blue } public struct TobaccoBlend { public int White; public int Green; public int Black; public int Brown; public int Blue; public int Count => White + Green + Black + Brown + Blue; public bool TryAdd(ShipItemTobacco tobacco) { if (TobaccoTypeResolver.TryResolve(tobacco, out var tobaccoType)) { return TryAdd(tobaccoType); } return false; } public bool TryAdd(CigarTobaccoType tobaccoType) { if (Count >= 3) { return false; } switch (tobaccoType) { case CigarTobaccoType.White: White++; return true; case CigarTobaccoType.Green: Green++; return true; case CigarTobaccoType.Black: Black++; return true; case CigarTobaccoType.Brown: Brown++; return true; case CigarTobaccoType.Blue: Blue++; return true; default: return false; } } } public static class TobaccoBlendCodec { public static int Encode(TobaccoBlend blend) { if (blend.Count < 1 || blend.Count > 3 || blend.White < 0 || blend.White > 3 || blend.Green < 0 || blend.Green > 3 || blend.Black < 0 || blend.Black > 3 || blend.Brown < 0 || blend.Brown > 3 || blend.Blue < 0 || blend.Blue > 3) { throw new ArgumentOutOfRangeException("blend"); } return 1 + blend.White + (blend.Green << 2) + (blend.Black << 4) + (blend.Brown << 6) + (blend.Blue << 8); } public static bool TryDecode(int code, out TobaccoBlend blend) { if (TobaccoRecipeCodec.TryDecodeOrdered(code, out var recipe)) { blend = recipe.ToBlend(); return true; } return TryDecodeLegacy(code, out blend); } internal static bool TryDecodeLegacy(int code, out TobaccoBlend blend) { blend = default(TobaccoBlend); if (code <= 0 || code >= 4096) { return false; } int num = code - 1; blend.White = num & 3; blend.Green = (num >> 2) & 3; blend.Black = (num >> 4) & 3; blend.Brown = (num >> 6) & 3; blend.Blue = (num >> 8) & 3; int num2 = 1023; if ((num & ~num2) == 0 && blend.Count >= 1) { return blend.Count <= 3; } return false; } public static bool TryDecodeCigar(float itemAmount, out TobaccoBlend blend) { blend = default(TobaccoBlend); int num = Mathf.RoundToInt(itemAmount); if (num < 0) { return TryDecode(-num, out blend); } return false; } } public struct TobaccoRecipe { private CigarTobaccoType first; private CigarTobaccoType second; private CigarTobaccoType third; private int count; public int Count => count; public bool IsFullSingleType { get { if (count == 3 && first == second) { return second == third; } return false; } } public CigarTobaccoType GetAt(int index) { switch (index) { case 0: if (count > 0) { return first; } break; case 1: if (count > 1) { return second; } break; case 2: if (count > 2) { return third; } break; } throw new ArgumentOutOfRangeException("index"); } public bool TryAdd(CigarTobaccoType tobaccoType) { if (count >= 3 || !TobaccoTypeResolver.IsSupported(tobaccoType)) { return false; } if (count == 0) { first = tobaccoType; } else if (count == 1) { second = tobaccoType; } else { third = tobaccoType; } count++; return true; } public bool TryAdd(ShipItemTobacco tobacco) { if (TobaccoTypeResolver.TryResolve(tobacco, out var tobaccoType)) { return TryAdd(tobaccoType); } return false; } public TobaccoBlend ToBlend() { TobaccoBlend result = default(TobaccoBlend); for (int i = 0; i < count; i++) { result.TryAdd(GetAt(i)); } return result; } internal static TobaccoRecipe FromLegacyBlend(TobaccoBlend blend) { TobaccoRecipe recipe = default(TobaccoRecipe); AddCopies(ref recipe, CigarTobaccoType.Green, blend.Green); AddCopies(ref recipe, CigarTobaccoType.White, blend.White); AddCopies(ref recipe, CigarTobaccoType.Brown, blend.Brown); AddCopies(ref recipe, CigarTobaccoType.Blue, blend.Blue); AddCopies(ref recipe, CigarTobaccoType.Black, blend.Black); return recipe; } private static void AddCopies(ref TobaccoRecipe recipe, CigarTobaccoType tobaccoType, int copies) { for (int i = 0; i < copies; i++) { recipe.TryAdd(tobaccoType); } } } public static class TobaccoRecipeCodec { public const int OrderedRecipeMarker = 4096; private const int Radix = 6; private const int MaximumPayload = 216; public static int Encode(TobaccoRecipe recipe) { if (recipe.Count < 1 || recipe.Count > 3) { throw new ArgumentOutOfRangeException("recipe"); } int num = 0; int num2 = 1; for (int i = 0; i < recipe.Count; i++) { num += (int)recipe.GetAt(i) * num2; num2 *= 6; } return 4096 + num; } public static bool TryDecode(int code, out TobaccoRecipe recipe, out bool wasLegacy) { wasLegacy = false; if (TryDecodeOrdered(code, out recipe)) { return true; } if (!TobaccoBlendCodec.TryDecodeLegacy(code, out var blend)) { recipe = default(TobaccoRecipe); return false; } recipe = TobaccoRecipe.FromLegacyBlend(blend); wasLegacy = true; return recipe.Count == blend.Count; } public static bool TryDecodeCigar(float itemAmount, out TobaccoRecipe recipe, out bool wasLegacy) { recipe = default(TobaccoRecipe); wasLegacy = false; int num = Mathf.RoundToInt(itemAmount); if (num < 0) { return TryDecode(-num, out recipe, out wasLegacy); } return false; } internal static bool TryDecodeOrdered(int code, out TobaccoRecipe recipe) { recipe = default(TobaccoRecipe); int num = code - 4096; if (num <= 0 || num >= 216) { return false; } int num2 = num % 6; int num3 = num / 6 % 6; int num4 = num / 36 % 6; if (!IsValidDigit(num2) || (num3 == 0 && num4 != 0) || (num3 != 0 && !IsValidDigit(num3)) || (num4 != 0 && !IsValidDigit(num4))) { return false; } recipe.TryAdd((CigarTobaccoType)num2); if (num3 != 0) { recipe.TryAdd((CigarTobaccoType)num3); } if (num4 != 0) { recipe.TryAdd((CigarTobaccoType)num4); } return true; } private static bool IsValidDigit(int value) { if (value >= 1) { return value <= 5; } return false; } } public static class TobaccoTypeResolver { public static bool TryResolve(ShipItemTobacco tobacco, out CigarTobaccoType tobaccoType) { tobaccoType = (CigarTobaccoType)0; if ((Object)(object)tobacco == (Object)null) { return false; } SaveablePrefab component = ((Component)tobacco).GetComponent(); if (((Object)(object)component != (Object)null && component.prefabIndex == 318) || tobacco.tobaccoType == 5) { tobaccoType = CigarTobaccoType.Blue; return true; } tobaccoType = (CigarTobaccoType)tobacco.tobaccoType; return IsSupported(tobaccoType); } public static bool IsSupported(CigarTobaccoType tobaccoType) { if (tobaccoType >= CigarTobaccoType.White) { return tobaccoType <= CigarTobaccoType.Blue; } return false; } } public sealed class CigarRuntimeState : MonoBehaviour { public const float DrawTilt = 77f; [SerializeField] private CigarVisualController cigarVisual; private ShipItemPipe pipe; private int fullRecipeValue; private bool valueInitialized; private bool destructionQueued; private float ashClearedAt01 = 1f; private AshtrayState restingTray; private int restSlot; private int savedTrayId; private Transform restSocket; private bool started; public bool IsResting => (Object)(object)restingTray != (Object)null; public float AccumulatedAsh01 { get { float initialHealth = GetInitialHealth(); if (!(initialHealth > 0f)) { return 0f; } return Mathf.Max(0f, ashClearedAt01 - Mathf.Clamp01(((ShipItem)pipe).health / initialHealth)); } } public ShipItemPipe Pipe => pipe; private void Awake() { pipe = ((Component)this).GetComponent(); if ((Object)(object)cigarVisual == (Object)null) { cigarVisual = ((Component)this).GetComponentInChildren(true); } if ((Object)(object)cigarVisual != (Object)null) { cigarVisual.BindRoot(pipe); } } private void Start() { started = true; RefreshValue(); SyncVisuals(snap: true, 0f, inhaling: false); if (savedTrayId != 0) { ((MonoBehaviour)this).StartCoroutine(RestoreRest()); } } public bool TryGetRecipe(out TobaccoRecipe recipe) { recipe = default(TobaccoRecipe); bool wasLegacy; if ((Object)(object)pipe != (Object)null) { return TobaccoRecipeCodec.TryDecodeCigar(((ShipItem)pipe).amount, out recipe, out wasLegacy); } return false; } public float GetInitialHealth() { if (!TryGetRecipe(out var recipe)) { return 0f; } return (float)recipe.Count * 100f; } public void SyncVisuals(bool snap, float heat01, bool inhaling) { if ((Object)(object)pipe == (Object)null) { pipe = ((Component)this).GetComponent(); } if (!((Object)(object)pipe == (Object)null)) { float initialHealth = GetInitialHealth(); SyncValueFromHealth(initialHealth); if (!((Object)(object)cigarVisual == (Object)null)) { float remaining = ((initialHealth > 0f) ? Mathf.Clamp01(((ShipItem)pipe).health / initialHealth) : 0f); cigarVisual.SetAshBaseline(ashClearedAt01); cigarVisual.SetRemaining01(remaining, ((ShipItem)pipe).health > 0f && initialHealth > 0f, Mathf.Clamp01(heat01), inhaling, snap); } } } public void RefreshValue() { if ((Object)(object)pipe == (Object)null) { pipe = ((Component)this).GetComponent(); } if (!((Object)(object)pipe == (Object)null)) { if (!TryGetRecipe(out var recipe)) { fullRecipeValue = 200; valueInitialized = true; ((GoPointerButton)pipe).description = string.Empty; SyncValueFromHealth(0f); } else { TobaccoBlend blend = recipe.ToBlend(); fullRecipeValue = CigarValueMath.Calculate(blend, GetPrefabValue(310), GetPrefabValue(312), GetPrefabValue(314), GetPrefabValue(316), GetPrefabValue(318)); valueInitialized = true; ((GoPointerButton)pipe).description = CigarHintText.Build(recipe); SyncValueFromHealth((float)blend.Count * 100f); } } } public bool TryDestroyIfConsumed() { if (destructionQueued) { return true; } if ((Object)(object)pipe == (Object)null) { pipe = ((Component)this).GetComponent(); } if ((Object)(object)pipe == (Object)null || ((ShipItem)pipe).health > 0f) { return false; } destructionQueued = true; ((ShipItem)pipe).DestroyItem(); return true; } private void SyncValueFromHealth(float initialHealth) { if (valueInitialized && !((Object)(object)pipe == (Object)null)) { int num = CigarValueMath.ScaleByRemainingHealth(fullRecipeValue, ((ShipItem)pipe).health, initialHealth); if (((ShipItem)pipe).value != num) { ((ShipItem)pipe).value = num; } } } private static int GetPrefabValue(int prefabIndex) { PrefabsDirectory instance = PrefabsDirectory.instance; if ((Object)(object)instance == (Object)null || instance.directory == null || prefabIndex < 0 || prefabIndex >= instance.directory.Length || (Object)(object)instance.directory[prefabIndex] == (Object)null) { return 0; } ShipItem component = instance.directory[prefabIndex].GetComponent(); if (!((Object)(object)component != (Object)null)) { return 0; } return component.value; } public void ClearAsh() { float initialHealth = GetInitialHealth(); ashClearedAt01 = ((initialHealth > 0f) ? Mathf.Clamp01(((ShipItem)pipe).health / initialHealth) : 0f); if ((Object)(object)cigarVisual != (Object)null) { cigarVisual.SetAshBaseline(ashClearedAt01); } } public void RestOn(AshtrayState tray, Transform socket, int slot) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) LeaveRest(); restingTray = tray; restSocket = socket; restSlot = slot; Vector3 val = RestOffset(); ((Component)this).transform.SetPositionAndRotation(((Component)tray).transform.TransformPoint(val), socket.rotation); ((ShipItem)pipe).ResetRigidbody(); ((ShipItem)pipe).itemRigidbodyC.EnterBox(((Component)tray).transform, val, socket.localRotation); SyncRestParent(); } public void LeaveRest() { savedTrayId = 0; if (!((Object)(object)restingTray == (Object)null)) { if ((Object)(object)pipe != (Object)null && (Object)(object)((ShipItem)pipe).itemRigidbodyC != (Object)null && (Object)(object)((ShipItem)pipe).itemRigidbodyC.GetCurrentBox() == (Object)(object)((Component)restingTray).transform) { ((ShipItem)pipe).itemRigidbodyC.ExitBox(); } restingTray.Release(this); restingTray = null; restSocket = null; } } private void LateUpdate() { if (IsResting) { SyncRestParent(); } } private void OnDestroy() { LeaveRest(); } public void SyncRestParent() { //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) if (!IsResting) { return; } ShipItem item = restingTray.Item; if (((Component)item).GetComponent().currentCrateId != 0 || ((Object)(object)item.itemRigidbodyC != (Object)null && (Object)(object)item.itemRigidbodyC.GetCurrentInventorySlot() != (Object)null)) { LeaveRest(); return; } ((ShipItem)pipe).currentActualBoat = item.currentActualBoat; ((ShipItem)pipe).currentWalkCol = item.currentWalkCol; ((Component)this).GetComponent().SetParentObject(((Component)item).GetComponent().GetParentObject()); if ((Object)(object)restSocket != (Object)null && (Object)(object)((ShipItem)pipe).itemRigidbodyC != (Object)null) { ((ShipItem)pipe).itemRigidbodyC.EnterBox(((Component)item).transform, RestOffset(), restSocket.localRotation); } } private Vector3 RestOffset() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) float initialHealth = GetInitialHealth(); float num = ((initialHealth > 0f) ? Mathf.Clamp01(((ShipItem)pipe).health / initialHealth) : 0f); return restSocket.localPosition + restSocket.localRotation * Vector3.up * (0.116f * (1f - num)); } public void WriteSave(SavePrefabData data) { if (IsResting) { SyncRestParent(); } data.extraValue0 = ashClearedAt01; int num = (IsResting ? ((Component)restingTray).GetComponent().instanceId : savedTrayId); data.extraValue1 = num & 0xFFFF; data.extraValue2 = (num >> 16) & 0x7FFF; data.extraValue3 = restSlot; data.extraValue4 = 110f; } public void ReadSave(SavePrefabData data) { ashClearedAt01 = (((data.extraValue4 == 110f || data.extraValue4 == 130f) && !float.IsNaN(data.extraValue0) && !float.IsInfinity(data.extraValue0)) ? Mathf.Clamp01(data.extraValue0) : 1f); savedTrayId = 0; if (data.extraValue4 == 110f && data.inventorySlot < 0 && data.crateId == 0 && data.extraValue1 >= 0f && data.extraValue1 <= 65535f && data.extraValue1 % 1f == 0f && data.extraValue2 >= 0f && data.extraValue2 <= 32767f && data.extraValue2 % 1f == 0f && (data.extraValue3 == 0f || data.extraValue3 == 1f)) { savedTrayId = (int)data.extraValue1 | ((int)data.extraValue2 << 16); restSlot = (int)data.extraValue3; } SyncVisuals(snap: true, 0f, inhaling: false); if (started && savedTrayId != 0) { ((MonoBehaviour)this).StartCoroutine(RestoreRest()); } } private IEnumerator RestoreRest() { while (GameState.currentlyLoading) { yield return null; } for (int frame = 0; frame < 120; frame++) { if (savedTrayId == 0) { break; } if ((Object)(object)SaveLoadManager.instance != (Object)null) { foreach (SaveablePrefab currentPrefab in SaveLoadManager.instance.GetCurrentPrefabs()) { if ((Object)(object)currentPrefab != (Object)null && currentPrefab.instanceId == savedTrayId) { AshtrayState component = ((Component)currentPrefab).GetComponent(); if ((Object)(object)component != (Object)null && component.TrySeat(this, restSlot)) { savedTrayId = 0; yield break; } } } } yield return null; } savedTrayId = 0; } } public sealed class CigarVisualController : MonoBehaviour { private const float BurnVisualLerpSpeed = 12f; private const float SpentFrontClearance = 0.008f; private const float MinimumPhysicalColliderRatio = 0.05f; private const float MinimumPickupLength = 0.04f; private const float MaximumEmberLightIntensity = 0.15f; private const int IgnoreRaycastLayer = 2; private static readonly int ColorProperty = Shader.PropertyToID("_Color"); private static readonly int EmissionColorProperty = Shader.PropertyToID("_EmissionColor"); private static readonly Color YellowColor = new Color(1f, 0.42f, 0.025f, 1f); private static readonly Color OrangeColor = new Color(0.92f, 0.12f, 0.008f, 1f); private static readonly Color YellowEmission = new Color(3.2f, 0.85f, 0.04f, 1f); private static readonly Color OrangeEmission = new Color(2.6f, 0.22f, 0.012f, 1f); private static readonly Color YellowLightColor = new Color(1f, 0.38f, 0.04f, 1f); private static readonly Color OrangeLightColor = new Color(1f, 0.12f, 0.015f, 1f); private static readonly Color RedLightColor = new Color(1f, 0.025f, 0.008f, 1f); [SerializeField] private Transform mouthAnchor; [SerializeField] private Transform burnableBody; [SerializeField] private Transform burnFront; [SerializeField] private Transform unlitTip; [SerializeField] private Transform ash; [SerializeField] private GameObject band; [SerializeField] private Renderer emberRenderer; [SerializeField] private Light emberLight; [SerializeField] private BoxCollider rootCollider; [SerializeField] private BoxCollider pickupCollider; [SerializeField] private Collider mouthSmokingTrigger; private ShipItemPipe pipe; private BoxCollider physicalCollider; private Vector3 fullBodyScale; private Vector3 fullBurnFrontPosition; private Vector3 spentBurnFrontPosition; private Vector3 fullRootColliderCenter; private Vector3 fullRootColliderSize; private Vector3 fullPickupColliderCenter; private Vector3 fullPickupColliderSize; private float rootColliderMouthEndY; private float pickupColliderMouthEndY; private float burnDirectionSign; private float targetRemaining01; private float visibleRemaining01; private float heat01; private float coolingStartHeat01; private bool inhaling; private bool wasInhaling; private bool hasCoolingStartHeat; private bool available; private bool initialized; private bool visualDirty = true; private MaterialPropertyBlock emberProperties; private Color emberBaseColor = Color.white; private Color emberBaseEmission = Color.black; private float ashBaseline01 = 1f; private Vector3 ashOriginalScale; private Vector3 ashOriginalPosition; private float ashMeshLength; private float ashMeshBase; private void Awake() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_0049: 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_009e: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_013c: 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_0160: 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_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Expected O, but got Unknown //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ash != (Object)null) { ashOriginalScale = ash.localScale; ashOriginalPosition = ash.localPosition; Bounds bounds = ((Component)ash).GetComponent().sharedMesh.bounds; ashMeshLength = ((Bounds)(ref bounds)).size.y * ashOriginalScale.y; ashMeshBase = ((Bounds)(ref bounds)).min.y * ashOriginalScale.y; } fullBodyScale = (((Object)(object)burnableBody != (Object)null) ? burnableBody.localScale : Vector3.one); fullBurnFrontPosition = (((Object)(object)burnFront != (Object)null) ? burnFront.localPosition : Vector3.zero); burnDirectionSign = (((Object)(object)mouthAnchor != (Object)null && (Object)(object)burnFront != (Object)null) ? Mathf.Sign(burnFront.localPosition.y - mouthAnchor.localPosition.y) : 1f); if (Mathf.Approximately(burnDirectionSign, 0f)) { burnDirectionSign = 1f; } spentBurnFrontPosition = fullBurnFrontPosition; if ((Object)(object)mouthAnchor != (Object)null) { spentBurnFrontPosition.y = mouthAnchor.localPosition.y + burnDirectionSign * 0.008f; } CacheRootColliderGeometry(); CachePickupColliderGeometry(); if ((Object)(object)emberRenderer != (Object)null && (Object)(object)emberRenderer.sharedMaterial != (Object)null) { Material sharedMaterial = emberRenderer.sharedMaterial; if (sharedMaterial.HasProperty(ColorProperty)) { emberBaseColor = sharedMaterial.GetColor(ColorProperty); } if (sharedMaterial.HasProperty(EmissionColorProperty)) { emberBaseEmission = sharedMaterial.GetColor(EmissionColorProperty); } emberProperties = new MaterialPropertyBlock(); } } public void BindRoot(ShipItemPipe newPipe) { pipe = newPipe; visualDirty = true; SyncInteractionLayers(); if ((Object)(object)rootCollider == (Object)null && (Object)(object)pipe != (Object)null) { rootCollider = ((Component)pipe).GetComponent(); CacheRootColliderGeometry(); } CachePickupColliderGeometry(); } public void SetAshBaseline(float remainingWhenCleared) { float num = Mathf.Clamp01(remainingWhenCleared); if (num != ashBaseline01) { ashBaseline01 = num; if (initialized) { ApplyAsh(); } } } private void ApplyAsh() { //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)ash == (Object)null) && !(ashMeshLength <= 0f)) { float num = Mathf.Max(0f, ashBaseline01 - visibleRemaining01) * Mathf.Abs(fullBurnFrontPosition.y - spentBurnFrontPosition.y); ((Component)ash).gameObject.SetActive(available && num > 1E-05f); float num2 = num / ashMeshLength; ash.localScale = new Vector3(ashOriginalScale.x, ashOriginalScale.y * num2, ashOriginalScale.z); ash.localPosition = ashOriginalPosition + Vector3.up * ashMeshBase * (1f - num2); } } public void SetRemaining01(float remaining, bool isAvailable, float newHeat01, bool isInhaling, bool snap) { float num = Mathf.Clamp01(remaining); float num2 = Mathf.Clamp01(newHeat01); visualDirty |= targetRemaining01 != num || available != isAvailable || heat01 != num2 || inhaling != isInhaling || snap; targetRemaining01 = num; available = isAvailable; heat01 = num2; UpdateInhaleState(isInhaling, snap); if (!available) { ResetEmberTimeline(); } if (!initialized || snap) { visibleRemaining01 = targetRemaining01; initialized = true; ApplyVisualState(); } } private void LateUpdate() { SyncInteractionLayers(); if (!initialized) { return; } TryBindPhysicalCollider(); if (visibleRemaining01 != targetRemaining01) { float num = 1f - Mathf.Exp(-12f * Time.deltaTime); visibleRemaining01 = Mathf.Lerp(visibleRemaining01, targetRemaining01, num); if (Mathf.Abs(visibleRemaining01 - targetRemaining01) < 0.0001f) { visibleRemaining01 = targetRemaining01; } visualDirty = true; } if (visualDirty) { ApplyVisualState(); } } private void UpdateInhaleState(bool newInhaling, bool snap) { inhaling = newInhaling; if (snap) { wasInhaling = newInhaling; hasCoolingStartHeat = false; coolingStartHeat01 = 0f; } else if (newInhaling) { wasInhaling = true; hasCoolingStartHeat = false; coolingStartHeat01 = 0f; } else if (wasInhaling) { wasInhaling = false; coolingStartHeat01 = heat01; hasCoolingStartHeat = coolingStartHeat01 > 0f; } } private void ResetEmberTimeline() { inhaling = false; wasInhaling = false; coolingStartHeat01 = 0f; hasCoolingStartHeat = false; } private void SyncInteractionLayers() { if ((Object)(object)mouthSmokingTrigger != (Object)null && ((Component)mouthSmokingTrigger).gameObject.layer != 2) { ((Component)mouthSmokingTrigger).gameObject.layer = 2; } } private void TryBindPhysicalCollider() { if (!((Object)(object)physicalCollider != (Object)null) && !((Object)(object)pipe == (Object)null) && !((Object)(object)((ShipItem)pipe).itemRigidbodyC == (Object)null)) { physicalCollider = ((Component)((ShipItem)pipe).itemRigidbodyC).GetComponent(); if ((Object)(object)physicalCollider != (Object)null) { visualDirty = true; } } } private void CacheRootColliderGeometry() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)rootCollider == (Object)null)) { fullRootColliderCenter = rootCollider.center; fullRootColliderSize = rootCollider.size; rootColliderMouthEndY = fullRootColliderCenter.y - burnDirectionSign * fullRootColliderSize.y * 0.5f; } } private void CachePickupColliderGeometry() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)pickupCollider == (Object)null)) { fullPickupColliderCenter = pickupCollider.center; fullPickupColliderSize = pickupCollider.size; pickupColliderMouthEndY = fullPickupColliderCenter.y - burnDirectionSign * fullPickupColliderSize.y * 0.5f; } } private void ApplyVisualState() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) visualDirty = false; if ((Object)(object)burnableBody != (Object)null) { Vector3 localScale = fullBodyScale; localScale.y = fullBodyScale.y * visibleRemaining01; burnableBody.localScale = localScale; } if ((Object)(object)burnFront != (Object)null) { burnFront.localPosition = Vector3.Lerp(spentBurnFrontPosition, fullBurnFrontPosition, visibleRemaining01); bool flag = targetRemaining01 < 0.99999f || heat01 > 0f || inhaling; ((Component)burnFront).gameObject.SetActive(available && ((Object)(object)unlitTip == (Object)null || flag)); if ((Object)(object)unlitTip != (Object)null) { unlitTip.localPosition = burnFront.localPosition; ((Component)unlitTip).gameObject.SetActive(available && !flag); } } ApplyPhysicalCollider(rootCollider); ApplyPhysicalCollider(physicalCollider); ApplyPickupCollider(); ApplyAsh(); ApplyEmber(); } private void ApplyPhysicalCollider(BoxCollider collider) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_0078: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)collider == (Object)null) && !(fullRootColliderSize.y <= 0f)) { float num = Mathf.Max(0.05f, visibleRemaining01); Vector3 val = fullRootColliderSize; val.y = fullRootColliderSize.y * num; Vector3 center = fullRootColliderCenter; center.y = rootColliderMouthEndY + burnDirectionSign * val.y * 0.5f; collider.size = val; collider.center = center; } } private void ApplyPickupCollider() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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_0085: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)pickupCollider == (Object)null) && !(fullPickupColliderSize.y <= 0f)) { Vector3 val = fullPickupColliderSize; val.y = Mathf.Max(0.04f, fullPickupColliderSize.y * visibleRemaining01); Vector3 center = fullPickupColliderCenter; center.y = pickupColliderMouthEndY + burnDirectionSign * val.y * 0.5f; pickupCollider.size = val; pickupCollider.center = center; } } private void ApplyEmber() { //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) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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) //IL_0032: 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_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: 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_00f5: 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_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //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_0115: 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_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //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_0131: 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_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) float num = (available ? heat01 : 0f); Color val; Color val2; Color color; if (num > 0f && inhaling) { val = YellowColor; val2 = YellowEmission; color = YellowLightColor; } else { if (num > 0f && !hasCoolingStartHeat) { coolingStartHeat01 = num; hasCoolingStartHeat = true; } CigarEmberCoolingPhase coolingPhase = CigarEmberMath.GetCoolingPhase(num, coolingStartHeat01); float phaseProgress = CigarEmberMath.GetPhaseProgress(coolingPhase, num, coolingStartHeat01); Color val3 = Color.Lerp(Color.black, emberBaseColor, 0.08f); switch (coolingPhase) { case CigarEmberCoolingPhase.YellowToOrange: val = Color.Lerp(YellowColor, OrangeColor, phaseProgress); val2 = Color.Lerp(YellowEmission, OrangeEmission, phaseProgress); color = Color.Lerp(YellowLightColor, OrangeLightColor, phaseProgress); break; case CigarEmberCoolingPhase.OrangeToRed: val = Color.Lerp(OrangeColor, emberBaseColor, phaseProgress); val2 = Color.Lerp(OrangeEmission, emberBaseEmission, phaseProgress); color = Color.Lerp(OrangeLightColor, RedLightColor, phaseProgress); break; case CigarEmberCoolingPhase.RedToDark: val = Color.Lerp(emberBaseColor, val3, phaseProgress); val2 = Color.Lerp(emberBaseEmission, Color.black, phaseProgress); color = Color.Lerp(RedLightColor, Color.black, phaseProgress); break; default: val = val3; val2 = Color.black; color = RedLightColor; break; } } if ((Object)(object)emberRenderer != (Object)null && emberProperties != null) { emberRenderer.GetPropertyBlock(emberProperties); emberProperties.SetColor(ColorProperty, val); emberProperties.SetColor(EmissionColorProperty, val2); emberRenderer.SetPropertyBlock(emberProperties); } if ((Object)(object)emberLight != (Object)null) { emberLight.color = color; emberLight.intensity = 0.15f * num; ((Behaviour)emberLight).enabled = num > 0.001f; } } } public sealed class CigarWrapperState : MonoBehaviour { [SerializeField] private CigarWrapperVisual wrapperVisual; private ShipItem item; private bool rolling; private bool invalidLogged; public int FillCount { get { if (!TryGetRecipe(out var recipe)) { return -1; } return recipe.Count; } } private void Awake() { item = ((Component)this).GetComponent(); if ((Object)(object)wrapperVisual == (Object)null) { wrapperVisual = ((Component)this).GetComponent(); } } private void Start() { SyncFromSavedState(); } public void BindVisual(CigarWrapperVisual visual) { wrapperVisual = visual; } public bool TryGetRecipe(out TobaccoRecipe recipe) { if ((Object)(object)item == (Object)null) { item = ((Component)this).GetComponent(); } recipe = default(TobaccoRecipe); if ((Object)(object)item != (Object)null) { return LeafStateRules.TryReadWrapper(item.health, item.amount, out recipe); } return false; } public bool CanInsert(ShipItemTobacco tobacco) { if ((Object)(object)item == (Object)null) { item = ((Component)this).GetComponent(); } if (!rolling && ((Component)this).gameObject.activeInHierarchy && (Object)(object)item != (Object)null && item.sold && (Object)(object)tobacco != (Object)null && ((ShipItem)tobacco).sold && ((Component)tobacco).gameObject.activeInHierarchy && PrefabReplacement.CanTransform(item) && PrefabReplacement.CanTransform((ShipItem)(object)tobacco) && TryGetRecipe(out var recipe) && recipe.Count < 3) { return recipe.TryAdd(tobacco); } return false; } public bool TryInsert(ShipItemTobacco tobacco) { if (!CanInsert(tobacco)) { return false; } if (!TryGetRecipe(out var recipe) || !recipe.TryAdd(tobacco)) { return false; } if ((Object)(object)wrapperVisual == (Object)null || (Object)(object)((Component)wrapperVisual).gameObject != (Object)(object)((Component)this).gameObject) { wrapperVisual = ((Component)this).GetComponent(); } if ((Object)(object)wrapperVisual == (Object)null) { if (!invalidLogged) { RuntimeDiagnostics.Error("Cigar Wrapper " + ((Object)this).GetInstanceID() + " has no visual component; tobacco was not consumed."); } invalidLogged = true; return false; } if (!wrapperVisual.TrySetRecipe(recipe)) { return false; } item.health = recipe.Count; item.amount = TobaccoRecipeCodec.Encode(recipe); PrefabReplacement.ConsumeOwned((ShipItem)(object)tobacco); SyncFromSavedState(); if ((Object)(object)UISoundPlayer.instance != (Object)null) { UISoundPlayer.instance.PlayUISound((UISounds)4, 0.5f, 0.5f); } return true; } public bool TryRoll() { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) if (rolling || !((Component)this).gameObject.activeInHierarchy || !TryGetRecipe(out var recipe) || recipe.Count == 0) { return false; } rolling = true; bool num = PrefabReplacement.ReplaceOwnedItem(item, 612, (float)recipe.Count * 100f, -TobaccoRecipeCodec.Encode(recipe), Vector3.up * 0.1f, ((Component)item).transform.rotation * Quaternion.Euler(0f, 0f, -90f)); if (!num) { rolling = false; } return num; } public void SyncFromSavedState() { if ((Object)(object)item == (Object)null) { item = ((Component)this).GetComponent(); } if ((Object)(object)item == (Object)null) { return; } item.name = "Cigar Wrapper"; if (!TryGetRecipe(out var recipe)) { ((GoPointerButton)item).description = string.Empty; if (!invalidLogged) { RuntimeDiagnostics.Error("Cigar Wrapper instance " + ((Object)this).GetInstanceID() + " has invalid count/recipe data; original values preserved and crafting disabled."); } invalidLogged = true; return; } invalidLogged = false; if ((Object)(object)wrapperVisual == (Object)null || (Object)(object)((Component)wrapperVisual).gameObject != (Object)(object)((Component)this).gameObject) { wrapperVisual = ((Component)this).GetComponent(); } if ((Object)(object)wrapperVisual != (Object)null) { wrapperVisual.SetRecipe(recipe); } ((GoPointerButton)item).description = "Tobacco: " + recipe.Count + " / 3"; } } public sealed class CigarWrapperVisual : MonoBehaviour { [Serializable] public sealed class Filling { public Mesh mesh; public Material[] materials; } [SerializeField] private Filling[] fillings; [SerializeField] private Color[] tobaccoColors; private MaterialPropertyBlock properties; private MeshFilter meshFilter; private MeshRenderer meshRenderer; private bool invalidLogged; private static CigarWrapperVisualData bundledData; private static Filling[] bundledFillings; private static readonly int ColorProperty = Shader.PropertyToID("_Color"); public void Configure(Filling[] states, Color[] colors) { fillings = states; tobaccoColors = colors; } public static void BindBundleData(CigarWrapperVisualData data) { string error = null; if ((Object)(object)data == (Object)null || !data.Validate(out error)) { throw new InvalidOperationException("Invalid wrapper visual bundle data: " + (((Object)(object)data == (Object)null) ? "missing asset" : error)); } bundledData = data; bundledFillings = data.GetFillings(); } public static void ClearBundleData() { bundledData = null; bundledFillings = null; } private void Awake() { BindConfiguration(); } private void BindConfiguration() { if ((Object)(object)bundledData != (Object)null) { Configure(bundledFillings, bundledData.tobaccoColors); } meshFilter = ((Component)this).GetComponent(); meshRenderer = ((Component)this).GetComponent(); } public static bool ValidateConfiguration(Filling[] states, Color[] colors, out string error) { if (states == null || states.Length != 4) { error = "expected four filling states"; return false; } if (colors == null || colors.Length != 5) { error = "expected five tobacco colours"; return false; } for (int i = 0; i < 4; i++) { Filling filling = states[i]; if (filling == null || (Object)(object)filling.mesh == (Object)null || filling.mesh.subMeshCount != i + 2 || filling.materials == null || filling.materials.Length != i + 2) { error = "invalid mesh/material slots at filling state " + i; return false; } for (int j = 0; j < filling.materials.Length; j++) { if ((Object)(object)filling.materials[j] == (Object)null || (Object)(object)filling.materials[j].shader == (Object)null || filling.mesh.GetIndexCount(j) == 0) { error = "missing geometry/material at filling state " + i + ", slot " + j; return false; } } } error = null; return true; } public bool IsConfigured(out string error) { BindConfiguration(); if ((Object)(object)meshFilter == (Object)null || (Object)(object)meshRenderer == (Object)null) { error = "missing root mesh filter/renderer"; return false; } return ValidateConfiguration(fillings, tobaccoColors, out error); } public void SetRecipe(TobaccoRecipe recipe) { TrySetRecipe(recipe); } public bool TrySetRecipe(TobaccoRecipe recipe) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) if (!IsConfigured(out var error)) { if (!invalidLogged) { RuntimeDiagnostics.Error("Cigar Wrapper " + ((Object)this).GetInstanceID() + " cannot display tobacco: " + error + ". Insertion is disabled until its visual assets are valid."); } invalidLogged = true; return false; } invalidLogged = false; if (properties == null) { properties = new MaterialPropertyBlock(); } Filling filling = fillings[recipe.Count]; meshFilter.sharedMesh = filling.mesh; ((Renderer)meshRenderer).sharedMaterials = filling.materials; for (int i = 0; i < filling.materials.Length; i++) { properties.Clear(); if (i >= 2) { Color val = tobaccoColors[(int)(recipe.GetAt(i - 2) - 1)]; properties.SetColor(ColorProperty, val); } ((Renderer)meshRenderer).SetPropertyBlock(properties, i); } LODGroup component = ((Component)this).GetComponent(); if ((Object)(object)component != (Object)null) { component.RecalculateBounds(); } return true; } } public sealed class CigarWrapperVisualData : ScriptableObject { public Mesh[] meshes; public Material[] emptyMaterials; public Material fillerMaterial; public Color[] tobaccoColors; public CigarWrapperVisual.Filling[] GetFillings() { if (meshes == null || meshes.Length != 4 || emptyMaterials == null || emptyMaterials.Length != 2 || (Object)(object)fillerMaterial == (Object)null) { return null; } CigarWrapperVisual.Filling[] array = new CigarWrapperVisual.Filling[4]; for (int i = 0; i < array.Length; i++) { Material[] array2 = (Material[])(object)new Material[i + 2]; array2[0] = emptyMaterials[0]; array2[1] = emptyMaterials[1]; for (int j = 2; j < array2.Length; j++) { array2[j] = fillerMaterial; } array[i] = new CigarWrapperVisual.Filling { mesh = meshes[i], materials = array2 }; } return array; } public bool Validate(out string error) { CigarWrapperVisual.Filling[] fillings = GetFillings(); if (fillings == null) { error = "native wrapper references: meshes=" + ((meshes == null) ? (-1) : meshes.Length) + ", base materials=" + ((emptyMaterials == null) ? (-1) : emptyMaterials.Length) + ", filler=" + ((Object)(object)fillerMaterial != (Object)null) + ", colours=" + ((tobaccoColors == null) ? (-1) : tobaccoColors.Length); return false; } return CigarWrapperVisual.ValidateConfiguration(fillings, tobaccoColors, out error); } } public sealed class CigarBoxState : DisplayStorageState { [SerializeField] private Transform lid; [SerializeField] private Bounds lidBounds; [SerializeField] private Bounds bodyBounds; [SerializeField] private int baseSeats; private float angle; private bool wantsOpen; private bool moving; private int previousAim = -1; private readonly Collider[] obstacles = (Collider[])(object)new Collider[128]; public override int Capacity { get { if (seats == null) { return 0; } return seats.Length; } } public float LidAngle => angle; public bool WantsOpen => wantsOpen; public bool IsMoving => moving; public Transform Lid => lid; protected override bool ExtinguishOnSeat => true; public void Configure(Transform hinge, Bounds lidShape, Bounds bodyShape, int bottomCount) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) lid = hinge; lidBounds = lidShape; bodyBounds = bodyShape; baseSeats = bottomCount; } public override bool Accepts(ShipItem held, int slot) { if ((Object)(object)held != (Object)null && (Object)(object)((Component)held).GetComponent() != (Object)null) { return held.health > 0f; } return false; } public override bool CanAccess(int slot) { if (base.CanAccess(slot)) { return angle > 1f; } return false; } public void ToggleLid() { if (base.Item.sold) { wantsOpen = !wantsOpen; } } private void Update() { if (GameState.playing && !GameState.currentlyLoading) { AdvanceLid(Time.deltaTime); } } public void AdvanceLid(float dt) { //IL_00ac: Unknown result type (might be due to invalid IL or missing references) moving = false; if ((Object)(object)lid == (Object)null || dt <= 0f) { return; } float num = (wantsOpen ? 180 : 0); float num2 = Mathf.MoveTowards(angle, num, 225f * Mathf.Min(dt, 0.05f)); while (Mathf.Abs(num2 - angle) > 0.0001f) { float degrees = Mathf.MoveTowards(angle, num2, 0.5f); if (!ClearAt(degrees)) { break; } angle = degrees; moving = true; } if (moving) { lid.localRotation = Quaternion.Euler(0f - angle, 0f, 0f); } } public bool ClearAt(float degrees) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_002d: 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_0039: Unknown result type (might be due to invalid IL or missing references) //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) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: 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_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) Quaternion val = ((Component)this).transform.rotation * Quaternion.Euler(0f - degrees, 0f, 0f); Vector3 lossyScale = ((Component)this).transform.lossyScale; Vector3 val2 = lid.position + val * Vector3.Scale(((Bounds)(ref lidBounds)).center, lossyScale); Vector3 half = Vector3.Scale(((Bounds)(ref lidBounds)).extents, lossyScale) + Vector3.one * 0.0016f; if (!VolumeClear(val2, half, val, boatPhysics: false)) { return false; } Transform currentActualBoat = base.Item.currentActualBoat; Transform currentWalkCol = base.Item.currentWalkCol; if ((Object)(object)currentActualBoat != (Object)null && (Object)(object)currentWalkCol != (Object)null) { val2 = currentWalkCol.TransformPoint(currentActualBoat.InverseTransformPoint(val2)); val = currentWalkCol.rotation * Quaternion.Inverse(currentActualBoat.rotation) * val; if (!VolumeClear(val2, half, val, boatPhysics: true)) { return false; } } return true; } private bool VolumeClear(Vector3 centre, Vector3 half, Quaternion rotation, bool boatPhysics) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) int num = Physics.OverlapBoxNonAlloc(centre, half, obstacles, rotation, -67117057, (QueryTriggerInteraction)2); if (num == obstacles.Length) { return false; } for (int i = 0; i < num; i++) { Collider val = obstacles[i]; if ((Object)(object)val == (Object)null || ((Component)val).transform.IsChildOf(((Component)this).transform) || (val is CapsuleCollider && (Object)(object)((Component)val).GetComponent() != (Object)null)) { continue; } SecuredDisplayItem componentInParent = ((Component)val).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null && (Object)(object)componentInParent.Owner == (Object)(object)this) { continue; } ItemRigidbody componentInParent2 = ((Component)val).GetComponentInParent(); if ((Object)(object)componentInParent2 != (Object)null) { if (!boatPhysics || (Object)(object)componentInParent2 == (Object)(object)base.Item.itemRigidbodyC) { continue; } bool flag = false; for (int j = 0; j < Capacity; j++) { SecuredDisplayItem content = GetContent(j); if ((Object)(object)content != (Object)null && (Object)(object)content.Item.itemRigidbodyC == (Object)(object)componentInParent2) { flag = true; break; } } if (flag) { continue; } } if ((!val.isTrigger || !((Object)(object)((Component)val).GetComponentInParent() == (Object)null)) && ((Component)val).gameObject.layer != 26) { return false; } } return true; } public bool ResolveInterior(Ray ray, out int slot, out Vector3 point) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: 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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //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) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: 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_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0158: 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_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: 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_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: 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_0310: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_0326: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_0347: Unknown result type (might be due to invalid IL or missing references) //IL_034c: Unknown result type (might be due to invalid IL or missing references) slot = -1; point = ((Component)this).transform.position; if (angle <= 1f) { previousAim = -1; return false; } float num = 1.8f; int num2 = -1; if (previousAim >= 0 && previousAim < seats.Length) { Transform val = seats[previousAim]; Ray val2 = default(Ray); ((Ray)(ref val2))..ctor(val.InverseTransformPoint(((Ray)(ref ray)).origin), val.InverseTransformDirection(((Ray)(ref ray)).direction)); Bounds val3 = new Bounds(new Vector3(0f, -0.12025f, 0f), new Vector3(0.03f, 0.258f, 0.03f)); float num3 = default(float); if (((Bounds)(ref val3)).IntersectRay(val2, ref num3) && num3 <= 1.8f && Exposed(ray, num3, previousAim >= baseSeats)) { slot = previousAim; point = ((Ray)(ref ray)).GetPoint(num3); return true; } } Ray val5 = default(Ray); Bounds val6 = default(Bounds); float num4 = default(float); for (int i = 0; i < seats.Length; i++) { Transform val4 = seats[i]; ((Ray)(ref val5))..ctor(val4.InverseTransformPoint(((Ray)(ref ray)).origin), val4.InverseTransformDirection(((Ray)(ref ray)).direction)); ((Bounds)(ref val6))..ctor(new Vector3(0f, -0.12025f, 0f), new Vector3(0.028f, 0.258f, 0.03f)); if (i == previousAim) { ((Bounds)(ref val6)).Expand(new Vector3(0.002f, 0f, 0f)); } if (((Bounds)(ref val6)).IntersectRay(val5, ref num4) && !(num4 > num)) { Vector3 point2 = ((Ray)(ref ray)).GetPoint(num4); if (Exposed(ray, num4, i >= baseSeats)) { num2 = i; num = num4; point = point2; } } } if (num2 >= 0) { slot = (previousAim = num2); return true; } previousAim = -1; Ray val7 = default(Ray); ((Ray)(ref val7))..ctor(((Component)this).transform.InverseTransformPoint(((Ray)(ref ray)).origin), ((Component)this).transform.InverseTransformDirection(((Ray)(ref ray)).direction)); Bounds val8 = default(Bounds); ((Bounds)(ref val8))..ctor(new Vector3(0f, ((Bounds)(ref bodyBounds)).max.y, 0f), new Vector3(((Bounds)(ref bodyBounds)).size.x - 0.014f, 0.014f, ((Bounds)(ref bodyBounds)).size.z - 0.014f)); float num5 = default(float); if (((Bounds)(ref val8)).IntersectRay(val7, ref num5) && num5 <= 1.8f && Vector3.Dot(((Ray)(ref ray)).direction, ((Component)this).transform.up) < 0f && Exposed(ray, num5, onLid: false)) { point = ((Ray)(ref ray)).GetPoint(num5); return true; } Ray val9 = default(Ray); ((Ray)(ref val9))..ctor(lid.InverseTransformPoint(((Ray)(ref ray)).origin), lid.InverseTransformDirection(((Ray)(ref ray)).direction)); if (baseSeats < Capacity && ((Bounds)(ref lidBounds)).IntersectRay(val9, ref num5) && num5 <= 1.8f && Vector3.Dot(((Ray)(ref ray)).direction, lid.up) > 0f) { point = ((Ray)(ref ray)).GetPoint(num5); return true; } return false; } private bool Exposed(Ray ray, float distance, bool onLid) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) if (onLid) { return Vector3.Dot(((Ray)(ref ray)).direction, lid.up) > 0.02f; } if (Vector3.Dot(((Ray)(ref ray)).direction, ((Component)this).transform.up) >= -0.02f) { return false; } Ray val = default(Ray); ((Ray)(ref val))..ctor(lid.InverseTransformPoint(((Ray)(ref ray)).origin), lid.InverseTransformDirection(((Ray)(ref ray)).direction)); float num = default(float); if (((Bounds)(ref lidBounds)).IntersectRay(val, ref num)) { return num > distance - 0.006f; } return true; } public override int NearestEmpty(ShipItem held, Vector3 point) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) EnsureContents(); int result = -1; float num = float.MaxValue; for (int i = 0; i < Capacity; i++) { if (CanAccess(i) && !((Object)(object)contents[i] != (Object)null) && Accepts(held, i)) { Vector3 val = seats[i].InverseTransformPoint(point); val.y -= Mathf.Clamp(val.y, -0.2405f, 0f); float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (sqrMagnitude < num) { result = i; num = sqrMagnitude; } } } return result; } public void WriteSave(SavePrefabData data) { data.extraValue0 = angle; data.extraValue1 = (wantsOpen ? 1 : 0); data.extraValue4 = 131f; } public void ReadSave(SavePrefabData data) { //IL_0089: Unknown result type (might be due to invalid IL or missing references) if (data.extraValue4 == 131f) { angle = ((float.IsNaN(data.extraValue0) || float.IsInfinity(data.extraValue0)) ? 0f : Mathf.Clamp(data.extraValue0, 0f, 180f)); wantsOpen = data.extraValue1 == 1f; moving = false; if ((Object)(object)lid != (Object)null) { lid.localRotation = Quaternion.Euler(0f - angle, 0f, 0f); } } } } public sealed class PipeRackState : DisplayStorageState { [SerializeField] private bool wallRack; [SerializeField] private Transform ashtraySeat; [SerializeField] private Transform jarTarget; [SerializeField] private float[] swingClearance; private Vector3 lastPosition; private Vector3 lastVelocity; private Quaternion lastRotation; private bool motionInitialized; private Coroutine openingJar; private readonly Vector2[] angle = (Vector2[])(object)new Vector2[3]; private readonly Vector2[] velocity = (Vector2[])(object)new Vector2[3]; public bool IsWallRack => wallRack; public bool HasJar => (Object)(object)jarTarget != (Object)null; public override int Capacity { get { if (!((Object)(object)ashtraySeat != (Object)null)) { return 3; } return 4; } } protected override bool ExtinguishOnSeat => wallRack; public void Configure(bool wall, Transform tray, Transform jar, float[] clearance) { wallRack = wall; ashtraySeat = tray; jarTarget = jar; swingClearance = clearance; } public override bool Accepts(ShipItem held, int slot) { if (slot != 3) { return RestingPipeState.NativePipeSlot((ShipItemPipe)(object)((held is ShipItemPipe) ? held : null)) >= 0; } if ((Object)(object)ashtraySeat != (Object)null) { return (Object)(object)((Component)held).GetComponent() != (Object)null; } return false; } public override Transform Seat(int slot, ShipItem held) { if (slot != 3) { return seats[slot * 3 + RestingPipeState.NativePipeSlot((ShipItemPipe)(object)((held is ShipItemPipe) ? held : null))]; } return ashtraySeat; } public bool RayAtJar(Ray ray, out Vector3 point) { //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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) point = Vector3.zero; if (!HasJar) { return false; } Ray val = default(Ray); ((Ray)(ref val))..ctor(jarTarget.InverseTransformPoint(((Ray)(ref ray)).origin), jarTarget.InverseTransformDirection(((Ray)(ref ray)).direction)); Bounds val2 = new Bounds(Vector3.zero, new Vector3(0.27f, 0.34f, 0.27f)); float num = default(float); if (!((Bounds)(ref val2)).IntersectRay(val, ref num) || num > 1.8f) { return false; } point = ((Ray)(ref ray)).GetPoint(num); return true; } public void OpenJar() { if (base.Available && HasJar && (Object)(object)CrateInventoryUI.instance != (Object)null && openingJar == null) { openingJar = ((MonoBehaviour)this).StartCoroutine(OpenJarAfterInput()); } } private IEnumerator OpenJarAfterInput() { yield return null; yield return null; openingJar = null; if (base.Available && (Object)(object)CrateInventoryUI.instance != (Object)null) { ((Component)this).GetComponent().OpenCrate(); } } public void PreparePickup() { if (openingJar != null) { ((MonoBehaviour)this).StopCoroutine(openingJar); openingJar = null; } CrateInventoryUI instance = CrateInventoryUI.instance; if (HasJar && (Object)(object)instance != (Object)null && instance.showingUI && (Object)(object)instance.currentCrate == (Object)(object)((Component)this).GetComponent()) { instance.HideInventory(false); } } protected override void OnDestroy() { PreparePickup(); base.OnDestroy(); } private void FixedUpdate() { if (!wallRack || !GameState.playing || GameState.currentlyLoading) { motionInitialized = false; } else { StepSwing(Time.fixedDeltaTime); } } public void StepSwing(float dt) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0099: 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_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: 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_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: 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_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0188: 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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: 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_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: Unknown result type (might be due to invalid IL or missing references) if (dt <= 0f) { return; } if (!motionInitialized) { lastPosition = ((Component)this).transform.position; lastRotation = ((Component)this).transform.rotation; lastVelocity = Vector3.zero; motionInitialized = true; return; } Vector3 val = ((Component)this).transform.position - lastPosition; if (((Vector3)(ref val)).sqrMagnitude > 4f) { lastPosition = ((Component)this).transform.position; lastVelocity = Vector3.zero; lastRotation = ((Component)this).transform.rotation; return; } Vector3 val2 = val / dt; Vector3 val3 = ((Component)this).transform.InverseTransformDirection((val2 - lastVelocity) / dt); Quaternion val4 = Quaternion.Inverse(lastRotation) * ((Component)this).transform.rotation; Vector3 eulerAngles = ((Quaternion)(ref val4)).eulerAngles; ((Vector3)(ref eulerAngles))..ctor(Mathf.DeltaAngle(0f, eulerAngles.x), 0f, Mathf.DeltaAngle(0f, eulerAngles.z)); Vector3 val5 = ((Component)this).transform.InverseTransformDirection(Vector3.down); Vector2 val6 = default(Vector2); ((Vector2)(ref val6))..ctor(val5.z * 55f - val3.z * 1.2f - eulerAngles.x * 2f, (0f - val5.x) * 55f + val3.x * 1.2f - eulerAngles.z * 2f); val6 = Vector2.ClampMagnitude(val6, 100f); for (int i = 0; i < 3; i++) { float num = 27 + i * 2; ref Vector2 reference = ref velocity[i]; reference += (val6 - angle[i] * num - velocity[i] * 4.5f) * dt; ref Vector2 reference2 = ref angle[i]; reference2 += velocity[i] * dt; for (int j = 0; j < 2; j++) { if (Mathf.Abs(((Vector2)(ref angle[i]))[j]) > 2f) { ((Vector2)(ref angle[i]))[j] = Mathf.Clamp(((Vector2)(ref angle[i]))[j], -2f, 2f); ref Vector2 reference3 = ref velocity[i]; int num2 = j; ((Vector2)(ref reference3))[num2] = ((Vector2)(ref reference3))[num2] * -0.18f; } } } lastPosition = ((Component)this).transform.position; lastVelocity = val2; lastRotation = ((Component)this).transform.rotation; } public Vector2 SwingAngle(int slot) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) return angle[slot]; } public override void Pose(int slot, ShipItem held, out Vector3 position, out Quaternion rotation) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: 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_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) base.Pose(slot, held, out position, out rotation); if (wallRack && slot < 3) { Vector2 val = angle[slot]; Quaternion val2 = Quaternion.Euler(val.x, 0f, val.y); Transform val3 = Seat(slot, held); Vector3 val4 = val3.localPosition + val3.localRotation * new Vector3(0f, 0.02f, 0.015f); Vector3 val5 = val4 + val2 * (val3.localPosition - val4); float num = Clearance(RestingPipeState.NativePipeSlot((ShipItemPipe)(object)((held is ShipItemPipe) ? held : null)), val); position = ((Component)this).transform.TransformPoint(val5 + Vector3.up * num); rotation = ((Component)this).transform.rotation * val2 * val3.localRotation; } } private float Clearance(int type, Vector2 a) { //IL_001d: 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) if (swingClearance == null || swingClearance.Length != 243) { return 0f; } float num = Mathf.Clamp(a.x * 2f + 4f, 0f, 8f); float num2 = Mathf.Clamp(a.y * 2f + 4f, 0f, 8f); int num3 = Mathf.Min((int)num, 7); int num4 = Mathf.Min((int)num2, 7); int num5 = type * 81 + num4 * 9 + num3; return Mathf.Lerp(Mathf.Lerp(swingClearance[num5], swingClearance[num5 + 1], num - (float)num3), Mathf.Lerp(swingClearance[num5 + 9], swingClearance[num5 + 10], num - (float)num3), num2 - (float)num4); } } public static class RackJarDisplay { public const float NativeCrateScale = 0.33f; public const float MaxInventoryScale = 1f; public static float ItemScale(float inventoryScale) { return 0.33f * Mathf.Min(inventoryScale, 1f); } } public abstract class DisplayStorageState : MonoBehaviour { [SerializeField] protected Transform[] seats; protected SecuredDisplayItem[] contents; private ShipItem item; private SaveablePrefab identity; private StoragePointerTarget pointerTarget; private Collider[] interactionColliders; public ShipItem Item { get { if (!((Object)(object)item != (Object)null)) { return item = ((Component)this).GetComponent(); } return item; } } public SaveablePrefab Identity { get { if (!((Object)(object)identity != (Object)null)) { return identity = ((Component)this).GetComponent(); } return identity; } } public abstract int Capacity { get; } protected virtual bool ExtinguishOnSeat => false; public bool Available { get { if (Item.sold && ((Component)this).gameObject.activeInHierarchy && !Object.op_Implicit((Object)(object)((PickupableItem)Item).held) && Identity.currentCrateId == 0 && (Object)(object)Item.itemRigidbodyC != (Object)null) { return (Object)(object)Item.itemRigidbodyC.GetCurrentInventorySlot() == (Object)null; } return false; } } public void ConfigureSeats(Transform[] value) { seats = value; } private void LateUpdate() { if (interactionColliders == null) { interactionColliders = ((Component)this).GetComponentsInChildren(true); } Collider[] array = interactionColliders; foreach (Collider val in array) { if ((Object)(object)val != (Object)null) { ((Component)val).gameObject.layer = ((Component)this).gameObject.layer; } } } public void SyncContents() { EnsureContents(); SecuredDisplayItem[] array = contents; foreach (SecuredDisplayItem securedDisplayItem in array) { if ((Object)(object)securedDisplayItem != (Object)null) { securedDisplayItem.Sync(); } } } public SecuredDisplayItem GetContent(int slot) { EnsureContents(); if (slot < 0 || slot >= contents.Length) { return null; } return contents[slot]; } protected void EnsureContents() { if (contents == null) { contents = new SecuredDisplayItem[Capacity]; } } public virtual bool CanAccess(int slot) { if (slot >= 0) { return slot < Capacity; } return false; } public virtual Transform Seat(int slot, ShipItem held) { return seats[slot]; } public abstract bool Accepts(ShipItem held, int slot); public virtual int NearestEmpty(ShipItem held, Vector3 point) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) EnsureContents(); int result = -1; float num = float.MaxValue; for (int i = 0; i < Capacity; i++) { if (!((Object)(object)contents[i] != (Object)null) && CanAccess(i) && Accepts(held, i)) { Vector3 val = Seat(i, held).position - point; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (sqrMagnitude < num) { result = i; num = sqrMagnitude; } } } return result; } public bool TrySeat(ShipItem held, int slot, bool restoring = false) { EnsureContents(); if ((Object)(object)held == (Object)null || (Object)(object)held == (Object)(object)Item || slot < 0 || slot >= Capacity || (Object)(object)contents[slot] != (Object)null || !Accepts(held, slot) || (Object)(object)held.itemRigidbodyC == (Object)null || !held.sold || held.nailed || (!restoring && (!Available || !CanAccess(slot)))) { return false; } SecuredDisplayItem component = ((Component)held).GetComponent(); if ((Object)(object)component != (Object)null && (Object)(object)component.Owner != (Object)null) { return false; } if ((Object)(object)((PickupableItem)held).held != (Object)null) { ((PickupableItem)held).held.DropItem(); } CigarRuntimeState component2 = ((Component)held).GetComponent(); if ((Object)(object)component2 != (Object)null) { component2.LeaveRest(); } RestingPipeState component3 = ((Component)held).GetComponent(); if ((Object)(object)component3 != (Object)null) { component3.LeaveRest(); } SecuredDisplayItem securedDisplayItem = (((Object)(object)component != (Object)null) ? component : ((Component)held).gameObject.AddComponent()); contents[slot] = securedDisplayItem; securedDisplayItem.Attach(this, slot); if (!restoring && ExtinguishOnSeat) { StoragePipeHeat.Extinguish((ShipItemPipe)(object)((held is ShipItemPipe) ? held : null)); } return true; } public bool TryPlace(ShipItem held, Vector3 point) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) int num = NearestEmpty(held, point); if (num >= 0) { return TrySeat(held, num); } return false; } internal void Release(SecuredDisplayItem state) { EnsureContents(); for (int i = 0; i < contents.Length; i++) { if ((Object)(object)contents[i] == (Object)(object)state) { contents[i] = null; } } } public virtual void Pose(int slot, ShipItem held, out Vector3 position, out Quaternion rotation) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_001d: Unknown result type (might be due to invalid IL or missing references) Transform val = Seat(slot, held); position = val.position; rotation = val.rotation; } public StoragePointerTarget Target(int slot, Vector3 point, GoPointer pointer) { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown if ((Object)(object)pointerTarget == (Object)null) { GameObject val = new GameObject("Storage interaction"); val.transform.SetParent(((Component)this).transform, false); ((Renderer)val.AddComponent()).enabled = false; pointerTarget = val.AddComponent(); pointerTarget.Owner = this; } pointerTarget.Slot = slot; pointerTarget.Point = point; pointerTarget.Refresh(pointer); return pointerTarget; } protected virtual void OnDestroy() { if (contents == null) { return; } for (int i = 0; i < contents.Length; i++) { if ((Object)(object)contents[i] != (Object)null) { contents[i].Detach(drop: true); } } } } [DefaultExecutionOrder(1000)] public sealed class SecuredDisplayItem : MonoBehaviour { private ShipItem item; private SaveablePrefab identity; private Transform[] layers; private int lastLayer = -1; private int savedOwner; private bool started; private bool inventoryHidden; private bool placed; private Vector3 placedPosition; private Vector3 placedScale; private Quaternion placedRotation; public DisplayStorageState Owner { get; private set; } public int Slot { get; private set; } public ShipItem Item { get { if (!((Object)(object)item != (Object)null)) { return item = ((Component)this).GetComponent(); } return item; } } private void Start() { started = true; if (savedOwner != 0) { ((MonoBehaviour)this).StartCoroutine(Restore()); } } public void Attach(DisplayStorageState owner, int slot) { Owner = owner; Slot = slot; savedOwner = 0; placed = false; if (layers == null) { layers = ((Component)this).GetComponentsInChildren(true); } Item.itemRigidbodyC.attached = true; Item.itemRigidbodyC.inStove = true; Item.itemRigidbodyC.disableCol = true; Item.ToggleDisallowDisembarking(true); Sync(); } public void Detach(bool drop = false) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) savedOwner = 0; placed = false; if ((Object)(object)Owner == (Object)null) { return; } DisplayStorageState owner = Owner; Owner = null; owner.Release(this); Item.ToggleDisallowDisembarking(false); SetLayer(((Object)(object)((PickupableItem)Item).held != (Object)null) ? 2 : 0); ((Component)this).transform.localScale = Vector3.one; if (!((Object)(object)Item.itemRigidbodyC == (Object)null)) { Item.itemRigidbodyC.ExitBox(); Item.itemRigidbodyC.attached = false; Item.itemRigidbodyC.inStove = false; Item.itemRigidbodyC.disableCol = false; if (inventoryHidden && (Object)(object)Item.itemRigidbodyC.GetCurrentInventorySlot() == (Object)null) { ((Component)Item).GetComponent().enabled = true; } inventoryHidden = false; Item.ResetRigidbody(); if ((Object)(object)Item.currentActualBoat != (Object)null && (Object)(object)Item.currentWalkCol != (Object)null) { Item.itemRigidbodyC.ForceRigidbodyToWalkCol(); } Rigidbody body = Item.itemRigidbodyC.GetBody(); if ((Object)(object)body != (Object)null && drop) { body.isKinematic = false; body.WakeUp(); } } } private void SetLayer(int layer) { if (lastLayer == layer) { return; } if (layers == null) { layers = ((Component)this).GetComponentsInChildren(true); } Transform[] array = layers; foreach (Transform val in array) { if ((Object)(object)val != (Object)null) { ((Component)val).gameObject.layer = layer; } } lastLayer = layer; } public void Sync() { //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: 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_0153: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: 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_00f7: 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_01da: Unknown result type (might be due to invalid IL or missing references) //IL_0103: 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_021e: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Owner == (Object)null || (Object)(object)Item.itemRigidbodyC == (Object)null) { return; } if ((Object)(object)((PickupableItem)Item).held != (Object)null) { Detach(); return; } ShipItem val = Owner.Item; Item.currentActualBoat = val.currentActualBoat; Item.currentWalkCol = val.currentWalkCol; if ((Object)(object)identity == (Object)null) { identity = ((Component)this).GetComponent(); } identity.SetParentObject(Owner.Identity.GetParentObject()); Owner.Pose(Slot, Item, out var position, out var rotation); Vector3 lossyScale = ((Component)Owner).transform.lossyScale; if (!placed || !((Object)(object)Item.currentActualBoat == (Object)null) || !(position == placedPosition) || !(rotation == placedRotation) || !(lossyScale == placedScale) || !(((Component)this).transform.position == position) || !((Object)(object)Item.itemRigidbodyC.GetCurrentBox() == (Object)(object)((Component)Owner).transform)) { ((Component)this).transform.SetPositionAndRotation(position, rotation); ((Component)this).transform.localScale = lossyScale; Item.itemRigidbodyC.EnterBox(((Component)Owner).transform, ((Component)Owner).transform.InverseTransformPoint(position), Quaternion.Inverse(((Component)Owner).transform.rotation) * rotation); Rigidbody body = Item.itemRigidbodyC.GetBody(); if ((Object)(object)body != (Object)null) { body.isKinematic = true; body.position = position; body.rotation = rotation; } if ((Object)(object)Item.currentActualBoat != (Object)null && (Object)(object)Item.currentWalkCol != (Object)null) { Item.itemRigidbodyC.ForceRigidbodyToWalkCol(); } placed = true; placedPosition = position; placedRotation = rotation; placedScale = lossyScale; } bool flag = (Object)(object)val.itemRigidbodyC.GetCurrentInventorySlot() != (Object)null; if (inventoryHidden != flag) { ((Component)Item).GetComponent().enabled = !flag; inventoryHidden = flag; } SetLayer((((Component)val).gameObject.layer == 26) ? 26 : (flag ? 5 : (((Object)(object)((PickupableItem)val).held != (Object)null) ? 2 : 0))); } private void LateUpdate() { Sync(); } private void OnDestroy() { if ((Object)(object)Owner != (Object)null) { Owner.Release(this); } } public void WriteSave(SavePrefabData data) { int num = (((Object)(object)Owner != (Object)null) ? Owner.Identity.instanceId : savedOwner); if (num != 0) { Sync(); data.extraValue1 = num & 0xFFFF; data.extraValue2 = (num >> 16) & 0x7FFF; data.extraValue3 = Slot; data.extraValue4 = 130f; } } public void ReadSave(SavePrefabData data) { if (data.extraValue4 == 130f && data.inventorySlot < 0 && data.crateId == 0 && !(data.extraValue1 < 0f) && !(data.extraValue1 > 65535f) && data.extraValue1 % 1f == 0f && !(data.extraValue2 < 0f) && !(data.extraValue2 > 32767f) && data.extraValue2 % 1f == 0f && !(data.extraValue3 < 0f) && !(data.extraValue3 >= 10f) && data.extraValue3 % 1f == 0f) { savedOwner = (int)data.extraValue1 | ((int)data.extraValue2 << 16); Slot = (int)data.extraValue3; if (started && savedOwner != 0) { ((MonoBehaviour)this).StartCoroutine(Restore()); } } } private IEnumerator Restore() { while (GameState.currentlyLoading) { yield return null; } for (int frame = 0; frame < 180; frame++) { if (savedOwner == 0) { break; } if ((Object)(object)SaveLoadManager.instance != (Object)null && (Object)(object)Item.itemRigidbodyC != (Object)null) { foreach (SaveablePrefab currentPrefab in SaveLoadManager.instance.GetCurrentPrefabs()) { if ((Object)(object)currentPrefab != (Object)null && currentPrefab.instanceId == savedOwner) { DisplayStorageState component = ((Component)currentPrefab).GetComponent(); if ((Object)(object)component != (Object)null && component.TrySeat(Item, Slot, restoring: true)) { yield break; } } } } yield return null; } savedOwner = 0; } } public sealed class StoragePointerTarget : GoPointerButton { public DisplayStorageState Owner; public int Slot; public Vector3 Point; private int withdrawalFrame = -1; private ShipItem lastHovered; public override void Start() { } private void LateUpdate() { } public void Refresh(GoPointer pointer) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) SecuredDisplayItem content = Owner.GetContent(Slot); ShipItem val = (((Object)(object)content != (Object)null) ? content.Item : null); if ((Object)(object)lastHovered != (Object)null && (Object)(object)lastHovered != (Object)(object)val) { ((GoPointerButton)lastHovered).ForceUnlook(); } lastHovered = val; ((Component)this).transform.position = Point; base.lookText = (((Object)(object)content != (Object)null) ? content.Item.name : string.Empty); base.description = (((Object)(object)content != (Object)null) ? ((GoPointerButton)content.Item).description : string.Empty); if ((Object)(object)content != (Object)null) { ((GoPointerButton)content.Item).Look(pointer); } } public override void OnActivate(GoPointer pointer) { if ((Object)(object)pointer.GetHeldItem() != (Object)null) { return; } if (Slot == -2 && Owner is PipeRackState) { if (!Owner.Item.nailed) { withdrawalFrame = Time.frameCount; pointer.PickUpItem((PickupableItem)(object)Owner.Item); } } else if (Owner.CanAccess(Slot)) { SecuredDisplayItem content = Owner.GetContent(Slot); if ((Object)(object)content != (Object)null && !content.Item.nailed) { withdrawalFrame = Time.frameCount; pointer.PickUpItem((PickupableItem)(object)content.Item); } } } public override bool OnItemClick(PickupableItem held) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) if (withdrawalFrame == Time.frameCount) { return false; } ShipItem val = (((Object)(object)held != (Object)null) ? ((Component)held).GetComponent() : null); if ((Object)(object)val != (Object)null) { Owner.TryPlace(val, Point); } return false; } public override void OnAltActivate() { CigarBoxState cigarBoxState = Owner as CigarBoxState; if ((Object)(object)cigarBoxState != (Object)null) { cigarBoxState.ToggleLid(); } PipeRackState pipeRackState = Owner as PipeRackState; if ((Object)(object)pipeRackState != (Object)null && Slot == -2) { pipeRackState.OpenJar(); } } } internal static class StoragePipeHeat { private static readonly FieldInfo Heat = typeof(ShipItemPipe).GetField("currentHeat", BindingFlags.Instance | BindingFlags.NonPublic); private static readonly FieldInfo Inhaling = typeof(ShipItemPipe).GetField("inhaling", BindingFlags.Instance | BindingFlags.NonPublic); private static readonly FieldInfo Drinking = typeof(ShipItemPipe).GetField("drinking", BindingFlags.Instance | BindingFlags.NonPublic); public static void Extinguish(ShipItemPipe pipe) { if ((Object)(object)pipe == (Object)null) { return; } Heat.SetValue(pipe, 0f); CigarRuntimeState component = ((Component)pipe).GetComponent(); if (!((Object)(object)component == (Object)null)) { Inhaling.SetValue(pipe, false); Drinking.SetValue(pipe, false); ParticleSystem[] componentsInChildren = ((Component)pipe).GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].Stop(true, (ParticleSystemStopBehavior)0); } component.SyncVisuals(snap: true, 0f, inhaling: false); } } } public static class PrefabReplacement { private static readonly GameObject[] CustomPrefabs = (GameObject[])(object)new GameObject[22]; public static void RegisterCustomPrefab(int index, GameObject prefab) { int num = index - 610; if (num < 0 || num >= CustomPrefabs.Length) { throw new ArgumentOutOfRangeException("index"); } CustomPrefabs[num] = prefab; } public static void ClearCustomPrefabs() { for (int i = 0; i < CustomPrefabs.Length; i++) { CustomPrefabs[i] = null; } } public static bool CanSpawn(int prefabIndex) { if ((Object)(object)ResolvePrefab(prefabIndex) != (Object)null) { return (Object)(object)SaveLoadManager.instance != (Object)null; } return false; } public static ShipItem SpawnOwned(int prefabIndex, Vector3 position, Quaternion rotation, ShipItem context, float health, float amount) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) GameObject val = ResolvePrefab(prefabIndex); if ((Object)(object)val == (Object)null) { return null; } if ((Object)(object)SaveLoadManager.instance == (Object)null) { RuntimeDiagnostics.Error("Cannot spawn prefab " + prefabIndex + ": SaveLoadManager is unavailable."); return null; } GameObject val2 = null; try { val2 = Object.Instantiate(val, position, rotation); ShipItem component = val2.GetComponent(); SaveablePrefab component2 = val2.GetComponent(); if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null) { RuntimeDiagnostics.Error("Registered prefab " + prefabIndex + " lost its ShipItem/SaveablePrefab contract."); Object.Destroy((Object)(object)val2); return null; } if ((Object)(object)context != (Object)null) { SaveablePrefab component3 = ((Component)context).GetComponent(); if ((Object)(object)component3 != (Object)null) { component2.SetParentObject(component3.GetParentObject()); component2.currentCrateId = component3.currentCrateId; } if ((Object)(object)((Component)context).transform.parent != (Object)null) { val2.transform.SetParent(((Component)context).transform.parent, true); } } component.sold = true; component.health = health; component.amount = amount; RuntimeStateSynchronizer.Sync(component, snapCigar: true); component2.RegisterToSave(); return component; } catch (Exception ex) { if ((Object)(object)val2 != (Object)null) { SaveablePrefab component4 = val2.GetComponent(); if ((Object)(object)component4 != (Object)null && (Object)(object)SaveLoadManager.instance != (Object)null) { component4.Unregister(); } val2.SetActive(false); Object.Destroy((Object)(object)val2); } RuntimeDiagnostics.Error("Could not create prefab " + prefabIndex + "; partial output removed: " + ex.Message); return null; } } public static bool ReplaceOwnedItem(ShipItem source, int resultPrefabIndex, float replacementHealth, float replacementAmount, Vector3 worldPositionOffset, Quaternion rotation) { //IL_0011: 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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) if (!CanTransform(source)) { return false; } if ((Object)(object)SpawnOwned(resultPrefabIndex, ((Component)source).transform.position + worldPositionOffset, rotation, source, replacementHealth, replacementAmount) == (Object)null) { return false; } ConsumeOwned(source); return true; } public static bool CombineOwnedItems(ShipItem target, ShipItem held, int resultPrefabIndex, Vector3 offset, Quaternion rotation) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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_002d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)target == (Object)(object)held || !CanTransform(target) || !CanTransform(held)) { return false; } if ((Object)(object)SpawnOwned(resultPrefabIndex, ((Component)target).transform.position + offset, rotation, target, 0f, 0f) == (Object)null) { return false; } ConsumeOwned(held); ConsumeOwned(target); return true; } public static void ConsumeOwned(ShipItem source) { if ((Object)(object)source == (Object)null) { return; } if ((Object)(object)((PickupableItem)source).held != (Object)null) { ((PickupableItem)source).held.DropItem(); } source.sold = false; if ((Object)(object)source.itemRigidbodyC != (Object)null) { source.FreezeItem(); } else { Collider[] components = ((Component)source).GetComponents(); for (int i = 0; i < components.Length; i++) { components[i].enabled = false; } } ((Component)source).gameObject.SetActive(false); source.DestroyItem(); } public static bool CanTransform(ShipItem source) { if ((Object)(object)source == (Object)null || !source.sold || !((Component)source).gameObject.activeInHierarchy || source.nailed) { return false; } SaveablePrefab component = ((Component)source).GetComponent(); if ((Object)(object)component == (Object)null) { return false; } if (component.currentCrateId > 0) { return false; } if ((Object)(object)source.itemRigidbodyC != (Object)null && source.GetCurrentInventorySlot() >= 0) { return false; } return true; } public static GameObject ResolvePrefab(int prefabIndex) { PrefabsDirectory instance = PrefabsDirectory.instance; if ((Object)(object)instance == (Object)null || instance.directory == null || prefabIndex < 0 || prefabIndex >= instance.directory.Length) { RuntimeDiagnostics.Error("Prefab directory cannot resolve index " + prefabIndex + "."); return null; } GameObject val = instance.directory[prefabIndex]; int num = prefabIndex - 610; if (num >= 0 && num < CustomPrefabs.Length && (Object)(object)val != (Object)(object)CustomPrefabs[num]) { RuntimeDiagnostics.Error("Custom prefab index " + prefabIndex + " is not the registered bundled asset."); return null; } return val; } } public static class RuntimeConstants { public const int FirstVanillaPipePrefabIndex = 300; public const int LastVanillaPipePrefabIndex = 302; public const int TobaccoPotPrefabIndex = 610; public const int FreshTobaccoLeafPrefabIndex = 611; public const int CigarPrefabIndex = 612; public const int DriedTobaccoLeafPrefabIndex = 613; public const int CigarWrapperPrefabIndex = 614; public const int ClayAshtrayPrefabIndex = 615; public const int MetalAshtrayPrefabIndex = 616; public const int CeramicAshtrayPrefabIndex = 617; public const int AlAnkhWoodAshtrayPrefabIndex = 618; public const int AestrinWoodAshtrayPrefabIndex = 619; public const int EmeraldWoodAshtrayPrefabIndex = 620; public const int MarbleAshtrayPrefabIndex = 621; public const int JadeAshtrayPrefabIndex = 622; public const int IvoryHornAshtrayPrefabIndex = 623; public const int GlassAshtrayPrefabIndex = 624; public const int AestrinDeskPipeRackPrefabIndex = 625; public const int AestrinWallPipeRackPrefabIndex = 626; public const int AlAnkhPipeRackPrefabIndex = 627; public const int DragonCliffsPipeRackPrefabIndex = 628; public const int AestrinCigarBoxPrefabIndex = 629; public const int AlAnkhCigarBoxPrefabIndex = 630; public const int DragonCliffsCigarBoxPrefabIndex = 631; public const int LastCustomPrefabIndex = 631; public const int CustomPrefabCount = 22; public const int WhiteTobaccoPrefabIndex = 310; public const int GreenTobaccoPrefabIndex = 312; public const int BlackTobaccoPrefabIndex = 314; public const int BrownTobaccoPrefabIndex = 316; public const int BlueTobaccoPrefabIndex = 318; } public static class RuntimeDiagnostics { public static Action InfoSink; public static Action ErrorSink; public static void Info(string message) { if (InfoSink != null) { InfoSink(message); } else { Debug.Log((object)("Tobacco pot and cigar: " + message)); } } public static void Error(string message) { if (ErrorSink != null) { ErrorSink(message); } else { Debug.LogError((object)("Tobacco pot and cigar: " + message)); } } public static void Reset() { InfoSink = null; ErrorSink = null; } } public static class RuntimeStateSynchronizer { public static void Sync(ShipItem item, bool snapCigar) { if (!((Object)(object)item == (Object)null)) { TobaccoPlantPotState component = ((Component)item).GetComponent(); if ((Object)(object)component != (Object)null) { component.SyncFromSavedState(); } RackOnlyDrying component2 = ((Component)item).GetComponent(); if ((Object)(object)component2 != (Object)null) { component2.SyncFromSavedState(); } DriedTobaccoLeafState component3 = ((Component)item).GetComponent(); if ((Object)(object)component3 != (Object)null) { component3.SyncFromSavedState(); } CigarWrapperState component4 = ((Component)item).GetComponent(); if ((Object)(object)component4 != (Object)null) { component4.SyncFromSavedState(); } AshtrayState component5 = ((Component)item).GetComponent(); if ((Object)(object)component5 != (Object)null) { component5.SyncFromSavedState(); } CigarRuntimeState component6 = ((Component)item).GetComponent(); if ((Object)(object)component6 != (Object)null && !component6.TryDestroyIfConsumed()) { component6.RefreshValue(); component6.SyncVisuals(snapCigar, 0f, inhaling: false); } } } } [Serializable] public sealed class LeafCurlMesh { [SerializeField] private MeshFilter filter; [SerializeField] private Vector3[] driedVertices; [NonSerialized] private Mesh source; [NonSerialized] private Mesh instance; [NonSerialized] private Vector3[] freshVertices; [NonSerialized] private Vector3[] workingVertices; public LeafCurlMesh(MeshFilter newFilter, Vector3[] target) { filter = newFilter; driedVertices = target; } public void Apply(float progress) { //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)filter == (Object)null || (Object)(object)filter.sharedMesh == (Object)null || !((Component)filter).gameObject.activeSelf) { return; } if ((Object)(object)instance == (Object)null) { source = filter.sharedMesh; if (driedVertices == null || driedVertices.Length != source.vertexCount) { throw new InvalidOperationException("Leaf curl target does not match its source mesh."); } freshVertices = source.vertices; workingVertices = (Vector3[])(object)new Vector3[freshVertices.Length]; instance = Object.Instantiate(source); ((Object)instance).name = ((Object)source).name + " (leaf instance)"; instance.MarkDynamic(); filter.sharedMesh = instance; } if (!((Object)(object)filter.sharedMesh != (Object)(object)instance)) { for (int i = 0; i < workingVertices.Length; i++) { workingVertices[i] = Vector3.LerpUnclamped(freshVertices[i], driedVertices[i], progress); } instance.vertices = workingVertices; instance.RecalculateNormals(); instance.RecalculateTangents(); instance.RecalculateBounds(); } } public void Release() { if (!((Object)(object)instance == (Object)null)) { if ((Object)(object)filter != (Object)null && (Object)(object)filter.sharedMesh == (Object)(object)instance) { filter.sharedMesh = source; } if (Application.isPlaying) { Object.Destroy((Object)(object)instance); } else { Object.DestroyImmediate((Object)(object)instance); } instance = null; freshVertices = null; workingVertices = null; } } } public static class LeafStateRules { public const float DryingHours = 144f; public const int HarvestCount = 3; public static bool IsDry(float hours) { if (!float.IsNaN(hours) && !float.IsInfinity(hours)) { return hours >= 144f; } return false; } public static bool TryReadWrapper(float count, float code, out TobaccoRecipe recipe) { recipe = default(TobaccoRecipe); if (float.IsNaN(count) || float.IsInfinity(count) || count < 0f || count > 3f || (double)count != Math.Floor(count) || float.IsNaN(code) || float.IsInfinity(code) || code < 0f || code > 2.1474836E+09f || (double)code != Math.Floor(code)) { return false; } if (count == 0f) { return code == 0f; } if (TobaccoRecipeCodec.TryDecode((int)code, out recipe, out var _)) { return recipe.Count == (int)count; } return false; } public static bool CanCombine(float targetHours, float heldHours, bool distinct, bool targetOwned, bool heldOwned) { if (distinct && targetOwned && heldOwned && IsDry(targetHours)) { return IsDry(heldHours); } return false; } } public static class LegacyLeafMigration { public static bool TryMigrate(SavePrefabData data) { //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: 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) if (data == null || data.prefabIndex != 613 || !data.isSold) { return false; } if (!LeafStateRules.TryReadWrapper(data.itemHealth, data.itemAmount, out var recipe)) { RuntimeDiagnostics.Error("Legacy leaf instance " + data.instanceId + " has conflicting count/recipe data (health=" + data.itemHealth + ", amount=" + data.itemAmount + "). Original ID 613 and values preserved; repair the save record before crafting."); return false; } if (recipe.Count == 0) { data.prefabIndex = 611; data.itemHealth = 144f; } else { data.prefabIndex = 614; data.rotation = SerializableQuaternion.op_Implicit(SerializableQuaternion.op_Implicit(data.rotation) * new Quaternion(0.70710677f, 0f, 0f, 0.70710677f)); } return true; } public static SaveContainer MigrateLoadedContainer(SaveContainer save) { if (save == null || save.savedPrefabs == null) { return save; } int num = 0; foreach (SavePrefabData savedPrefab in save.savedPrefabs) { if (TryMigrate(savedPrefab)) { num++; } } if (num > 0) { RuntimeDiagnostics.Info("Migrated " + num + " legacy leaf records for 1.0.2 before native object loading."); } return save; } } public static class TobaccoDryingChain { public static bool TryGetNextStage(int sourcePrefabIndex, out int resultPrefabIndex) { switch (sourcePrefabIndex) { case 312: resultPrefabIndex = 310; return true; case 310: resultPrefabIndex = 316; return true; case 316: resultPrefabIndex = 314; return true; default: resultPrefabIndex = 0; return false; } } public static bool IsStageTransition(int sourcePrefabIndex, int resultPrefabIndex) { if (TryGetNextStage(sourcePrefabIndex, out var resultPrefabIndex2)) { return resultPrefabIndex2 == resultPrefabIndex; } return false; } } public sealed class DriedTobaccoLeafState : MonoBehaviour { [SerializeField] private DriedTobaccoLeafVisual leafVisual; private ShipItem item; private bool logged; public int FillCount { get { if (!((Object)(object)item != (Object)null) || !LeafStateRules.TryReadWrapper(item.health, item.amount, out var recipe)) { return -1; } return recipe.Count; } } public void BindVisual(DriedTobaccoLeafVisual visual) { leafVisual = visual; } private void Awake() { item = ((Component)this).GetComponent(); } private void Start() { SyncFromSavedState(); } public void SyncFromSavedState() { if ((Object)(object)item == (Object)null) { item = ((Component)this).GetComponent(); } if (!((Object)(object)item == (Object)null)) { TobaccoRecipe recipe; bool flag = LeafStateRules.TryReadWrapper(item.health, item.amount, out recipe); if ((Object)(object)leafVisual != (Object)null) { leafVisual.SetFillCount(flag ? recipe.Count : 0); } ((GoPointerButton)item).description = string.Empty; if (!flag && !logged) { RuntimeDiagnostics.Error("Legacy leaf instance " + ((Object)this).GetInstanceID() + " has invalid count/recipe data; preserved without normalization."); logged = true; } } } } public sealed class DriedTobaccoLeafVisual : MonoBehaviour { [SerializeField] private GameObject fill0Empty; [SerializeField] private GameObject fill1OneThird; [SerializeField] private GameObject fill2TwoThirds; [SerializeField] private GameObject fill3Full; public void Configure(GameObject newFill0Empty, GameObject newFill1OneThird, GameObject newFill2TwoThirds, GameObject newFill3Full) { fill0Empty = newFill0Empty; fill1OneThird = newFill1OneThird; fill2TwoThirds = newFill2TwoThirds; fill3Full = newFill3Full; } public void SetFillCount(int fillCount) { fillCount = Mathf.Clamp(fillCount, 0, 3); if ((Object)(object)fill0Empty != (Object)null) { fill0Empty.SetActive(fillCount == 0); } if ((Object)(object)fill1OneThird != (Object)null) { fill1OneThird.SetActive(fillCount == 1); } if ((Object)(object)fill2TwoThirds != (Object)null) { fill2TwoThirds.SetActive(fillCount == 2); } if ((Object)(object)fill3Full != (Object)null) { fill3Full.SetActive(fillCount == 3); } } } public sealed class FreshTobaccoLeafState : MonoBehaviour { [SerializeField] private FreshTobaccoLeafVisual leafVisual; private ShipItem item; private bool crafting; public bool IsFullyDry { get { if ((Object)(object)item != (Object)null) { return LeafStateRules.IsDry(item.health); } return false; } } public bool CanCombineWith(FreshTobaccoLeafState heldLeaf) { if (!crafting && (Object)(object)heldLeaf != (Object)null && !heldLeaf.crafting && (Object)(object)item != (Object)null && (Object)(object)heldLeaf.item != (Object)null && LeafStateRules.CanCombine(item.health, heldLeaf.item.health, (Object)(object)heldLeaf != (Object)(object)this, item.sold, heldLeaf.item.sold) && PrefabReplacement.CanTransform(item)) { return PrefabReplacement.CanTransform(heldLeaf.item); } return false; } public bool TryCombineWith(FreshTobaccoLeafState heldLeaf) { //IL_002c: 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_0046: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) if (!CanCombineWith(heldLeaf)) { return false; } crafting = (heldLeaf.crafting = true); try { return PrefabReplacement.CombineOwnedItems(item, heldLeaf.item, 614, Vector3.up * 0.035f, Quaternion.FromToRotation(((Component)item).transform.rotation * Quaternion.Euler(90f, 0f, 0f) * Vector3.up, Vector3.up) * ((Component)item).transform.rotation * Quaternion.Euler(90f, 0f, 0f)); } finally { if ((Object)(object)this != (Object)null && ((Component)this).gameObject.activeSelf) { crafting = false; } if ((Object)(object)heldLeaf != (Object)null && ((Component)heldLeaf).gameObject.activeSelf) { heldLeaf.crafting = false; } } } private void Awake() { item = ((Component)this).GetComponent(); if ((Object)(object)leafVisual == (Object)null) { leafVisual = ((Component)this).GetComponentInChildren(true); } } private void Start() { SyncDryingVisual(); } public void BindVisual(FreshTobaccoLeafVisual newLeafVisual) { leafVisual = newLeafVisual; } public void SyncDryingVisual() { if ((Object)(object)item == (Object)null) { item = ((Component)this).GetComponent(); } if (!((Object)(object)item == (Object)null)) { if (float.IsNaN(item.health) || float.IsInfinity(item.health)) { item.health = 0f; } item.health = Mathf.Clamp(item.health, 0f, 144f); bool isFullyDry = IsFullyDry; item.name = (isFullyDry ? "dried tobacco leaf" : "tobacco leaf"); item.value = (isFullyDry ? 200 : 500); float num = (isFullyDry ? 0.1f : 0.15f); bool num2 = !Mathf.Approximately(item.mass, num); item.mass = num; ((GoPointerButton)item).description = string.Empty; if ((Object)(object)leafVisual != (Object)null) { leafVisual.SetDryingHours(item.health); } if (num2 && (Object)(object)item.itemRigidbodyC != (Object)null && (Object)(object)item.itemRigidbodyC.GetBody() != (Object)null) { item.itemRigidbodyC.UpdateMass(); } } } } public sealed class FreshTobaccoLeafVisual : MonoBehaviour { public const float GameHoursPerDay = 24f; public const float WhiteColorGameHours = 72f; public const float FullyDriedGameHours = 144f; public const int VeinsHiddenPerDay = 2; private static readonly int ColorProperty = Shader.PropertyToID("_LeafTint"); [SerializeField] private Renderer bladeRenderer; [SerializeField] private GameObject[] lateralVeins; [SerializeField] private GameObject centralMidrib; [SerializeField] private Renderer[] lateralVeinRenderers; [SerializeField] private Renderer centralMidribRenderer; [SerializeField] private Color freshColor = Color.white; [SerializeField] private Color whiteTobaccoColor = Color.white; [SerializeField] private Color driedLeafColor = Color.white; [SerializeField] private LeafCurlMesh[] curlMeshes; private MaterialPropertyBlock colorProperties; [SerializeField] private float[] lateralVeinBrightness; [SerializeField] private float centralMidribBrightness = 1f; private float displayedHours = float.NaN; public int CurlMeshCount { get { if (curlMeshes == null) { return 0; } return curlMeshes.Length; } } public int LateralVeinCount { get { if (lateralVeins == null) { return 0; } return lateralVeins.Length; } } public void ConfigureCurl(LeafCurlMesh[] meshes) { ReleaseCurlMeshes(); curlMeshes = meshes; displayedHours = float.NaN; } public static float EvaluateCurlProgress(float hours) { if (float.IsNaN(hours)) { return 0f; } float num = Mathf.Clamp01(hours / 144f); return num * num * (3f - 2f * num); } private void OnDestroy() { ReleaseCurlMeshes(); } public void ReleaseCurlMeshes() { displayedHours = float.NaN; if (curlMeshes != null) { LeafCurlMesh[] array = curlMeshes; for (int i = 0; i < array.Length; i++) { array[i]?.Release(); } } } private void Awake() { CacheDetailRenderersAndBrightness(refreshBrightness: false); } public void Configure(Renderer newBladeRenderer, GameObject[] newLateralVeins, GameObject newCentralMidrib, Color newFreshColor, Color newWhiteTobaccoColor, Color newDriedLeafColor) { //IL_0016: 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_001e: 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_0026: 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) bladeRenderer = newBladeRenderer; lateralVeins = newLateralVeins; centralMidrib = newCentralMidrib; freshColor = newFreshColor; whiteTobaccoColor = newWhiteTobaccoColor; driedLeafColor = newDriedLeafColor; CacheDetailRenderersAndBrightness(refreshBrightness: true); displayedHours = float.NaN; } public void SetDryingHours(float gameHours) { //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) if (float.IsNaN(gameHours)) { gameHours = 0f; } float num = Mathf.Clamp(gameHours, 0f, 144f); if (!float.IsNaN(displayedHours) && Mathf.Abs(displayedHours - num) < 0.0001f) { return; } displayedHours = num; int hiddenVeinCount = GetHiddenVeinCount(num, LateralVeinCount); for (int i = 0; i < LateralVeinCount; i++) { if ((Object)(object)lateralVeins[i] != (Object)null) { lateralVeins[i].SetActive(i >= hiddenVeinCount); } } if ((Object)(object)centralMidrib != (Object)null) { centralMidrib.SetActive(true); } float progress = EvaluateCurlProgress(num); if (curlMeshes != null) { LeafCurlMesh[] array = curlMeshes; for (int j = 0; j < array.Length; j++) { array[j]?.Apply(progress); } } ApplyColor(EvaluateDryingColor(num, freshColor, whiteTobaccoColor, driedLeafColor)); } public static Color EvaluateDryingColor(float gameHours, Color fresh, Color white, Color dried) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_0019: 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_0022: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Clamp(gameHours, 0f, 144f); if (num <= 72f) { return Color.Lerp(fresh, white, num / 72f); } return Color.Lerp(white, dried, (num - 72f) / 72f); } public static int GetHiddenVeinCount(float gameHours, int veinCount) { return Mathf.Clamp(Mathf.FloorToInt(Mathf.Max(0f, gameHours) / 24f) * 2, 0, Mathf.Max(0, veinCount)); } private void ApplyColor(Color color) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown //IL_007a: 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_0058: 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) if (colorProperties == null) { colorProperties = new MaterialPropertyBlock(); } ApplyRendererColor(bladeRenderer, color); if (lateralVeinRenderers != null) { for (int i = 0; i < lateralVeinRenderers.Length; i++) { float brightness = ((lateralVeinBrightness != null && i < lateralVeinBrightness.Length) ? lateralVeinBrightness[i] : 1f); ApplyRendererColor(lateralVeinRenderers[i], ApplyBrightness(color, brightness)); } } ApplyRendererColor(centralMidribRenderer, ApplyBrightness(color, centralMidribBrightness)); } public static Color ApplyBrightness(Color color, float brightness) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) return new Color(Mathf.Clamp01(color.r * brightness), Mathf.Clamp01(color.g * brightness), Mathf.Clamp01(color.b * brightness), color.a); } private void ApplyRendererColor(Renderer target, Color color) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)target == (Object)null)) { colorProperties.Clear(); target.GetPropertyBlock(colorProperties); colorProperties.SetColor(ColorProperty, color); colorProperties.SetFloat("_Drying", Mathf.Clamp01(displayedHours / 144f)); target.SetPropertyBlock(colorProperties); } } private void CacheDetailRenderersAndBrightness(bool refreshBrightness) { int lateralVeinCount = LateralVeinCount; if (lateralVeinRenderers == null || lateralVeinRenderers.Length != lateralVeinCount) { lateralVeinRenderers = (Renderer[])(object)new Renderer[lateralVeinCount]; } bool flag = lateralVeinBrightness == null || lateralVeinBrightness.Length != lateralVeinCount; if (flag) { lateralVeinBrightness = new float[lateralVeinCount]; } for (int i = 0; i < lateralVeinCount; i++) { if ((Object)(object)lateralVeinRenderers[i] == (Object)null && (Object)(object)lateralVeins[i] != (Object)null) { lateralVeinRenderers[i] = lateralVeins[i].GetComponentInChildren(true); } if (refreshBrightness || flag) { lateralVeinBrightness[i] = GetBrightnessRatio(lateralVeinRenderers[i]); } } if ((Object)(object)centralMidribRenderer == (Object)null && (Object)(object)centralMidrib != (Object)null) { centralMidribRenderer = centralMidrib.GetComponentInChildren(true); } if (refreshBrightness || flag) { centralMidribBrightness = GetBrightnessRatio(centralMidribRenderer); } } private float GetBrightnessRatio(Renderer target) { //IL_003a: 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_0041: 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) if ((Object)(object)target == (Object)null || (Object)(object)target.sharedMaterial == (Object)null || !target.sharedMaterial.HasProperty(ColorProperty)) { return 1f; } Color color = target.sharedMaterial.GetColor(ColorProperty); float luminance = GetLuminance(freshColor); if (!(luminance > 0.001f)) { return 1f; } return Mathf.Clamp(GetLuminance(color) / luminance, 0f, 4f); } private static float GetLuminance(Color color) { //IL_0000: 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_0019: Unknown result type (might be due to invalid IL or missing references) return color.r * 0.2126f + color.g * 0.7152f + color.b * 0.0722f; } } public sealed class RackOnlyDrying : MonoBehaviour { public const float LooseTobaccoRequiredGameHours = 72f; public const float FreshLeafRequiredGameHours = 144f; [SerializeField] private int resultPrefabIndex; private readonly HashSet racks = new HashSet(); private ShipItem item; private Coroutine dryingRoutine; private FreshTobaccoLeafState freshState; private bool leafKindKnown; private float nextVisualTime; private int visualDay = -1; public int ResultPrefabIndex => resultPrefabIndex; public float CurrentRequiredGameHours => GetRequiredGameHours(); private void Awake() { item = ((Component)this).GetComponent(); freshState = ((Component)this).GetComponent(); leafKindKnown = true; } private void Start() { SyncFromSavedState(); } private void OnDisable() { StopDrying(); racks.Clear(); } private void OnTriggerEnter(Collider other) { RegisterRack(other); } private void OnTriggerStay(Collider other) { RegisterRack(other); } private void OnTriggerExit(Collider other) { DryingRackCol val = FindRack(other); if (!((Object)(object)val == (Object)null) && racks.Remove(val) && racks.Count == 0) { StopDrying(); } } public void ConfigureResultPrefab(int newResultPrefabIndex) { resultPrefabIndex = newResultPrefabIndex; } public void SyncFromSavedState() { if ((Object)(object)item == (Object)null) { item = ((Component)this).GetComponent(); } if ((Object)(object)item == (Object)null) { return; } freshState = ((Component)item).GetComponent(); leafKindKnown = true; item.health = Mathf.Clamp(item.health, 0f, GetRequiredGameHours()); if ((Object)(object)freshState != (Object)null) { freshState.SyncDryingVisual(); resultPrefabIndex = 0; if (freshState.IsFullyDry) { ((Behaviour)this).enabled = false; } } } private void RegisterRack(Collider other) { if (((Behaviour)this).enabled) { DryingRackCol val = FindRack(other); if ((Object)(object)val != (Object)null && racks.Add(val) && dryingRoutine == null) { dryingRoutine = ((MonoBehaviour)this).StartCoroutine(DryWhileRacked()); } } } private static DryingRackCol FindRack(Collider other) { if ((Object)(object)other == (Object)null) { return null; } DryingRackCol component = ((Component)other).GetComponent(); if (!((Object)(object)component != (Object)null)) { return ((Component)other).GetComponentInParent(); } return component; } private IEnumerator DryWhileRacked() { while (racks.Count > 0) { Sun sun = Sun.sun; if ((Object)(object)item != (Object)null && item.sold && (Object)(object)sun != (Object)null && !Sun.SunPaused() && (resultPrefabIndex > 0 || (Object)(object)freshState != (Object)null)) { float requiredGameHours = GetRequiredGameHours(); item.health = Mathf.Min(requiredGameHours, item.health + Time.deltaTime * sun.timescale); if ((Object)(object)freshState != (Object)null) { int num = Mathf.FloorToInt(item.health / 24f); if (Time.unscaledTime >= nextVisualTime || num != visualDay || item.health >= requiredGameHours) { freshState.SyncDryingVisual(); nextVisualTime = Time.unscaledTime + 0.1f; visualDay = num; } } if (item.health >= requiredGameHours) { if ((Object)(object)freshState != (Object)null) { resultPrefabIndex = 0; dryingRoutine = null; ((Behaviour)this).enabled = false; yield break; } if (TryAdvanceLooseTobaccoInPlace()) { if (resultPrefabIndex <= 0) { dryingRoutine = null; ((Behaviour)this).enabled = false; yield break; } yield return null; continue; } RuntimeDiagnostics.Error("Could not advance rack drying from prefab " + GetCurrentPrefabIndex() + " to " + resultPrefabIndex + " in place. The physical item was preserved; replacement spawning was not attempted."); dryingRoutine = null; ((Behaviour)this).enabled = false; yield break; } } yield return null; } dryingRoutine = null; } private bool TryAdvanceLooseTobaccoInPlace() { ShipItem obj = item; ShipItemTobacco val = (ShipItemTobacco)(object)((obj is ShipItemTobacco) ? obj : null); SaveablePrefab val2 = (((Object)(object)item != (Object)null) ? ((Component)item).GetComponent() : null); if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null || !TobaccoDryingChain.IsStageTransition(val2.prefabIndex, resultPrefabIndex)) { return false; } if (!TryResolveTarget(resultPrefabIndex, out var targetPrefab, out var targetItem, out var targetRenderer)) { return false; } ShipItemTobacco val3 = (((Object)(object)targetPrefab != (Object)null) ? targetPrefab.GetComponent() : null); Renderer component = ((Component)item).GetComponent(); if ((Object)(object)val3 == (Object)null || (Object)(object)component == (Object)null || (Object)(object)targetRenderer == (Object)null) { return false; } int num = resultPrefabIndex; CopyRenderer(component, targetRenderer); MeshFilter component2 = ((Component)item).GetComponent(); MeshFilter component3 = targetPrefab.GetComponent(); if ((Object)(object)component2 != (Object)null && (Object)(object)component3 != (Object)null) { component2.sharedMesh = component3.sharedMesh; } ((Object)((Component)item).gameObject).name = ((Object)targetPrefab).name + "(Clone)"; CopyItemPresentation(item, targetItem); item.amount = ((ShipItem)val3).amount; item.health = 0f; val.tobaccoType = val3.tobaccoType; val2.prefabIndex = num; if ((Object)(object)item.itemRigidbodyC != (Object)null) { item.itemRigidbodyC.UpdateMass(); } resultPrefabIndex = (TobaccoDryingChain.TryGetNextStage(num, out var num2) ? num2 : 0); RuntimeDiagnostics.Info("Advanced loose tobacco to prefab " + num + " in place while preserving its rack contact and save identity."); return true; } private static bool TryResolveTarget(int prefabIndex, out GameObject targetPrefab, out ShipItem targetItem, out Renderer targetRenderer) { targetPrefab = null; targetItem = null; targetRenderer = null; PrefabsDirectory instance = PrefabsDirectory.instance; if ((Object)(object)instance == (Object)null || instance.directory == null || prefabIndex < 0 || prefabIndex >= instance.directory.Length) { return false; } targetPrefab = instance.directory[prefabIndex]; if ((Object)(object)targetPrefab == (Object)null) { return false; } targetItem = targetPrefab.GetComponent(); targetRenderer = targetPrefab.GetComponent(); if ((Object)(object)targetItem != (Object)null) { return (Object)(object)targetRenderer != (Object)null; } return false; } private int GetCurrentPrefabIndex() { SaveablePrefab val = (((Object)(object)item != (Object)null) ? ((Component)item).GetComponent() : null); if (!((Object)(object)val != (Object)null)) { return -1; } return val.prefabIndex; } private float GetRequiredGameHours() { if (!leafKindKnown && (Object)(object)item != (Object)null) { freshState = ((Component)item).GetComponent(); leafKindKnown = true; } if (!((Object)(object)freshState != (Object)null)) { return 72f; } return 144f; } private static void CopyRenderer(Renderer target, Renderer source) { //IL_001a: 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_003e: Unknown result type (might be due to invalid IL or missing references) target.sharedMaterials = source.sharedMaterials; target.enabled = source.enabled; target.shadowCastingMode = source.shadowCastingMode; target.receiveShadows = source.receiveShadows; target.lightProbeUsage = source.lightProbeUsage; target.reflectionProbeUsage = source.reflectionProbeUsage; } private static void CopyItemPresentation(ShipItem target, ShipItem source) { //IL_0032: 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) target.name = source.name; ((GoPointerButton)target).description = ((GoPointerButton)source).description; target.mass = source.mass; target.value = source.value; target.category = source.category; target.inventoryScale = source.inventoryScale; target.inventoryRotation = source.inventoryRotation; target.inventoryRotationX = source.inventoryRotationX; target.wallAttachment = source.wallAttachment; target.delayLook = source.delayLook; ((PickupableItem)target).big = ((PickupableItem)source).big; ((PickupableItem)target).holdDistance = ((PickupableItem)source).holdDistance; ((PickupableItem)target).furniturePlaceHeight = ((PickupableItem)source).furniturePlaceHeight; ((PickupableItem)target).holdHeight = ((PickupableItem)source).holdHeight; ((PickupableItem)target).itemClickDistance = ((PickupableItem)source).itemClickDistance; } private void StopDrying() { if (dryingRoutine != null) { ((MonoBehaviour)this).StopCoroutine(dryingRoutine); dryingRoutine = null; if ((Object)(object)freshState != (Object)null) { freshState.SyncDryingVisual(); } nextVisualTime = 0f; } } } public static class GrowthMath { public const float Capacity = 15f; public const float GameHoursPerDay = 24f; public const int RequiredDays = 15; public const float RequiredGameHours = 360f; public static int Advance(ref float storedWater, ref float growthGameHours, float availableGameHours) { storedWater = Mathf.Clamp(storedWater, 0f, 15f); growthGameHours = Mathf.Clamp(growthGameHours, 0f, 360f); availableGameHours = Mathf.Max(0f, availableGameHours); int num = 0; while (availableGameHours > 1E-05f && storedWater >= 1f && growthGameHours < 360f) { float num2 = Mathf.Min((float)(Mathf.FloorToInt(growthGameHours / 24f) + 1) * 24f, 360f); float num3 = Mathf.Min(availableGameHours, num2 - growthGameHours); if (num3 <= 0f) { break; } growthGameHours += num3; availableGameHours -= num3; if (growthGameHours >= num2 - 0.0001f) { growthGameHours = num2; storedWater = Mathf.Max(0f, storedWater - 1f); num++; } } return num; } } public static class RainWaterMath { public const float UnitsPerIntensityGameHour = 0.3f; public static float Collect(float water, float intensity, float gameHours) { if (float.IsNaN(intensity) || float.IsInfinity(intensity) || float.IsNaN(gameHours) || float.IsInfinity(gameHours)) { return water; } return Mathf.Clamp(water + Mathf.Max(0f, intensity) * Mathf.Max(0f, gameHours) * 0.3f, 0f, 15f); } } public sealed class TobaccoPlantPotState : MonoBehaviour { [SerializeField] private TobaccoPlantVisual plantVisual; private ShipItem item; private Coroutine growthRoutine; private bool harvesting; private SaveablePrefab saveable; private int rainExposure; private int displayedWater = -1; public bool IsRainExposed => rainExposure == 2; public float StoredWater { get { if (!((Object)(object)item == (Object)null)) { return Mathf.Clamp(item.health, 0f, 15f); } return 0f; } } public float GrowthGameHours { get { if (!((Object)(object)item == (Object)null)) { return Mathf.Clamp(item.amount, 0f, 360f); } return 0f; } } public bool FullyGrown => GrowthGameHours >= 360f; public void ClearRainExposure() { rainExposure = 0; } public void ReadRainSave(SavePrefabData data) { rainExposure = ((data.extraValue0 == 1f) ? 1 : ((data.extraValue0 == 2f) ? 2 : 0)); } public void WriteRainSave(SavePrefabData data) { data.extraValue0 = rainExposure; } private bool IsPlacedInWorld() { if ((Object)(object)item != (Object)null && item.sold && (Object)(object)((PickupableItem)item).held == (Object)null && ((Component)this).gameObject.activeInHierarchy && (Object)(object)saveable != (Object)null && saveable.currentCrateId == 0 && (Object)(object)item.itemRigidbodyC != (Object)null) { return item.GetCurrentInventorySlot() < 0; } return false; } public void CheckRainExposureOnPlacement() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: 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_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //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_00f6: 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_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) rainExposure = 0; if (!IsPlacedInWorld()) { return; } MeshFilter component = ((Component)this).GetComponent(); if ((Object)(object)component == (Object)null || (Object)(object)component.sharedMesh == (Object)null) { return; } Bounds bounds = component.sharedMesh.bounds; Vector3 val = ((Component)this).transform.TransformPoint(new Vector3(((Bounds)(ref bounds)).center.x, ((Bounds)(ref bounds)).max.y + 0.01f, ((Bounds)(ref bounds)).center.z)); Physics.SyncTransforms(); rainExposure = (HasRainCover(val, Vector3.up, -232876341, null) ? 1 : 2); if (rainExposure == 1) { return; } Transform currentActualBoat = item.currentActualBoat; Transform currentWalkCol = item.currentWalkCol; if (!((Object)(object)currentActualBoat == (Object)null) && !((Object)(object)currentWalkCol == (Object)null)) { Vector3 opening = currentWalkCol.TransformPoint(currentActualBoat.InverseTransformPoint(val)); Vector3 val2 = currentWalkCol.TransformDirection(currentActualBoat.InverseTransformDirection(Vector3.up)); Vector3 normalized = ((Vector3)(ref val2)).normalized; if (HasRainCover(opening, normalized, -1, currentWalkCol)) { rainExposure = 1; } } } private bool HasRainCover(Vector3 opening, Vector3 up, int mask, Transform requiredParent) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //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_0011: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) RaycastHit[] array = Physics.RaycastAll(opening + up * 1000f, -up, 1000f, mask, (QueryTriggerInteraction)1); for (int i = 0; i < array.Length; i++) { RaycastHit val = array[i]; if ((!((Object)(object)requiredParent != (Object)null) || ((Component)((RaycastHit)(ref val)).collider).transform.IsChildOf(requiredParent)) && !((Component)((RaycastHit)(ref val)).collider).transform.IsChildOf(((Component)this).transform) && !((Object)(object)((Component)((RaycastHit)(ref val)).collider).GetComponentInParent() == (Object)(object)item.itemRigidbodyC)) { return true; } } return false; } private void Awake() { item = ((Component)this).GetComponent(); saveable = ((Component)this).GetComponent(); if ((Object)(object)plantVisual == (Object)null) { plantVisual = ((Component)this).GetComponentInChildren(true); } } private void Start() { SyncFromSavedState(); } private void OnEnable() { if (growthRoutine == null) { growthRoutine = ((MonoBehaviour)this).StartCoroutine(GrowUsingGameTime()); } } private void OnDisable() { if (growthRoutine != null) { ((MonoBehaviour)this).StopCoroutine(growthRoutine); growthRoutine = null; } } public void SyncFromSavedState() { if ((Object)(object)item == (Object)null) { item = ((Component)this).GetComponent(); } if (!((Object)(object)item == (Object)null)) { item.health = Mathf.Clamp(item.health, 0f, 15f); item.amount = Mathf.Clamp(item.amount, 0f, 360f); if ((Object)(object)plantVisual != (Object)null) { plantVisual.SetHarvestReady(FullyGrown); } RefreshDescription(); } } public bool TryAcceptWater(ShipItemBottle source) { if ((Object)(object)source == (Object)null || !((ShipItem)source).sold || !Mathf.Approximately(((ShipItem)source).amount, 1f) || ((ShipItem)source).health <= 0f || StoredWater >= 15f) { return false; } Good component = ((Component)source).GetComponent(); if ((Object)(object)component != (Object)null && component.GetMissionIndex() > -1) { return false; } float num = Mathf.Min(((ShipItem)source).health, 15f - item.health); ((ShipItem)source).health = ((ShipItem)source).health - num; ShipItem obj = item; obj.health += num; if (((ShipItem)source).health <= 0f) { source.EmptyBottle(); } else { ((ShipItem)source).UpdateLookText(); } if ((Object)(object)((ShipItem)source).itemRigidbodyC != (Object)null) { ((ShipItem)source).itemRigidbodyC.UpdateMass(); } if ((Object)(object)UISoundPlayer.instance != (Object)null) { UISoundPlayer.instance.PlayLiquidPourSound(); } RefreshDescription(); return true; } public bool TryHarvest() { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: 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_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: 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_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_010d: 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) if (harvesting || (Object)(object)item == (Object)null || !item.sold || !FullyGrown || !PrefabReplacement.CanSpawn(611)) { return false; } harvesting = true; List list = new List(3); BoxCollider component = PrefabReplacement.ResolvePrefab(611).GetComponent(); float num = (((Object)(object)component != (Object)null) ? (Mathf.Max(component.size.x, component.size.z) + 0.04f) : 0.45f); for (int i = 0; i < 3; i++) { Vector3 val = ((Component)this).transform.right * ((float)(i - 1) * num) + ((Component)this).transform.forward * 0.5f; ShipItem val2 = PrefabReplacement.SpawnOwned(611, ((Component)this).transform.position + ((Component)this).transform.up * 0.5f + val, ((Component)this).transform.rotation * Quaternion.Euler(-90f, 0f, 0f), item, 0f, 0f); if ((Object)(object)val2 != (Object)null) { list.Add(val2); } } if (list.Count != 3) { for (int j = 0; j < list.Count; j++) { PrefabReplacement.ConsumeOwned(list[j]); } harvesting = false; RuntimeDiagnostics.Error("Tobacco harvest could not create all three leaves; partial output was rolled back and growth was not reset."); return false; } item.amount = 0f; SyncFromSavedState(); harvesting = false; return true; } private IEnumerator GrowUsingGameTime() { while (true) { Sun sun = Sun.sun; if ((Object)(object)item != (Object)null && item.sold && (Object)(object)sun != (Object)null && !Sun.SunPaused()) { AdvanceWaterAndGrowth(Time.deltaTime * sun.timescale); } yield return null; } } private void AdvanceWaterAndGrowth(float gameHours) { if ((Object)(object)item == (Object)null || !item.sold || Sun.SunPaused()) { return; } if (IsPlacedInWorld() && !GameState.currentlyLoading && !GameState.justStarted && !GameState.loadingBoatLocalItems && GameState.loadingScenes == 0) { if (rainExposure == 0) { CheckRainExposureOnPlacement(); } if (IsRainExposed) { item.health = RainWaterMath.Collect(item.health, GameState.rainIntensity, gameHours); } } float storedWater = item.health; float growthGameHours = item.amount; bool fullyGrown = FullyGrown; int num = GrowthMath.Advance(ref storedWater, ref growthGameHours, gameHours); item.health = storedWater; item.amount = growthGameHours; if (num > 0 || (!fullyGrown && FullyGrown)) { SyncFromSavedState(); } else if (displayedWater != Mathf.RoundToInt(item.health)) { RefreshDescription(); } } private void RefreshDescription() { if (!((Object)(object)item == (Object)null)) { displayedWater = Mathf.RoundToInt(item.health); ((GoPointerButton)item).description = "Water: " + item.health.ToString("0") + " / 15"; } } } public sealed class TobaccoPlantVisual : MonoBehaviour { [SerializeField] private GameObject plantBase; [SerializeField] private GameObject harvestLeaves; public void SetHarvestReady(bool ready) { if ((Object)(object)plantBase != (Object)null && !plantBase.activeSelf) { plantBase.SetActive(true); } if ((Object)(object)harvestLeaves != (Object)null) { harvestLeaves.SetActive(ready); } } } }