From 9edd31fad303ca58f56f55a05646b83bfb35af5d Mon Sep 17 00:00:00 2001 From: Anuken Date: Mon, 13 Oct 2025 22:53:16 +0900 Subject: [PATCH] Map objective curve & unnecessary rebuild fix --- core/src/mindustry/editor/MapObjectivesCanvas.java | 13 +++++++++++-- core/src/mindustry/editor/MapObjectivesDialog.java | 7 +++---- core/src/mindustry/game/MapObjectives.java | 2 +- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/core/src/mindustry/editor/MapObjectivesCanvas.java b/core/src/mindustry/editor/MapObjectivesCanvas.java index 0cde471b89..0a035aef79 100644 --- a/core/src/mindustry/editor/MapObjectivesCanvas.java +++ b/core/src/mindustry/editor/MapObjectivesCanvas.java @@ -255,7 +255,12 @@ public class MapObjectivesCanvas extends WidgetGroup{ float dist = Math.abs(x1 - x2) / 2f; float cx1 = x1 + dist; float cx2 = x2 - dist; - Lines.curve(x1, y1, cx1, y1, cx2, y2, x2, y2, Math.max(4, (int) (Mathf.dst(x1, y1, x2, y2) / 4f))); + + if(Mathf.equal(y1, y2, 0.1f)){ + Lines.line(x1, y1, x2, y2); + }else{ + Lines.curve(x1, y1, cx1, y1, cx2, y2, x2, y2, Math.max(4, (int) (Mathf.dst(x1, y1, x2, y2) / 4f))); + } float progress = (Time.time % (60 * 4)) / (60 * 4); @@ -292,7 +297,11 @@ public class MapObjectivesCanvas extends WidgetGroup{ } public boolean createTile(int x, int y, MapObjective obj){ - if(!validPlace(x, y, null)) return false; + return createTile(x, y, obj, false); + } + + public boolean createTile(int x, int y, MapObjective obj, boolean force){ + if(!force && !validPlace(x, y, null)) return false; ObjectiveTile tile = new ObjectiveTile(obj, x, y); tile.pack(); diff --git a/core/src/mindustry/editor/MapObjectivesDialog.java b/core/src/mindustry/editor/MapObjectivesDialog.java index b1be72ecfc..36c513478f 100644 --- a/core/src/mindustry/editor/MapObjectivesDialog.java +++ b/core/src/mindustry/editor/MapObjectivesDialog.java @@ -545,10 +545,7 @@ public class MapObjectivesDialog extends BaseDialog{ if( objectives.any() && ( // If the objectives were previously programmatically made... - objectives.contains(obj -> obj.editorX == -1 || obj.editorY == -1) || - // ... or some idiot somehow made it not work... - objectives.contains(obj -> !canvas.tilemap.createTile(obj)) - )){ + objectives.contains(obj -> obj.editorX == -999 || obj.editorY == -999))){ // ... then rebuild the structure. canvas.clearObjectives(); @@ -573,6 +570,8 @@ public class MapObjectivesDialog extends BaseDialog{ if(i >= objectives.size) break loop; } } + }else{ + objectives.each(o -> canvas.tilemap.createTile(o.editorX, o.editorY, o, true)); } canvas.objectives.set(objectives); diff --git a/core/src/mindustry/game/MapObjectives.java b/core/src/mindustry/game/MapObjectives.java index 024c7bdb2f..1cf552149c 100644 --- a/core/src/mindustry/game/MapObjectives.java +++ b/core/src/mindustry/game/MapObjectives.java @@ -185,7 +185,7 @@ public class MapObjectives implements Iterable, Eachable children = new Seq<>(2); /** For the objectives UI dialog. Do not modify directly! */ - public transient int editorX = -1, editorY = -1; + public transient int editorX = -999, editorY = -999; /** Whether this objective has been done yet. This is internally set. */ private boolean completed;