Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

Commit

Permalink
1.3.2
Browse files Browse the repository at this point in the history
- Fix XP being gained when previewing some buildings and roundabouts.
  • Loading branch information
algernon-A committed Dec 25, 2023
1 parent 7fd8c1f commit 8c644fe
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 28 deletions.
2 changes: 1 addition & 1 deletion BepInEx/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace LineTool
/// <summary>
/// BepInEx plugin to substitute for IMod support.
/// </summary>
[BepInPlugin(GUID, "Line Tool Lite", "1.3.1")]
[BepInPlugin(GUID, "Line Tool Lite", "1.3.2")]
[HarmonyPatch]
public class Plugin : BaseUnityPlugin
{
Expand Down
2 changes: 1 addition & 1 deletion BepInEx/manifest.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
40 changes: 20 additions & 20 deletions Code/Systems/LineToolSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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();
}
}
}
Expand Down Expand Up @@ -804,6 +786,24 @@ private Entity CreateEntity()
return newEntity;
}

/// <summary>
/// Reduces XP gain for the current object to zero and records the original value.
/// </summary>
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;
}
}

/// <summary>
/// Restores the selected prefab's original XP gain.
/// </summary>
Expand Down
3 changes: 0 additions & 3 deletions Code/Systems/LineToolUISystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion LineToolLite.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Authors>algernon</Authors>
<Copyright>Copyright © 2023 algernon (github.com/algernon-A). All rights reserved.</Copyright>
<Product>$(Title)</Product>
<Version>1.3.1</Version>
<Version>1.3.2</Version>
<LangVersion>9.0</LangVersion>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion UI/modes.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="item-content_nNz">
<div class="label_RZX">Line mode</div>
<div class="content_ZIz">
<button id="line-tool-mode-point" class="button_KVN">
<button id="line-tool-mode-point" class="button_KVN selected">
<img class="icon_Ysc" src="Media/Tools/Net Tool/Point.svg">
</button>
<button id="line-tool-mode-straight" class="button_KVN">
Expand Down

0 comments on commit 8c644fe

Please sign in to comment.