Map objective curve & unnecessary rebuild fix

This commit is contained in:
Anuken
2025-10-13 22:53:16 +09:00
parent 30da4c0f47
commit 9edd31fad3
3 changed files with 15 additions and 7 deletions

View File

@@ -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();

View File

@@ -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);

View File

@@ -185,7 +185,7 @@ public class MapObjectives implements Iterable<MapObjective>, Eachable<MapObject
private transient final Seq<MapObjective> 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;