diff --git a/Core/TimberApi.Core/ConfiguratorSystem/ConfiguratorPatcher.cs b/Core/TimberApi.Core/ConfiguratorSystem/ConfiguratorPatcher.cs index 6705c675..d74b1742 100644 --- a/Core/TimberApi.Core/ConfiguratorSystem/ConfiguratorPatcher.cs +++ b/Core/TimberApi.Core/ConfiguratorSystem/ConfiguratorPatcher.cs @@ -14,13 +14,13 @@ public class ConfiguratorPatcher : BaseHarmonyPatcher public override void Apply(Harmony harmony) { - harmony.Patch(AccessTools.Method(typeof(GameSceneConfigurator), "Configure"), + harmony.Patch(AccessTools.Method(typeof(GameSceneInstaller), nameof(GameSceneInstaller.Configure)), new HarmonyMethod(AccessTools.Method(typeof(ConfiguratorPatcher), nameof(PatchMasterSceneConfigurator)))); - harmony.Patch(AccessTools.Method(typeof(MainMenuSceneConfigurator), "Configure"), + harmony.Patch(AccessTools.Method(typeof(MainMenuSceneConfigurator), nameof(MainMenuSceneConfigurator.Configure)), new HarmonyMethod(AccessTools.Method(typeof(ConfiguratorPatcher), nameof(PatchMainMenuSceneConfigurator)))); - harmony.Patch(AccessTools.Method(typeof(MapEditorSceneConfigurator), "Configure"), + harmony.Patch(AccessTools.Method(typeof(MapEditorSceneConfigurator), nameof(MainMenuSceneConfigurator.Configure)), new HarmonyMethod(AccessTools.Method(typeof(ConfiguratorPatcher), nameof(PatchMapEditorSceneConfigurator)))); } diff --git a/Core/TimberApi.Core/ConsoleSystem/ConsoleMonitor.cs b/Core/TimberApi.Core/ConsoleSystem/ConsoleMonitor.cs deleted file mode 100644 index a2c8dc20..00000000 --- a/Core/TimberApi.Core/ConsoleSystem/ConsoleMonitor.cs +++ /dev/null @@ -1,72 +0,0 @@ -using System; -using System.IO; -using System.Linq; -using TimberApi.Common; -using TimberApi.Common.LoggingSystem; -using TimberApi.Core.ConsoleSystemUi; -using TimberApi.Core.LoggingSystem; -using Timberborn.InputSystem; -using UnityEngine; -using UnityEngine.InputSystem; -using UnityEngine.UIElements; - -namespace TimberApi.Core.ConsoleSystem -{ - internal class ConsoleMonitor : MonoBehaviour, ILogListener - { - private static readonly Key ConsoleKey = Key.Backslash; - private bool _isConsoleKeyPressed; - - private KeyboardController _keyboardController = null!; - private ConsoleMonitorController _monitorController = null!; - - private void Awake() - { - try - { - _keyboardController = GetComponent(); - var uiDocument = GetComponent(); - uiDocument.panelSettings = Resources.FindObjectsOfTypeAll() - .First(document => document != uiDocument).panelSettings; - uiDocument.sortingOrder = 100000; - - VisualElement consoleMonitor = ConsoleMonitorUi.Create(); - uiDocument.rootVisualElement.Add(consoleMonitor); - - _monitorController = new ConsoleMonitorController(consoleMonitor); - Application.logMessageReceivedThreaded += OnUnityLogMessageReceived; - } - catch (Exception e) - { - File.WriteAllText(Path.Combine(Paths.Logs, "ConsoleMonitorException.txt"), e.ToString()); - throw; - } - } - - private void Update() - { - if (!_keyboardController.IsKeyHeld(ConsoleKey)) - { - _isConsoleKeyPressed = false; - } - - if (!_keyboardController.IsKeyHeld(ConsoleKey) || _isConsoleKeyPressed) - { - return; - } - - _isConsoleKeyPressed = true; - _monitorController.ToggleConsole(); - } - - public void OnLogMessageReceived(string tagName, string message, string stacktrace, LogType type, Color color) - { - _monitorController.AddLog(tagName, message, stacktrace, type, color); - } - - private void OnUnityLogMessageReceived(string message, string stacktrace, LogType type) - { - _monitorController.AddLog("Unity", message, stacktrace, type, LogTextColors.Internal[type]); - } - } -} diff --git a/Core/TimberApi.Core/ConsoleSystem/ConsoleSystemConfigurator.cs b/Core/TimberApi.Core/ConsoleSystem/ConsoleSystemConfigurator.cs index c3e40ac7..90a8ca6f 100644 --- a/Core/TimberApi.Core/ConsoleSystem/ConsoleSystemConfigurator.cs +++ b/Core/TimberApi.Core/ConsoleSystem/ConsoleSystemConfigurator.cs @@ -14,16 +14,13 @@ internal class ConsoleSystemConfigurator : PrefabConfigurator { public override void Configure(IContainerDefinition containerDefinition) { - containerDefinition.MultiBind().ToInstance(GetInstanceFromPrefab()); containerDefinition.Bind().To().AsSingleton(); containerDefinition.Bind().To().AsSingleton(); } public static void Prefab(GameObject parent) { - PrefabBuilder.Create("ConsoleSystemConfigurator") - .AddGameObject("ConsoleMonitor", consoleMonitor => consoleMonitor.AddComponent().AddComponent().AddComponent()) - .FinishAndSetParent(parent); + PrefabBuilder.Create("ConsoleSystemConfigurator").FinishAndSetParent(parent); } } } \ No newline at end of file diff --git a/Core/TimberApi.Core/ModLoaderSystem/ModLoader.cs b/Core/TimberApi.Core/ModLoaderSystem/ModLoader.cs index 5de9ae56..f5e51995 100644 --- a/Core/TimberApi.Core/ModLoaderSystem/ModLoader.cs +++ b/Core/TimberApi.Core/ModLoaderSystem/ModLoader.cs @@ -13,7 +13,7 @@ using TimberApi.Core.ModLoaderSystem.ObjectDeserializers; using TimberApi.ModSystem; using Timberborn.Persistence; -using Timberborn.WorldSerialization; +using Timberborn.SerializationSystem; using UnityEngine; using Logger = TimberApi.Core.LoggingSystem.Logger; diff --git a/Core/TimberApi.Core/ModLoaderSystem/ModLoaderSystemConfigurator.cs b/Core/TimberApi.Core/ModLoaderSystem/ModLoaderSystemConfigurator.cs index 526b3508..d784c509 100644 --- a/Core/TimberApi.Core/ModLoaderSystem/ModLoaderSystemConfigurator.cs +++ b/Core/TimberApi.Core/ModLoaderSystem/ModLoaderSystemConfigurator.cs @@ -3,7 +3,7 @@ using TimberApi.Common.Helpers; using TimberApi.Core.ModLoaderSystem.ObjectDeserializers; using TimberApi.ModSystem; -using Timberborn.WorldSerialization; +using Timberborn.SerializationSystem; using UnityEngine; namespace TimberApi.Core.ModLoaderSystem diff --git a/Core/TimberApi/AssetSystem/AssetSpecificationDeserializer.cs b/Core/TimberApi/AssetSystem/AssetSpecificationDeserializer.cs index 8ca442a3..58514909 100644 --- a/Core/TimberApi/AssetSystem/AssetSpecificationDeserializer.cs +++ b/Core/TimberApi/AssetSystem/AssetSpecificationDeserializer.cs @@ -1,4 +1,5 @@ using System.Collections.Immutable; +using TimberApi.Common.Extensions; using Timberborn.Persistence; namespace TimberApi.AssetSystem @@ -13,7 +14,7 @@ public void Serialize(AssetSpecification value, IObjectSaver objectSaver) public Obsoletable Deserialize(IObjectLoader objectLoader) { return new AssetSpecification( - objectLoader.GetValueOrDefault(new ListKey("IgnoreDirectoryPrefixes")).ToImmutableArray() + objectLoader.GetValueOrEmpty(new ListKey("IgnoreDirectoryPrefixes")).ToImmutableArray() ); } } diff --git a/Core/TimberApi/BottomBarSystem/BottomBarButton.cs b/Core/TimberApi/BottomBarSystem/BottomBarButton.cs index 84fe44a7..04e13999 100644 --- a/Core/TimberApi/BottomBarSystem/BottomBarButton.cs +++ b/Core/TimberApi/BottomBarSystem/BottomBarButton.cs @@ -1,5 +1,5 @@ using System; -using Timberborn.WorldSerialization; +using Timberborn.SerializationSystem; namespace TimberApi.BottomBarSystem { diff --git a/Core/TimberApi/ObjectSelectionSystem/PickObjectTool.cs b/Core/TimberApi/ObjectSelectionSystem/PickObjectTool.cs index cd011bcf..261502a2 100644 --- a/Core/TimberApi/ObjectSelectionSystem/PickObjectTool.cs +++ b/Core/TimberApi/ObjectSelectionSystem/PickObjectTool.cs @@ -95,7 +95,7 @@ public bool ProcessInput() { _highlighter.HighlightSecondary(hitObject, _colors.EntitySelection); _warning = _validateCandidate(hitObject.GameObjectFast); - if (_inputService is { SelectionStart: true, MouseOverUI: false }) + if (_inputService is { MainMouseButtonDown: true, MouseOverUI: false }) { _toolManager.SwitchToDefaultTool(); _callback(hitObject.GameObjectFast); diff --git a/Core/TimberApi/SpecificationSystem/ApiSpecificationService.cs b/Core/TimberApi/SpecificationSystem/ApiSpecificationService.cs index c24f3cab..ae0bbcf0 100644 --- a/Core/TimberApi/SpecificationSystem/ApiSpecificationService.cs +++ b/Core/TimberApi/SpecificationSystem/ApiSpecificationService.cs @@ -2,7 +2,7 @@ using System.Linq; using Newtonsoft.Json.Linq; using Timberborn.Persistence; -using Timberborn.WorldSerialization; +using Timberborn.SerializationSystem; namespace TimberApi.SpecificationSystem { diff --git a/Core/TimberApi/ToolGroupSystem/ToolGroupSpecification.cs b/Core/TimberApi/ToolGroupSystem/ToolGroupSpecification.cs index 8bf2af08..2aa6aa29 100644 --- a/Core/TimberApi/ToolGroupSystem/ToolGroupSpecification.cs +++ b/Core/TimberApi/ToolGroupSystem/ToolGroupSpecification.cs @@ -1,4 +1,4 @@ -using Timberborn.WorldSerialization; +using Timberborn.SerializationSystem; using UnityEngine; namespace TimberApi.ToolGroupSystem diff --git a/Core/TimberApi/ToolGroupSystem/ToolGroupSpecificationDeserializer.cs b/Core/TimberApi/ToolGroupSystem/ToolGroupSpecificationDeserializer.cs index 999bdf77..97016680 100644 --- a/Core/TimberApi/ToolGroupSystem/ToolGroupSpecificationDeserializer.cs +++ b/Core/TimberApi/ToolGroupSystem/ToolGroupSpecificationDeserializer.cs @@ -2,7 +2,7 @@ using TimberApi.Common.Extensions; using Timberborn.AssetSystem; using Timberborn.Persistence; -using Timberborn.WorldSerialization; +using Timberborn.SerializationSystem; using UnityEngine; namespace TimberApi.ToolGroupSystem diff --git a/Core/TimberApi/ToolSystem/ToolSpecification.cs b/Core/TimberApi/ToolSystem/ToolSpecification.cs index 2b1f8b07..302fb05c 100644 --- a/Core/TimberApi/ToolSystem/ToolSpecification.cs +++ b/Core/TimberApi/ToolSystem/ToolSpecification.cs @@ -1,4 +1,4 @@ -using Timberborn.WorldSerialization; +using Timberborn.SerializationSystem; using UnityEngine; namespace TimberApi.ToolSystem diff --git a/Core/TimberApi/ToolSystem/ToolSpecificationDeserliaser.cs b/Core/TimberApi/ToolSystem/ToolSpecificationDeserliaser.cs index e951e3ad..8a01002a 100644 --- a/Core/TimberApi/ToolSystem/ToolSpecificationDeserliaser.cs +++ b/Core/TimberApi/ToolSystem/ToolSpecificationDeserliaser.cs @@ -1,7 +1,7 @@ using System; using TimberApi.Common.Extensions; using Timberborn.Persistence; -using Timberborn.WorldSerialization; +using Timberborn.SerializationSystem; namespace TimberApi.ToolSystem { diff --git a/Core/TimberApi/ToolSystem/Tools/SettingBox/SettingBoxTool.cs b/Core/TimberApi/ToolSystem/Tools/SettingBox/SettingBoxTool.cs index dac4188f..b30193ec 100644 --- a/Core/TimberApi/ToolSystem/Tools/SettingBox/SettingBoxTool.cs +++ b/Core/TimberApi/ToolSystem/Tools/SettingBox/SettingBoxTool.cs @@ -1,27 +1,26 @@ using TimberApi.ToolGroupSystem; using Timberborn.Options; -using Timberborn.SingletonSystem; using Timberborn.ToolSystem; namespace TimberApi.ToolSystem.Tools.SettingBox { public class SettingBoxTool : Tool { - private readonly EventBus _eventBus; - private readonly ToolGroupManager _toolGroupManager; - public SettingBoxTool(ToolGroup? toolGroup, EventBus eventBus, ToolGroupManager toolGroupManager) + private readonly IOptionsBox _optionsBox; + + public SettingBoxTool(ToolGroup? toolGroup, ToolGroupManager toolGroupManager, IOptionsBox optionsBox) { ToolGroup = toolGroup; - _eventBus = eventBus; _toolGroupManager = toolGroupManager; + _optionsBox = optionsBox; } public override void Enter() { _toolGroupManager.SwitchToolGroup(new ExitingToolGroup()); - _eventBus.Post(new ShowOptionsEvent()); + _optionsBox.Show(); } public override void Exit() diff --git a/Core/TimberApi/ToolSystem/Tools/SettingBox/SettingBoxToolFactory.cs b/Core/TimberApi/ToolSystem/Tools/SettingBox/SettingBoxToolFactory.cs index 649ca10a..2dcf319f 100644 --- a/Core/TimberApi/ToolSystem/Tools/SettingBox/SettingBoxToolFactory.cs +++ b/Core/TimberApi/ToolSystem/Tools/SettingBox/SettingBoxToolFactory.cs @@ -1,25 +1,25 @@ -using Timberborn.SingletonSystem; +using Timberborn.Options; using Timberborn.ToolSystem; namespace TimberApi.ToolSystem.Tools.SettingBox { public class SettingBoxToolFactory : IToolFactory { - private readonly EventBus _eventBus; + private readonly IOptionsBox _optionsBox; private readonly ToolGroupManager _toolGroupManager; - public SettingBoxToolFactory(EventBus eventBus, ToolGroupManager toolGroupManager) + public SettingBoxToolFactory(ToolGroupManager toolGroupManager, IOptionsBox optionsBox) { - _eventBus = eventBus; _toolGroupManager = toolGroupManager; + _optionsBox = optionsBox; } public string Id => "SettingBoxTool"; public Tool Create(ToolSpecification toolSpecification, ToolGroup? toolGroup = null) { - return new SettingBoxTool(toolGroup, _eventBus, _toolGroupManager); + return new SettingBoxTool(toolGroup, _toolGroupManager, _optionsBox); } } } \ No newline at end of file diff --git a/GameImports.targets b/GameImports.targets index 8240240f..6fc8c602 100644 --- a/GameImports.targets +++ b/GameImports.targets @@ -15,7 +15,7 @@ - +