Decompiled source of PlanBuild v0.18.1
plugins/PlanBuild/PlanBuild.dll
Decompiled 2 weeks ago
The result has been truncated due to the large size, download it to view full contents!
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 ComfyGizmo.Patches; 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 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("Copyright © 2024")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")] [assembly: AssemblyFileVersion("0.18.1.0")] [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.1.0")] [module: UnverifiableCode] namespace PlanBuild { internal static class Config { public enum DefaultBuildMode { Planned, Direct } private const string ServerSection = "Server Settings"; public static ConfigEntry<bool> AllowDirectBuildConfig; public static ConfigEntry<bool> AllowTerrainmodConfig; public static ConfigEntry<bool> AllowServerBlueprints; public static ConfigEntry<bool> AllowBlueprintRune; public static ConfigEntry<bool> AllowMarketHotkey; public static ConfigEntry<string> PlanBlacklistConfig; private const string RuneSection = "Blueprints"; public static ConfigEntry<DefaultBuildMode> DefaultBuildModeConfig; public static ConfigEntry<bool> UnlimitedHealthConfig; public static ConfigEntry<float> RayDistanceConfig; public static ConfigEntry<float> TerrainSmoothConfig; public static ConfigEntry<float> CameraOffsetIncrementConfig; public static ConfigEntry<bool> InvertCameraOffsetScrollConfig; public static ConfigEntry<float> PlacementOffsetIncrementConfig; public static ConfigEntry<bool> InvertPlacementOffsetScrollConfig; public static ConfigEntry<float> SelectionIncrementConfig; public static ConfigEntry<bool> InvertSelectionScrollConfig; public static ConfigEntry<int> RotationIncrementConfig; public static ConfigEntry<bool> InvertRotationScrollConfig; public static ConfigEntry<float> SelectionConnectedMarginConfig; public static ConfigEntry<bool> ShowGridConfig; public static ConfigEntry<bool> TooltipEnabledConfig; public static ConfigEntry<Color> TooltipBackgroundConfig; public static ConfigEntry<string> BlueprintUndoQueueNameConfig; public static ConfigEntry<bool> AddPlayerNameConfig; private const string DirectorySection = "Directories"; public static ConfigEntry<string> BlueprintSearchDirectoryConfig; public static ConfigEntry<string> BlueprintSaveDirectoryConfig; private const string KeybindSection = "Keybindings"; public static ConfigEntry<KeyCode> MarketHotkeyConfig; public static ButtonConfig MarketHotkeyButton; public static ConfigEntry<KeyCode> ShiftModifierConfig; public static ButtonConfig ShiftModifierButton; public static ConfigEntry<KeyCode> CtrlModifierConfig; public static ButtonConfig CtrlModifierButton; public static ConfigEntry<KeyCode> ToggleConfig; public static ButtonConfig ToggleButton; public static ConfigEntry<KeyCode> AltModifierConfig; public static ButtonConfig AltModifierButton; private const string PlansSection = "Plans"; public static ConfigEntry<bool> ShowAllPieces; public static ConfigEntry<float> RadiusConfig; public static ConfigEntry<bool> ShowParticleEffects; private const string VisualSection = "Visual"; public static ConfigEntry<bool> ConfigTransparentGhostPlacement; public static ConfigEntry<Color> UnsupportedColorConfig; public static ConfigEntry<Color> SupportedPlanColorConfig; public static ConfigEntry<float> TransparencyConfig; public static ConfigEntry<Color> 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<bool>("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<bool>("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<bool>("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<bool>("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<bool>("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<string>("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<DefaultBuildMode>("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<bool>("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<float>("Blueprints", "Place distance", 50f, new ConfigDescription("Place distance while using the Blueprint Rune.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(8f, 80f), new object[1] { (object)new ConfigurationManagerAttributes { Order = (num -= 1) } })); TerrainSmoothConfig = ((BaseUnityPlugin)PlanBuildPlugin.Instance).Config.Bind<float>("Blueprints", "Terrain smoothing", 0.5f, new ConfigDescription("Smoothing value of the terrain tool when flattening with smoothing modifier key pressed.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), new object[1] { (object)new ConfigurationManagerAttributes { Order = (num -= 1) } })); CameraOffsetIncrementConfig = ((BaseUnityPlugin)PlanBuildPlugin.Instance).Config.Bind<float>("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<bool>("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<float>("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<bool>("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<float>("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<bool>("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<int>("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<bool>("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<float>("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<bool>("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<bool>("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<Color>("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<string>("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<bool>("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<string>("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<string>("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<KeyCode>("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<KeyCode>("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<KeyCode>("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<KeyCode>("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<KeyCode>("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<bool>("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<float>("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<bool>("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<bool>("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<Color>("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<Color>("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<float>("Visual", "Transparency", 0.3f, new ConfigDescription("Additional transparency for finer control.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), new object[1] { (object)new ConfigurationManagerAttributes { Order = (num -= 1) } })); GlowColorConfig = ((BaseUnityPlugin)PlanBuildPlugin.Instance).Config.Bind<Color>("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<OldMeshData>(); 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<OldMeshData> 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<Material> 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 void ResetHighlight(this WearNTear self) { //IL_004e: 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_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) if (self.m_oldMaterials == null) { self.ResetHighlight(); return; } IEnumerable<OldMeshData> enumerable = self.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; } } self.m_oldMaterials = null; self.ResetHighlight(); } 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.1")] [BepInDependency("com.jotunn.jotunn", "2.21.2")] [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.1"; 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(); 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<PlanPiece.IInventory> __result) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) if (!BepInExPlugin.modEnabled.Value) { return; } foreach (Container nearbyContainer in BepInExPlugin.GetNearbyContainers(((Component)player).transform.position)) { __result.Add(new PlanPiece.StandardInventory(nearbyContainer.GetInventory())); } } } internal class PatcherAzuCraftyBoxes { internal class AzuCraftyBoxesInventory : PlanPiece.IInventory { private IContainer container; internal static Dictionary<string, string> resource_prefab_mapping = new Dictionary<string, string>(); 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<ItemDrop>(); 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<PlanPiece.IInventory> __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<Humanoid>(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<MoveableBaseRootComponent>())) { __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<MoveableBaseRootComponent>(); if (Object.op_Implicit((Object)(object)componentInParent)) { componentInParent.AddNewPiece(placedPiece.GetComponent<Piece>()); } } [HarmonyPatch(typeof(PlacementComponent), "OnPiecePlaced")] [HarmonyPrefix] private static void BlueprintManager_OnPiecePlaced_Postfix(GameObject placedPiece) { ValheimRAFT_Patch.PlacedPiece(Player.m_localPlayer, placedPiece); } } internal class PatcherGizmo { [HarmonyPatch(typeof(PlayerPatch), "UpdatePlacementPostfix")] [HarmonyPrefix] private static bool ComfyGizmo_UpdatePlacementPostfix_Prefix() { if (!Object.op_Implicit((Object)(object)Player.m_localPlayer) || !Object.op_Implicit((Object)(object)Player.m_localPlayer.m_buildPieces) || !Object.op_Implicit((Object)(object)Player.m_localPlayer.m_placementGhost) || Gizmos._gizmoInstances.Count <= 0) { return true; } ToolComponentBase toolComponentBase = default(ToolComponentBase); if (Player.m_localPlayer.m_placementGhost.TryGetComponent<ToolComponentBase>(ref toolComponentBase) && toolComponentBase.SuppressGizmo) { foreach (Gizmos gizmoInstance in Gizmos._gizmoInstances) { gizmoInstance.Hide(); } return false; } if (((Object)Player.m_localPlayer.m_buildPieces).name.StartsWith("_PlanHammerPieceTable", StringComparison.Ordinal) && ((Object)Player.m_localPlayer.m_placementGhost).name.StartsWith("piece_plan_delete", StringComparison.Ordinal)) { foreach (Gizmos gizmoInstance2 in Gizmos._gizmoInstances) { gizmoInstance2.Hide(); } return false; } return true; } } } 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<GameObject>(prefab.GetComponentInChildren<CircleProjector>().m_prefab); _segment.SetActive(false); } return _segment; } } public void Enable() { if (Shape == ProjectorShape.Circle && (Object)(object)Circle == (Object)null) { Circle = ((Component)this).gameObject.AddComponent<CircleProjector>(); 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<SquareProjector>(); 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<Transform> cubesNorth = new List<Transform>(); private List<Transform> cubesEast = new List<Transform>(); private List<Transform> cubesSouth = new List<Transform>(); private List<Transform> cubesWest = new List<Transform>(); 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<GameObject>(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<Transform> 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<GameObject>(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<Transform> 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<Material>().First((Material k) => ((Object)k).name == "Default-Line"); int num = 0; for (int i = -1; i <= 1; i++) { for (int j = -1; j <= 1; j++) { Color color = ((i == 0 && j == 0) ? Color.red : Color.gray); CreateLaser(transform, num++, bounds, new Vector3(-1f, (float)i, (float)j), new Vector3(1f, (float)i, (float)j), material, color); CreateLaser(transform, num++, bounds, new Vector3((float)i, -1f, (float)j), new Vector3((float)i, 1f, (float)j), material, color); CreateLaser(transform, num++, bounds, new Vector3((float)i, (float)j, -1f), new Vector3((float)i, (float)j, 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<LineRenderer>(); 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<string, Material> OriginalMaterialDict = new Dictionary<string, Material>(); private static readonly Dictionary<string, Material> SupportedMaterialDict = new Dictionary<string, Material>(); private static readonly Dictionary<string, Material> UnsupportedMaterialDict = new Dictionary<string, Material>(); private static Shader _planShader; public static Shader PlanShader => _planShader ?? (_planShader = Cache.GetPrefab<Shader>("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<Renderer> GetRenderers(GameObject gameObject) { List<Renderer> list = new List<Renderer>(); list.AddRange((IEnumerable<Renderer>)(object)gameObject.GetComponentsInChildren<MeshRenderer>()); list.AddRange((IEnumerable<Renderer>)(object)gameObject.GetComponentsInChildren<SkinnedMeshRenderer>()); return list; } public static void UpdateTextures(GameObject gameObject, ShaderState shaderState) { WearNTear val = default(WearNTear); if (gameObject.TryGetComponent<WearNTear>(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<float> list = new List<float>(); 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<string>((IEnumerable<string>)PlanBlacklist.GetNames(), (Func<string, string>)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<Piece>())) { Console.instance.Print("Prefab " + text + " has no piece component"); } else { PlanBlacklist.Add(text); } } public override List<string> 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<string> 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<string> Names = new List<string>(); private static readonly List<int> Hashes = new List<int>(); 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<string> 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<string>((IEnumerable<string>)Names.OrderBy((string x) => x), (Func<string, string>)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<string>((IEnumerable<string>)Names.OrderBy((string x) => x), (Func<string, string>)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<string, int> requirements; public PieceRequirements(Dictionary<string, int> requirements) { this.requirements = requirements; } public override int GetHashCode() { int num = 13; IOrderedEnumerable<KeyValuePair<string, int>> orderedEnumerable = requirements.OrderBy((KeyValuePair<string, int> kvp) => kvp.Key); foreach (KeyValuePair<string, int> 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<string, int> x) => x.Key + ":" + x.Value)); } } private static PlanDB _instance; public readonly Dictionary<string, Piece> PlanToOriginalMap = new Dictionary<string, Piece>(); public readonly Dictionary<string, PlanPiecePrefab> OriginalToPlanMap = new Dictionary<string, PlanPiecePrefab>(); public Dictionary<string, List<Piece>> NamePiecePrefabMapping = new Dictionary<string, List<Piece>>(); public static PlanDB Instance => _instance ?? (_instance = new PlanDB()); private static bool IsValidPieceTable(PieceTable pieceTable) { if (Object.op_Implicit((Object)(object)pieceTable) && !((Object)pieceTable).name.Equals("_PlanHammerPieceTable")) { return !((Object)pieceTable).name.Equals("_BlueprintPieceTable"); } return false; } public void ScanPieceTables() { Logger.LogDebug((object)"Scanning PieceTables for Pieces"); PieceTable pieceTable = PieceManager.Instance.GetPieceTable("_PlanHammerPieceTable"); IEnumerable<PieceTable> enumerable = Resources.FindObjectsOfTypeAll<PieceTable>().Where(IsValidPieceTable); HashSet<string> hashSet = new HashSet<string>(); 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<Piece>(); if (!Object.op_Implicit((Object)(object)component)) { Logger.LogWarning((object)("Prefab " + ((Object)piece).name + " has no Piece?!")); } else { if (((Object)component).name == "piece_repair") { 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<Piece>(); 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<string, IEnumerable<IGrouping<PieceRequirements, Piece>>> dictionary = new Dictionary<string, IEnumerable<IGrouping<PieceRequirements, Piece>>>(); foreach (KeyValuePair<string, List<Piece>> item in NamePiecePrefabMapping) { List<Piece> value = item.Value; if (value.Count != 1) { IEnumerable<IGrouping<PieceRequirements, Piece>> 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<string, IEnumerable<IGrouping<PieceRequirements, Piece>>> item2 in dictionary) { stringBuilder.AppendLine("Piece.m_name: " + item2.Key); foreach (IGrouping<PieceRequirements, Piece> 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<string, int> dictionary = new Dictionary<string, int>(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<PlanPiecePrefab> 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<Piece> 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<Plant>() == (Object)null && (Object)(object)((Component)piece).GetComponent<TerrainOp>() == (Object)null && (Object)(object)((Component)piece).GetComponent<TerrainModifier>() == (Object)null && (Object)(object)((Component)piece).GetComponent<Ship>() == (Object)null && (Object)(object)((Component)piece).GetComponent<PlanPiece>() == (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<PlanPiece>(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<Sprite>("plan_hammer"); PieceDeletePlansPrefab = planbuildBundle.LoadAsset<GameObject>("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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Expected O, but got Unknown try { Logger.LogDebug((object)"Creating PlanHammer piece table"); IEnumerable<string> source = from