diff --git a/BepInEx/Plugin.cs b/BepInEx/Plugin.cs index 48972da..57ded73 100644 --- a/BepInEx/Plugin.cs +++ b/BepInEx/Plugin.cs @@ -14,7 +14,7 @@ namespace LineTool /// /// BepInEx plugin to substitute for IMod support. /// - [BepInPlugin(GUID, "Line Tool Lite", "1.1.1")] + [BepInPlugin(GUID, "Line Tool Lite", "1.1.2")] [HarmonyPatch] public class Plugin : BaseUnityPlugin { diff --git a/BepInEx/manifest.json b/BepInEx/manifest.json index d35483a..ea75556 100644 --- a/BepInEx/manifest.json +++ b/BepInEx/manifest.json @@ -1,6 +1,6 @@ { "name": "Line_Tool_Lite", - "version_number": "1.1.1", + "version_number": "1.1.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.txt b/Changelog.txt index acefb79..5b6212b 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,5 +1,8 @@ +1.1.2 +- Additional updates for Tree Controller integration. + 1.1.1 -- Update Tree Controller integration +- Update Tree Controller integration. 1.1.0 - Add dragging of line control points in fixed preview mode. diff --git a/Code/Systems/LineToolSystem.cs b/Code/Systems/LineToolSystem.cs index b781ad0..c31544e 100644 --- a/Code/Systems/LineToolSystem.cs +++ b/Code/Systems/LineToolSystem.cs @@ -9,6 +9,8 @@ namespace LineTool using Colossal.Entities; using Colossal.Logging; using Colossal.Mathematics; + using Colossal.Serialization.Entities; + using Game; using Game.Common; using Game.Input; using Game.Objects; @@ -380,6 +382,16 @@ protected override void OnCreate() hotKey.AddCompositeBinding("ButtonWithOneModifier").With("Modifier", "/ctrl").With("Button", "/l"); hotKey.performed += EnableTool; hotKey.Enable(); + } + + /// + /// Called by the game when loading is complete. + /// + /// Loading purpose. + /// Current game mode. + protected override void OnGameLoadingComplete(Purpose purpose, GameMode mode) + { + base.OnGameLoadingComplete(purpose, mode); // Try to get tree controller tool. if (World.GetOrCreateSystemManaged().tools.Find(x => x.toolID.Equals("Tree Controller Tool")) is ToolBaseSystem treeControllerTool) @@ -546,23 +558,30 @@ protected override JobHandle OnUpdate(JobHandle inputDeps) // Update cursor entity if we haven't got an initial position set. if (!_mode.HasStart) { - // Delete any existing cursor entity and create a new one. - if (_cursorEntity != Entity.Null) + // Don't update if the cursor hasn't moved. + if (position.x != _previousPos.x || position.z != _previousPos.z) { - EntityManager.AddComponent(_cursorEntity); - } + // Delete any existing cursor entity and create a new one. + if (_cursorEntity != Entity.Null) + { + EntityManager.AddComponent(_cursorEntity); + } - _cursorEntity = CreateEntity(); + _cursorEntity = CreateEntity(); - // Highlight cursor entity. - EntityManager.AddComponent(_cursorEntity); + // Highlight cursor entity. + EntityManager.AddComponent(_cursorEntity); - // Update cursor entity position. - EntityManager.SetComponentData(_cursorEntity, new Transform { m_Position = position, m_Rotation = GetEffectiveRotation(position) }); - EntityManager.AddComponent(_cursorEntity); + // Update cursor entity position. + EntityManager.SetComponentData(_cursorEntity, new Transform { m_Position = position, m_Rotation = GetEffectiveRotation(position) }); + EntityManager.AddComponent(_cursorEntity); - // Ensure cursor entity tree state. - EnsureTreeState(_cursorEntity); + // Ensure cursor entity tree state. + EnsureTreeState(_cursorEntity); + + // Update previous position. + _previousPos = position; + } return inputDeps; } diff --git a/LineToolLite.csproj b/LineToolLite.csproj index b54315f..c7b7da8 100644 --- a/LineToolLite.csproj +++ b/LineToolLite.csproj @@ -6,7 +6,7 @@ algernon Copyright © 2023 algernon (github.com/algernon-A). All rights reserved. $(Title) - 1.1.1 + 1.1.2 9.0 True