From 0919063ca3be31ce430730a73f5cedc7f269fca1 Mon Sep 17 00:00:00 2001 From: Phinner <62483793+Phinner@users.noreply.github.com> Date: Thu, 11 May 2023 01:03:08 +0000 Subject: [PATCH 1/3] Add BlockRotateEvent (#8577) * feat: Add BuildRotateEvent * fix: Fix invalid argument * fix: Goofy aaah static imports * chore: Update ConfigEvent doc + Add forgotten annotation * chore: Remove final keyword * fix: Remove rotation validation in Build#beginPlace * Already covered by client snapshots * fix: Remove useless imports --- core/src/mindustry/game/EventType.java | 18 +++++++++++++++--- core/src/mindustry/input/InputHandler.java | 2 ++ core/src/mindustry/world/Build.java | 2 ++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/core/src/mindustry/game/EventType.java b/core/src/mindustry/game/EventType.java index 2bfe8367d8..e7118db61c 100644 --- a/core/src/mindustry/game/EventType.java +++ b/core/src/mindustry/game/EventType.java @@ -257,13 +257,13 @@ public class EventType{ } } - /** Called when the player configures a specific building. */ + /** Called when a specific building has its configuration changed. */ public static class ConfigEvent{ public final Building tile; - public final Player player; + public final @Nullable Player player; public final Object value; - public ConfigEvent(Building tile, Player player, Object value){ + public ConfigEvent(Building tile, @Nullable Player player, Object value){ this.tile = tile; this.player = player; this.value = value; @@ -473,6 +473,18 @@ public class EventType{ } } + public static class BuildRotateEvent{ + public final Building build; + public final @Nullable Unit unit; + public final int previous; + + public BuildRotateEvent(Building build, @Nullable Unit unit, int previous){ + this.build = build; + this.unit = unit; + this.previous = previous; + } + } + /** * Called when a player or drone begins building something. * This does not necessarily happen when a new ConstructBlock is created. diff --git a/core/src/mindustry/input/InputHandler.java b/core/src/mindustry/input/InputHandler.java index 11877512e5..9a456b1fd0 100644 --- a/core/src/mindustry/input/InputHandler.java +++ b/core/src/mindustry/input/InputHandler.java @@ -464,10 +464,12 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ } if(player != null) build.lastAccessed = player.name; + int previous = build.rotation; build.rotation = Mathf.mod(build.rotation + Mathf.sign(direction), 4); build.updateProximity(); build.noSleep(); Fx.rotateBlock.at(build.x, build.y, build.block.size); + Events.fire(new BuildRotateEvent(build, player.unit(), previous)); } @Remote(targets = Loc.both, called = Loc.both, forward = true) diff --git a/core/src/mindustry/world/Build.java b/core/src/mindustry/world/Build.java index 5a06e8f2ce..ecec0e1c04 100644 --- a/core/src/mindustry/world/Build.java +++ b/core/src/mindustry/world/Build.java @@ -77,10 +77,12 @@ public class Build{ //auto-rotate the block to the correct orientation and bail out if(tile.team() == team && tile.block == result && tile.build != null && tile.block.quickRotate){ if(unit != null && unit.getControllerName() != null) tile.build.lastAccessed = unit.getControllerName(); + int previous = tile.build.rotation; tile.build.rotation = Mathf.mod(rotation, 4); tile.build.updateProximity(); tile.build.noSleep(); Fx.rotateBlock.at(tile.build.x, tile.build.y, tile.build.block.size); + Events.fire(new BuildRotateEvent(tile.build, unit, previous)); return; } From 397fd087f2a6000de042f90d20b8be5e5eff64c5 Mon Sep 17 00:00:00 2001 From: MEEPofFaith <54301439+MEEPofFaith@users.noreply.github.com> Date: Wed, 10 May 2023 18:07:40 -0700 Subject: [PATCH 2/3] RegionPart movement should not be affected by growth scale (#8578) --- core/src/mindustry/entities/part/RegionPart.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/mindustry/entities/part/RegionPart.java b/core/src/mindustry/entities/part/RegionPart.java index 341dd6f3fc..d920f7eff8 100644 --- a/core/src/mindustry/entities/part/RegionPart.java +++ b/core/src/mindustry/entities/part/RegionPart.java @@ -95,7 +95,7 @@ public class RegionPart extends DrawPart{ //can be null var region = drawRegion ? regions[Math.min(i, regions.length - 1)] : null; float sign = (i == 0 ? 1 : -1) * params.sideMultiplier; - Tmp.v1.set((x + mx) * sign * Draw.xscl, (y + my) * Draw.yscl).rotateRadExact((params.rotation - 90) * Mathf.degRad); + Tmp.v1.set((x + mx) * sign, y + my).rotateRadExact((params.rotation - 90) * Mathf.degRad); float rx = params.x + Tmp.v1.x, From 2c774779874395d00d583603d86eff6c9b82f095 Mon Sep 17 00:00:00 2001 From: MEEPofFaith <54301439+MEEPofFaith@users.noreply.github.com> Date: Wed, 10 May 2023 22:06:49 -0700 Subject: [PATCH 3/3] PartMove progress is ignored for growth (#8580) --- core/src/mindustry/entities/part/RegionPart.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/mindustry/entities/part/RegionPart.java b/core/src/mindustry/entities/part/RegionPart.java index d920f7eff8..d632587db0 100644 --- a/core/src/mindustry/entities/part/RegionPart.java +++ b/core/src/mindustry/entities/part/RegionPart.java @@ -78,8 +78,8 @@ public class RegionPart extends DrawPart{ mx += move.x * p; my += move.y * p; mr += move.rot * p; - gx += move.gx; - gy += move.gy; + gx += move.gx * p; + gy += move.gy * p; } }