From 8c644fe66865be029f83e68d8a61bed76fe38448 Mon Sep 17 00:00:00 2001 From: algernon-A Date: Mon, 25 Dec 2023 12:54:46 +1100 Subject: [PATCH] 1.3.2 - Fix XP being gained when previewing some buildings and roundabouts. --- BepInEx/Plugin.cs | 2 +- BepInEx/manifest.json | 2 +- CHANGELOG.md | 4 +++- Code/Systems/LineToolSystem.cs | 40 ++++++++++++++++---------------- Code/Systems/LineToolUISystem.cs | 3 --- LineToolLite.csproj | 2 +- UI/modes.html | 2 +- 7 files changed, 27 insertions(+), 28 deletions(-) diff --git a/BepInEx/Plugin.cs b/BepInEx/Plugin.cs index 9927ba4..33b085e 100644 --- a/BepInEx/Plugin.cs +++ b/BepInEx/Plugin.cs @@ -16,7 +16,7 @@ namespace LineTool /// /// BepInEx plugin to substitute for IMod support. /// - [BepInPlugin(GUID, "Line Tool Lite", "1.3.1")] + [BepInPlugin(GUID, "Line Tool Lite", "1.3.2")] [HarmonyPatch] public class Plugin : BaseUnityPlugin { diff --git a/BepInEx/manifest.json b/BepInEx/manifest.json index 58a6750..64ff518 100644 --- a/BepInEx/manifest.json +++ b/BepInEx/manifest.json @@ -1,6 +1,6 @@ { "name": "Line_Tool_Lite", - "version_number": "1.3.1", + "version_number": "1.3.2", "website_url": "https://github.com/algernon-A/LineToolLite", "description": "Place objects in lines, curves, or circles. A variety of options and controls are availalbe to specify and fine-tune results.", "dependencies": [ diff --git a/CHANGELOG.md b/CHANGELOG.md index 619f63d..de25c08 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,9 @@ +## 1.3.2 +- Fix XP being gained when previewing some buildings and roundabouts. + ## 1.3.1 - Update README with tool mode location image. - ## 1.3 - Add integration with existing tool panels (no more hotkey). - Add initial localizations for Simplified Chinese, German, and Spanish from CrowdIn translation volunteers. diff --git a/Code/Systems/LineToolSystem.cs b/Code/Systems/LineToolSystem.cs index 19689ae..f40b924 100644 --- a/Code/Systems/LineToolSystem.cs +++ b/Code/Systems/LineToolSystem.cs @@ -255,16 +255,7 @@ private PrefabBase SelectedPrefab { set { - // Don't do anything else if no change. - ObjectGeometryPrefab geometryPrefab = value as ObjectGeometryPrefab; - if (_selectedPrefab == geometryPrefab) - { - return; - } - - // Revert XP changes and get new value. - RestoreXP(); - _selectedPrefab = geometryPrefab; + _selectedPrefab = value as ObjectGeometryPrefab; // Update selected entity. if (_selectedPrefab is null) @@ -291,16 +282,7 @@ private PrefabBase SelectedPrefab } // Reduce any XP to zero while we're using the tool. - if (EntityManager.TryGetComponent(_selectedEntity, out PlaceableObjectData placeableData)) - { - _originalXP = placeableData.m_XPReward; - placeableData.m_XPReward = 0; - EntityManager.SetComponentData(_selectedEntity, placeableData); - } - else - { - _originalXP = 0; - } + SaveXP(); } } } @@ -804,6 +786,24 @@ private Entity CreateEntity() return newEntity; } + /// + /// Reduces XP gain for the current object to zero and records the original value. + /// + private void SaveXP() + { + // Reduce any XP to zero while we're using the tool. + if (EntityManager.TryGetComponent(_selectedEntity, out PlaceableObjectData placeableData)) + { + _originalXP = placeableData.m_XPReward; + placeableData.m_XPReward = 0; + EntityManager.SetComponentData(_selectedEntity, placeableData); + } + else + { + _originalXP = 0; + } + } + /// /// Restores the selected prefab's original XP gain. /// diff --git a/Code/Systems/LineToolUISystem.cs b/Code/Systems/LineToolUISystem.cs index 21a9068..24d4b2f 100644 --- a/Code/Systems/LineToolUISystem.cs +++ b/Code/Systems/LineToolUISystem.cs @@ -246,9 +246,6 @@ protected override void OnUpdate() ExecuteScript(_uiView, _modeHTML); ExecuteScript(_uiView, _modeJS); - // Select point mode. - ExecuteScript(_uiView, "document.getElementById(\"line-tool-mode-point\").classList.add(\"selected\");"); - _eventHandles.Add(_uiView.RegisterForEvent("SetPointMode", (Action)SetPointMode)); _eventHandles.Add(_uiView.RegisterForEvent("SetStraightMode", (Action)SetStraightMode)); _eventHandles.Add(_uiView.RegisterForEvent("SetSimpleCurveMode", (Action)SetSimpleCurveMode)); diff --git a/LineToolLite.csproj b/LineToolLite.csproj index 16e9511..7b5606f 100644 --- a/LineToolLite.csproj +++ b/LineToolLite.csproj @@ -6,7 +6,7 @@ algernon Copyright © 2023 algernon (github.com/algernon-A). All rights reserved. $(Title) - 1.3.1 + 1.3.2 9.0 True diff --git a/UI/modes.html b/UI/modes.html index 9eb0a40..c539eba 100644 --- a/UI/modes.html +++ b/UI/modes.html @@ -2,7 +2,7 @@
Line mode
-