using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using AzuCraftyBoxes; using AzuCraftyBoxes.IContainers; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using ComfyGizmo; using CraftFromContainers; using HarmonyLib; using Jotunn; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.GUI; using Jotunn.Managers; using Jotunn.Utils; using On; using PlanBuild.Blueprints; using PlanBuild.Blueprints.Components; using PlanBuild.ModCompat; using PlanBuild.Plans; using PlanBuild.Utils; using SimpleJson; using Splatform; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.Rendering; using UnityEngine.SceneManagement; using UnityEngine.UI; using ValheimRAFT; using ValheimRAFT.Patches; using Valheim_Build_Camera; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("PlanBuild")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("PlanBuild")] [assembly: AssemblyCopyright("WTFPL")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")] [assembly: AssemblyFileVersion("0.18.8")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.18.8.0")] [module: UnverifiableCode] namespace PlanBuild { internal static class Config { public enum DefaultBuildMode { Planned, Direct } private const string ServerSection = "Server Settings"; public static ConfigEntry AllowDirectBuildConfig; public static ConfigEntry AllowTerrainmodConfig; public static ConfigEntry AllowServerBlueprints; public static ConfigEntry AllowBlueprintRune; public static ConfigEntry AllowMarketHotkey; public static ConfigEntry PlanBlacklistConfig; private const string RuneSection = "Blueprints"; public static ConfigEntry DefaultBuildModeConfig; public static ConfigEntry UnlimitedHealthConfig; public static ConfigEntry RayDistanceConfig; public static ConfigEntry TerrainSmoothConfig; public static ConfigEntry CameraOffsetIncrementConfig; public static ConfigEntry InvertCameraOffsetScrollConfig; public static ConfigEntry PlacementOffsetIncrementConfig; public static ConfigEntry InvertPlacementOffsetScrollConfig; public static ConfigEntry SelectionIncrementConfig; public static ConfigEntry InvertSelectionScrollConfig; public static ConfigEntry RotationIncrementConfig; public static ConfigEntry InvertRotationScrollConfig; public static ConfigEntry SelectionConnectedMarginConfig; public static ConfigEntry ShowGridConfig; public static ConfigEntry TooltipEnabledConfig; public static ConfigEntry TooltipBackgroundConfig; public static ConfigEntry BlueprintUndoQueueNameConfig; public static ConfigEntry AddPlayerNameConfig; private const string DirectorySection = "Directories"; public static ConfigEntry BlueprintSearchDirectoryConfig; public static ConfigEntry BlueprintSaveDirectoryConfig; private const string KeybindSection = "Keybindings"; public static ConfigEntry MarketHotkeyConfig; public static ButtonConfig MarketHotkeyButton; public static ConfigEntry ShiftModifierConfig; public static ButtonConfig ShiftModifierButton; public static ConfigEntry CtrlModifierConfig; public static ButtonConfig CtrlModifierButton; public static ConfigEntry ToggleConfig; public static ButtonConfig ToggleButton; public static ConfigEntry AltModifierConfig; public static ButtonConfig AltModifierButton; private const string PlansSection = "Plans"; public static ConfigEntry ShowAllPieces; public static ConfigEntry RadiusConfig; public static ConfigEntry ShowParticleEffects; private const string VisualSection = "Visual"; public static ConfigEntry ConfigTransparentGhostPlacement; public static ConfigEntry UnsupportedColorConfig; public static ConfigEntry SupportedPlanColorConfig; public static ConfigEntry TransparencyConfig; public static ConfigEntry GlowColorConfig; public static bool DirectBuildDefault => DefaultBuildModeConfig.Value == DefaultBuildMode.Direct; internal static void Init() { //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_0051: Expected O, but got Unknown //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Expected O, but got Unknown //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Expected O, but got Unknown //IL_00f0: 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_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Expected O, but got Unknown //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Expected O, but got Unknown //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_014b: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Expected O, but got Unknown //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Expected O, but got Unknown //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_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Expected O, but got Unknown //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Expected O, but got Unknown //IL_01ff: 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_020b: 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_0228: Expected O, but got Unknown //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Expected O, but got Unknown //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Expected O, but got Unknown //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Expected O, but got Unknown //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Expected O, but got Unknown //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Expected O, but got Unknown //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_033b: Expected O, but got Unknown //IL_033b: Unknown result type (might be due to invalid IL or missing references) //IL_0345: Expected O, but got Unknown //IL_037f: Unknown result type (might be due to invalid IL or missing references) //IL_0384: Unknown result type (might be due to invalid IL or missing references) //IL_0395: Expected O, but got Unknown //IL_0395: Unknown result type (might be due to invalid IL or missing references) //IL_039f: Expected O, but got Unknown //IL_03cb: Unknown result type (might be due to invalid IL or missing references) //IL_03d0: Unknown result type (might be due to invalid IL or missing references) //IL_03e1: Expected O, but got Unknown //IL_03e1: Unknown result type (might be due to invalid IL or missing references) //IL_03eb: Expected O, but got Unknown //IL_0413: Unknown result type (might be due to invalid IL or missing references) //IL_0418: Unknown result type (might be due to invalid IL or missing references) //IL_0429: Expected O, but got Unknown //IL_0429: Unknown result type (might be due to invalid IL or missing references) //IL_0433: Expected O, but got Unknown //IL_045f: Unknown result type (might be due to invalid IL or missing references) //IL_0464: Unknown result type (might be due to invalid IL or missing references) //IL_0475: Expected O, but got Unknown //IL_0475: Unknown result type (might be due to invalid IL or missing references) //IL_047f: Expected O, but got Unknown //IL_04a7: Unknown result type (might be due to invalid IL or missing references) //IL_04ac: Unknown result type (might be due to invalid IL or missing references) //IL_04bd: Expected O, but got Unknown //IL_04bd: Unknown result type (might be due to invalid IL or missing references) //IL_04c7: Expected O, but got Unknown //IL_04f3: Unknown result type (might be due to invalid IL or missing references) //IL_04f8: Unknown result type (might be due to invalid IL or missing references) //IL_0509: Expected O, but got Unknown //IL_0509: Unknown result type (might be due to invalid IL or missing references) //IL_0513: Expected O, but got Unknown //IL_053b: Unknown result type (might be due to invalid IL or missing references) //IL_0540: Unknown result type (might be due to invalid IL or missing references) //IL_0551: Expected O, but got Unknown //IL_0551: Unknown result type (might be due to invalid IL or missing references) //IL_055b: Expected O, but got Unknown //IL_0583: Unknown result type (might be due to invalid IL or missing references) //IL_0588: Unknown result type (might be due to invalid IL or missing references) //IL_0599: Expected O, but got Unknown //IL_0599: Unknown result type (might be due to invalid IL or missing references) //IL_05a3: Expected O, but got Unknown //IL_05cb: Unknown result type (might be due to invalid IL or missing references) //IL_05d0: Unknown result type (might be due to invalid IL or missing references) //IL_05e1: Expected O, but got Unknown //IL_05e1: Unknown result type (might be due to invalid IL or missing references) //IL_05eb: Expected O, but got Unknown //IL_0617: Unknown result type (might be due to invalid IL or missing references) //IL_061c: Unknown result type (might be due to invalid IL or missing references) //IL_062d: Expected O, but got Unknown //IL_062d: Unknown result type (might be due to invalid IL or missing references) //IL_0637: Expected O, but got Unknown //IL_065f: Unknown result type (might be due to invalid IL or missing references) //IL_0664: Unknown result type (might be due to invalid IL or missing references) //IL_0675: Expected O, but got Unknown //IL_0675: Unknown result type (might be due to invalid IL or missing references) //IL_067f: Expected O, but got Unknown //IL_06a7: Unknown result type (might be due to invalid IL or missing references) //IL_06ac: Unknown result type (might be due to invalid IL or missing references) //IL_06bd: Expected O, but got Unknown //IL_06bd: Unknown result type (might be due to invalid IL or missing references) //IL_06c7: Expected O, but got Unknown //IL_06f4: Unknown result type (might be due to invalid IL or missing references) //IL_0707: Unknown result type (might be due to invalid IL or missing references) //IL_070c: Unknown result type (might be due to invalid IL or missing references) //IL_071d: Expected O, but got Unknown //IL_071d: Unknown result type (might be due to invalid IL or missing references) //IL_0727: Expected O, but got Unknown //IL_0753: Unknown result type (might be due to invalid IL or missing references) //IL_0758: Unknown result type (might be due to invalid IL or missing references) //IL_0769: Expected O, but got Unknown //IL_0769: Unknown result type (might be due to invalid IL or missing references) //IL_0773: Expected O, but got Unknown //IL_079b: Unknown result type (might be due to invalid IL or missing references) //IL_07a0: Unknown result type (might be due to invalid IL or missing references) //IL_07b1: Expected O, but got Unknown //IL_07b1: Unknown result type (might be due to invalid IL or missing references) //IL_07bb: Expected O, but got Unknown //IL_07e7: Unknown result type (might be due to invalid IL or missing references) //IL_07ec: Unknown result type (might be due to invalid IL or missing references) //IL_07fd: Expected O, but got Unknown //IL_07fd: Unknown result type (might be due to invalid IL or missing references) //IL_0807: Expected O, but got Unknown //IL_0833: Unknown result type (might be due to invalid IL or missing references) //IL_0838: Unknown result type (might be due to invalid IL or missing references) //IL_0849: Expected O, but got Unknown //IL_0849: Unknown result type (might be due to invalid IL or missing references) //IL_0853: Expected O, but got Unknown //IL_087f: Unknown result type (might be due to invalid IL or missing references) //IL_0884: Unknown result type (might be due to invalid IL or missing references) //IL_0895: Expected O, but got Unknown //IL_0895: Unknown result type (might be due to invalid IL or missing references) //IL_089f: Expected O, but got Unknown //IL_08cb: Unknown result type (might be due to invalid IL or missing references) //IL_08d0: Unknown result type (might be due to invalid IL or missing references) //IL_08e1: Expected O, but got Unknown //IL_08e1: Unknown result type (might be due to invalid IL or missing references) //IL_08eb: Expected O, but got Unknown //IL_0917: Unknown result type (might be due to invalid IL or missing references) //IL_091c: Unknown result type (might be due to invalid IL or missing references) //IL_092d: Expected O, but got Unknown //IL_092d: Unknown result type (might be due to invalid IL or missing references) //IL_0937: Expected O, but got Unknown //IL_0963: Unknown result type (might be due to invalid IL or missing references) //IL_0968: Unknown result type (might be due to invalid IL or missing references) //IL_0979: Expected O, but got Unknown //IL_0979: Unknown result type (might be due to invalid IL or missing references) //IL_0983: Expected O, but got Unknown //IL_09ac: Unknown result type (might be due to invalid IL or missing references) //IL_09b1: Unknown result type (might be due to invalid IL or missing references) //IL_09c2: Expected O, but got Unknown //IL_09c2: Unknown result type (might be due to invalid IL or missing references) //IL_09cc: Expected O, but got Unknown //IL_0a46: Unknown result type (might be due to invalid IL or missing references) //IL_0a4b: Unknown result type (might be due to invalid IL or missing references) //IL_0a52: Unknown result type (might be due to invalid IL or missing references) //IL_0a63: Expected O, but got Unknown //IL_0a63: Unknown result type (might be due to invalid IL or missing references) //IL_0a6d: Expected O, but got Unknown //IL_0a99: Unknown result type (might be due to invalid IL or missing references) //IL_0a9e: Unknown result type (might be due to invalid IL or missing references) //IL_0aa5: Unknown result type (might be due to invalid IL or missing references) //IL_0ab6: Expected O, but got Unknown //IL_0ab6: Unknown result type (might be due to invalid IL or missing references) //IL_0ac0: Expected O, but got Unknown //IL_0ae8: Unknown result type (might be due to invalid IL or missing references) //IL_0aed: Unknown result type (might be due to invalid IL or missing references) //IL_0af4: Unknown result type (might be due to invalid IL or missing references) //IL_0b05: Expected O, but got Unknown //IL_0b05: Unknown result type (might be due to invalid IL or missing references) //IL_0b0f: Expected O, but got Unknown //IL_0b60: Unknown result type (might be due to invalid IL or missing references) //IL_0b65: Unknown result type (might be due to invalid IL or missing references) //IL_0b76: Expected O, but got Unknown //IL_0b76: Unknown result type (might be due to invalid IL or missing references) //IL_0b80: Expected O, but got Unknown //IL_0bad: Unknown result type (might be due to invalid IL or missing references) //IL_0bc0: Unknown result type (might be due to invalid IL or missing references) //IL_0bc5: Unknown result type (might be due to invalid IL or missing references) //IL_0bd6: Expected O, but got Unknown //IL_0bd6: Unknown result type (might be due to invalid IL or missing references) //IL_0be0: Expected O, but got Unknown //IL_0c0d: Unknown result type (might be due to invalid IL or missing references) //IL_0c20: Unknown result type (might be due to invalid IL or missing references) //IL_0c25: Unknown result type (might be due to invalid IL or missing references) //IL_0c36: Expected O, but got Unknown //IL_0c36: Unknown result type (might be due to invalid IL or missing references) //IL_0c40: Expected O, but got Unknown //IL_0c7a: Unknown result type (might be due to invalid IL or missing references) //IL_0c7f: Unknown result type (might be due to invalid IL or missing references) //IL_0c90: Expected O, but got Unknown //IL_0c90: Unknown result type (might be due to invalid IL or missing references) //IL_0c9a: Expected O, but got Unknown //IL_0cb3: Unknown result type (might be due to invalid IL or missing references) //IL_0cc6: Unknown result type (might be due to invalid IL or missing references) //IL_0ccb: Unknown result type (might be due to invalid IL or missing references) //IL_0cdc: Expected O, but got Unknown //IL_0cdc: Unknown result type (might be due to invalid IL or missing references) //IL_0ce6: Expected O, but got Unknown int num = 0; AllowBlueprintRune = ((BaseUnityPlugin)PlanBuildPlugin.Instance).Config.Bind("Server Settings", "Allow blueprint rune", true, new ConfigDescription("Allow usage of blueprint rune for clients connecting to the server." + Environment.NewLine + "Admins are always allowed to use it.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true, Order = (num -= 1) } })); AllowDirectBuildConfig = ((BaseUnityPlugin)PlanBuildPlugin.Instance).Config.Bind("Server Settings", "Allow direct build", false, new ConfigDescription("Allow placement of blueprints without materials on this server." + Environment.NewLine + "Admins are always allowed to use it.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true, Order = (num -= 1) } })); AllowTerrainmodConfig = ((BaseUnityPlugin)PlanBuildPlugin.Instance).Config.Bind("Server Settings", "Allow terrain tools", false, new ConfigDescription("Allow usage of the terrain modification tools on this server." + Environment.NewLine + "Admins are always allowed to use them.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true, Order = (num -= 1) } })); AllowServerBlueprints = ((BaseUnityPlugin)PlanBuildPlugin.Instance).Config.Bind("Server Settings", "Allow serverside blueprints", false, new ConfigDescription("Allow sharing of blueprints on this server.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true, Order = (num -= 1) } })); AllowMarketHotkey = ((BaseUnityPlugin)PlanBuildPlugin.Instance).Config.Bind("Server Settings", "Allow clients to use the GUI toggle key", true, new ConfigDescription("Allow clients to use the Hotkey to access server blueprints." + Environment.NewLine + "Admins are always allowed to use it.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true, Order = (num -= 1) } })); PlanBlacklistConfig = ((BaseUnityPlugin)PlanBuildPlugin.Instance).Config.Bind("Server Settings", "Excluded plan prefabs", "AltarPrefab,FloatingIslandMO", new ConfigDescription("Comma separated list of prefab names to exclude from the planned piece table on this server" + Environment.NewLine + "Admins are always allowed to build them.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true, Order = (num -= 1), Browsable = false } })); DefaultBuildModeConfig = ((BaseUnityPlugin)PlanBuildPlugin.Instance).Config.Bind("Blueprints", "Default build mode", DefaultBuildMode.Planned, new ConfigDescription("Default build mode when placing blueprints.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { Order = (num -= 1) } })); DefaultBuildModeConfig.SettingChanged += delegate { foreach (Blueprint value in BlueprintManager.LocalBlueprints.Values) { value.CreateKeyHint(); } }; UnlimitedHealthConfig = ((BaseUnityPlugin)PlanBuildPlugin.Instance).Config.Bind("Blueprints", "Unlimited health", false, new ConfigDescription("Set Piece health to its maximum value when directly building blueprints.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { Order = (num -= 1) } })); RayDistanceConfig = ((BaseUnityPlugin)PlanBuildPlugin.Instance).Config.Bind("Blueprints", "Place distance", 50f, new ConfigDescription("Place distance while using the Blueprint Rune.", (AcceptableValueBase)(object)new AcceptableValueRange(8f, 80f), new object[1] { (object)new ConfigurationManagerAttributes { Order = (num -= 1) } })); TerrainSmoothConfig = ((BaseUnityPlugin)PlanBuildPlugin.Instance).Config.Bind("Blueprints", "Terrain smoothing", 0.5f, new ConfigDescription("Smoothing value of the terrain tool when flattening with smoothing modifier key pressed.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), new object[1] { (object)new ConfigurationManagerAttributes { Order = (num -= 1) } })); CameraOffsetIncrementConfig = ((BaseUnityPlugin)PlanBuildPlugin.Instance).Config.Bind("Blueprints", "Camera offset increment", 2f, new ConfigDescription("Camera height change when holding the camera modifier key and scrolling.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { Order = (num -= 1) } })); InvertCameraOffsetScrollConfig = ((BaseUnityPlugin)PlanBuildPlugin.Instance).Config.Bind("Blueprints", "Invert camera offset scroll", false, new ConfigDescription("Invert the direction of camera offset scrolling.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { Order = (num -= 1) } })); PlacementOffsetIncrementConfig = ((BaseUnityPlugin)PlanBuildPlugin.Instance).Config.Bind("Blueprints", "Placement offset increment", 0.1f, new ConfigDescription("Placement height change when holding the modifier key and scrolling.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { Order = (num -= 1) } })); InvertPlacementOffsetScrollConfig = ((BaseUnityPlugin)PlanBuildPlugin.Instance).Config.Bind("Blueprints", "Invert placement height change scroll", false, new ConfigDescription("Invert the direction of placement offset scrolling.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { Order = (num -= 1) } })); SelectionIncrementConfig = ((BaseUnityPlugin)PlanBuildPlugin.Instance).Config.Bind("Blueprints", "Selection increment", 1f, new ConfigDescription("Selection radius increment when scrolling.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { Order = (num -= 1) } })); InvertSelectionScrollConfig = ((BaseUnityPlugin)PlanBuildPlugin.Instance).Config.Bind("Blueprints", "Invert selection scroll", false, new ConfigDescription("Invert the direction of selection scrolling.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { Order = (num -= 1) } })); RotationIncrementConfig = ((BaseUnityPlugin)PlanBuildPlugin.Instance).Config.Bind("Blueprints", "Rotation increment", 5, new ConfigDescription("Selection rotation increment when scrolling.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { Order = (num -= 1) } })); InvertRotationScrollConfig = ((BaseUnityPlugin)PlanBuildPlugin.Instance).Config.Bind("Blueprints", "Invert rotation scroll", false, new ConfigDescription("Invert the direction of rotation scrolling.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { Order = (num -= 1) } })); SelectionConnectedMarginConfig = ((BaseUnityPlugin)PlanBuildPlugin.Instance).Config.Bind("Blueprints", "Selection connected check margin", 0.01f, new ConfigDescription("Distance of the shell used to check for connectedness.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { Order = (num -= 1) } })); ShowGridConfig = ((BaseUnityPlugin)PlanBuildPlugin.Instance).Config.Bind("Blueprints", "Show the transform bound grid", false, new ConfigDescription("Shows a grid around the blueprints' bounds to visualize the blueprints' edges.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { Order = (num -= 1) } })); TooltipEnabledConfig = ((BaseUnityPlugin)PlanBuildPlugin.Instance).Config.Bind("Blueprints", "Tooltip enabled", true, new ConfigDescription("Show a tooltip with a bigger thumbnail for blueprint pieces.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { Order = (num -= 1) } })); TooltipBackgroundConfig = ((BaseUnityPlugin)PlanBuildPlugin.Instance).Config.Bind("Blueprints", "Tooltip Color", new Color(0.13f, 0.13f, 0.13f, 0.65f), new ConfigDescription("Set the background color for the tooltip on blueprint pieces.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { Order = (num -= 1) } })); BlueprintUndoQueueNameConfig = ((BaseUnityPlugin)PlanBuildPlugin.Instance).Config.Bind("Blueprints", "Undo queue name", "blueprintqueue", new ConfigDescription("Global name of the blueprint undo queue used for bp.undo and bp.redo commands. Can be set to the same value as other mods' config (if supported) to combine their undo queues.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { Order = (num -= 1) } })); AddPlayerNameConfig = ((BaseUnityPlugin)PlanBuildPlugin.Instance).Config.Bind("Blueprints", "Add player prefix to file name", true, new ConfigDescription("Add your current player profile name to any blueprint file created with that player.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { Order = (num -= 1) } })); BlueprintSearchDirectoryConfig = ((BaseUnityPlugin)PlanBuildPlugin.Instance).Config.Bind("Directories", "Search directory", ".", new ConfigDescription("Base directory to scan (recursively) for blueprints and vbuild files, relative paths are relative to the valheim.exe location", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { Order = (num -= 1) } })); BlueprintSaveDirectoryConfig = ((BaseUnityPlugin)PlanBuildPlugin.Instance).Config.Bind("Directories", "Save directory", "BepInEx/config/PlanBuild/blueprints", new ConfigDescription("Directory to save blueprint files, relative paths are relative to the valheim.exe location", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { Order = (num -= 1) } })); MarketHotkeyConfig = ((BaseUnityPlugin)PlanBuildPlugin.Instance).Config.Bind("Keybindings", "Blueprint Marketplace GUI toggle key", (KeyCode)279, new ConfigDescription("Hotkey to show the blueprint marketplace GUI", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { Order = (num -= 1) } })); ShiftModifierConfig = ((BaseUnityPlugin)PlanBuildPlugin.Instance).Config.Bind("Keybindings", "ShiftModifier", (KeyCode)304, new ConfigDescription("First modifier key to change behaviours on various tools (defaults to LeftShift)", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { Order = (num -= 1) } })); CtrlModifierConfig = ((BaseUnityPlugin)PlanBuildPlugin.Instance).Config.Bind("Keybindings", "CtrlModifier", (KeyCode)306, new ConfigDescription("Second modifier key to change behaviours on various tools (defaults to LeftCtrl)", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { Order = (num -= 1) } })); AltModifierConfig = ((BaseUnityPlugin)PlanBuildPlugin.Instance).Config.Bind("Keybindings", "AltModifier", (KeyCode)308, new ConfigDescription("Third modifier key to change behaviours on various tools (defaults to LeftAlt)", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { Order = (num -= 1) } })); ToggleConfig = ((BaseUnityPlugin)PlanBuildPlugin.Instance).Config.Bind("Keybindings", "Toggle", (KeyCode)113, new ConfigDescription("Key to switch between modes on various tools", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { Order = (num -= 1) } })); CtrlModifierConfig.SettingChanged += delegate { foreach (Blueprint value2 in BlueprintManager.LocalBlueprints.Values) { value2.CreateKeyHint(); } }; AltModifierConfig.SettingChanged += delegate { foreach (Blueprint value3 in BlueprintManager.LocalBlueprints.Values) { value3.CreateKeyHint(); } }; ShowAllPieces = ((BaseUnityPlugin)PlanBuildPlugin.Instance).Config.Bind("Plans", "Plan unknown pieces", false, new ConfigDescription("Show all plans, even for pieces you don't know yet", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true, Order = (num -= 1) } })); RadiusConfig = ((BaseUnityPlugin)PlanBuildPlugin.Instance).Config.Bind("Plans", "Plan totem build radius", 30f, new ConfigDescription("Build radius of the plan totem", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true, Order = (num -= 1) } })); ShowParticleEffects = ((BaseUnityPlugin)PlanBuildPlugin.Instance).Config.Bind("Plans", "Plan totem particle effects", true, new ConfigDescription("Show particle effects when building pieces with the plan totem", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true, Order = (num -= 1) } })); ShowAllPieces.SettingChanged += delegate { PlanManager.UpdateKnownRecipes(); }; ConfigTransparentGhostPlacement = ((BaseUnityPlugin)PlanBuildPlugin.Instance).Config.Bind("Visual", "Transparent Ghost Placement", true, new ConfigDescription("Apply plan shader to ghost placement (currently placing piece)", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { Order = (num -= 1) } })); UnsupportedColorConfig = ((BaseUnityPlugin)PlanBuildPlugin.Instance).Config.Bind("Visual", "Unsupported color", new Color(1f, 1f, 1f, 0.1f), new ConfigDescription("Color of unsupported plan pieces", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { Order = (num -= 1) } })); SupportedPlanColorConfig = ((BaseUnityPlugin)PlanBuildPlugin.Instance).Config.Bind("Visual", "Supported color", new Color(1f, 1f, 1f, 0.5f), new ConfigDescription("Color of supported plan pieces", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { Order = (num -= 1) } })); TransparencyConfig = ((BaseUnityPlugin)PlanBuildPlugin.Instance).Config.Bind("Visual", "Transparency", 0.3f, new ConfigDescription("Additional transparency for finer control.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), new object[1] { (object)new ConfigurationManagerAttributes { Order = (num -= 1) } })); GlowColorConfig = ((BaseUnityPlugin)PlanBuildPlugin.Instance).Config.Bind("Visual", "Plan totem glow color", Color.cyan, new ConfigDescription("Color of the glowing lines on the Plan totem", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { Order = (num -= 1) } })); ConfigTransparentGhostPlacement.SettingChanged += UpdateGhostPlanPieceTextures; UnsupportedColorConfig.SettingChanged += UpdateAllPlanPieceTextures; SupportedPlanColorConfig.SettingChanged += UpdateAllPlanPieceTextures; TransparencyConfig.SettingChanged += UpdateAllPlanPieceTextures; GlowColorConfig.SettingChanged += UpdateAllPlanTotems; CreateCustomButtons(); } private static void CreateCustomButtons() { //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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_003b: 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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_006f: 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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Expected O, but got Unknown //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_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Expected O, but got Unknown MarketHotkeyButton = new ButtonConfig { Name = "GUIToggle", Config = MarketHotkeyConfig, ActiveInCustomGUI = true }; InputManager.Instance.AddButton("marcopogo.PlanBuild", MarketHotkeyButton); ShiftModifierButton = new ButtonConfig { Name = "ShiftModifierButton", Config = ShiftModifierConfig }; InputManager.Instance.AddButton("marcopogo.PlanBuild", ShiftModifierButton); CtrlModifierButton = new ButtonConfig { Name = "CtrlModifierButton", Config = CtrlModifierConfig }; InputManager.Instance.AddButton("marcopogo.PlanBuild", CtrlModifierButton); AltModifierButton = new ButtonConfig { Name = "AltModifierButton", Config = AltModifierConfig }; InputManager.Instance.AddButton("marcopogo.PlanBuild", AltModifierButton); ToggleButton = new ButtonConfig { Name = "ToggleButton", Config = ToggleConfig }; InputManager.Instance.AddButton("marcopogo.PlanBuild", ToggleButton); } private static void UpdateGhostPlanPieceTextures(object sender, EventArgs e) { PlanManager.UpdateAllPlanPieceTextures(); } private static void UpdateAllPlanPieceTextures(object sender, EventArgs e) { ShaderHelper.ClearCache(); PlanManager.UpdateAllPlanPieceTextures(); } private static void UpdateAllPlanTotems(object sender, EventArgs e) { PlanManager.UpdateAllPlanTotems(); } } internal static class Extensions { public static void Highlight(this WearNTear self, Color color, float highlightTime = 0f) { //IL_0031: 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_0157: 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_015e: 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_0071: 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_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_0086: 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_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) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_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_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) if (self.m_oldMaterials == null) { self.m_oldMaterials = new List(); foreach (Renderer highlightRenderer in self.GetHighlightRenderers()) { OldMeshData val = default(OldMeshData); val.m_materials = highlightRenderer.sharedMaterials; val.m_color = (Color[])(object)new Color[val.m_materials.Length]; val.m_emissiveColor = (Color[])(object)new Color[val.m_materials.Length]; for (int i = 0; i < val.m_materials.Length; i++) { if (val.m_materials[i].HasProperty("_Color")) { val.m_color[i] = val.m_materials[i].GetColor("_Color"); } if (val.m_materials[i].HasProperty("_EmissionColor")) { val.m_emissiveColor[i] = val.m_materials[i].GetColor("_EmissionColor"); } } val.m_renderer = highlightRenderer; self.m_oldMaterials.Add(val); } } IEnumerable enumerable = self.m_oldMaterials.Where((OldMeshData mat) => Object.op_Implicit((Object)(object)mat.m_renderer)); foreach (OldMeshData item in enumerable) { Material[] materials = item.m_renderer.materials; IEnumerable enumerable2 = materials.Where((Material material) => material.HasProperty("_EmissionColor") && material.HasProperty("_Color")); foreach (Material item2 in enumerable2) { item2.SetColor("_EmissionColor", color * 0.3f); item2.color = color; } } ((MonoBehaviour)self).CancelInvoke("ResetHighlight"); if (highlightTime > 0f) { ((MonoBehaviour)self).Invoke("ResetHighlight", highlightTime); } } public static ZDOID? GetZDOID(this Piece piece) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) if (piece == null) { return null; } ZNetView nview = piece.m_nview; if (nview == null) { return null; } return nview.GetZDO()?.m_uid; } public static ZDOID? GetZDOID(this WearNTear wearNTear) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) if (wearNTear == null) { return null; } ZNetView nview = wearNTear.m_nview; if (nview == null) { return null; } return nview.GetZDO()?.m_uid; } } internal class Patches { public const string BuildCameraGUID = "org.gittywithexcitement.plugins.valheim.buildCamera"; public const string CraftFromContainersGUID = "aedenthorn.CraftFromContainers"; public const string AzuCraftyBoxesGUID = "Azumatt.AzuCraftyBoxes"; public const string GizmoGUID = "bruce.valheim.comfymods.gizmo"; public const string ValheimRaftGUID = "BepIn.Sarcen.ValheimRAFT"; public const string ItemDrawersGUID = "mkz.itemdrawers"; private static Harmony Harmony; internal static void Apply() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected O, but got Unknown Harmony = new Harmony("marcopogo.PlanBuild"); Harmony.PatchAll(typeof(PlanPiece)); if (Chainloader.PluginInfos.ContainsKey("org.gittywithexcitement.plugins.valheim.buildCamera")) { Logger.LogInfo((object)"Applying BuildCamera patches"); Harmony.PatchAll(typeof(PatcherBuildCamera)); } if (Chainloader.PluginInfos.ContainsKey("aedenthorn.CraftFromContainers")) { Logger.LogInfo((object)"Applying CraftFromContainers patches"); Harmony.PatchAll(typeof(PatcherCraftFromContainers)); } else if (Chainloader.PluginInfos.ContainsKey("Azumatt.AzuCraftyBoxes")) { Logger.LogInfo((object)"Applying AzuCraftyBoxes patches"); Harmony.PatchAll(typeof(PatcherAzuCraftyBoxes)); } if (Chainloader.PluginInfos.ContainsKey("bruce.valheim.comfymods.gizmo")) { Logger.LogInfo((object)"Applying Gizmo patches"); Harmony.PatchAll(typeof(PatcherGizmo)); } if (Chainloader.PluginInfos.ContainsKey("BepIn.Sarcen.ValheimRAFT")) { Logger.LogInfo((object)"Applying ValheimRAFT patches"); Harmony.PatchAll(typeof(PatcherValheimRaft)); } } } [BepInPlugin("marcopogo.PlanBuild", "PlanBuild", "0.18.8")] [BepInDependency("com.jotunn.jotunn", "2.30.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] internal class PlanBuildPlugin : BaseUnityPlugin { public const string PluginGUID = "marcopogo.PlanBuild"; public const string PluginName = "PlanBuild"; public const string PluginVersion = "0.18.8"; public static PlanBuildPlugin Instance; public void Awake() { Instance = this; Assembly assembly = typeof(PlanBuildPlugin).Assembly; Config.Init(); AssetBundle val = AssetUtils.LoadAssetBundleFromResources("blueprints", assembly); BlueprintAssets.Load(val); val.Unload(false); BlueprintManager.Init(); AssetBundle val2 = AssetUtils.LoadAssetBundleFromResources("planbuild", assembly); PlanTotemPrefab.Create(val2); PlanCrystalPrefab.Create(val2); PlanHammerPrefab.Create(val2); val2.Unload(false); PlanManager.Init(); CustomLocalization localization = LocalizationManager.Instance.GetLocalization(); string text = "English"; string text2 = "$hud_snappoint"; localization.AddTranslation(ref text, ref text2, "Recreated Snappoint"); Patches.Apply(); } public void Update() { if (ZInput.instance != null && (!Object.op_Implicit((Object)(object)Settings.instance) || !((Behaviour)Settings.instance).isActiveAndEnabled)) { if (BlueprintGUI.IsAvailable() && !SelectionSaveGUI.IsVisible() && !TerrainModGUI.IsVisible() && !SelectionGUI.IsVisible() && (Config.AllowMarketHotkey.Value || SynchronizationManager.Instance.PlayerIsAdmin) && ZInput.GetButtonDown(Config.MarketHotkeyButton.Name)) { BlueprintGUI.Instance.Toggle(); } if (BlueprintGUI.IsVisible() && !BlueprintGUI.TextFieldHasFocus() && ZInput.GetButtonDown("Use")) { BlueprintGUI.Instance.Toggle(shutWindow: true); ZInput.ResetButtonStatus("Use"); } } } public void UpdateScanPieces() { PlanDB.Instance.ScanPieceTables(); } } } namespace PlanBuild.ModCompat { internal class PatcherBuildCamera { internal static bool UpdateCamera = true; [HarmonyPatch(typeof(Valheim_Build_Camera), "IsTool")] [HarmonyPrefix] private static bool ValheimBuildCamera_IsTool_Prefix(ItemData itemData, ref bool __result) { if (itemData?.m_shared.m_name == "$item_blueprintrune" || itemData?.m_shared.m_name == "$item_plan_hammer") { __result = true; return false; } return true; } [HarmonyPatch(typeof(Valheim_Build_Camera), "EnableBuildMode")] [HarmonyPostfix] internal static void ValheimBuildCamera_EnableBuildMode_Postfix() { UpdateCamera = false; } [HarmonyPatch(typeof(Valheim_Build_Camera), "DisableBuildMode")] [HarmonyPostfix] internal static void ValheimBuildCamera_DisableBuildMode_Postfix() { UpdateCamera = true; } } internal class PatcherCraftFromContainers { [HarmonyPatch(typeof(PlanPiece), "GetInventories")] [HarmonyPostfix] private static void PlanPiece_GetInventories_Postfix(Humanoid player, ref List __result) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) if (!CraftFromContainers.modEnabled.Value) { return; } List nearbyContainers = CraftFromContainers.GetNearbyContainers(((Component)player).transform.position); foreach (Container item in nearbyContainers) { __result.Add(new PlanPiece.StandardInventory(item.GetInventory())); } } } internal class PatcherAzuCraftyBoxes { internal class AzuCraftyBoxesInventory : PlanPiece.IInventory { private IContainer container; internal static Dictionary resource_prefab_mapping = new Dictionary(); internal static string GetResourcePrefabName(string resourceName) { if (!resource_prefab_mapping.TryGetValue(resourceName, out var value)) { value = null; foreach (GameObject item in ObjectDB.instance.m_items) { ItemDrop component = item.GetComponent(); if ((Object)(object)component != (Object)null && component.m_itemData != null && component.m_itemData.m_shared.m_name == resourceName) { value = Utils.GetPrefabName(item); break; } } resource_prefab_mapping.Add(resourceName, value); } return value; } public AzuCraftyBoxesInventory(IContainer container) { this.container = container; } public int CountItems(string resourceName) { return container.ItemCount(resourceName); } public bool HaveItem(string resourceName) { string resourcePrefabName = GetResourcePrefabName(resourceName); if (API.CanItemBePulled(container.GetPrefabName(), resourcePrefabName)) { return container.ItemCount(resourceName) > 0; } return false; } public void RemoveItem(string resourceName, int amount) { container.RemoveItem(resourceName, amount); } } [HarmonyPatch(typeof(PlanPiece), "GetInventories")] [HarmonyPostfix] private static void PlanPiece_GetInventories_Postfix(Humanoid player, ref List __result) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Invalid comparison between Unknown and I4 if ((int)AzuCraftyBoxesPlugin.ModEnabled.Value != 1) { return; } foreach (IContainer nearbyContainer in API.GetNearbyContainers(player, AzuCraftyBoxesPlugin.mRange.Value)) { __result.Add(new AzuCraftyBoxesInventory(nearbyContainer)); } } } internal class PatcherValheimRaft { private PatcherValheimRaft() { } [HarmonyPatch(typeof(PlanPiece), "CalculateSupported")] [HarmonyPrefix] private static bool PlanPiece_CalculateSupported_Prefix(PlanPiece __instance, ref bool __result) { if (Object.op_Implicit((Object)(object)((Component)__instance).GetComponentInParent())) { __result = true; return false; } return true; } [HarmonyPatch(typeof(PlanPiece), "OnPieceReplaced")] [HarmonyPrefix] private static void PlanPiece_OnPieceReplaced_Postfix(GameObject originatingPiece, GameObject placedPiece) { MoveableBaseRootComponent componentInParent = originatingPiece.GetComponentInParent(); if (Object.op_Implicit((Object)(object)componentInParent)) { componentInParent.AddNewPiece(placedPiece.GetComponent()); } } [HarmonyPatch(typeof(PlacementComponent), "OnPiecePlaced")] [HarmonyPrefix] private static void BlueprintManager_OnPiecePlaced_Postfix(GameObject placedPiece) { ValheimRAFT_Patch.PlacedPiece(Player.m_localPlayer, placedPiece); } } internal static class PatcherGizmo { [HarmonyPatch(typeof(PlayerPatch), "UpdatePlacementPostfix")] [HarmonyPrefix] private static bool ComfyGizmo_UpdatePlacementPostfix_Prefix() { bool flag = Object.op_Implicit((Object)(object)Player.m_localPlayer) && Object.op_Implicit((Object)(object)Player.m_localPlayer.m_buildPieces); if (!flag || !Object.op_Implicit((Object)(object)Player.m_localPlayer.m_placementGhost) || Gizmos._gizmoInstances.Count <= 0) { return true; } Action action = delegate { foreach (Gizmos gizmoInstance in Gizmos._gizmoInstances) { gizmoInstance.Hide(); } }; ToolComponentBase toolComponentBase = default(ToolComponentBase); if (Player.m_localPlayer.m_placementGhost.TryGetComponent(ref toolComponentBase) && toolComponentBase.SuppressGizmo) { action(); return false; } bool flag2 = ((Object)Player.m_localPlayer.m_buildPieces).name.StartsWith("_PlanHammerPieceTable", StringComparison.Ordinal); bool flag3 = ((Object)Player.m_localPlayer.m_placementGhost).name.StartsWith("piece_plan_delete", StringComparison.Ordinal); if (flag2 && flag3) { action(); return false; } bool flag4 = ((Object)Player.m_localPlayer.m_buildPieces).name.StartsWith("_BlueprintPieceTable", StringComparison.Ordinal); bool flag5 = ZInput.GetButton(Config.ShiftModifierButton.Name) || ZInput.GetButton(Config.AltModifierButton.Name) || ZInput.GetButton(Config.CtrlModifierButton.Name); if (flag && flag4 && flag5) { return false; } return true; } [HarmonyPatch(typeof(ToolComponentBase), "Player_UpdatePlacementGhost")] [HarmonyPostfix] private static void PlanBuild_Player_UpdatePlacementGhost_Postfix(Player self) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)self.m_placementGhost)) { return; } foreach (Gizmos gizmoInstance in Gizmos._gizmoInstances) { gizmoInstance.SetPosition(self.m_placementGhost.transform.position); } } } } namespace PlanBuild.Utils { internal class ShapedProjector : MonoBehaviour { internal enum ProjectorShape { Circle, Square } private static GameObject _segment; private ProjectorShape Shape; private float Radius = 10f; private int Rotation; private CircleProjector Circle; private SquareProjector Square; private static GameObject SelectionSegment { get { if (!Object.op_Implicit((Object)(object)_segment)) { GameObject prefab = PrefabManager.Instance.GetPrefab("piece_workbench"); _segment = Object.Instantiate(prefab.GetComponentInChildren().m_prefab); _segment.SetActive(false); } return _segment; } } public void Enable() { if (Shape == ProjectorShape.Circle && (Object)(object)Circle == (Object)null) { Circle = ((Component)this).gameObject.AddComponent(); Circle.m_prefab = SelectionSegment; Circle.m_prefab.SetActive(true); Circle.m_radius = Radius; Circle.m_nrOfSegments = (int)Radius * 4; } if (Shape == ProjectorShape.Square && (Object)(object)Square == (Object)null) { Square = ((Component)this).gameObject.AddComponent(); Square.prefab = SelectionSegment; Square.radius = Radius; Square.rotation = Rotation; } } public void Disable() { if ((Object)(object)Circle != (Object)null) { foreach (GameObject segment in Circle.m_segments) { Object.DestroyImmediate((Object)(object)segment); } Object.DestroyImmediate((Object)(object)Circle); } if ((Object)(object)Square != (Object)null) { Square.StopProjecting(); Object.DestroyImmediate((Object)(object)Square); } } public bool IsEnabled() { if (Shape == ProjectorShape.Circle && (Object)(object)Circle != (Object)null) { return true; } if (Shape == ProjectorShape.Square && (Object)(object)Square != (Object)null) { return true; } return false; } public void ToggleEnabled() { if (IsEnabled()) { Disable(); } else { Enable(); } } public void SwitchShape() { if (Shape == ProjectorShape.Circle) { SetShape(ProjectorShape.Square); } else if (Shape == ProjectorShape.Square) { SetShape(ProjectorShape.Circle); } } public void SetShape(ProjectorShape newShape) { if (Shape != newShape) { Disable(); Shape = newShape; Enable(); } } public ProjectorShape GetShape() { return Shape; } public Vector3 GetPosition() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return ((Component)this).transform.position; } public void SetRadius(float newRadius) { Radius = newRadius; if (Shape == ProjectorShape.Circle && (Object)(object)Circle != (Object)null) { Circle.m_radius = Radius; Circle.m_nrOfSegments = (int)Radius * 4; } if (Shape == ProjectorShape.Square && (Object)(object)Square != (Object)null) { Square.radius = Radius; } } public float GetRadius() { return Radius; } public void SetRotation(int newRotation) { Rotation = newRotation; if (Shape == ProjectorShape.Square && (Object)(object)Square != (Object)null) { Square.rotation = Rotation; } } public int GetRotation() { return Rotation; } public void EnableMask() { //IL_001c: 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_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_007b: 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) if (Shape == ProjectorShape.Circle && (Object)(object)Circle != (Object)null && LayerMask.op_Implicit(Circle.m_mask) != 2048) { Circle.m_mask = LayerMask.op_Implicit(2048); } if (Shape == ProjectorShape.Square && (Object)(object)Square != (Object)null && LayerMask.op_Implicit(Square.mask) != 2048) { Square.mask = LayerMask.op_Implicit(2048); } } public void DisableMask() { //IL_001c: 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_002f: 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_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) if (Shape == ProjectorShape.Circle && (Object)(object)Circle != (Object)null && LayerMask.op_Implicit(Circle.m_mask) != 0) { Circle.m_mask = LayerMask.op_Implicit(0); } if (Shape == ProjectorShape.Square && (Object)(object)Square != (Object)null && LayerMask.op_Implicit(Square.mask) != 0) { Square.mask = LayerMask.op_Implicit(0); } } } internal class SquareProjector : MonoBehaviour { public float cubesSpeed = 1f; public float radius = 2f; public int rotation; public GameObject prefab; private GameObject cube; private float cubesThickness = 0.15f; private float cubesHeight = 0.1f; private float cubesLength = 1f; public LayerMask mask = LayerMask.op_Implicit(0); private float updatesPerSecond = 60f; private int cubesPerSide; private float sideLength; private float cubesLength100; private float sideLengthHalved; private Quaternion translatedRotation; private bool isRunning; private Transform center; private Transform parentNorth; private Transform parentEast; private Transform parentSouth; private Transform parentWest; private List cubesNorth = new List(); private List cubesEast = new List(); private List cubesSouth = new List(); private List cubesWest = new List(); public void Start() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0047: 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_008d: Unknown result type (might be due to invalid IL or missing references) cube = new GameObject("cube"); GameObject val = Object.Instantiate(prefab); val.transform.SetParent(cube.transform); val.transform.localScale = new Vector3(1f, 1f, 1f); val.transform.localPosition = new Vector3(0f, 0f, -0.5f); cube.transform.localScale = new Vector3(cubesThickness, cubesHeight, cubesLength); cube.SetActive(false); RefreshStuff(); StartProjecting(); } private void OnEnable() { if (!isRunning && !((Object)(object)parentNorth == (Object)null)) { isRunning = true; ((MonoBehaviour)this).StartCoroutine(AnimateElements(parentNorth, cubesNorth)); ((MonoBehaviour)this).StartCoroutine(AnimateElements(parentEast, cubesEast)); ((MonoBehaviour)this).StartCoroutine(AnimateElements(parentSouth, cubesSouth)); ((MonoBehaviour)this).StartCoroutine(AnimateElements(parentWest, cubesWest)); } } private void OnDisable() { isRunning = false; } public void StartProjecting() { //IL_0016: 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_0063: Unknown result type (might be due to invalid IL or missing references) if (!isRunning) { isRunning = true; center = new GameObject("center").transform; center.SetParent(((Component)this).transform); center.position = ((Component)this).transform.position; center.rotation = Quaternion.Euler(0f, (float)rotation, 0f); parentNorth = CreateElements(rotation, cubesNorth); parentEast = CreateElements(rotation + 90, cubesEast); parentSouth = CreateElements(rotation + 180, cubesSouth); parentWest = CreateElements(rotation + 270, cubesWest); ((MonoBehaviour)this).StartCoroutine(AnimateElements(parentNorth, cubesNorth)); ((MonoBehaviour)this).StartCoroutine(AnimateElements(parentEast, cubesEast)); ((MonoBehaviour)this).StartCoroutine(AnimateElements(parentSouth, cubesSouth)); ((MonoBehaviour)this).StartCoroutine(AnimateElements(parentWest, cubesWest)); } } public void StopProjecting() { if (isRunning) { isRunning = false; ((MonoBehaviour)this).StopAllCoroutines(); Object.Destroy((Object)(object)((Component)center).gameObject); cubesNorth.Clear(); cubesEast.Clear(); cubesSouth.Clear(); cubesWest.Clear(); } } private void RefreshStuff() { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0090: 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_00ae: Unknown result type (might be due to invalid IL or missing references) cubesPerSide = Mathf.FloorToInt(radius); sideLength = radius * 2f; cubesLength100 = sideLength / (float)cubesPerSide; sideLengthHalved = sideLength / 2f; translatedRotation = Quaternion.Euler(0f, (float)rotation, 0f); if (isRunning) { if (cubesPerSide + 1 != cubesNorth.Count) { StopProjecting(); StartProjecting(); } if (translatedRotation != center.rotation) { center.rotation = translatedRotation; } } } private Transform CreateElements(int localRotation, List cubes) { //IL_0007: 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_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_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_0090: 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_00c7: Unknown result type (might be due to invalid IL or missing references) Transform transform = new GameObject(localRotation.ToString()).transform; ((Component)transform).transform.position = center.position; ((Component)transform).transform.RotateAround(center.position, Vector3.up, (float)localRotation); transform.SetParent(center); for (int i = 0; i < cubesPerSide + 1; i++) { cubes.Add(Object.Instantiate(cube, ((Component)this).transform.position, Quaternion.identity, transform).transform); } Transform transform2 = new GameObject("Start").transform; Transform transform3 = new GameObject("End").transform; transform2.SetParent(transform); transform3.SetParent(transform); for (int j = 0; j < cubes.Count; j++) { cubes[j].forward = transform.right; } return transform; } private IEnumerator AnimateElements(Transform cubeParent, List cubes) { Transform a = cubeParent.Find("Start"); Transform b = cubeParent.Find("End"); Vector3 localScale = default(Vector3); RaycastHit val4 = default(RaycastHit); while (true) { RefreshStuff(); a.position = cubeParent.forward * (sideLengthHalved - cubesThickness / 2f) - cubeParent.right * sideLengthHalved + cubeParent.position; b.position = cubeParent.forward * (sideLengthHalved - cubesThickness / 2f) + cubeParent.right * sideLengthHalved + cubeParent.position; Vector3 val = b.position - a.position; for (int i = 0; i < cubes.Count; i++) { Transform val2 = cubes[i]; ((Component)val2).gameObject.SetActive(true); float num = (Time.time * cubesSpeed + sideLength / (float)cubesPerSide * (float)i) % (sideLength + cubesLength100); Vector3 val3; if (num < cubesLength) { val3 = ((Vector3)(ref val)).normalized * num + a.position; ((Vector3)(ref localScale))..ctor(val2.localScale.x, val2.localScale.y, cubesLength - (cubesLength - num)); } else if (num >= sideLength && num <= sideLength + cubesLength) { val3 = ((Vector3)(ref val)).normalized * sideLength + a.position; ((Vector3)(ref localScale))..ctor(val2.localScale.x, val2.localScale.y, cubesLength - (num - sideLength)); } else { if (num >= sideLength && num >= sideLength + cubesLength) { ((Component)val2).gameObject.SetActive(false); continue; } val3 = ((Vector3)(ref val)).normalized * num + a.position; ((Vector3)(ref localScale))..ctor(val2.localScale.x, val2.localScale.y, cubesLength); } if (Physics.Raycast(val3 + Vector3.up * 500f, Vector3.down, ref val4, 1000f, ((LayerMask)(ref mask)).value)) { val3.y = ((RaycastHit)(ref val4)).point.y; } val2.position = val3; val2.localScale = localScale; } yield return (object)new WaitForSecondsRealtime(1f / updatesPerSecond); } } } internal class DebugUtils { public static void InitLaserGrid(GameObject gameObject, Bounds bounds) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_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) //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_008a: 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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: 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_00c2: 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_00d7: 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) Transform transform = gameObject.transform; Material material = Resources.FindObjectsOfTypeAll().First((Material k) => ((Object)k).name == "Default-Line"); int num = 0; for (int num2 = -1; num2 <= 1; num2++) { for (int num3 = -1; num3 <= 1; num3++) { Color color = ((num2 == 0 && num3 == 0) ? Color.red : Color.gray); CreateLaser(transform, num++, bounds, new Vector3(-1f, (float)num2, (float)num3), new Vector3(1f, (float)num2, (float)num3), material, color); CreateLaser(transform, num++, bounds, new Vector3((float)num2, -1f, (float)num3), new Vector3((float)num2, 1f, (float)num3), material, color); CreateLaser(transform, num++, bounds, new Vector3((float)num2, (float)num3, -1f), new Vector3((float)num2, (float)num3, 1f), material, color); } } } private static void CreateLaser(Transform parent, int i, Bounds bounds, Vector3 first, Vector3 second, Material material, Color color) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_004d: 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_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_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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_00a4: 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_00b1: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("laser_" + i, new Type[1] { typeof(LineRenderer) }); val.transform.SetParent(parent); LineRenderer component = val.GetComponent(); component.useWorldSpace = false; ((Renderer)component).material = material; component.startColor = color; component.endColor = color; component.startWidth = 0.005f; component.endWidth = 0.005f; Vector3 extents = ((Bounds)(ref bounds)).extents; component.SetPositions((Vector3[])(object)new Vector3[2] { ((Bounds)(ref bounds)).center + Vector3.Scale(first, extents), ((Bounds)(ref bounds)).center + Vector3.Scale(second, extents) }); } } public class ShaderHelper { public enum ShaderState { Supported, Floating, Skuld } private static readonly Dictionary OriginalMaterialDict = new Dictionary(); private static readonly Dictionary SupportedMaterialDict = new Dictionary(); private static readonly Dictionary UnsupportedMaterialDict = new Dictionary(); private static Shader _planShader; public static Shader PlanShader => _planShader ?? (_planShader = Cache.GetPrefab("Lux Lit Particles/ Bumped")); public static void ClearCache() { UnsupportedMaterialDict.Clear(); SupportedMaterialDict.Clear(); } public static Texture2D GetTexture(Color color) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_000b: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(1, 1); val.SetPixel(0, 0, color); return val; } public static Texture2D CreateScaledTexture(Texture2D texture, int width) { //IL_000d: 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 Texture2D val = new Texture2D(((Texture)texture).width, ((Texture)texture).height, texture.format, false); val.SetPixels(texture.GetPixels()); val.Apply(); ScaleTexture(val, width); return val; } public static void ScaleTexture(Texture2D texture, int width) { //IL_000d: 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 //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) Texture2D val = new Texture2D(((Texture)texture).width, ((Texture)texture).height, texture.format, false); val.SetPixels(texture.GetPixels()); val.Apply(); int num = (int)Math.Round((float)width * (float)((Texture)texture).height / (float)((Texture)texture).width); texture.Reinitialize(width, num); texture.Apply(); Color[] pixels = texture.GetPixels(0); float num2 = 1f / (float)width; float num3 = 1f / (float)num; for (int i = 0; i < pixels.Length; i++) { pixels[i] = val.GetPixelBilinear(num2 * ((float)i % (float)width), num3 * Mathf.Floor((float)i / (float)width)); } texture.SetPixels(pixels, 0); texture.Apply(); Object.Destroy((Object)(object)val); } public static List GetRenderers(GameObject gameObject) { List list = new List(); list.AddRange((IEnumerable)(object)gameObject.GetComponentsInChildren()); list.AddRange((IEnumerable)(object)gameObject.GetComponentsInChildren()); return list; } public static void UpdateTextures(GameObject gameObject, ShaderState shaderState) { WearNTear val = default(WearNTear); if (gameObject.TryGetComponent(ref val) && val.m_oldMaterials != null) { val.ResetHighlight(); } foreach (Renderer renderer in GetRenderers(gameObject)) { if ((Object)(object)renderer.sharedMaterial != (Object)null) { Material[] sharedMaterials = renderer.sharedMaterials; UpdateMaterials(shaderState, sharedMaterials); renderer.sharedMaterials = sharedMaterials; renderer.shadowCastingMode = (ShadowCastingMode)0; } } } private static string AdjustMaterialName(string name) { return name.Split(new char[1] { ' ' })[0]; } private static void UpdateMaterials(ShaderState shaderState, Material[] sharedMaterials) { for (int i = 0; i < sharedMaterials.Length; i++) { Material val = sharedMaterials[i]; if (!((Object)(object)val == (Object)null)) { string key = AdjustMaterialName(((Object)val).name); if (!OriginalMaterialDict.ContainsKey(key)) { OriginalMaterialDict[key] = val; } sharedMaterials[i] = GetMaterial(shaderState, val); } } } private static Material GetMaterial(ShaderState shaderState, Material originalMaterial) { //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_0063: Expected O, but got Unknown //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_00da: 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_00ec: Expected O, but got Unknown //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) float value = Config.TransparencyConfig.Value; value *= value; switch (shaderState) { case ShaderState.Skuld: return OriginalMaterialDict[AdjustMaterialName(((Object)originalMaterial).name)]; case ShaderState.Supported: { if (!SupportedMaterialDict.TryGetValue(((Object)originalMaterial).name, out var value4)) { value4 = new Material(originalMaterial) { name = ((Object)originalMaterial).name }; value4.SetOverrideTag("RenderType", "Transparent"); value4.shader = PlanShader; Color value5 = Config.SupportedPlanColorConfig.Value; value5.a *= value; value4.color = value5; value4.EnableKeyword("_EMISSION"); value4.DisableKeyword("DIRECTIONAL"); SupportedMaterialDict[((Object)originalMaterial).name] = value4; } return value4; } case ShaderState.Floating: { if (!UnsupportedMaterialDict.TryGetValue(((Object)originalMaterial).name, out var value2)) { value2 = new Material(originalMaterial) { name = ((Object)originalMaterial).name }; value2.SetOverrideTag("RenderType", "Transparent"); value2.shader = PlanShader; Color value3 = Config.UnsupportedColorConfig.Value; value3.a *= value; value2.color = value3; value2.EnableKeyword("_EMISSION"); value2.DisableKeyword("DIRECTIONAL"); UnsupportedMaterialDict[((Object)originalMaterial).name] = value2; } return value2; } default: throw new ArgumentException("Unknown shaderState: " + shaderState); } } internal static void SetEmissionColor(GameObject gameObject, Color color) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) foreach (Renderer renderer in GetRenderers(gameObject)) { if (renderer.sharedMaterials.Length != 0) { SetEmissionColor(renderer.materials, color); } } } private static void SetEmissionColor(Material[] sharedMaterials, Color color) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) foreach (Material val in sharedMaterials) { if (val.HasProperty("_EmissionColor")) { val.SetColor("_EmissionColor", color); } } } public static Texture2D FromHeightmap(Heightmap terrain) { //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) return FromHeightmap(terrain, Color.gray, Color.black); } public static Texture2D FromHeightmap(Heightmap terrain, Color bandColor, Color bkgColor) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_0039: 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_0197: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) int width = terrain.m_width; int width2 = terrain.m_width; Texture2D val = new Texture2D(width, width2) { anisoLevel = 16 }; Color[] array = (Color[])(object)new Color[width * width2]; for (int i = 0; i < width2; i++) { for (int j = 0; j < width; j++) { array[i * width + j] = bkgColor; } } float num = 1f; float num2 = 0f; for (int k = 0; k < width2; k++) { for (int l = 0; l < width; l++) { float height = terrain.GetHeight(l, k); if (num > height) { num = height; } if (num2 < height) { num2 = height; } } } float num3 = 1f; List list = new List(); for (float num4 = num + num3; num4 < num2; num4 += num3) { list.Add(num4); } bool[,] array2 = new bool[width, width2]; for (int m = 0; m < list.Count; m++) { for (int n = 0; n < width2; n++) { for (int num5 = 0; num5 < width; num5++) { if (terrain.GetHeight(num5, n) >= list[m]) { array2[num5, n] = true; } else { array2[num5, n] = false; } } } for (int num6 = 1; num6 < width2 - 1; num6++) { for (int num7 = 1; num7 < width - 1; num7++) { if (array2[num7, num6] && (!array2[num7 - 1, num6] || !array2[num7 + 1, num6] || !array2[num7, num6 - 1] || !array2[num7, num6 + 1])) { int num8 = (width2 - num6 - 1) * width + (width - num7 - 1); array[num8] = bandColor; } } } } val.SetPixels(array); val.Apply(); return val; } } } namespace PlanBuild.Plans { internal class PlanCommands { private class PrintBlacklistCommand : ConsoleCommand { public override string Name => "plan.blacklist.print"; public override string Help => "Print out the server's plan blacklist"; public override void Run(string[] args) { if (Object.op_Implicit((Object)(object)ZNet.instance)) { if (!SynchronizationManager.Instance.PlayerIsAdmin) { Console.instance.Print("You need to be admin for this"); } else { Console.instance.Print(GeneralExtensions.Join((IEnumerable)PlanBlacklist.GetNames(), (Func)null, ", ") ?? ""); } } } } private class AddBlacklistCommand : ConsoleCommand { public override string Name => "plan.blacklist.add"; public override string Help => "[prefab_name] Add a prefab to the server's plan blacklist"; public override void Run(string[] args) { if (!Object.op_Implicit((Object)(object)ZNet.instance)) { return; } if (!SynchronizationManager.Instance.PlayerIsAdmin) { Console.instance.Print("You need to be admin for this"); return; } if (args.Length != 1 || string.IsNullOrWhiteSpace(args[0])) { Console.instance.Print("Usage: " + ((ConsoleCommand)this).Name + " [prefab_name]"); return; } string text = args[0].Trim(); GameObject prefab = PrefabManager.Instance.GetPrefab(text); if (!Object.op_Implicit((Object)(object)prefab)) { Console.instance.Print("Prefab " + text + " does not exist"); } else if (!Object.op_Implicit((Object)(object)prefab.GetComponent())) { Console.instance.Print("Prefab " + text + " has no piece component"); } else { PlanBlacklist.Add(text); } } public override List CommandOptionList() { return ZNetScene.instance.GetPrefabNames(); } } private class RemoveBlacklistCommand : ConsoleCommand { public override string Name => "plan.blacklist.remove"; public override string Help => "[prefab_name] Removes a prefab from the server's plan blacklist"; public override void Run(string[] args) { if (Object.op_Implicit((Object)(object)ZNet.instance)) { if (!SynchronizationManager.Instance.PlayerIsAdmin) { Console.instance.Print("You need to be admin for this"); return; } if (args.Length != 1 || string.IsNullOrWhiteSpace(args[0])) { Console.instance.Print("Usage: " + ((ConsoleCommand)this).Name + " [prefab_name]"); return; } string prefabName = args[0].Trim(); PlanBlacklist.Remove(prefabName); } } public override List CommandOptionList() { return PlanBlacklist.GetNames(); } } public static void Init() { CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new PrintBlacklistCommand()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new AddBlacklistCommand()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new RemoveBlacklistCommand()); } } internal class PlanBlacklist { private static readonly List Names = new List(); private static readonly List Hashes = new List(); public static void Init() { Reload(); SynchronizationManager.OnConfigurationSynchronized += delegate { Reload(); }; SynchronizationManager.OnAdminStatusChanged += PlanManager.UpdateKnownRecipes; } public static void Reload() { Names.Clear(); Hashes.Clear(); foreach (string item in from x in Config.PlanBlacklistConfig.Value.Split(new char[1] { ',' }) select x.Trim() into x where !string.IsNullOrEmpty(x) select x) { int stableHashCode = StringExtensionMethods.GetStableHashCode(item); if (!Hashes.Contains(stableHashCode)) { Logger.LogDebug((object)("Adding " + item + " to plan blacklist")); Names.Add(item); Hashes.Add(stableHashCode); } } PlanManager.UpdateKnownRecipes(); } public static List GetNames() { return Names.OrderBy((string x) => x).ToList(); } public static void Add(string prefabName) { if (!SynchronizationManager.Instance.PlayerIsAdmin) { return; } int stableHashCode = StringExtensionMethods.GetStableHashCode(prefabName.Trim()); if (!Hashes.Contains(stableHashCode)) { Names.Add(prefabName); Hashes.Add(stableHashCode); Config.PlanBlacklistConfig.Value = GeneralExtensions.Join((IEnumerable)Names.OrderBy((string x) => x), (Func)null, ", "); ((BaseUnityPlugin)PlanBuildPlugin.Instance).Config.Reload(); } } public static void Remove(string prefabName) { if (!SynchronizationManager.Instance.PlayerIsAdmin) { return; } int stableHashCode = StringExtensionMethods.GetStableHashCode(prefabName.Trim()); if (Hashes.Contains(stableHashCode)) { Names.Remove(prefabName); Hashes.Remove(stableHashCode); Config.PlanBlacklistConfig.Value = GeneralExtensions.Join((IEnumerable)Names.OrderBy((string x) => x), (Func)null, ", "); ((BaseUnityPlugin)PlanBuildPlugin.Instance).Config.Reload(); } } public static bool Contains(PlanPiecePrefab planPiecePrefab) { if (SynchronizationManager.Instance.PlayerIsAdmin) { return false; } if (!Object.op_Implicit((Object)(object)planPiecePrefab.OriginalPiece)) { return false; } return Hashes.Contains(planPiecePrefab.OriginalHash); } public static bool Contains(Piece piece) { if (SynchronizationManager.Instance.PlayerIsAdmin) { return false; } if (!Object.op_Implicit((Object)(object)piece)) { return false; } int stableHashCode = StringExtensionMethods.GetStableHashCode(((Object)piece).name.Split(new char[1] { '(' })[0].Trim()); return Hashes.Contains(stableHashCode); } public static bool Contains(string pieceName) { if (SynchronizationManager.Instance.PlayerIsAdmin) { return false; } if (string.IsNullOrEmpty(pieceName)) { return false; } int stableHashCode = StringExtensionMethods.GetStableHashCode(pieceName); return Hashes.Contains(stableHashCode); } } internal class PlanDB { private class PieceRequirements { private readonly Dictionary requirements; public PieceRequirements(Dictionary requirements) { this.requirements = requirements; } public override int GetHashCode() { int num = 13; IOrderedEnumerable> orderedEnumerable = requirements.OrderBy((KeyValuePair kvp) => kvp.Key); foreach (KeyValuePair item in orderedEnumerable) { num = num * 7 + item.Key.GetHashCode(); num = num * 7 + item.Value.GetHashCode(); } return num; } public override bool Equals(object obj) { if (!(obj is PieceRequirements pieceRequirements)) { return false; } if (requirements.Count == pieceRequirements.requirements.Count) { return !requirements.Except(pieceRequirements.requirements).Any(); } return false; } public override string ToString() { return string.Join(", ", requirements.Select((KeyValuePair x) => x.Key + ":" + x.Value)); } } private static PlanDB _instance; public readonly Dictionary PlanToOriginalMap = new Dictionary(); public readonly Dictionary OriginalToPlanMap = new Dictionary(); public Dictionary> NamePiecePrefabMapping = new Dictionary>(); public static PlanDB Instance => _instance ?? (_instance = new PlanDB()); private static bool IsValidPieceTable(PieceTable pieceTable) { if (Object.op_Implicit((Object)(object)pieceTable)) { if (!((Object)pieceTable).name.Equals("_PlanHammerPieceTable")) { return !((Object)pieceTable).name.Equals("_BlueprintPieceTable"); } return false; } return false; } public void ScanPieceTables() { Logger.LogDebug((object)"Scanning PieceTables for Pieces"); PieceTable pieceTable = PieceManager.Instance.GetPieceTable("_PlanHammerPieceTable"); IEnumerable enumerable = Resources.FindObjectsOfTypeAll().Where(IsValidPieceTable); HashSet hashSet = new HashSet(); foreach (PieceTable item in enumerable) { foreach (GameObject piece in item.m_pieces) { if (!Object.op_Implicit((Object)(object)piece)) { Logger.LogWarning((object)("Invalid prefab in " + ((Object)item).name + " PieceTable")); continue; } Piece component = piece.GetComponent(); if (!Object.op_Implicit((Object)(object)component)) { Logger.LogWarning((object)("Prefab " + ((Object)piece).name + " has no Piece?!")); } else { if (((Object)component).name == "piece_repair" || ((Object)component).name == "piece_remove_feaster") { continue; } if (hashSet.Contains(((Object)component).name)) { Logger.LogDebug((object)("Multiple prefabs with name: " + ((Object)component).name)); } else { hashSet.Add(((Object)component).name); } try { if (OriginalToPlanMap.TryGetValue(((Object)component).name, out var value)) { ((CustomPiece)value).Piece.m_enabled = component.m_enabled; ((CustomPiece)value).Piece.m_icon = component.m_icon; } else if (CanCreatePlan(component) && EnsurePrefabRegistered(component)) { PlanPiecePrefab planPiecePrefab = new PlanPiecePrefab(component); PrefabManager.Instance.RegisterToZNetScene(((CustomPiece)planPiecePrefab).PiecePrefab); PieceManager.Instance.AddPiece((CustomPiece)(object)planPiecePrefab); PlanToOriginalMap.Add(((Object)((CustomPiece)planPiecePrefab).PiecePrefab).name, planPiecePrefab.OriginalPiece); OriginalToPlanMap.Add(((Object)component).name, planPiecePrefab); if (!NamePiecePrefabMapping.TryGetValue(component.m_name, out var value2)) { value2 = new List(); NamePiecePrefabMapping.Add(component.m_name, value2); } value2.Add(component); } } catch (Exception arg) { Logger.LogWarning((object)$"Error while creating plan of {((Object)component).name}: {arg}"); } } } } pieceTable.m_pieces.Clear(); foreach (string key in OriginalToPlanMap.Keys) { try { if (hashSet.Contains(key) && OriginalToPlanMap.TryGetValue(key, out var value3)) { pieceTable.m_pieces.Add(((CustomPiece)value3).PiecePrefab); } } catch (Exception arg2) { Logger.LogWarning((object)$"Error while adding plan {key} to table: {arg2}"); } } WarnDuplicatesWithDifferentResources(); } private void WarnDuplicatesWithDifferentResources() { Dictionary>> dictionary = new Dictionary>>(); foreach (KeyValuePair> item in NamePiecePrefabMapping) { List value = item.Value; if (value.Count != 1) { IEnumerable> enumerable = from x in value group x by GetResourceMap(x); if (enumerable.Count() > 1) { dictionary[item.Key] = enumerable; } } } if (!dictionary.Any()) { return; } StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("Warning for mod developers:\nMultiple pieces with the same m_name but different resource requirements, this will cause issues with Player.m_knownRecipes!"); foreach (KeyValuePair>> item2 in dictionary) { stringBuilder.AppendLine("Piece.m_name: " + item2.Key); foreach (IGrouping item3 in item2.Value) { stringBuilder.AppendLine($" Requirements: {item3.Key}"); stringBuilder.AppendLine(" Pieces: " + string.Join(", ", item3.Select((Piece x) => ((Object)x).name)) + "\n"); } } Logger.LogWarning((object)stringBuilder.ToString()); } private PieceRequirements GetResourceMap(Piece y) { Dictionary dictionary = new Dictionary(y.m_resources.Length); Requirement[] resources = y.m_resources; foreach (Requirement val in resources) { dictionary[val.m_resItem.m_itemData.m_shared.m_name] = val.m_amount; } return new PieceRequirements(dictionary); } internal IEnumerable GetPlanPiecePrefabs() { return OriginalToPlanMap.Values; } private bool EnsurePrefabRegistered(Piece piece) { //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) GameObject prefab = PrefabManager.Instance.GetPrefab(((Object)((Component)piece).gameObject).name); if (Object.op_Implicit((Object)(object)prefab)) { return true; } Logger.LogWarning((object)("Piece " + ((Object)piece).name + " in Hammer not fully registered? Could not find prefab " + ((Object)((Component)piece).gameObject).name)); if (!ZNetScene.instance.m_prefabs.Contains(((Component)piece).gameObject)) { Logger.LogWarning((object)" Not registered in ZNetScene.m_prefabs! Adding now"); ZNetScene.instance.m_prefabs.Add(((Component)piece).gameObject); } if (!ZNetScene.instance.m_namedPrefabs.ContainsKey(StringExtensionMethods.GetStableHashCode(((Object)((Component)piece).gameObject).name))) { Logger.LogWarning((object)" Not registered in ZNetScene.m_namedPrefabs! Adding now"); ZNetScene.instance.m_namedPrefabs[StringExtensionMethods.GetStableHashCode(((Object)((Component)piece).gameObject).name)] = ((Component)piece).gameObject; } Transform parent = ((Component)piece).gameObject.transform.parent; GameObject val = ((parent != null) ? ((Component)parent).gameObject : null); if (!Object.op_Implicit((Object)(object)val)) { Logger.LogWarning((object)" Prefab has no parent?! Adding to Jotunn"); PrefabManager.Instance.AddPrefab(((Component)piece).gameObject); } else { Scene scene = val.scene; if (((Scene)(ref scene)).buildIndex != -1) { Logger.LogWarning((object)" Prefab container not marked as DontDestroyOnLoad! Marking now"); Object.DontDestroyOnLoad((Object)(object)val); } } return (Object)(object)PrefabManager.Instance.GetPrefab(((Object)((Component)piece).gameObject).name) != (Object)null; } internal bool FindOriginalByPrefabName(string name, out Piece originalPiece) { return PlanToOriginalMap.TryGetValue(name, out originalPiece); } internal bool FindOriginalByPieceName(string m_name, out List originalPieces) { return NamePiecePrefabMapping.TryGetValue(m_name, out originalPieces); } internal bool FindPlanByPrefabName(string name, out PlanPiecePrefab planPiecePrefab) { int num = name.IndexOf("(Clone)", StringComparison.Ordinal); if (num != -1) { name = name.Substring(0, num); } return OriginalToPlanMap.TryGetValue(name, out planPiecePrefab); } public bool CanCreatePlan(Piece piece) { if ((Object)(object)((Component)piece).GetComponent() == (Object)null && (Object)(object)((Component)piece).GetComponent() == (Object)null && (Object)(object)((Component)piece).GetComponent() == (Object)null && (Object)(object)((Component)piece).GetComponent() == (Object)null && (Object)(object)((Component)piece).GetComponent() == (Object)null) { return !((Object)piece).name.Equals("piece_plan_totem"); } return false; } } internal class PlanHammerPrefab { private class DeletePlansComponent : MonoBehaviour { private Piece LastHoveredPiece; private void Start() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown Player.PieceRayTest += new hook_PieceRayTest(Player_PieceRayTest); Player.TryPlacePiece += new hook_TryPlacePiece(Player_TryPlacePiece); Logger.LogDebug((object)(((Object)((Component)this).gameObject).name + " started")); } private void OnDestroy() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown Player.TryPlacePiece -= new hook_TryPlacePiece(Player_TryPlacePiece); Player.PieceRayTest -= new hook_PieceRayTest(Player_PieceRayTest); Logger.LogDebug((object)(((Object)((Component)this).gameObject).name + " destroyed")); } private bool Player_PieceRayTest(orig_PieceRayTest orig, Player self, out Vector3 point, out Vector3 normal, out Piece piece, out Heightmap heightmap, out Collider waterSurface, bool water) { bool result = orig.Invoke(self, ref point, ref normal, ref piece, ref heightmap, ref waterSurface, water); LastHoveredPiece = piece; return result; } private bool Player_TryPlacePiece(orig_TryPlacePiece orig, Player self, Piece piece) { PlanPiece planPiece = default(PlanPiece); if (Object.op_Implicit((Object)(object)LastHoveredPiece) && ((Component)LastHoveredPiece).TryGetComponent(ref planPiece)) { planPiece.m_wearNTear.Remove(false); } return false; } } public const string PlanHammerName = "PlanHammer"; public const string PlanHammerItemName = "$item_plan_hammer"; public const string PieceTableName = "_PlanHammerPieceTable"; public const string PieceDeletePlansName = "piece_plan_delete"; private static Sprite HammerIcon; private static GameObject PieceDeletePlansPrefab; private static CustomItem PlanHammerItem; public static void Create(AssetBundle planbuildBundle) { HammerIcon = planbuildBundle.LoadAsset("plan_hammer"); PieceDeletePlansPrefab = planbuildBundle.LoadAsset("piece_plan_delete"); PrefabManager.OnVanillaPrefabsAvailable += CreatePlanHammerItem; PieceManager.OnPiecesRegistered += CreatePlanTable; GUIManager.OnCustomGUIAvailable += CreateCustomKeyHints; } private static void CreatePlanHammerItem() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown //IL_004d: 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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Expected O, but got Unknown try { Logger.LogDebug((object)"Creating PlanHammer item"); ItemConfig val = new ItemConfig(); val.Name = "$item_plan_hammer"; val.Description = "$item_plan_hammer_description"; val.Icons = (Sprite[])(object)new Sprite[1] { HammerIcon }; val.Requirements = (RequirementConfig[])(object)new RequirementConfig[1] { new RequirementConfig { Item = "Wood", Amount = 1 } }; PlanHammerItem = new CustomItem("PlanHammer", "Hammer", val); ItemManager.Instance.AddItem(PlanHammerItem); SharedData shared = PlanHammerItem.ItemDrop.m_itemData.m_shared; shared.m_useDurability = false; shared.m_maxQuality = 1; shared.m_weight = 0f; shared.m_buildPieces = null; } catch (Exception arg) { Logger.LogWarning((object)$"Error caught while creating the PlanHammer item: {arg}"); } finally { PrefabManager.OnVanillaPrefabsAvailable -= CreatePlanHammerItem; } } private static void CreatePlanTable() { //IL_0067: 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_0073: Unknown result type (might be due to invalid IL or missing references) //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_0092: Expected O, but got Unknown //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Expected O, but got Unknown //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Expected O, but got Unknown try { Logger.LogDebug((object)"Creating PlanHammer piece table"); List list = (from x in PieceManager.Instance.GetPieceCategoriesMap() where x.Value != "Blueprints" && x.Value != "Clipboard" && x.Value != "Tools" select x.Value).ToList(); CustomPieceTable val = new CustomPieceTable("_PlanHammerPieceTable", new PieceTableConfig { CanRemovePieces = true, UseCategories = true, UseCustomCategories = true, CustomCategories = list.ToArray() }); PieceManager.Instance.AddPieceTable(val); for (int num = val.PieceTable.m_availablePiecesByCategory.Count; num < 100; num++) { val.PieceTable.m_availablePiecesByCategory.Add(new List()); } Array.Resize(ref val.PieceTable.m_selectedPiece, val.PieceTable.m_availablePiecesByCategory.Count); PlanHammerItem.ItemDrop.m_itemData.m_shared.m_buildPieces = val.PieceTable; PieceDeletePlansPrefab.AddComponent(); CustomPiece val2 = new CustomPiece(PieceDeletePlansPrefab, "_PlanHammerPieceTable", false); PieceManager.Instance.AddPiece(val2); PieceManager.Instance.RegisterPieceInPieceTable(PieceDeletePlansPrefab, "_PlanHammerPieceTable", "All"); } catch (Exception arg) { Logger.LogWarning((object)$"Error caught while creating the PlanHammer table: {arg}"); } finally { PieceManager.OnPiecesRegistered -= CreatePlanTable; } } private static void CreateCustomKeyHints() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown KeyHintManager instance = KeyHintManager.Instance; KeyHintConfig val = new KeyHintConfig(); val.Item = "PlanHammer"; val.Piece = "piece_plan_delete"; val.ButtonConfigs = (ButtonConfig[])(object)new ButtonConfig[1] { new ButtonConfig { Name = "Attack", HintToken = "$hud_plandelete" } }; instance.AddKeyHint(val); GUIManager.OnCustomGUIAvailable -= CreateCustomKeyHints; } } internal class OdinLevel : MonoBehaviour, Interactable, Hoverable { public string GetHoverName() { return "Level"; } public string GetHoverText() { return Localization.instance.Localize("[$KEY_Use] Toggle grid"); } public bool Interact(Humanoid user, bool hold, bool alt) { return true; } public bool UseItem(Humanoid user, ItemData item) { return false; } public float GetHoverOffset() { return 0f; } } internal class OdinLevelPrefab { private int radius = 10; private float distance = 1f; private KitbashObject odinLevelPrefab; public OdinLevelPrefab(AssetBundle planbuildBundle) { //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_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) //IL_0046: 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_005c: 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_0068: 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_0081: Expected O, but got Unknown //IL_008b: Expected O, but got Unknown //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Expected O, but got Unknown //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_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Expected O, but got Unknown //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Expected O, but got Unknown odinLevelPrefab = KitbashManager.Instance.AddKitbash(planbuildBundle.LoadAsset("piece_odin_level"), new KitbashConfig { Layer = "piece", KitbashSources = new List { new KitbashSourceConfig { SourcePrefab = "SurtlingCore", SourcePath = "attach/core", TargetParentPath = "new", Scale = Vector3.one * 0.1104584f } } }); KitbashObject obj = odinLevelPrefab; obj.OnKitbashApplied = (Action)Delegate.Combine(obj.OnKitbashApplied, new Action(InitLaserGrid)); GameObject prefab = odinLevelPrefab.Prefab; PieceConfig val = new PieceConfig(); val.PieceTable = "Hammer"; val.Requirements = (RequirementConfig[])(object)new RequirementConfig[1] { new RequirementConfig { Item = "SurtlingCore", Recover = true } }; CustomPiece val2 = new CustomPiece(prefab, false, val); PieceManager.Instance.AddPiece(val2); val2.PiecePrefab.AddComponent(); } private void InitLaserGrid() { //IL_006a: 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_008a: 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_00a0: 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_00ce: 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_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0102: 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_0071: Unknown result type (might be due to invalid IL or missing references) Material material = Resources.FindObjectsOfTypeAll().First((Material k) => ((Object)k).name == "Default-Line"); int num = 1 + (int)Math.Ceiling((float)radius * 2f / distance); List list = new List(); int num2 = 0; for (int num3 = -2; num3 <= 2; num3++) { for (int num4 = -2; num4 <= 2; num4++) { Color color = ((num3 == 0 && num4 == 0) ? Color.red : Color.gray); list.Add(CreateLaser(num2++, new Vector3(-2f, (float)num3, (float)num4), new Vector3(2f, (float)num3, (float)num4), material, color)); list.Add(CreateLaser(num2++, new Vector3((float)num3, -2f, (float)num4), new Vector3((float)num3, 2f, (float)num4), material, color)); list.Add(CreateLaser(num2++, new Vector3((float)num3, (float)num4, -2f), new Vector3((float)num3, (float)num4, 2f), material, color)); } } } private GameObject CreateLaser(int i, Vector3 first, Vector3 second, Material material, Color color) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_0041: 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_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_0077: 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) GameObject val = new GameObject("laser_" + i, new Type[1] { typeof(LineRenderer) }); LineRenderer component = val.GetComponent(); component.useWorldSpace = false; ((Renderer)component).material = material; component.startColor = color; component.endColor = color; component.startWidth = 0.005f; component.endWidth = 0.005f; component.SetPositions((Vector3[])(object)new Vector3[2] { first, second }); val.transform.SetParent(odinLevelPrefab.Prefab.transform); return val; } } internal class PlanCrystalPrefab { private const string PrefabName = "PlanCrystal"; private const string LocalizationName = "plan_crystal"; public static bool ShowRealTextures; private static Sprite CrystalIcon; private static CustomItem PlanCrystalItem; public static void Create(AssetBundle planbuildBundle) { CrystalIcon = planbuildBundle.LoadAsset("plan_crystal"); PrefabManager.OnVanillaPrefabsAvailable += CreatePlanCrystalItem; ItemManager.OnItemsRegistered += FixShader; } private static void CreatePlanCrystalItem() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown //IL_00be: 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_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Expected O, but got Unknown //IL_010e: 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) //IL_011a: 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_0129: Expected O, but got Unknown //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Expected O, but got Unknown //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Expected O, but got Unknown //IL_0194: Unknown result type (might be due to invalid IL or missing references) try { Logger.LogDebug((object)"Creating PlanCrystal item"); ItemConfig val = new ItemConfig(); val.Name = "$item_plan_crystal"; val.Description = "$item_plan_crystal_description"; val.Icons = (Sprite[])(object)new Sprite[1] { CrystalIcon }; val.CraftingStation = "piece_workbench"; val.Requirements = (RequirementConfig[])(object)new RequirementConfig[1] { new RequirementConfig { Item = "GreydwarfEye", Amount = 1 } }; PlanCrystalItem = new CustomItem("PlanCrystal", "GreydwarfEye", val); SharedData shared = PlanCrystalItem.ItemDrop.m_itemData.m_shared; ScriptableObject obj = ScriptableObject.CreateInstance(typeof(StatusEffect)); StatusEffect val2 = (StatusEffect)(object)((obj is StatusEffect) ? obj : null); val2.m_icon = CrystalIcon; val2.m_startMessageType = (MessageType)2; val2.m_startMessage = "$message_plan_crystal_start"; val2.m_stopMessageType = (MessageType)2; val2.m_stopMessage = "$message_plan_crystal_stop"; GameObject val3 = PrefabManager.Instance.CreateClonedPrefab("PlanCrystalStartEffect", "vfx_blocked"); val3.AddComponent(); EffectList val4 = new EffectList(); val4.m_effectPrefabs = (EffectData[])(object)new EffectData[1] { new EffectData { m_enabled = true, m_prefab = val3, m_attach = true } }; val2.m_startEffects = val4; GameObject val5 = PrefabManager.Instance.CreateClonedPrefab("PlanCrystalStopEffect", "vfx_blocked"); val5.AddComponent(); val4 = new EffectList(); val4.m_effectPrefabs = (EffectData[])(object)new EffectData[1] { new EffectData { m_enabled = true, m_prefab = val5, m_attach = true } }; val2.m_stopEffects = val4; shared.m_equipStatusEffect = val2; shared.m_itemType = (ItemType)18; shared.m_maxStackSize = 1; shared.m_centerCamera = true; shared.m_maxQuality = 1; ItemManager.Instance.AddItem(PlanCrystalItem); } catch (Exception arg) { Logger.LogWarning((object)$"Error caught while creating the PlanCrytal item: {arg}"); } finally { PrefabManager.OnVanillaPrefabsAvailable -= CreatePlanCrystalItem; } } private static void FixShader() { ShaderHelper.UpdateTextures(PlanCrystalItem.ItemDrop.m_itemData.m_dropPrefab, ShaderHelper.ShaderState.Supported); } } public class StartPlanCrystalStatusEffect : MonoBehaviour { public void Awake() { if (((Component)this).gameObject.GetComponent().IsOwner()) { PlanCrystalPrefab.ShowRealTextures = true; PlanManager.UpdateAllPlanPieceTextures(); } } } public class StopPlanCrystalStatusEffect : MonoBehaviour { public void Awake() { if (((Component)this).gameObject.GetComponent().IsOwner()) { PlanCrystalPrefab.ShowRealTextures = false; PlanManager.UpdateAllPlanPieceTextures(); } } } internal static class PlanManager { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static hook_Start <>9__0_0; internal void b__0_0(orig_Start orig, DungeonDB self) { orig.Invoke(self); PlanDB.Instance.ScanPieceTables(); } } internal static void Init() { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected O, but got Unknown //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Expected O, but got Unknown //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_0033: Expected O, but got Unknown Logger.LogInfo((object)"Initializing PlanManager"); PlanBlacklist.Init(); PlanCommands.Init(); object obj = <>c.<>9__0_0; if (obj == null) { hook_Start val = delegate(orig_Start orig, DungeonDB self) { orig.Invoke(self); PlanDB.Instance.ScanPieceTables(); }; <>c.<>9__0_0 = val; obj = (object)val; } DungeonDB.Start += (hook_Start)obj; Player.AddKnownPiece += new hook_AddKnownPiece(Player_AddKnownPiece); Player.HaveRequirements_Piece_RequirementMode += new hook_HaveRequirements_Piece_RequirementMode(Player_HaveRequirements); Player.SetupPlacementGhost += new hook_SetupPlacementGhost(Player_SetupPlacementGhost); Player.CheckCanRemovePiece += new hook_CheckCanRemovePiece(Player_CheckCanRemovePiece); WearNTear.Highlight += new hook_Highlight(WearNTear_Highlight); WearNTear.Destroy += new hook_Destroy(WearNTear_Destroy); } public static void UpdateKnownRecipes() { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } Logger.LogDebug((object)"Updating known Recipes"); foreach (PlanPiecePrefab planPiecePrefab in PlanDB.Instance.GetPlanPiecePrefabs()) { if (PlanBlacklist.Contains(planPiecePrefab) || (!Config.ShowAllPieces.Value && !PlayerKnowsPiece(localPlayer, planPiecePrefab.OriginalPiece))) { if (localPlayer.m_knownRecipes.Contains(((CustomPiece)planPiecePrefab).Piece.m_name)) { localPlayer.m_knownRecipes.Remove(((CustomPiece)planPiecePrefab).Piece.m_name); Logger.LogDebug((object)("Removing planned piece from m_knownRecipes: " + ((CustomPiece)planPiecePrefab).Piece.m_name)); } } else if (!localPlayer.m_knownRecipes.Contains(((CustomPiece)planPiecePrefab).Piece.m_name)) { localPlayer.m_knownRecipes.Add(((CustomPiece)planPiecePrefab).Piece.m_name); Logger.LogDebug((object)("Adding planned piece to m_knownRecipes: " + ((CustomPiece)planPiecePrefab).Piece.m_name)); } } PieceManager.Instance.GetPieceTable("_PlanHammerPieceTable").UpdateAvailable(localPlayer.m_knownRecipes, localPlayer, true, false); } public static void UpdateAllPlanPieceTextures() { Player localPlayer = Player.m_localPlayer; if (Object.op_Implicit((Object)(object)localPlayer) && Object.op_Implicit((Object)(object)localPlayer.m_placementGhost) && (((Object)localPlayer.m_placementGhost).name.StartsWith("piece_blueprint") || ((Object)localPlayer.m_placementGhost).name.Split(new char[1] { '(' })[0].EndsWith("_planned"))) { if (PlanCrystalPrefab.ShowRealTextures || !Config.ConfigTransparentGhostPlacement.Value) { ShaderHelper.UpdateTextures(localPlayer.m_placementGhost, ShaderHelper.ShaderState.Skuld); } else { ShaderHelper.UpdateTextures(localPlayer.m_placementGhost, ShaderHelper.ShaderState.Supported); } } PlanPiece[] array = Object.FindObjectsOfType(); foreach (PlanPiece planPiece in array) { planPiece.UpdateTextures(); } } public static void UpdateAllPlanTotems() { KitbashObject planTotemKitbash = PlanTotemPrefab.PlanTotemKitbash; PlanTotemPrefab.UpdateGlowColor((planTotemKitbash != null) ? planTotemKitbash.Prefab : null); foreach (PlanTotem allPlanTotem in PlanTotem.m_allPlanTotems) { PlanTotemPrefab.UpdateGlowColor(((Component)allPlanTotem).gameObject); } } private static void Player_AddKnownPiece(orig_AddKnownPiece orig, Player self, Piece piece) { if (((Object)piece).name.EndsWith("_planned")) { Player.m_localPlayer.m_knownRecipes.Add(piece.m_name); } else { orig.Invoke(self, piece); } } private static bool PlayerKnowsPiece(Player player, Piece originalPiece) { if (!PlanDB.Instance.FindOriginalByPieceName(originalPiece.m_name, out var originalPieces)) { return player.HaveRequirements(originalPiece, (RequirementMode)1); } foreach (Piece item in originalPieces) { if (player.HaveRequirements(item, (RequirementMode)1)) { return true; } } return false; } private static bool Player_HaveRequirements(orig_HaveRequirements_Piece_RequirementMode orig, Player self, Piece piece, RequirementMode mode) { //IL_0051: 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) try { if (Object.op_Implicit((Object)(object)piece) && PlanDB.Instance.FindOriginalByPrefabName(((Object)((Component)piece).gameObject).name, out var originalPiece)) { if (PlanBlacklist.Contains(originalPiece)) { return false; } if (Config.ShowAllPieces.Value) { return true; } return self.HaveRequirements(originalPiece, (RequirementMode)1); } } catch (Exception arg) { Logger.LogWarning((object)$"Error while executing Player.HaveRequirements({piece},{mode}): {arg}"); } return orig.Invoke(self, piece, mode); } private static void Player_SetupPlacementGhost(orig_SetupPlacementGhost orig, Player self) { try { PlanPiece.m_forceDisableInit = true; orig.Invoke(self); if (Object.op_Implicit((Object)(object)self.m_placementGhost)) { if (PlanCrystalPrefab.ShowRealTextures) { ShaderHelper.UpdateTextures(self.m_placementGhost, ShaderHelper.ShaderState.Skuld); } else if (Config.ConfigTransparentGhostPlacement.Value && (((Object)self.m_placementGhost).name.StartsWith("piece_blueprint") || ((Object)self.m_placementGhost).name.Split(new char[1] { '(' })[0].EndsWith("_planned"))) { ShaderHelper.UpdateTextures(self.m_placementGhost, ShaderHelper.ShaderState.Supported); } } } catch (Exception arg) { Logger.LogWarning((object)$"Exception caught while executing Player.SetupPlacementGhost(): {arg}"); } finally { PlanPiece.m_forceDisableInit = false; } } private static bool Player_CheckCanRemovePiece(orig_CheckCanRemovePiece orig, Player self, Piece piece) { bool flag = ((Humanoid)self).m_visEquipment.m_rightItem.Equals("PlanHammer"); PlanPiece planPiece = default(PlanPiece); bool flag2 = ((Component)piece).TryGetComponent(ref planPiece); if (flag) { return flag2; } if (flag2) { return false; } return orig.Invoke(self, piece); } private static void WearNTear_Highlight(orig_Highlight orig, WearNTear self) { PlanPiece planPiece = default(PlanPiece); if (!PlanCrystalPrefab.ShowRealTextures && ((Component)self).TryGetComponent(ref planPiece)) { planPiece.Highlight(); } else { orig.Invoke(self); } } private static void WearNTear_Destroy(orig_Destroy orig, WearNTear wearNTear, HitData hitData, bool blockDrop) { if (Object.op_Implicit((Object)(object)wearNTear.m_nview) && wearNTear.m_nview.IsOwner() && (hitData != null || wearNTear.m_support <= 0f) && PlanDB.Instance.FindPlanByPrefabName(((Object)wearNTear).name, out var planPiecePrefab)) { foreach (PlanTotem allPlanTotem in PlanTotem.m_allPlanTotems) { if (allPlanTotem.GetEnabled()) { GameObject gameObject = ((Component)wearNTear).gameObject; if (allPlanTotem.InRange(gameObject)) { allPlanTotem.Replace(gameObject, planPiecePrefab); break; } } } } orig.Invoke(wearNTear, hitData, blockDrop); } } public class PlanPiece : MonoBehaviour, Interactable, Hoverable { public interface IInventory { int CountItems(string resourceName); void RemoveItem(string resourceName, int amount); bool HaveItem(string resourceName); } internal class StandardInventory : IInventory { private Inventory inventory; public StandardInventory(Inventory inventory) { this.inventory = inventory; } public int CountItems(string resourceName) { return inventory.CountItems(resourceName, -1, true); } public bool HaveItem(string resourceName) { return inventory.HaveItem(resourceName, true); } public void RemoveItem(string resourceName, int amount) { inventory.RemoveItem(resourceName, amount, -1, true); } } public const string zdoPlanResource = "PlanResource"; internal static readonly List m_planPieces = new List(); private Piece m_piece; private ZNetView m_nView; internal WearNTear m_wearNTear; public Piece originalPiece; public static bool m_forceDisableInit; private bool hasSupport; private static readonly List typesToDestroyInChildren = new List { typeof(Joint), typeof(Rigidbody), typeof(TerrainModifier), typeof(GuidePoint), typeof(Light), typeof(LightLod), typeof(Interactable), typeof(Hoverable) }; public static int m_planLayer = LayerMask.NameToLayer("piece_nonsolid"); public static int m_placeRayMask = LayerMask.GetMask(new string[7] { "Default", "static_solid", "Default_small", "piece", "piece_nonsolid", "terrain", "vehicle" }); private float m_lastLookedTime = -9999f; private float m_lastUseTime = -9999f; private readonly float m_holdRepeatInterval = 1f; private float m_minSupport; internal float m_maxSupport; public void Awake() { if (m_forceDisableInit) { Object.Destroy((Object)(object)this); return; } if (!Object.op_Implicit((Object)(object)originalPiece)) { InvalidPlanPiece(); return; } WearNTear val = default(WearNTear); if (((Component)originalPiece).TryGetComponent(ref val)) { m_minSupport = val.GetMinSupport(); m_maxSupport = val.GetMaxSupport(); } m_planPieces.Add(this); m_wearNTear = ((Component)this).GetComponent(); m_nView = ((Component)this).GetComponent(); m_piece = ((Component)this).GetComponent(); DisablePiece(((Component)this).gameObject); WearNTear wearNTear = m_wearNTear; wearNTear.m_onDestroyed = (Action)Delegate.Combine(wearNTear.m_onDestroyed, new Action(OnDestroyed)); if (m_nView.IsOwner()) { m_nView.GetZDO().Set("support", 0f); } m_nView.Register("Refund", (Action)RPC_Refund); m_nView.Register("AddResource", (Action)RPC_AddResource); m_nView.Register("SpawnPieceAndDestroy", (Action)RPC_SpawnPieceAndDestroy); } private void OnDestroyed() { if (m_nView.IsOwner()) { Refund(all: true); } } public void OnDestroy() { m_planPieces.Remove(this); } private void RPC_Refund(long sender, bool all) { if (m_nView.IsOwner()) { Refund(all); } } internal bool CalculateSupported() { return m_nView.GetZDO().GetFloat("support", 0f) >= m_minSupport; } public void Update() { if (m_nView.IsValid()) { bool flag = CalculateSupported(); if (flag != hasSupport) { hasSupport = flag; UpdateTextures(); } } } internal void Highlight() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) m_wearNTear.Highlight(Config.UnsupportedColorConfig.Value, 0.6f); } public void DisablePiece(GameObject gameObject) { foreach (Type typesToDestroyInChild in typesToDestroyInChildren) { Component[] componentsInChildren = gameObject.GetComponentsInChildren(typesToDestroyInChild); foreach (Component val in componentsInChildren) { if (!(((object)val).GetType() == typeof(PlanPiece))) { Object.Destroy((Object)(object)val); } } } Collider[] componentsInChildren2 = gameObject.GetComponentsInChildren(); Collider[] array = componentsInChildren2; foreach (Collider val2 in array) { if (((1 << ((Component)val2).gameObject.layer) & m_placeRayMask) == 0) { ((Component)val2).gameObject.layer = m_planLayer; } } Transform[] componentsInChildren3 = gameObject.GetComponentsInChildren(); int planLayer = m_planLayer; Transform[] array2 = componentsInChildren3; for (int k = 0; k < array2.Length; k++) { ((Component)array2[k]).gameObject.layer = planLayer; } AudioSource[] componentsInChildren4 = gameObject.GetComponentsInChildren(); for (int l = 0; l < componentsInChildren4.Length; l++) { ((Behaviour)componentsInChildren4[l]).enabled = false; } ZSFX[] componentsInChildren5 = gameObject.GetComponentsInChildren(); for (int m = 0; m < componentsInChildren5.Length; m++) { ((Behaviour)componentsInChildren5[m]).enabled = false; } Windmill componentInChildren = gameObject.GetComponentInChildren(); if (Object.op_Implicit((Object)(object)componentInChildren)) { ((Behaviour)componentInChildren).enabled = false; } ParticleSystem[] componentsInChildren6 = gameObject.GetComponentsInChildren(); for (int n = 0; n < componentsInChildren6.Length; n++) { ((Component)componentsInChildren6[n]).gameObject.SetActive(false); } UpdateTextures(); } internal bool HasRequiredCraftingStationInRange() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)originalPiece.m_craftingStation)) { return Object.op_Implicit((Object)(object)CraftingStation.HaveBuildStationInRange(originalPiece.m_craftingStation.m_name, ((Component)this).transform.position)); } return true; } private void InvalidPlanPiece() { //IL_001b: 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) Logger.LogWarning((object)("Invalid PlanPiece , destroying self: " + ((Object)this).name + " @ " + ((object)((Component)this).gameObject.transform.position/*cast due to .constrained prefix*/).ToString())); ZNetScene.instance.Destroy(((Component)this).gameObject); } internal void UpdateTextures() { //IL_0027: 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) bool flag = Selection.Instance.IsHighlighted(m_piece); if (flag) { Selection.Instance.Unhighlight(m_piece.GetZDOID().Value, ((Component)this).gameObject); } ShaderHelper.UpdateTextures(((Component)this).gameObject, GetShaderState()); if (flag) { Selection.Instance.Highlight(m_piece.GetZDOID().Value, ((Component)this).gameObject); } } private ShaderHelper.ShaderState GetShaderState() { if (PlanCrystalPrefab.ShowRealTextures) { return ShaderHelper.ShaderState.Skuld; } if (HasSupport()) { return ShaderHelper.ShaderState.Supported; } return ShaderHelper.ShaderState.Floating; } public string GetHoverName() { return "Planned " + originalPiece.m_name; } public string GetHoverText() { if (Time.time - m_lastLookedTime > 0.2f) { m_lastLookedTime = Time.time; SetupPieceInfo(originalPiece); } Hud.instance.m_buildHud.SetActive(true); if (!HasAllResources()) { return Localization.instance.Localize("[$KEY_Use] [1-8] $plan_piece_hover_add_material\n[$plan_piece_hover_hold $KEY_Use] $plan_piece_hover_add_all_materials"); } return Localization.instance.Localize("[$KEY_Use] $plan_piece_hover_build"); } public float GetHoverOffset() { return 0f; } private void SetupPieceInfo(Piece piece) { //IL_00e7: 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_01ab: 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_0206: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; Hud.instance.m_buildSelection.text = Localization.instance.Localize(piece.m_name); Hud.instance.m_pieceDescription.text = Localization.instance.Localize(piece.m_description); ((Behaviour)Hud.instance.m_buildIcon).enabled = true; Hud.instance.m_buildIcon.sprite = piece.m_icon; GameObject[] requirementItems = Hud.instance.m_requirementItems; for (int i = 0; i < requirementItems.Length; i++) { if (i < piece.m_resources.Length) { Requirement req = piece.m_resources[i]; requirementItems[i].SetActive(true); SetupRequirement(requirementItems[i].transform, req, GetResourceCount(GetResourceName(req))); } else { requirementItems[i].SetActive(false); } } if (Object.op_Implicit((Object)(object)piece.m_craftingStation)) { CraftingStation val = CraftingStation.HaveBuildStationInRange(piece.m_craftingStation.m_name, ((Component)localPlayer).transform.position); GameObject val2 = requirementItems[piece.m_resources.Length]; val2.SetActive(true); Image component = ((Component)val2.transform.Find("res_icon")).GetComponent(); TMP_Text component2 = ((Component)val2.transform.Find("res_name")).GetComponent(); TMP_Text component3 = ((Component)val2.transform.Find("res_amount")).GetComponent(); UITooltip component4 = val2.GetComponent(); component.sprite = piece.m_craftingStation.m_icon; component2.text = Localization.instance.Localize(piece.m_craftingStation.m_name); component4.m_text = piece.m_craftingStation.m_name; if ((Object)(object)val != (Object)null) { val.ShowAreaMarker(); ((Graphic)component).color = Color.white; component3.text = ""; ((Graphic)component3).color = Color.white; } else { ((Graphic)component).color = Color.gray; component3.text = "None"; ((Graphic)component3).color = ((Mathf.Sin(Time.time * 10f) > 0f) ? Color.red : Color.white); } } } public bool SetupRequirement(Transform elementRoot, Requirement req, int currentAmount) { //IL_009c: 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_0194: 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_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) Image component = ((Component)((Component)elementRoot).transform.Find("res_icon")).GetComponent(); TMP_Text component2 = ((Component)((Component)elementRoot).transform.Find("res_name")).GetComponent(); TMP_Text component3 = ((Component)((Component)elementRoot).transform.Find("res_amount")).GetComponent(); UITooltip component4 = ((Component)elementRoot).GetComponent(); if ((Object)(object)req.m_resItem != (Object)null) { ((Component)component).gameObject.SetActive(true); ((Component)component2).gameObject.SetActive(true); ((Component)component3).gameObject.SetActive(true); component.sprite = req.m_resItem.m_itemData.GetIcon(); ((Graphic)component).color = Color.white; component4.m_text = Localization.instance.Localize(req.m_resItem.m_itemData.m_shared.m_name); component2.text = Localization.instance.Localize(req.m_resItem.m_itemData.m_shared.m_name); int amount = req.GetAmount(0); string resourceName = GetResourceName(req); bool flag = GetInventories((Humanoid)(object)Player.m_localPlayer).Exists((IInventory inv) => inv.HaveItem(resourceName)); int num = amount - currentAmount; component3.text = currentAmount + "/" + amount; if (num > 0 && !flag) { ((Graphic)component).color = Color.gray; ((Graphic)component3).color = ((Mathf.Sin(Time.time * 10f) > 0f) ? Color.red : Color.white); } else { ((Graphic)component).color = Color.white; ((Graphic)component3).color = Color.white; } } return true; } public List GetInventories(Humanoid player) { return new List { new StandardInventory(player.GetInventory()) }; } public bool Interact(Humanoid user, bool hold, bool alt) { //IL_01ac: Unknown result type (might be due to invalid IL or missing references) Player val = (Player)(object)((user is Player) ? user : null); if (val == null) { return false; } if (val.m_noPlacementCost) { Build(val.GetPlayerID()); return false; } if (hold) { if (Time.time - m_lastUseTime < m_holdRepeatInterval) { return false; } m_lastUseTime = Time.time; bool flag = false; { foreach (IInventory inventory in GetInventories(user)) { flag |= AddAllMaterials(inventory); } return flag; } } List inventories = GetInventories(user); Requirement[] resources = originalPiece.m_resources; foreach (Requirement val2 in resources) { string resourceName = GetResourceName(val2); int resourceCount = GetResourceCount(resourceName); if (resourceCount >= val2.m_amount) { continue; } foreach (IInventory item in inventories) { if (item.HaveItem(resourceName)) { m_nView.InvokeRPC("AddResource", new object[2] { resourceName, 1 }); item.RemoveItem(resourceName, 1); return true; } } } if (!HasAllResources()) { ((Character)user).Message((MessageType)2, "$msg_missingrequirement", 0, (Sprite)null, false); return false; } if (user.GetInventory().GetItem("$item_plan_hammer", -1, false) == null) { ((Character)user).Message((MessageType)2, "$message_plan_piece_need_hammer", 0, (Sprite)null, false); return false; } if (Object.op_Implicit((Object)(object)originalPiece.m_craftingStation)) { CraftingStation val3 = CraftingStation.HaveBuildStationInRange(originalPiece.m_craftingStation.m_name, ((Component)user).transform.position); if (!Object.op_Implicit((Object)(object)val3)) { ((Character)user).Message((MessageType)2, "$msg_missingstation", 0, (Sprite)null, false); return false; } } if (!HasSupport()) { ((Character)user).Message((MessageType)2, "$message_plan_piece_not_enough_support", 0, (Sprite)null, false); return false; } Build(val.GetPlayerID()); return false; } public bool HasSupport() { return hasSupport; } public void Build(long playerID) { m_nView.InvokeRPC("Refund", new object[1] { false }); m_nView.InvokeRPC("SpawnPieceAndDestroy", new object[1] { playerID }); } public bool AddAllMaterials(IInventory inventory) { bool result = false; Requirement[] resources = originalPiece.m_resources; foreach (Requirement req in resources) { string resourceName = GetResourceName(req); int remaining = GetRemaining(req); if (remaining > 0 && inventory.HaveItem(resourceName)) { int num = Math.Min(remaining, inventory.CountItems(resourceName)); if (num > 0) { m_nView.InvokeRPC("AddResource", new object[2] { resourceName, num }); inventory.RemoveItem(resourceName, num); result = true; } } } return result; } public Dictionary GetRemaining() { Dictionary dictionary = new Dictionary(); Requirement[] resources = originalPiece.m_resources; foreach (Requirement req in resources) { dictionary.Add(GetResourceName(req), GetRemaining(req)); } return dictionary; } private int GetRemaining(Requirement req) { int resourceCount = GetResourceCount(req); return req.m_amount - resourceCount; } private int GetResourceCount(Requirement req) { return GetResourceCount(GetResourceName(req)); } private static string GetResourceName(Requirement req) { return req.m_resItem.m_itemData.m_shared.m_name; } public bool UseItem(Humanoid user, ItemData item) { Requirement[] resources = originalPiece.m_resources; foreach (Requirement val in resources) { string resourceName = GetResourceName(val); if (!(resourceName != item.m_shared.m_name)) { int resourceCount = GetResourceCount(resourceName); int num = val.m_amount - resourceCount; if (num > 0) { m_nView.InvokeRPC("AddResource", new object[2] { resourceName, 1 }); user.GetInventory().RemoveOneItem(item); return true; } } } return false; } private void Refund(bool all) { //IL_007f: 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_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) Requirement[] resources = originalPiece.m_resources; foreach (Requirement val in resources) { string resourceName = GetResourceName(val); int num = GetResourceCount(resourceName); if (!all) { num -= val.m_amount; } while (num > 0) { ItemData val2 = val.m_resItem.m_itemData.Clone(); int num2 = (val2.m_stack = Mathf.Min(num, val2.m_shared.m_maxStackSize)); num -= num2; Object.Instantiate(((Component)val.m_resItem).gameObject, ((Component)this).transform.position + Vector3.up, Quaternion.identity).GetComponent().SetStack(num2); } } } internal void Remove() { m_wearNTear.Remove(false); } public bool HasAllResources() { Requirement[] resources = originalPiece.m_resources; foreach (Requirement val in resources) { string resourceName = GetResourceName(val); int resourceCount = GetResourceCount(resourceName); if (resourceCount < val.m_amount) { return false; } } return true; } public void RPC_AddResource(long sender, string resource, int amount) { if (m_nView.IsOwner()) { AddResource(resource, amount); } } private void AddResource(string resource, int amount) { int resourceCount = GetResourceCount(resource); SetResourceCount(resource, resourceCount + amount); } private void SetResourceCount(string resource, int count) { m_nView.GetZDO().Set("PlanResource_" + resource, count); } private int GetResourceCount(string resource) { if (!m_nView.IsValid()) { return 0; } return m_nView.GetZDO().GetInt("PlanResource_" + resource, 0); } private void RPC_SpawnPieceAndDestroy(long sender, long creatorID) { //IL_001b: 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) if (m_nView.IsOwner()) { GameObject val = SpawnPiece(((Component)this).gameObject, creatorID, ((Component)this).transform.position, ((Component)this).transform.rotation, ((Component)originalPiece).gameObject, m_nView.GetZDO().GetString("AdditionalText", "")); ZNetScene.instance.Destroy(((Component)this).gameObject); } } internal static GameObject SpawnPiece(GameObject originatingObject, long creatorID, Vector3 position, Quaternion rotation, GameObject prefab, string additionalInfo) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_012b: 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_00af: 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_00c8: Unknown result type (might be due to invalid IL or missing references) GameObject val = Object.Instantiate(prefab, position, rotation); OnPieceReplaced(originatingObject, val); Player localPlayer = Player.m_localPlayer; if (creatorID == ((localPlayer != null) ? new long?(localPlayer.GetPlayerID()) : ((long?)null))) { CraftingStation componentInChildren = val.GetComponentInChildren(); if (Object.op_Implicit((Object)(object)componentInChildren)) { Player.m_localPlayer.AddKnownStation(componentInChildren); } PrivateArea component = val.GetComponent(); if (Object.op_Implicit((Object)(object)component)) { component.Setup(Game.instance.GetPlayerProfile().GetName()); } Piece val2 = default(Piece); if (val.TryGetComponent(ref val2)) { val2.m_placeEffect.Create(val.transform.position, val.transform.rotation, val.transform, 1f, -1, default(ZDOID)); } Game.instance.GetPlayerProfile().IncrementStat((PlayerStatType)2, 1f, false); } WearNTear component2 = val.GetComponent(); if (Object.op_Implicit((Object)(object)component2)) { component2.OnPlaced(); } TextReceiver component3 = val.GetComponent(); if (component3 != null) { component3.SetText(additionalInfo); } ItemDrop component4 = val.GetComponent(); if ((Object)(object)component4 != (Object)null) { component4.MakePiece(true); } val.GetComponent().SetCreator(creatorID, PlatformUserID.None); return val; } internal static void OnPieceReplaced(GameObject originatingPiece, GameObject placedPiece) { } [HarmonyPatch(typeof(WearNTear), "Damage")] [HarmonyPrefix] private static bool WearNTear_Damage_Prefix(WearNTear __instance) { if (Object.op_Implicit((Object)(object)((Component)__instance).GetComponent())) { return false; } return true; } [HarmonyPatch(typeof(WearNTear), "GetSupport")] [HarmonyPrefix] private static bool WearNTear_GetSupport_Prefix(WearNTear __instance, ref float __result) { if (Object.op_Implicit((Object)(object)((Component)__instance).GetComponent())) { __result = 0f; return false; } return true; } [HarmonyPatch(typeof(WearNTear), "HaveSupport")] [HarmonyPrefix] private static bool WearNTear_HaveSupport_Prefix(WearNTear __instance, ref bool __result) { if (Object.op_Implicit((Object)(object)((Component)__instance).GetComponent())) { __result = true; return false; } return true; } [HarmonyPatch(typeof(WearNTear), "ResetHighlight")] [HarmonyPrefix] private static bool WearNTear_ResetHighlight_Prefix(WearNTear __instance) { //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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) if (__instance.m_oldMaterials == null) { return true; } IEnumerable enumerable = __instance.m_oldMaterials.Where((OldMeshData mat) => Object.op_Implicit((Object)(object)mat.m_renderer)); foreach (OldMeshData oldMaterial in enumerable) { Material[] materials = oldMaterial.m_renderer.materials; var enumerable2 = materials.Select((Material mat, int idx) => new { Material = mat, OriginalColor = oldMaterial.m_color[idx], OriginalEmissionColor = oldMaterial.m_emissiveColor[idx] }); foreach (var item in enumerable2) { item.Material.SetColor("_EmissionColor", item.OriginalEmissionColor); item.Material.color = item.OriginalColor; } } __instance.m_oldMaterials = null; return true; } } internal class PlanPiecePrefab : CustomPiece { public const string PlannedSuffix = "_planned"; public Piece OriginalPiece; public int OriginalHash; private static readonly List TypesToKeepInChildren = new List { typeof(ZNetView), typeof(WearNTear), typeof(Piece), typeof(Interactable), typeof(Hoverable), typeof(PlanPiece), typeof(ItemDrop) }; public static int PlanLayer = LayerMask.NameToLayer("piece_nonsolid"); public static int PlaceRayMask = LayerMask.GetMask(new string[7] { "Default", "static_solid", "Default_small", "piece", "piece_nonsolid", "terrain", "vehicle" }); public PlanPiecePrefab(Piece piece) : base(((Object)((Component)piece).gameObject).name + "_planned", ((Object)((Component)piece).gameObject).name, "_PlanHammerPieceTable") { //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Invalid comparison between Unknown and I4 //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Expected O, but got Unknown //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Expected O, but got Unknown OriginalPiece = piece; OriginalHash = StringExtensionMethods.GetStableHashCode(((Object)piece).name); ((CustomPiece)this).Piece.m_name = Localization.instance.Localize("$item_plan_piece_name", new string[1] { OriginalPiece.m_name }); ((CustomPiece)this).Piece.m_description = Localization.instance.Localize("$item_plan_piece_description", new string[1] { OriginalPiece.m_name }); ((CustomPiece)this).Piece.m_resources = Array.Empty(); ((CustomPiece)this).Piece.m_craftingStation = null; ((CustomPiece)this).Piece.m_placeEffect.m_effectPrefabs = Array.Empty(); ((CustomPiece)this).Piece.m_comfort = 0; ((CustomPiece)this).Piece.m_canBeRemoved = true; ((StaticTarget)((CustomPiece)this).Piece).m_randomTarget = false; ((StaticTarget)((CustomPiece)this).Piece).m_primaryTarget = false; ((CustomPiece)this).Piece.m_enabled = OriginalPiece.m_enabled; ((CustomPiece)this).Piece.m_category = (PieceCategory)(((int)OriginalPiece.m_category != 9) ? ((int)OriginalPiece.m_category) : 0); ((CustomPiece)this).Piece.m_groundOnly = OriginalPiece.m_groundOnly; ((CustomPiece)this).Piece.m_groundPiece = OriginalPiece.m_groundPiece; ((CustomPiece)this).Piece.m_icon = OriginalPiece.m_icon; ((CustomPiece)this).Piece.m_inCeilingOnly = OriginalPiece.m_inCeilingOnly; ((CustomPiece)this).Piece.m_isUpgrade = OriginalPiece.m_isUpgrade; ((StaticTarget)((CustomPiece)this).Piece).m_haveCenter = ((StaticTarget)OriginalPiece).m_haveCenter; ((CustomPiece)this).Piece.m_dlc = OriginalPiece.m_dlc; ((CustomPiece)this).Piece.m_allowAltGroundPlacement = OriginalPiece.m_allowAltGroundPlacement; ((CustomPiece)this).Piece.m_allowedInDungeons = OriginalPiece.m_allowedInDungeons; ((CustomPiece)this).PieceTable = "_PlanHammerPieceTable"; WearNTear orAddComponent = ExposedGameObjectExtension.GetOrAddComponent(((CustomPiece)this).PiecePrefab); orAddComponent.m_noSupportWear = true; orAddComponent.m_noRoofWear = false; orAddComponent.m_autoCreateFragments = false; orAddComponent.m_supports = true; orAddComponent.m_hitEffect = new EffectList(); orAddComponent.m_hitNoise = 0f; orAddComponent.m_destroyedEffect = new EffectList(); orAddComponent.m_destroyNoise = 0f; PlanPiece planPiece = ((CustomPiece)this).PiecePrefab.AddComponent(); planPiece.originalPiece = OriginalPiece; DisablePiece(((CustomPiece)this).PiecePrefab); } public void DisablePiece(GameObject gameObject) { gameObject.layer = PlanLayer; EffectArea[] componentsInChildren = gameObject.GetComponentsInChildren(); foreach (EffectArea val in componentsInChildren) { Object.DestroyImmediate((Object)(object)((Component)val).gameObject); } MonoBehaviour[] componentsInChildren2 = gameObject.GetComponentsInChildren(); foreach (MonoBehaviour component in componentsInChildren2) { if (!TypesToKeepInChildren.Any((Type x) => ReflectionHelper.IsSameOrSubclass(x, ((object)component).GetType()))) { Object.DestroyImmediate((Object)(object)component); } } } } internal class PlanTotem : Container { public static readonly List m_allPlanTotems; private CircleProjector m_areaMarker; private GameObject m_activeMarker; private MeshRenderer m_model; private int m_supportedPieces; internal static GameObject m_connectionPrefab; private Bounds m_chestBounds; private List> m_sortedRequired; private readonly List m_connectedPieces = new List(); private readonly Dictionary m_remainingRequirements = new Dictionary(); private readonly HashSet m_missingCraftingStations = new HashSet(); static PlanTotem() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown m_allPlanTotems = new List(); Container.GetHoverText += new hook_GetHoverText(OnContainerHoverText); Container.Interact += new hook_Interact(OnContainerInteract); } private static bool OnContainerInteract(orig_Interact orig, Container self, Humanoid character, bool hold, bool alt) { PlanTotem planTotem = self as PlanTotem; if (Object.op_Implicit((Object)(object)planTotem) && !hold && ZInput.GetButton("Crouch") && !self.IsInUse()) { ((Container)planTotem).m_nview.InvokeRPC("ToggleEnabled", Array.Empty()); return true; } return orig.Invoke(self, character, hold, alt); } private static string OnContainerHoverText(orig_GetHoverText orig, Container self) { PlanTotem planTotem = self as PlanTotem; if (Object.op_Implicit((Object)(object)planTotem)) { return planTotem.GetHoverText(); } return orig.Invoke(self); } public void Awake() { //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) base.m_width = 7; base.m_height = 4; ((Container)this).Awake(); ((MonoBehaviour)this).StartCoroutine((IEnumerator)UpdatePlanTotem()); m_areaMarker = ((Component)this).GetComponentInChildren(true); m_activeMarker = ((Component)((Component)this).transform.Find("new/pivot")).gameObject; m_model = ((Component)((Component)this).transform.Find("new/totem")).GetComponent(); m_areaMarker.m_radius = Config.RadiusConfig.Value; m_chestBounds = ((Collider)((Component)((Component)this).transform.Find("new/chest/privatechest")).GetComponent()).bounds; m_allPlanTotems.Add(this); if (Object.op_Implicit((Object)(object)base.m_nview)) { base.m_nview.Register("ToggleEnabled", (Action)RPC_ToggleEnabled); } HideMarker(); } internal void Replace(GameObject gameObject, PlanPiecePrefab planPrefab) { //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) //IL_0046: Unknown result type (might be due to invalid IL or missing references) Transform transform = gameObject.transform; TextReceiver component = gameObject.GetComponent(); string additionalInfo = ((component != null) ? component.GetText() : null); GameObject val = PlanPiece.SpawnPiece(gameObject, base.m_piece.m_creator, transform.position, transform.rotation, ((CustomPiece)planPrefab).PiecePrefab, additionalInfo); TriggerConnection(val.transform.position); } public void OnDestroy() { m_allPlanTotems.Remove(this); } public bool InRange(GameObject go) { return GetDistanceTo(go) <= Config.RadiusConfig.Value; } private float GetDistanceTo(GameObject go) { //IL_0002: 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_000e: 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_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_0033: 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) Vector3 center = GetCenter(go); return Vector2.Distance(new Vector2(((Component)this).transform.position.x, ((Component)this).transform.position.z), new Vector2(center.x, center.z)); } private List FindPlanPiecesInRange() { Dictionary dictionary = new Dictionary(); foreach (Piece s_allPiece in Piece.s_allPieces) { try { float distanceTo = GetDistanceTo(((Component)s_allPiece).gameObject); if (distanceTo <= Config.RadiusConfig.Value) { PlanPiece component = ((Component)s_allPiece).GetComponent(); if (Object.op_Implicit((Object)(object)component)) { dictionary.Add(component, distanceTo); } } } catch (Exception arg) { Logger.LogWarning((object)$"Exception caught while collecting plan piece {s_allPiece}: {arg}"); } } return (from pair in dictionary.AsEnumerable() orderby pair.Key.m_maxSupport descending, ((Component)pair.Key).transform.position.y, pair.Value select pair.Key).ToList(); } public IEnumerator UpdatePlanTotem() { if (!Object.op_Implicit((Object)(object)base.m_nview) || !base.m_nview.IsValid()) { yield break; } while (true) { yield return (YieldInstruction)new WaitForSeconds(3f); if (!GetEnabled()) { continue; } m_remainingRequirements.Clear(); m_supportedPieces = 0; m_connectedPieces.Clear(); m_missingCraftingStations.Clear(); PlanPiece.IInventory inventory = new PlanPiece.StandardInventory(base.m_inventory); List list = FindPlanPiecesInRange(); foreach (PlanPiece item in list) { if (item.HasSupport()) { m_supportedPieces++; } if (base.m_nview.IsOwner() && item.HasSupport()) { if (base.m_inventory.m_inventory.Count != 0) { item.AddAllMaterials(inventory); } if (item.HasAllResources()) { if (item.HasRequiredCraftingStationInRange()) { if (Config.ShowParticleEffects.Value) { TriggerConnection(GetCenter(((Component)item).gameObject)); } item.Build(base.m_piece.m_creator); continue; } m_missingCraftingStations.Add(item.originalPiece.m_craftingStation.m_name); } } m_connectedPieces.Add(item); Dictionary remaining = item.GetRemaining(); foreach (string key in remaining.Keys) { int num = remaining[key]; if (m_remainingRequirements.TryGetValue(key, out var value)) { num += value; } m_remainingRequirements[key] = num; } } m_sortedRequired = (from pair in m_remainingRequirements.Select(delegate(KeyValuePair pair) { int num2 = pair.Value; if (pair.Value > 0) { num2 -= base.m_inventory.CountItems(pair.Key, -1, true); } return new KeyValuePair(pair.Key, num2); }) where pair.Value > 0 orderby pair.Value descending select pair).ToList(); bool active = m_connectedPieces.Count > 0; SetActive(active); } } private void SetActive(bool active) { m_activeMarker.SetActive(active); Material[] materials = ((Renderer)m_model).materials; Material[] array = materials; foreach (Material val in array) { if (active) { val.EnableKeyword("_EMISSION"); } else { val.DisableKeyword("_EMISSION"); } } } internal void RPC_ToggleEnabled(long sender) { if (base.m_nview.IsOwner()) { SetEnabled(!GetEnabled()); } } private void SetEnabled(bool enabled) { if (Object.op_Implicit((Object)(object)base.m_nview) && base.m_nview.IsValid()) { base.m_nview.GetZDO().Set("enabled", enabled); } SetActive(enabled); } internal bool GetEnabled() { if (Object.op_Implicit((Object)(object)base.m_nview) && base.m_nview.IsValid()) { return base.m_nview.GetZDO().GetBool("enabled", true); } return false; } public void ShowAreaMarker() { if (Object.op_Implicit((Object)(object)m_areaMarker)) { ((Component)m_areaMarker).gameObject.SetActive(true); ((MonoBehaviour)this).CancelInvoke("HideMarker"); ((MonoBehaviour)this).Invoke("HideMarker", 0.5f); } } public void HideMarker() { ((Component)m_areaMarker).gameObject.SetActive(false); } public string GetHoverText() { ShowAreaMarker(); bool enabled = GetEnabled(); StringBuilder stringBuilder = new StringBuilder("$piece_plan_totem " + (enabled ? "" : "($piece_plan_totem_disabled)") + "\n[$KEY_Use] $piece_container_open\n[$KEY_Crouch + $KEY_Use] " + (enabled ? "$piece_plan_totem_disable" : "$piece_plan_totem_enable") + "\n\n"); if (m_missingCraftingStations.Count > 0) { stringBuilder.Append("$piece_plan_totem_missing \n"); foreach (string missingCraftingStation in m_missingCraftingStations) { stringBuilder.Append("" + missingCraftingStation + "\n"); } } stringBuilder.Append(Localization.instance.Localize("$piece_plan_totem_connected \n", new string[2] { m_connectedPieces.Count.ToString(), m_supportedPieces.ToString() })); if (m_remainingRequirements.Count > 0) { stringBuilder.Append("$piece_plan_totem_required\n"); foreach (KeyValuePair item in m_sortedRequired) { stringBuilder.Append($" {item.Value} {item.Key}\n"); } } return Localization.instance.Localize(stringBuilder.ToString()); } public Vector3 GetCenter(GameObject target) { //IL_000d: 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_0022: 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_002a: 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_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_0050: Unknown result type (might be due to invalid IL or missing references) Collider[] componentsInChildren = target.GetComponentsInChildren(); Vector3 val = target.transform.position; Collider[] array = componentsInChildren; Collider[] array2 = array; foreach (Collider val2 in array2) { Vector3 val3 = val; Bounds bounds = val2.bounds; val = (val3 + ((Bounds)(ref bounds)).center) / 2f; } return val; } public void TriggerConnection(Vector3 targetPos) { //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_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_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_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_003f: 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) //IL_0052: 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) Vector3 center = ((Bounds)(ref m_chestBounds)).center; GameObject val = Object.Instantiate(m_connectionPrefab, center, Quaternion.identity); TimedDestruction val2 = val.AddComponent(); Vector3 val3 = targetPos - center; val2.Trigger(((Vector3)(ref val3)).magnitude); val.transform.position = center; val.transform.rotation = Quaternion.LookRotation(((Vector3)(ref val3)).normalized); val.transform.localScale = new Vector3(1f, 1f, ((Vector3)(ref val3)).magnitude); } } internal class PlanTotemPrefab { public const string PlanTotemPieceName = "piece_plan_totem"; public static KitbashObject PlanTotemKitbash; public static void UpdateGlowColor(GameObject prefab) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)prefab)) { MeshRenderer component = ((Component)prefab.transform.Find("new/totem")).GetComponent(); ((Renderer)component).materials.First((Material material) => ((Object)material).name.StartsWith("Guardstone_OdenGlow_mat")).SetColor("_EmissionColor", Config.GlowColorConfig.Value); } } public static void Create(AssetBundle planbuildBundle) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: 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_0023: 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_0033: 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_0049: 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_0055: 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_006e: Expected O, but got Unknown //IL_006f: 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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0095: 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_00b0: 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_00bb: 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_00cf: 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_00ee: Expected O, but got Unknown //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: 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_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0154: 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_015f: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Expected O, but got Unknown //IL_0178: Expected O, but got Unknown //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Expected O, but got Unknown //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: 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_01fa: Expected O, but got Unknown //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Expected O, but got Unknown //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Expected O, but got Unknown PlanTotemKitbash = KitbashManager.Instance.AddKitbash(planbuildBundle.LoadAsset("piece_plan_totem"), new KitbashConfig { FixReferences = true, KitbashSources = new List { new KitbashSourceConfig { Name = "totem", TargetParentPath = "new", SourcePrefab = "guard_stone", SourcePath = "new/default", Scale = Vector3.one * 0.6f }, new KitbashSourceConfig { Name = "chest", TargetParentPath = "new", SourcePrefab = "piece_chest_private", SourcePath = "New", Position = new Vector3(0f, 0f, 0.591f), Scale = Vector3.one * 0.9f, Rotation = Quaternion.Euler(180f, 180f, 180f) }, new KitbashSourceConfig { Name = "hammer", TargetParentPath = "new/pivot", SourcePrefab = "Hammer", SourcePath = "attach/hammer", Position = new Vector3(0.07f, 1.9f, 0f), Rotation = Quaternion.Euler(0f, 0f, 20f), Scale = Vector3.one * 0.3f } } }); KitbashObject planTotemKitbash = PlanTotemKitbash; planTotemKitbash.OnKitbashApplied = (Action)Delegate.Combine(planTotemKitbash.OnKitbashApplied, (Action)delegate { //IL_00f9: Unknown result type (might be due to invalid IL or missing references) GameObject connectionPrefab = PrefabManager.Instance.GetPrefab("forge_ext1").GetComponent().m_connectionPrefab; GameObject connectionPrefab2 = PrefabManager.Instance.CreateClonedPrefab("vfx_PlanBuildConnection", connectionPrefab); GameObject prefab2 = PlanTotemKitbash.Prefab; ShaderHelper.UpdateTextures(((Component)prefab2.transform.Find("new/pivot/hammer")).gameObject, ShaderHelper.ShaderState.Supported); PlanTotem planTotem = prefab2.AddComponent(); PlanTotem.m_connectionPrefab = connectionPrefab2; ((Container)planTotem).m_name = "$piece_plan_totem_container"; ((Container)planTotem).m_open = ((Component)prefab2.transform.Find("new/chest/privatechesttop_open")).gameObject; ((Container)planTotem).m_closed = ((Component)prefab2.transform.Find("new/chest/privatechesttop_closed")).gameObject; ((Container)planTotem).m_height = 2; ((Container)planTotem).m_width = 6; MeshRenderer component = ((Component)prefab2.transform.Find("new/totem")).GetComponent(); ((Renderer)component).materials.First((Material material) => ((Object)material).name.StartsWith("Guardstone_OdenGlow_mat")).SetColor("_EmissionColor", Config.GlowColorConfig.Value); CircleProjector componentInChildren = prefab2.GetComponentInChildren(true); componentInChildren.m_prefab = PrefabManager.Instance.GetPrefab("guard_stone").GetComponentInChildren().m_prefab; componentInChildren.m_radius = Config.RadiusConfig.Value; }); GameObject prefab = PlanTotemKitbash.Prefab; PieceConfig val = new PieceConfig(); val.PieceTable = "Hammer"; val.Requirements = (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig { Item = "Wood", Amount = 1, Recover = true }, new RequirementConfig { Item = "GreydwarfEye", Amount = 1, Recover = true } }; CustomPiece val2 = new CustomPiece(prefab, false, val); PieceManager.Instance.AddPiece(val2); } } } namespace PlanBuild.Blueprints { internal class Blueprint { public enum Format { VBuild, Blueprint } private enum ParserState { SnapPoints, Terrain, Pieces } public const string PieceBlueprintName = "piece_blueprint"; public const string PlaceColliderName = "place_collider"; public const string AdditionalInfo = "AdditionalText"; private const string HeaderName = "#Name:"; private const string HeaderCreator = "#Creator:"; private const string HeaderDescription = "#Description:"; private const string HeaderCategory = "#Category:"; private const string HeaderSnapPoints = "#SnapPoints"; private const string HeaderTerrain = "#Terrain"; private const string HeaderPieces = "#Pieces"; private const int ThumbnailSize = 256; public string FileLocation; public Format FileFormat; public string ThumbnailLocation; public string ID; public string Name; public string Creator; public string Description = string.Empty; public string Category = "Blueprints"; public PieceEntry[] PieceEntries; public SnapPointEntry[] SnapPoints; public TerrainModEntry[] TerrainMods; private Texture2D ResizedThumbnail; private GameObject Prefab; private KeyHintConfig KeyHint; private Bounds Bounds; internal float GhostActiveTime; public Texture2D Thumbnail { get { return ResizedThumbnail; } set { if (((Texture)value).width > 256) { ShaderHelper.ScaleTexture(value, 256); } ResizedThumbnail = value; } } private string PrefabName => "piece_blueprint:" + ID; public static string CreateIDString(string name) { string text = string.Concat(name.Split(Path.GetInvalidFileNameChars())); string text2 = text.Replace(' ', '_').Trim(); if (Config.AddPlayerNameConfig.Value) { text2 = Player.m_localPlayer.GetPlayerName() + "_" + text2; } return text2; } public static Blueprint FromFile(string fileLocation) { string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileLocation); string text = Path.GetExtension(fileLocation).ToLowerInvariant(); Format format; if (!(text == ".vbuild")) { if (!(text == ".blueprint")) { throw new Exception("Format " + text + " not recognized"); } format = Format.Blueprint; } else { format = Format.VBuild; } string[] array = File.ReadAllLines(fileLocation); Logger.LogDebug((object)$"Read {array.Length} lines from {fileLocation}"); Blueprint blueprint = FromArray(fileNameWithoutExtension, array, format); blueprint.FileFormat = format; blueprint.FileLocation = fileLocation; blueprint.ThumbnailLocation = fileLocation.Replace(text, ".png"); if (File.Exists(blueprint.ThumbnailLocation)) { blueprint.Thumbnail = AssetUtils.LoadTexture(blueprint.ThumbnailLocation, false); Logger.LogDebug((object)("Read thumbnail data from " + blueprint.ThumbnailLocation)); } return blueprint; } public static Blueprint FromZPackage(ZPackage pkg) { string id = pkg.ReadString(); return FromBlob(id, pkg.ReadByteArray()); } public static Blueprint FromBlob(string id, byte[] payload) { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown List list = new List(); using MemoryStream input = new MemoryStream(Utils.Decompress(payload)); Blueprint blueprint; using (BinaryReader binaryReader = new BinaryReader(input)) { int num = binaryReader.ReadInt32(); for (int i = 0; i < num; i++) { list.Add(binaryReader.ReadString()); } blueprint = FromArray(id, list.ToArray(), Format.Blueprint); int num2 = binaryReader.ReadInt32(); if (num2 > 0) { byte[] array = binaryReader.ReadBytes(num2); Texture2D val = new Texture2D(1, 1); val.LoadRawTextureData(array); blueprint.Thumbnail = val; } } return blueprint; } public static Blueprint FromArray(string id, string[] lines, Format format) { Blueprint blueprint = new Blueprint(); blueprint.ID = id; blueprint.FileFormat = Format.Blueprint; blueprint.FileLocation = Path.Combine(Config.BlueprintSaveDirectoryConfig.Value, id + ".blueprint"); blueprint.ThumbnailLocation = Path.Combine(Config.BlueprintSaveDirectoryConfig.Value, id + ".png"); List list = new List(); List list2 = new List(); List list3 = new List(); ParserState parserState = ParserState.Pieces; foreach (string text in lines) { if (string.IsNullOrEmpty(text)) { continue; } if (text.StartsWith("#Name:")) { blueprint.Name = text.Substring("#Name:".Length); continue; } if (text.StartsWith("#Creator:")) { blueprint.Creator = text.Substring("#Creator:".Length); continue; } if (text.StartsWith("#Description:")) { blueprint.Description = text.Substring("#Description:".Length); if (blueprint.Description.StartsWith("\"")) { blueprint.Description = SimpleJson.DeserializeObject(blueprint.Description); } continue; } if (text.StartsWith("#Category:")) { blueprint.Category = text.Substring("#Category:".Length); if (string.IsNullOrEmpty(blueprint.Category)) { blueprint.Category = "Blueprints"; } continue; } switch (text) { case "#SnapPoints": parserState = ParserState.SnapPoints; continue; case "#Terrain": parserState = ParserState.Terrain; continue; case "#Pieces": parserState = ParserState.Pieces; continue; } if (text.StartsWith("#")) { continue; } switch (parserState) { case ParserState.SnapPoints: list2.Add(new SnapPointEntry(text)); break; case ParserState.Terrain: list3.Add(new TerrainModEntry(text)); break; case ParserState.Pieces: switch (format) { case Format.VBuild: list.Add(PieceEntry.FromVBuild(text)); break; case Format.Blueprint: list.Add(PieceEntry.FromBlueprint(text)); break; } break; } } if (string.IsNullOrEmpty(blueprint.Name)) { blueprint.Name = blueprint.ID; } blueprint.PieceEntries = list.ToArray(); blueprint.SnapPoints = list2.ToArray(); blueprint.TerrainMods = list3.ToArray(); return blueprint; } public string[] ToArray() { if (PieceEntries == null) { return null; } List list = new List(); list.Add("#Name:" + Name); list.Add("#Creator:" + Creator); list.Add("#Description:" + SimpleJson.SerializeObject((object)Description)); list.Add("#Category:" + Category); if (SnapPoints.Any()) { list.Add("#SnapPoints"); SnapPointEntry[] snapPoints = SnapPoints; foreach (SnapPointEntry snapPointEntry in snapPoints) { list.Add(snapPointEntry.line); } } if (TerrainMods.Any()) { list.Add("#Terrain"); TerrainModEntry[] terrainMods = TerrainMods; foreach (TerrainModEntry terrainModEntry in terrainMods) { list.Add(terrainModEntry.line); } } list.Add("#Pieces"); PieceEntry[] pieceEntries = PieceEntries; foreach (PieceEntry pieceEntry in pieceEntries) { list.Add(pieceEntry.line); } return list.ToArray(); } public byte[] ToBlob(bool includeThumbnail = false) { string[] array = ToArray(); if (array == null || array.Length == 0) { return null; } using MemoryStream memoryStream = new MemoryStream(); using (BinaryWriter binaryWriter = new BinaryWriter(memoryStream)) { binaryWriter.Write(array.Length); string[] array2 = array; foreach (string value in array2) { binaryWriter.Write(value); } if (!includeThumbnail || (Object)(object)Thumbnail == (Object)null) { binaryWriter.Write(0); } else { byte[] array3 = ImageConversion.EncodeToPNG(Thumbnail); binaryWriter.Write(array3.Length); binaryWriter.Write(array3); } } return Utils.Compress(memoryStream.ToArray()); } public ZPackage ToZPackage() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown ZPackage val = new ZPackage(); val.Write(ID); val.Write(ToBlob()); return val; } public bool ToFile() { string[] array = ToArray(); if (array == null || array.Length == 0) { return false; } using (TextWriter textWriter = new StreamWriter(FileLocation)) { string[] array2 = array; foreach (string value in array2) { textWriter.WriteLine(value); } Logger.LogDebug((object)$"Wrote {PieceEntries.Length} pieces to {FileLocation}"); } if (FileFormat == Format.VBuild) { string text = FileLocation.Replace(".vbuild", ".blueprint"); File.Move(FileLocation, text); FileLocation = text; FileFormat = Format.Blueprint; } if ((Object)(object)Thumbnail != (Object)null) { File.WriteAllBytes(ThumbnailLocation, ImageConversion.EncodeToPNG(Thumbnail)); Logger.LogDebug((object)("Wrote thumbnail data to " + ThumbnailLocation)); } return true; } public override string ToString() { return Localization.instance.Localize(ID + " ($gui_bpmarket_pieces)", new string[1] { GetPieceCount().ToString() }); } public string ToGUIString() { return Localization.instance.Localize("" + Name + "\n ($gui_bpmarket_pieces)", new string[1] { GetPieceCount().ToString() }); } public int GetPieceCount() { return PieceEntries.Length; } public int GetSnapPointCount() { return SnapPoints.Length; } public int GetTerrainModCount() { return TerrainMods.Length; } public Bounds GetBounds() { //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_001b: 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_004c: Unknown result type (might be due to invalid IL or missing references) Vector3 size = ((Bounds)(ref Bounds)).size; if (((Vector3)(ref size)).magnitude != 0f) { return Bounds; } PieceEntry[] pieceEntries = PieceEntries; foreach (PieceEntry pieceEntry in pieceEntries) { ((Bounds)(ref Bounds)).Encapsulate(pieceEntry.GetPosition()); } return Bounds; } public bool Capture(Selection selection, bool captureCurrentSnapPoints = false, bool keepMarkers = false) { //IL_0030: 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_0037: 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_0120: 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_0340: Unknown result type (might be due to invalid IL or missing references) //IL_0345: Unknown result type (might be due to invalid IL or missing references) //IL_0205: 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_042f: Unknown result type (might be due to invalid IL or missing references) //IL_0434: Unknown result type (might be due to invalid IL or missing references) //IL_0442: 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_0452: Unknown result type (might be due to invalid IL or missing references) //IL_06cb: Unknown result type (might be due to invalid IL or missing references) //IL_06d0: Unknown result type (might be due to invalid IL or missing references) //IL_076b: Unknown result type (might be due to invalid IL or missing references) //IL_076d: Unknown result type (might be due to invalid IL or missing references) //IL_0771: Unknown result type (might be due to invalid IL or missing references) //IL_0865: Unknown result type (might be due to invalid IL or missing references) //IL_086a: Unknown result type (might be due to invalid IL or missing references) //IL_086c: Unknown result type (might be due to invalid IL or missing references) //IL_0902: Unknown result type (might be due to invalid IL or missing references) //IL_0907: Unknown result type (might be due to invalid IL or missing references) //IL_0909: Unknown result type (might be due to invalid IL or missing references) Logger.LogDebug((object)"Collecting piece information"); int num = 0; List list = new List(); List list2 = new List(); Transform val = null; List list3 = new List(); foreach (ZDOID item2 in selection) { GameObject gameObject = BlueprintManager.GetGameObject(item2, required: true); if (((Object)gameObject).name.StartsWith("piece_bpsnappoint")) { list2.Add(gameObject.transform.position); if (!keepMarkers) { WearNTear component = gameObject.GetComponent(); component.Remove(false); } continue; } if (((Object)gameObject).name.StartsWith("piece_bpcenterpoint")) { if ((Object)(object)val == (Object)null) { val = gameObject.transform; } else { Logger.LogWarning((object)$"Multiple center points! Ignoring @ {gameObject.transform.position}"); } if (!keepMarkers) { WearNTear component2 = gameObject.GetComponent(); component2.Remove(false); } continue; } if (((Object)gameObject).name.StartsWith("piece_bpterrainmod")) { ZDO zDO = gameObject.GetComponent().GetZDO(); TerrainModEntry item = new TerrainModEntry(zDO.GetString("shape", ""), gameObject.transform.position, float.Parse(zDO.GetString("radius", ""), CultureInfo.InvariantCulture), int.Parse(zDO.GetString("rotation", ""), CultureInfo.InvariantCulture), float.Parse(zDO.GetString("smooth", ""), CultureInfo.InvariantCulture), zDO.GetString("paint", "")); list3.Add(item); if (!keepMarkers) { WearNTear component3 = gameObject.GetComponent(); component3.Remove(false); } continue; } Piece component4 = gameObject.GetComponent(); if (!BlueprintManager.CanCapture(component4)) { Logger.LogWarning((object)$"Ignoring piece {component4}, not able to make blueprint"); continue; } if (captureCurrentSnapPoints) { Transform[] componentsInChildren = gameObject.GetComponentsInChildren(true); foreach (Transform val2 in componentsInChildren) { if (((Object)val2).name.StartsWith("$hud_snappoint")) { list2.Add(val2.position); } } } list.Add(component4); num++; } if (!list.Any()) { return false; } Logger.LogDebug((object)$"Found {num} pieces"); Vector3 position = default(Vector3); if ((Object)(object)val == (Object)null) { float num2 = 10000000f; float num3 = 10000000f; float num4 = 10000000f; foreach (Piece item3 in list) { num3 = Math.Min(item3.m_nview.GetZDO().m_position.x, num3); num2 = Math.Min(item3.m_nview.GetZDO().m_position.z, num2); num4 = Math.Min(item3.m_nview.GetZDO().m_position.y, num4); } Logger.LogDebug((object)$"{num3} - {num4} - {num2}"); ((Vector3)(ref position))..ctor(num3, num4, num2); } else { position = val.position; } IOrderedEnumerable orderedEnumerable = from x in list orderby ((Component)x).transform.position.y, ((Component)x).transform.position.x, ((Component)x).transform.position.z select x; int num5 = orderedEnumerable.Count(); if (PieceEntries == null) { PieceEntries = new PieceEntry[num5]; } else if (PieceEntries.Length != 0) { Array.Clear(PieceEntries, 0, PieceEntries.Length - 1); Array.Resize(ref PieceEntries, num5); } uint num6 = 0u; foreach (Piece item4 in orderedEnumerable) { Vector3 pos = item4.m_nview.GetZDO().GetPosition() - position; Quaternion rotation = item4.m_nview.GetZDO().GetRotation(); ((Quaternion)(ref rotation)).eulerAngles = ((Component)item4).transform.eulerAngles; string text = string.Empty; TextReceiver component5 = ((Component)item4).GetComponent(); if (component5 != null) { text = component5.GetText(); } ItemStand component6 = ((Component)item4).GetComponent(); if ((Object)(object)component6 != (Object)null && component6.HaveAttachment() && Object.op_Implicit((Object)(object)component6.m_nview)) { text = string.Format("{0}:{1}:{2}:{3}", component6.m_nview.m_zdo.GetString("item", ""), component6.m_nview.m_zdo.GetInt("variant", 0), component6.m_nview.m_zdo.GetInt("quality", 0), component6.m_nview.m_zdo.GetInt("type", 0)); } ArmorStand component7 = ((Component)item4).GetComponent(); if ((Object)(object)component7 != (Object)null && Object.op_Implicit((Object)(object)component7.m_nview)) { text = $"{component7.m_pose}:"; text += $"{component7.m_slots.Count}:"; foreach (ArmorStandSlot slot in component7.m_slots) { text += $"{slot.m_currentItemName}:{slot.m_visualVariant}:"; } } Door component8 = ((Component)item4).GetComponent(); if ((Object)(object)component8 != (Object)null && Object.op_Implicit((Object)(object)component8.m_nview)) { text = string.Format("{0}", component8.m_nview.m_zdo.GetInt("state", 0)); } PrivateArea component9 = ((Component)item4).GetComponent(); if ((Object)(object)component9 != (Object)null && Object.op_Implicit((Object)(object)component9.m_nview)) { text = string.Format("{0}", component9.m_nview.m_zdo.GetBool("enabled", false)); } Container component10 = ((Component)item4).GetComponent(); if ((Object)(object)component10 != (Object)null && Object.op_Implicit((Object)(object)component10.m_nview)) { text = component10.m_nview.GetZDO().GetString("items", ""); } Vector3 localScale = ((Component)item4).transform.localScale; string text2 = ((Object)item4).name.Split(new char[1] { '(' })[0]; ZNetView component11 = ((Component)item4).gameObject.GetComponent(); if (component11 != null && component11.m_zdo != null) { GameObject prefab = ZNetScene.instance.GetPrefab(component11.m_zdo.m_prefab); if (prefab != null) { text2 = ((Object)prefab).name; } } if (text2.EndsWith("_planned")) { text2 = text2.Replace("_planned", null); } PieceEntries[num6++] = new PieceEntry(text2, ((object)Unsafe.As(ref item4.m_category)/*cast due to .constrained prefix*/).ToString(), pos, rotation, text, localScale); } List list4 = (from x in list2 group x by x into x where x.Count() == 1 select x.Key).ToList(); if (SnapPoints == null) { SnapPoints = new SnapPointEntry[list4.Count]; } else if (SnapPoints.Length != 0) { Array.Clear(SnapPoints, 0, SnapPoints.Length - 1); Array.Resize(ref SnapPoints, list4.Count); } for (int num7 = 0; num7 < list4.Count; num7++) { SnapPoints[num7] = new SnapPointEntry(list4[num7] - position); } if (TerrainMods == null) { TerrainMods = new TerrainModEntry[list3.Count]; } else if (TerrainMods.Length != 0) { Array.Clear(TerrainMods, 0, TerrainMods.Length - 1); Array.Resize(ref TerrainMods, list3.Count); } uint num8 = 0u; foreach (TerrainModEntry item5 in list3) { TerrainMods[num8++] = new TerrainModEntry(item5.shape, item5.GetPosition() - position, item5.radius, item5.rotation, item5.smooth, item5.paint); } return true; } public bool CreatePiece() { //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)Prefab)) { return false; } Logger.LogDebug((object)("Creating dynamic prefab " + PrefabName)); if (PieceEntries == null) { Logger.LogWarning((object)"Could not create blueprint prefab: No pieces loaded"); return false; } GameObject prefab = PrefabManager.Instance.GetPrefab("piece_blueprint"); if ((Object)(object)prefab == (Object)null) { Logger.LogWarning((object)"Could not load blueprint stub from prefabs"); return false; } ZNetView.m_forceDisableInit = true; Prefab = Object.Instantiate(prefab); ZNetView.m_forceDisableInit = false; ((Object)Prefab).name = PrefabName; Piece component = Prefab.GetComponent(); component.m_name = Name; component.m_enabled = true; component.m_description = LocalizationManager.Instance.TryTranslate("$gui_desc_id") + " " + ID; if (PieceEntries != null) { component.m_description += string.Format("{0}{1} {2}", Environment.NewLine, LocalizationManager.Instance.TryTranslate("$gui_desc_pieces"), PieceEntries.Length); } if (!string.IsNullOrEmpty(Description)) { Piece val = component; val.m_description = val.m_description + Environment.NewLine + LocalizationManager.Instance.TryTranslate("$gui_desc_description") + Environment.NewLine + Description; } if ((Object)(object)Thumbnail != (Object)null) { component.m_icon = Sprite.Create(Thumbnail, new Rect(0f, 0f, (float)((Texture)Thumbnail).width, (float)((Texture)Thumbnail).height), Vector2.zero); } PieceManager.Instance.RegisterPieceInPieceTable(Prefab, "_BlueprintPieceTable", Category); CreateKeyHint(); Prefab.AddComponent(); return true; } public void CreateKeyHint() { //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Expected O, but got Unknown //IL_00f7: 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_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Expected O, but got Unknown //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_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Expected O, but got Unknown //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Expected O, but got Unknown //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) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Expected O, but got Unknown //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_01bd: 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_01d4: Expected O, but got Unknown //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: 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_01f9: Expected O, but got Unknown if (KeyHint != null) { KeyHintManager.Instance.RemoveKeyHint(KeyHint); } string text = LocalizationManager.Instance.TryTranslate("$hud_bpoffsetpiece"); string text2 = LocalizationManager.Instance.TryTranslate(ZInput.instance.GetBoundKeyString(Config.CtrlModifierButton.Name, false)); string text3 = LocalizationManager.Instance.TryTranslate(ZInput.instance.GetBoundKeyString(Config.AltModifierButton.Name, false)); string text4 = text + " " + text2 + " + " + text3 + " = Y\n" + text2 + " = Z, " + text3 + " = X"; text4 = text4.Replace("[", null); text4 = text4.Replace("]", null); KeyHintConfig val = new KeyHintConfig(); val.Item = "BlueprintRune"; val.Piece = PrefabName; val.ButtonConfigs = (ButtonConfig[])(object)new ButtonConfig[6] { new ButtonConfig { Name = "Attack", HintToken = "$hud_bpplace" }, new ButtonConfig { Name = Config.CtrlModifierButton.Name, Config = Config.CtrlModifierConfig, HintToken = (Config.DirectBuildDefault ? "$hud_bpplanned" : "$hud_bpdirect") }, new ButtonConfig { Name = Config.ShiftModifierButton.Name, Config = Config.ShiftModifierConfig, HintToken = "$hud_bpcamera" }, new ButtonConfig { Name = Config.ToggleButton.Name, Config = Config.ToggleConfig, HintToken = "$hud_bpresetoffset" }, new ButtonConfig { Name = "Scroll", Axis = "Mouse ScrollWheel", HintToken = "$hud_bprotatepiece" }, new ButtonConfig { Name = "Scroll", Axis = "Mouse ScrollWheel", Hint = text4 } }; KeyHint = val; KeyHintManager.Instance.AddKeyHint(KeyHint); } public bool CreateThumbnail(int additionalRotation = 0, bool flush = true) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: 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_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) //IL_0036: 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_004d: Expected O, but got Unknown //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) if (!InstantiateGhost()) { return false; } RenderRequest val = new RenderRequest(Prefab) { Rotation = RenderManager.IsometricRotation * Quaternion.Euler(0f, (float)additionalRotation, 0f), Width = 256, Height = 256 }; Sprite val2 = RenderManager.Instance.Render(val); if ((Object)(object)val2 == (Object)null) { return false; } Thumbnail = val2.texture; Prefab.GetComponent().m_icon = Sprite.Create(Thumbnail, new Rect(0f, 0f, (float)((Texture)Thumbnail).width, (float)((Texture)Thumbnail).height), Vector2.zero); if (flush) { File.WriteAllBytes(ThumbnailLocation, ImageConversion.EncodeToPNG(Thumbnail)); } return true; } public bool InstantiateGhost() { //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: 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_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0207: 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_0288: 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_0058: 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) //IL_0080: Expected O, but got Unknown //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Expected O, but got Unknown //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)Prefab)) { return false; } if (Prefab.transform.childCount > 1) { return true; } GameObject prefab = Prefab; bool result = true; ZNetView.m_forceDisableInit = true; try { List list = new List(PieceEntries); SnapPointEntry[] snapPoints = SnapPoints; foreach (SnapPointEntry snapPointEntry in snapPoints) { GameObject val = new GameObject { name = "$hud_snappoint", layer = LayerMask.NameToLayer("piece"), tag = "snappoint" }; val.SetActive(false); GameObject val2 = Object.Instantiate(val, snapPointEntry.GetPosition(), Quaternion.identity, prefab.transform); ((Object)val2).name = "$hud_snappoint"; } GameObject val3 = new GameObject("place_collider"); val3.transform.SetParent(prefab.transform); val3.layer = LayerMask.NameToLayer("piece_nonsolid"); SphereCollider val4 = val3.AddComponent(); val4.radius = 0.002f; Transform transform = prefab.transform; Dictionary dictionary = new Dictionary(); foreach (PieceEntry item in from x in list group x by x.name into x select x.FirstOrDefault()) { GameObject prefab2 = PrefabManager.Instance.GetPrefab(item.name); if (!Object.op_Implicit((Object)(object)prefab2)) { Logger.LogWarning((object)("No prefab found for " + item.name + "! You are probably missing a dependency for blueprint " + Name)); } else { dictionary.Add(item.name, prefab2); } } for (int num = 0; num < list.Count; num++) { PieceEntry pieceEntry = list[num]; try { Vector3 val5 = transform.position + pieceEntry.GetPosition(); Quaternion val6 = transform.rotation * pieceEntry.GetRotation(); Vector3 scale = pieceEntry.GetScale(); if (dictionary.TryGetValue(pieceEntry.name, out var value)) { GameObject val7 = Object.Instantiate(value, val5, val6, transform); val7.transform.localScale = scale; PrepareGhostPiece(val7); } } catch (Exception arg) { Logger.LogWarning((object)$"Error while creating ghost of line: {pieceEntry.line}\n{arg}"); } } if (Config.ShowGridConfig.Value) { DebugUtils.InitLaserGrid(prefab, GetBounds()); } } catch (Exception arg2) { Logger.LogWarning((object)$"Error caught while instantiating {Name}: {arg2}"); result = false; } finally { ZNetView.m_forceDisableInit = false; } return result; } private void PrepareGhostPiece(GameObject child) { //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Expected O, but got Unknown MonoBehaviour[] componentsInChildren = child.GetComponentsInChildren(); foreach (MonoBehaviour val in componentsInChildren) { Object.DestroyImmediate((Object)(object)val); } Collider[] componentsInChildren2 = child.GetComponentsInChildren(); foreach (Collider val2 in componentsInChildren2) { Object.DestroyImmediate((Object)(object)val2); } Transform[] componentsInChildren3 = child.GetComponentsInChildren(true); foreach (Transform val3 in componentsInChildren3) { if (((Object)val3).name.StartsWith("$hud_snappoint")) { Object.DestroyImmediate((Object)(object)((Component)val3).gameObject); } } MeshRenderer[] componentsInChildren4 = child.GetComponentsInChildren(); MeshRenderer[] array = componentsInChildren4; foreach (MeshRenderer val4 in array) { if ((Object)(object)((Renderer)val4).sharedMaterial != (Object)null) { Material[] sharedMaterials = ((Renderer)val4).sharedMaterials; for (int m = 0; m < sharedMaterials.Length; m++) { Material val5 = new Material(sharedMaterials[m]); val5.SetFloat("_RippleDistance", 0f); val5.SetFloat("_ValueNoise", 0f); sharedMaterials[m] = val5; } ((Renderer)val4).sharedMaterials = sharedMaterials; ((Renderer)val4).shadowCastingMode = (ShadowCastingMode)0; } } } public void DestroyGhost() { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown if (!Object.op_Implicit((Object)(object)Prefab) || Prefab.transform.childCount <= 1) { return; } foreach (Transform item in Prefab.transform) { Transform val = item; if (((Object)val).name != "_GhostOnly") { Object.Destroy((Object)(object)((Component)val).gameObject); } } GhostActiveTime = 0f; } public void DestroyBlueprint() { if (Object.op_Implicit((Object)(object)Prefab)) { PieceTable pieceTable = PieceManager.Instance.GetPieceTable("_BlueprintPieceTable"); if ((Object)(object)pieceTable == (Object)null) { Logger.LogWarning((object)"_BlueprintPieceTable not found"); return; } if (pieceTable.m_pieces.Contains(Prefab)) { Logger.LogInfo((object)("Removing " + PrefabName + " from BlueprintRune")); pieceTable.m_pieces.Remove(Prefab); } if (PieceManager.Instance.GetPiece(PrefabName) != null) { PieceManager.Instance.RemovePiece(PrefabName); } PrefabManager.Instance.DestroyPrefab(PrefabName); if (Object.op_Implicit((Object)(object)Player.m_localPlayer) && Player.m_localPlayer.m_knownRecipes.Contains(PrefabName)) { Player.m_localPlayer.m_knownRecipes.Remove(PrefabName); } Prefab = null; } if (KeyHint != null) { KeyHintManager.Instance.RemoveKeyHint(KeyHint); KeyHint = null; } if (File.Exists(FileLocation)) { File.Delete(FileLocation); } if (File.Exists(ThumbnailLocation)) { File.Delete(ThumbnailLocation); } } } internal class TerrainModGUI { private class SaveGUIBehaviour : MonoBehaviour { private void Update() { if (IsVisible()) { if (Input.GetKeyUp((KeyCode)13)) { Instance.OnOk(); } if (Input.GetKeyUp((KeyCode)27)) { Instance.OnCancel(); } } } } public static TerrainModGUI Instance; private GameObject Prefab; private GameObject Window; private Dropdown Shape; private InputField Radius; private InputField Rotation; private InputField Smooth; private Dropdown Paint; private Button OkButton; private Button CancelButton; private Action OkAction; private Action CancelAction; public static void Init(GameObject prefab) { if (!GUIManager.IsHeadless()) { Instance = new TerrainModGUI(); Instance.Prefab = prefab; GUIManager.OnCustomGUIAvailable += Instance.Register; } } public static bool IsAvailable() { return Instance != null; } public static bool IsVisible() { if (IsAvailable() && (Object)(object)Instance.Window != (Object)null) { return Instance.Window.activeSelf; } return false; } public void Show(string shape, string radius, string rotation, string smooth, string paint, Action okAction, Action cancelAction) { OkAction = okAction; CancelAction = cancelAction; Shape.value = Shape.options.FindIndex((OptionData x) => x.text.Equals(shape, StringComparison.OrdinalIgnoreCase)); Radius.text = radius; Rotation.text = rotation; Smooth.text = smooth; Paint.value = Paint.options.FindIndex((OptionData x) => x.text.Equals(paint, StringComparison.OrdinalIgnoreCase)); Window.SetActive(true); ((Selectable)Shape).Select(); GUIManager.BlockInput(true); } private void Register() { //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Expected O, but got Unknown //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Expected O, but got Unknown if (!Object.op_Implicit((Object)(object)Window)) { Logger.LogDebug((object)"Recreating TerrainModGUI"); Window = Object.Instantiate(Prefab, GUIManager.CustomGUIFront.transform); Window.AddComponent(); Image component = Window.GetComponent(); component.sprite = GUIManager.Instance.GetSprite("woodpanel_settings"); component.type = (Type)1; ((Graphic)component).material = Cache.GetPrefab("litpanel"); Text[] componentsInChildren = Window.GetComponentsInChildren(true); foreach (Text val in componentsInChildren) { val.font = GUIManager.Instance.AveriaSerif; } Dropdown[] componentsInChildren2 = Window.GetComponentsInChildren(true); foreach (Dropdown val2 in componentsInChildren2) { GUIManager.Instance.ApplyDropdownStyle(val2, 15); } InputField[] componentsInChildren3 = Window.GetComponentsInChildren(true); foreach (InputField val3 in componentsInChildren3) { GUIManager.Instance.ApplyInputFieldStyle(val3, 16); } Button[] componentsInChildren4 = Window.GetComponentsInChildren