From 260755b42a6a8caeb64bdad310fd9bed945bcab9 Mon Sep 17 00:00:00 2001 From: KYPremco <33104651+KYPremco@users.noreply.github.com> Date: Sun, 21 Jan 2024 19:31:36 +0100 Subject: [PATCH] Stable 0 5 7 0 fixes (#98) * Added missing tools * Updated gamelibs * Fixed bottom bar scrolling * Removed unused imports --- .../TimberApiBootstrapSystemConfigurator.cs | 1 - .../ConsoleSystemConfigurator.cs | 3 -- Core/TimberApi/AssetSystem/AssetLoader.cs | 2 - .../BottomBarSystem/BottomBarService.cs | 1 - .../Patchers/ToolButtonPatcher.cs | 2 - .../Patchers/ToolGroupButtonPatcher.cs | 38 +++++++------------ .../Patchers/ToolbarButtonRetrieverPatcher.cs | 27 +++++++++++++ .../LocalizationSystem/LocalizationFetcher.cs | 1 - .../SpecificationTypes/FileSpecification.cs | 1 - .../ToolGroupSystem/ToolGroupService.cs | 1 - .../ToolGroupSpecificationService.cs | 1 - .../ToolGroupButtonFactory.cs | 13 ++++++- .../TimberApi/ToolSystem/IUnselectableTool.cs | 7 ++++ .../BuilderPriorityToolFactory.cs | 5 ++- .../Demolishing/DeleteRubbleToolFactory.cs | 23 +++++++++++ .../DemolishingToolConfigurator.cs | 1 + .../Demolishing/DemolishingToolGenerator.cs | 24 +++++++++++- .../Tools/SettingBox/SettingBoxTool.cs | 2 +- .../TreeCuttingAreaSelectionToolFactory.cs | 2 + .../TreeCuttingAreaUnselectionToolFactory.cs | 2 + .../WaterGeneratorToolConfigurator.cs | 17 +++++++++ .../WaterGeneratorToolFactory.cs | 23 +++++++++++ .../WaterGeneratorToolGenerator.cs | 32 ++++++++++++++++ .../Examples/ConfigExample/ExampleConfig.cs | 4 +- .../UIBuilderPanelConfigurator.cs | 1 - Examples/TimberApiExamplePlugin.cs | 3 -- GameImports.targets | 2 +- 27 files changed, 189 insertions(+), 50 deletions(-) create mode 100644 Core/TimberApi/BottomBarSystem/Patchers/ToolbarButtonRetrieverPatcher.cs create mode 100644 Core/TimberApi/ToolSystem/IUnselectableTool.cs create mode 100644 Core/TimberApi/ToolSystem/Tools/Demolishing/DeleteRubbleToolFactory.cs create mode 100644 Core/TimberApi/ToolSystem/Tools/WaterGenerator/WaterGeneratorToolConfigurator.cs create mode 100644 Core/TimberApi/ToolSystem/Tools/WaterGenerator/WaterGeneratorToolFactory.cs create mode 100644 Core/TimberApi/ToolSystem/Tools/WaterGenerator/WaterGeneratorToolGenerator.cs diff --git a/Core/TimberApi.Core/BootstrapSystem/TimberApiBootstrapSystemConfigurator.cs b/Core/TimberApi.Core/BootstrapSystem/TimberApiBootstrapSystemConfigurator.cs index 24f5697b..eb13358d 100644 --- a/Core/TimberApi.Core/BootstrapSystem/TimberApiBootstrapSystemConfigurator.cs +++ b/Core/TimberApi.Core/BootstrapSystem/TimberApiBootstrapSystemConfigurator.cs @@ -9,7 +9,6 @@ using TimberApi.Core.LoggingSystem; using TimberApi.Core.ModLoaderSystem; using TimberApi.HarmonyPatcherSystem; -using TimberApi.SceneSystem; namespace TimberApi.Core.BootstrapSystem { diff --git a/Core/TimberApi.Core/ConsoleSystem/ConsoleSystemConfigurator.cs b/Core/TimberApi.Core/ConsoleSystem/ConsoleSystemConfigurator.cs index 90a8ca6f..79a71b93 100644 --- a/Core/TimberApi.Core/ConsoleSystem/ConsoleSystemConfigurator.cs +++ b/Core/TimberApi.Core/ConsoleSystem/ConsoleSystemConfigurator.cs @@ -2,11 +2,8 @@ using Bindito.Unity; using TimberApi.Common.ConsoleSystem; using TimberApi.Common.Helpers; -using TimberApi.Common.LoggingSystem; using TimberApi.ConsoleSystem; -using Timberborn.InputSystem; using UnityEngine; -using UnityEngine.UIElements; namespace TimberApi.Core.ConsoleSystem { diff --git a/Core/TimberApi/AssetSystem/AssetLoader.cs b/Core/TimberApi/AssetSystem/AssetLoader.cs index 68bc5fd7..b4ae1be7 100644 --- a/Core/TimberApi/AssetSystem/AssetLoader.cs +++ b/Core/TimberApi/AssetSystem/AssetLoader.cs @@ -1,12 +1,10 @@ using System; -using System.Diagnostics; using System.Linq; using TimberApi.AssetSystem.Exceptions; using TimberApi.ShaderSystem; using Timberborn.Persistence; using Timberborn.SingletonSystem; using UnityEngine; -using Debug = UnityEngine.Debug; using Object = UnityEngine.Object; namespace TimberApi.AssetSystem diff --git a/Core/TimberApi/BottomBarSystem/BottomBarService.cs b/Core/TimberApi/BottomBarSystem/BottomBarService.cs index bafe4134..ecebf4aa 100644 --- a/Core/TimberApi/BottomBarSystem/BottomBarService.cs +++ b/Core/TimberApi/BottomBarSystem/BottomBarService.cs @@ -4,7 +4,6 @@ using TimberApi.Common.SingletonSystem; using TimberApi.ToolGroupSystem; using TimberApi.ToolSystem; -using Timberborn.SingletonSystem; namespace TimberApi.BottomBarSystem { diff --git a/Core/TimberApi/BottomBarSystem/Patchers/ToolButtonPatcher.cs b/Core/TimberApi/BottomBarSystem/Patchers/ToolButtonPatcher.cs index 07905039..33a703db 100644 --- a/Core/TimberApi/BottomBarSystem/Patchers/ToolButtonPatcher.cs +++ b/Core/TimberApi/BottomBarSystem/Patchers/ToolButtonPatcher.cs @@ -1,9 +1,7 @@ using HarmonyLib; using TimberApi.HarmonyPatcherSystem; using TimberApi.SceneSystem; -using Timberborn.BuilderPrioritySystemUI; using Timberborn.ToolSystem; -using UnityEngine; namespace TimberApi.BottomBarSystem.Patchers { diff --git a/Core/TimberApi/BottomBarSystem/Patchers/ToolGroupButtonPatcher.cs b/Core/TimberApi/BottomBarSystem/Patchers/ToolGroupButtonPatcher.cs index 5caf6be2..980bb87b 100644 --- a/Core/TimberApi/BottomBarSystem/Patchers/ToolGroupButtonPatcher.cs +++ b/Core/TimberApi/BottomBarSystem/Patchers/ToolGroupButtonPatcher.cs @@ -7,9 +7,13 @@ using TimberApi.HarmonyPatcherSystem; using TimberApi.SceneSystem; using TimberApi.ToolGroupSystem; +using TimberApi.ToolSystem; +using Timberborn.Common; using Timberborn.CoreUI; +using Timberborn.CursorToolSystem; using Timberborn.Debugging; using Timberborn.ToolSystem; +using UnityEngine; using UnityEngine.UIElements; namespace TimberApi.BottomBarSystem.Patchers @@ -20,8 +24,6 @@ public class ToolGroupButtonPatcher : BaseHarmonyPatcher, ITimberApiLoadableSing private static BottomBarService _bottomBarService = null!; - private static DevModeManager _devModeManager = null!; - private static readonly string ActiveClassName = "button--active"; public override string UniqueId => "TimberApi.ToolGroupButton"; @@ -29,17 +31,15 @@ public class ToolGroupButtonPatcher : BaseHarmonyPatcher, ITimberApiLoadableSing public void Load() { _bottomBarService = DependencyContainer.GetInstance(); - _devModeManager = DependencyContainer.GetInstance(); _toolGroupService = DependencyContainer.GetInstance(); } public override void Apply(Harmony harmony) { - harmony.Patch( GetMethodInfo(nameof(ToolButtonService.Add), new Type[] { typeof(ToolButton) }), GetHarmonyMethod(nameof(AddPatch))); - + harmony.Patch( AccessTools.PropertyGetter(typeof(ToolGroupButton), nameof(ToolGroupButton.IsVisible)), GetHarmonyMethod(nameof(ContainsToolPatch)) @@ -55,31 +55,21 @@ public override void Apply(Harmony harmony) GetHarmonyMethod(nameof(OnToolGroupExited)) ); } - + public static bool AddPatch(ToolButton toolButton, ToolButtonService __instance) { - if(toolButton.Tool?.Default == true) + __instance._toolButtons.Add(toolButton); + + if (toolButton.Tool.ToolGroup != null) { - __instance._toolButtons.Insert(0, toolButton); - } - else - { - __instance._toolButtons.Insert(__instance._toolButtons.Count > 0 ? 1 : 0, toolButton); + return false; } - if (toolButton.Tool?.ToolGroup == null) + + if (toolButton.Tool is not IUnselectableTool && toolButton.Tool is not CursorTool) { - if (toolButton.Root.Q("ToolImage")?.style.backgroundImage.ToString() != "Options (UnityEngine.Sprite)") - { - if (toolButton.Tool?.Default == true) - { - __instance._rootButtons.Insert(0, toolButton); - } - else - { - __instance._rootButtons.Insert(1, toolButton); - } - } + __instance._rootButtons.Add(toolButton); } + return false; } diff --git a/Core/TimberApi/BottomBarSystem/Patchers/ToolbarButtonRetrieverPatcher.cs b/Core/TimberApi/BottomBarSystem/Patchers/ToolbarButtonRetrieverPatcher.cs new file mode 100644 index 00000000..b8ca2a25 --- /dev/null +++ b/Core/TimberApi/BottomBarSystem/Patchers/ToolbarButtonRetrieverPatcher.cs @@ -0,0 +1,27 @@ +using System.Collections.Generic; +using System.Linq; +using HarmonyLib; +using TimberApi.HarmonyPatcherSystem; +using Timberborn.ToolSystem; + +namespace TimberApi.BottomBarSystem.Patchers +{ + public class ToolbarButtonRetrieverPatcher : BaseHarmonyPatcher + { + public override string UniqueId => "TimberApi.ToolButtonRetriever"; + + public override void Apply(Harmony harmony) + { + harmony.Patch( + GetMethodInfo(nameof(ToolbarButtonRetriever.TryGetPreviousVisibleButton)), + GetHarmonyMethod(nameof(TryGetPreviousVisibleButtonPatch)) + ); + } + + public static bool TryGetPreviousVisibleButtonPatch(IEnumerable buttons, out IToolbarButton? previousButton) + { + previousButton = null; + return buttons.Any(button => button.IsVisible); + } + } +} \ No newline at end of file diff --git a/Core/TimberApi/LocalizationSystem/LocalizationFetcher.cs b/Core/TimberApi/LocalizationSystem/LocalizationFetcher.cs index 7f6e94b2..e013a94e 100644 --- a/Core/TimberApi/LocalizationSystem/LocalizationFetcher.cs +++ b/Core/TimberApi/LocalizationSystem/LocalizationFetcher.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; diff --git a/Core/TimberApi/SpecificationSystem/SpecificationTypes/FileSpecification.cs b/Core/TimberApi/SpecificationSystem/SpecificationTypes/FileSpecification.cs index ab7d2453..c3a3c320 100644 --- a/Core/TimberApi/SpecificationSystem/SpecificationTypes/FileSpecification.cs +++ b/Core/TimberApi/SpecificationSystem/SpecificationTypes/FileSpecification.cs @@ -1,5 +1,4 @@ using System.IO; -using UnityEngine; namespace TimberApi.SpecificationSystem.SpecificationTypes { diff --git a/Core/TimberApi/ToolGroupSystem/ToolGroupService.cs b/Core/TimberApi/ToolGroupSystem/ToolGroupService.cs index 19fb6bde..28bfc124 100644 --- a/Core/TimberApi/ToolGroupSystem/ToolGroupService.cs +++ b/Core/TimberApi/ToolGroupSystem/ToolGroupService.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; diff --git a/Core/TimberApi/ToolGroupSystem/ToolGroupSpecificationService.cs b/Core/TimberApi/ToolGroupSystem/ToolGroupSpecificationService.cs index 370d1f33..7d26ed37 100644 --- a/Core/TimberApi/ToolGroupSystem/ToolGroupSpecificationService.cs +++ b/Core/TimberApi/ToolGroupSystem/ToolGroupSpecificationService.cs @@ -3,7 +3,6 @@ using System.Linq; using TimberApi.Common.SingletonSystem; using Timberborn.Persistence; -using UnityEngine; namespace TimberApi.ToolGroupSystem { diff --git a/Core/TimberApi/ToolGroupUISystem/ToolGroupButtonFactory.cs b/Core/TimberApi/ToolGroupUISystem/ToolGroupButtonFactory.cs index a91cecbd..81353cb6 100644 --- a/Core/TimberApi/ToolGroupUISystem/ToolGroupButtonFactory.cs +++ b/Core/TimberApi/ToolGroupUISystem/ToolGroupButtonFactory.cs @@ -1,4 +1,5 @@ using System; +using TimberApi.ToolGroupSystem; using Timberborn.AssetSystem; using Timberborn.CoreUI; using Timberborn.Localization; @@ -56,7 +57,7 @@ public ToolGroupButton Create(ToolGroup toolGroup, Sprite toolGroupImage, Sprite visualElement.Q("ToolButtons"), visualElement.Q("ToolGroupButtonWrapper")); _eventBus.Register(toolGroupButton); - _toolButtonService.Add(toolGroupButton); + Add((IToolGroup)toolGroup, toolGroupButton); return toolGroupButton; } @@ -84,5 +85,15 @@ private void OnButtonClick(VisualElement tooltip, ToolGroup toolGroup) tooltip.parent.ToggleDisplayStyle(false); } } + + private void Add(IToolGroup toolGroup, ToolGroupButton toolButton) + { + _toolButtonService._toolGroupButtons.Add(toolButton); + + if (toolGroup.GroupId == null) + { + _toolButtonService._rootButtons.Add(toolButton); + } + } } } \ No newline at end of file diff --git a/Core/TimberApi/ToolSystem/IUnselectableTool.cs b/Core/TimberApi/ToolSystem/IUnselectableTool.cs new file mode 100644 index 00000000..3e0d560e --- /dev/null +++ b/Core/TimberApi/ToolSystem/IUnselectableTool.cs @@ -0,0 +1,7 @@ +namespace TimberApi.ToolSystem +{ + public interface IUnselectableTool + { + + } +} \ No newline at end of file diff --git a/Core/TimberApi/ToolSystem/Tools/BuilderPriority/BuilderPriorityToolFactory.cs b/Core/TimberApi/ToolSystem/Tools/BuilderPriority/BuilderPriorityToolFactory.cs index 58808a35..505edab6 100644 --- a/Core/TimberApi/ToolSystem/Tools/BuilderPriority/BuilderPriorityToolFactory.cs +++ b/Core/TimberApi/ToolSystem/Tools/BuilderPriority/BuilderPriorityToolFactory.cs @@ -17,7 +17,10 @@ public BuilderPriorityToolFactory(TimberbornBuilderPriorityToolFactory builderPr protected override Tool CreateTool(ToolSpecification toolSpecification, BuilderPriorityToolToolInformation toolInformation, ToolGroup? toolGroup) { - return _builderPriorityToolFactory.Create(toolInformation.Priority); + var priorityTool = _builderPriorityToolFactory.Create(toolInformation.Priority); + priorityTool.ToolGroup = toolGroup; + + return priorityTool; } protected override BuilderPriorityToolToolInformation DeserializeToolInformation(IObjectLoader objectLoader) diff --git a/Core/TimberApi/ToolSystem/Tools/Demolishing/DeleteRubbleToolFactory.cs b/Core/TimberApi/ToolSystem/Tools/Demolishing/DeleteRubbleToolFactory.cs new file mode 100644 index 00000000..12a09db2 --- /dev/null +++ b/Core/TimberApi/ToolSystem/Tools/Demolishing/DeleteRubbleToolFactory.cs @@ -0,0 +1,23 @@ +using Timberborn.RecoveredGoodSystemUI; +using Timberborn.ToolSystem; + +namespace TimberApi.ToolSystem.Tools.Demolishing +{ + public class DeleteRubbleToolFactory : IToolFactory + { + public string Id => "DeleteRecoveredGoodStackTool"; + + private readonly RecoveredGoodStackDeletionTool _recoveredGoodStackDeletionTool; + + public DeleteRubbleToolFactory(RecoveredGoodStackDeletionTool recoveredGoodStackDeletionTool) + { + _recoveredGoodStackDeletionTool = recoveredGoodStackDeletionTool; + } + + public Tool Create(ToolSpecification toolSpecification, ToolGroup? toolGroup = null) + { + _recoveredGoodStackDeletionTool.Initialize(toolGroup); + return _recoveredGoodStackDeletionTool; + } + } +} \ No newline at end of file diff --git a/Core/TimberApi/ToolSystem/Tools/Demolishing/DemolishingToolConfigurator.cs b/Core/TimberApi/ToolSystem/Tools/Demolishing/DemolishingToolConfigurator.cs index 930b6f9d..851da401 100644 --- a/Core/TimberApi/ToolSystem/Tools/Demolishing/DemolishingToolConfigurator.cs +++ b/Core/TimberApi/ToolSystem/Tools/Demolishing/DemolishingToolConfigurator.cs @@ -14,6 +14,7 @@ public void Configure(IContainerDefinition containerDefinition) containerDefinition.MultiBind().To().AsSingleton(); containerDefinition.MultiBind().To().AsSingleton(); containerDefinition.MultiBind().To().AsSingleton(); + containerDefinition.MultiBind().To().AsSingleton(); containerDefinition.MultiBind().To().AsSingleton(); } } diff --git a/Core/TimberApi/ToolSystem/Tools/Demolishing/DemolishingToolGenerator.cs b/Core/TimberApi/ToolSystem/Tools/Demolishing/DemolishingToolGenerator.cs index 3aec0460..3c701194 100644 --- a/Core/TimberApi/ToolSystem/Tools/Demolishing/DemolishingToolGenerator.cs +++ b/Core/TimberApi/ToolSystem/Tools/Demolishing/DemolishingToolGenerator.cs @@ -11,6 +11,7 @@ public IEnumerable Generate() { yield return CreateDemolishingToolGroup(); yield return DemolishableSelectionTool(); + yield return DeleteRecoveredGoodStackTool(); yield return DemolishableUnselectionTool(); yield return BuildingDeconstructionTool(); yield return EntityBlockObjectDeletionTool(); @@ -24,7 +25,7 @@ private static GeneratedSpecification EntityBlockObjectDeletionTool() GroupId = "Demolishing", Type = "EntityBlockObjectDeletionTool", Layout = "Default", - Order = 20, + Order = 30, NameLocKey = "CAN NOT BE MODIFIED", DescriptionLocKey = "CAN NOT BE MODIFIED", Icon = "Sprites/BottomBar/DeleteObjectIcon", @@ -34,6 +35,25 @@ private static GeneratedSpecification EntityBlockObjectDeletionTool() return new GeneratedSpecification(json, "EntityBlockObjectDeletion", "ToolSpecification"); } + + private static GeneratedSpecification DeleteRecoveredGoodStackTool() + { + var json = JsonConvert.SerializeObject(new + { + Id = "DeleteRecoveredGoodStack", + GroupId = "Demolishing", + Type = "DeleteRecoveredGoodStackTool", + Layout = "Default", + Order = 10, + NameLocKey = "CAN NOT BE MODIFIED", + DescriptionLocKey = "CAN NOT BE MODIFIED", + Icon = "Sprites/BottomBar/DeleteRecoveredGoodStackToolIcon", + DevMode = false, + Hidden = false, + }); + + return new GeneratedSpecification(json, "EntityBlockObjectDeletion", "ToolSpecification"); + } private static GeneratedSpecification BuildingDeconstructionTool() { @@ -62,7 +82,7 @@ private static GeneratedSpecification DemolishableSelectionTool() GroupId = "Demolishing", Type = "DemolishableSelectionTool", Layout = "Default", - Order = 10, + Order = 20, NameLocKey = "CAN NOT BE MODIFIED", DescriptionLocKey = "CAN NOT BE MODIFIED", Icon = "Sprites/BottomBar/DemolishResourcesTool", diff --git a/Core/TimberApi/ToolSystem/Tools/SettingBox/SettingBoxTool.cs b/Core/TimberApi/ToolSystem/Tools/SettingBox/SettingBoxTool.cs index b30193ec..e9a01a71 100644 --- a/Core/TimberApi/ToolSystem/Tools/SettingBox/SettingBoxTool.cs +++ b/Core/TimberApi/ToolSystem/Tools/SettingBox/SettingBoxTool.cs @@ -4,7 +4,7 @@ namespace TimberApi.ToolSystem.Tools.SettingBox { - public class SettingBoxTool : Tool + public class SettingBoxTool : Tool, IUnselectableTool { private readonly ToolGroupManager _toolGroupManager; diff --git a/Core/TimberApi/ToolSystem/Tools/TreeCuttingArea/TreeCuttingAreaSelectionToolFactory.cs b/Core/TimberApi/ToolSystem/Tools/TreeCuttingArea/TreeCuttingAreaSelectionToolFactory.cs index 4601a781..264e2d13 100644 --- a/Core/TimberApi/ToolSystem/Tools/TreeCuttingArea/TreeCuttingAreaSelectionToolFactory.cs +++ b/Core/TimberApi/ToolSystem/Tools/TreeCuttingArea/TreeCuttingAreaSelectionToolFactory.cs @@ -16,6 +16,8 @@ public TreeCuttingAreaSelectionToolFactory(TreeCuttingAreaSelectionTool treeCutt public Tool Create(ToolSpecification toolSpecification, ToolGroup? toolGroup = null) { + _treeCuttingAreaSelectionTool.ToolGroup = toolGroup; + return _treeCuttingAreaSelectionTool; } } diff --git a/Core/TimberApi/ToolSystem/Tools/TreeCuttingArea/TreeCuttingAreaUnselectionToolFactory.cs b/Core/TimberApi/ToolSystem/Tools/TreeCuttingArea/TreeCuttingAreaUnselectionToolFactory.cs index 093c93eb..93f9bc81 100644 --- a/Core/TimberApi/ToolSystem/Tools/TreeCuttingArea/TreeCuttingAreaUnselectionToolFactory.cs +++ b/Core/TimberApi/ToolSystem/Tools/TreeCuttingArea/TreeCuttingAreaUnselectionToolFactory.cs @@ -17,6 +17,8 @@ public TreeCuttingAreaUnselectionToolFactory(TreeCuttingAreaUnselectionTool tree public Tool Create(ToolSpecification toolSpecification, ToolGroup? toolGroup = null) { + _treeCuttingAreaUnselectionTool.ToolGroup = toolGroup; + return _treeCuttingAreaUnselectionTool; } } diff --git a/Core/TimberApi/ToolSystem/Tools/WaterGenerator/WaterGeneratorToolConfigurator.cs b/Core/TimberApi/ToolSystem/Tools/WaterGenerator/WaterGeneratorToolConfigurator.cs new file mode 100644 index 00000000..56c5be5c --- /dev/null +++ b/Core/TimberApi/ToolSystem/Tools/WaterGenerator/WaterGeneratorToolConfigurator.cs @@ -0,0 +1,17 @@ +using Bindito.Core; +using TimberApi.ConfiguratorSystem; +using TimberApi.SceneSystem; +using TimberApi.SpecificationSystem; + +namespace TimberApi.ToolSystem.Tools.WaterGenerator +{ + [Configurator(SceneEntrypoint.InGame)] + public class WaterGeneratorToolConfigurator : IConfigurator + { + public void Configure(IContainerDefinition containerDefinition) + { + containerDefinition.MultiBind().To().AsSingleton(); + containerDefinition.MultiBind().To().AsSingleton(); + } + } +} \ No newline at end of file diff --git a/Core/TimberApi/ToolSystem/Tools/WaterGenerator/WaterGeneratorToolFactory.cs b/Core/TimberApi/ToolSystem/Tools/WaterGenerator/WaterGeneratorToolFactory.cs new file mode 100644 index 00000000..6fc5034f --- /dev/null +++ b/Core/TimberApi/ToolSystem/Tools/WaterGenerator/WaterGeneratorToolFactory.cs @@ -0,0 +1,23 @@ +using Timberborn.ToolSystem; +using Timberborn.WaterBrushesUI; + +namespace TimberApi.ToolSystem.Tools.WaterGenerator +{ + public class WaterGeneratorToolFactory : IToolFactory + { + public string Id => "WaterGeneratorTool"; + + private readonly WaterHeightBrushTool _waterHeightBrushTool; + + public WaterGeneratorToolFactory(WaterHeightBrushTool waterHeightBrushTool) + { + _waterHeightBrushTool = waterHeightBrushTool; + } + + public Tool Create(ToolSpecification toolSpecification, ToolGroup? toolGroup = null) + { + _waterHeightBrushTool.ToolGroup = toolGroup; + return _waterHeightBrushTool; + } + } +} \ No newline at end of file diff --git a/Core/TimberApi/ToolSystem/Tools/WaterGenerator/WaterGeneratorToolGenerator.cs b/Core/TimberApi/ToolSystem/Tools/WaterGenerator/WaterGeneratorToolGenerator.cs new file mode 100644 index 00000000..f762d49d --- /dev/null +++ b/Core/TimberApi/ToolSystem/Tools/WaterGenerator/WaterGeneratorToolGenerator.cs @@ -0,0 +1,32 @@ +using System.Collections.Generic; +using Newtonsoft.Json; +using TimberApi.SpecificationSystem; +using TimberApi.SpecificationSystem.SpecificationTypes; + +namespace TimberApi.ToolSystem.Tools.WaterGenerator +{ + public class WaterGeneratorToolGenerator : ISpecificationGenerator + { + public IEnumerable Generate() + { + var json = JsonConvert.SerializeObject(new + { + Id = "WaterGenerator", + Type = "WaterGeneratorTool", + Layout = "GrouplessRed", + Order = 80, + NameLocKey = "Cursor", + DescriptionLocKey = "Cursor", + Icon = "Sprites/BottomBar/WaterHeightBrushTool", + DevMode = true, + Hidden = false, + ToolInformation = new + { + BottomBarSection = 0 + } + }); + + yield return new GeneratedSpecification(json, "WaterGenerator", "ToolSpecification"); + } + } +} \ No newline at end of file diff --git a/Examples/Examples/ConfigExample/ExampleConfig.cs b/Examples/Examples/ConfigExample/ExampleConfig.cs index b1d12ff3..aafcae57 100644 --- a/Examples/Examples/ConfigExample/ExampleConfig.cs +++ b/Examples/Examples/ConfigExample/ExampleConfig.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; +using System.Collections.Generic; using TimberApi.ConfigSystem; namespace TimberAPIExample.Examples.ConfigExample diff --git a/Examples/Examples/UIBuilderExample/UIBuilderPreviewPanel/UIBuilderPanelConfigurator.cs b/Examples/Examples/UIBuilderExample/UIBuilderPreviewPanel/UIBuilderPanelConfigurator.cs index 74cb0ae7..b5a8a883 100644 --- a/Examples/Examples/UIBuilderExample/UIBuilderPreviewPanel/UIBuilderPanelConfigurator.cs +++ b/Examples/Examples/UIBuilderExample/UIBuilderPreviewPanel/UIBuilderPanelConfigurator.cs @@ -7,7 +7,6 @@ using TimberApi.UiBuilderSystem.CustomElements; using TimberAPIExample.Examples.UIBuilderExample.UIBuilderPreviewPanel.Previews; using Timberborn.MainMenuScene; -using Timberborn.Options; using UnityEngine.UIElements; namespace TimberAPIExample.Examples.UIBuilderExample.UIBuilderPreviewPanel diff --git a/Examples/TimberApiExamplePlugin.cs b/Examples/TimberApiExamplePlugin.cs index dcd4ee42..80e22c8c 100644 --- a/Examples/TimberApiExamplePlugin.cs +++ b/Examples/TimberApiExamplePlugin.cs @@ -1,9 +1,6 @@ using HarmonyLib; using TimberApi.ModSystem; using TimberApi.ConsoleSystem; -using Bindito.Core; -using TimberApi.ConfiguratorSystem; -using TimberApi.SceneSystem; using TimberAPIExample.Examples.ConfigExample; namespace TimberAPIExample diff --git a/GameImports.targets b/GameImports.targets index 6fc8c602..f1af619f 100644 --- a/GameImports.targets +++ b/GameImports.targets @@ -15,7 +15,7 @@ - +