diff --git a/core/assets/scripts/global.js b/core/assets/scripts/global.js index 04ebb37a27..3074cebde7 100755 --- a/core/assets/scripts/global.js +++ b/core/assets/scripts/global.js @@ -124,7 +124,7 @@ const BlockBuildBeginEvent = Packages.mindustry.game.EventType.BlockBuildBeginEv const ResearchEvent = Packages.mindustry.game.EventType.ResearchEvent const UnlockEvent = Packages.mindustry.game.EventType.UnlockEvent const StateChangeEvent = Packages.mindustry.game.EventType.StateChangeEvent -const BuildinghangeEvent = Packages.mindustry.game.EventType.BuildinghangeEvent +const TileChangeEvent = Packages.mindustry.game.EventType.TileChangeEvent const GameOverEvent = Packages.mindustry.game.EventType.GameOverEvent const ConfigEvent = Packages.mindustry.game.EventType.ConfigEvent const DepositEvent = Packages.mindustry.game.EventType.DepositEvent diff --git a/core/src/mindustry/entities/bullet/ShrapnelBulletType.java b/core/src/mindustry/entities/bullet/ShrapnelBulletType.java index 3303f40fdb..a6a9ca6be0 100644 --- a/core/src/mindustry/entities/bullet/ShrapnelBulletType.java +++ b/core/src/mindustry/entities/bullet/ShrapnelBulletType.java @@ -32,6 +32,11 @@ public class ShrapnelBulletType extends BulletType{ Damage.collideLaser(b, length); } + @Override + public float range(){ + return length; + } + @Override public void draw(Bullet b){ float realLength = b.fdata; diff --git a/core/src/mindustry/entities/comp/PlayerComp.java b/core/src/mindustry/entities/comp/PlayerComp.java index ce0f36d908..39a6f55ad6 100644 --- a/core/src/mindustry/entities/comp/PlayerComp.java +++ b/core/src/mindustry/entities/comp/PlayerComp.java @@ -34,6 +34,7 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra @Import float x, y; @NonNull @ReadOnly Unit unit = Nulls.unit; + transient private Unit lastReadUnit = Nulls.unit; transient @Nullable NetConnection con; @ReadOnly Team team = Team.sharded; @@ -54,13 +55,11 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra return unit instanceof Minerc; } - public @Nullable - CoreBuild closestCore(){ + public @Nullable CoreBuild closestCore(){ return state.teams.closestCore(x, y, team); } - public @Nullable - CoreBuild core(){ + public @Nullable CoreBuild core(){ return team.core(); } @@ -93,6 +92,12 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra @Override public void afterSync(){ + //simulate a unit change after sync + Unit set = unit; + unit = lastReadUnit; + unit(set); + lastReadUnit = unit; + unit.aim(mouseX, mouseY); //this is only necessary when the thing being controlled isn't synced unit.controlWeapons(shooting, shooting); @@ -165,6 +170,7 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra public void unit(Unit unit){ if(unit == null) throw new IllegalArgumentException("Unit cannot be null. Use clearUnit() instead."); if(this.unit == unit) return; + if(this.unit != Nulls.unit){ //un-control the old unit this.unit.controller(this.unit.type().createController()); diff --git a/core/src/mindustry/input/InputHandler.java b/core/src/mindustry/input/InputHandler.java index b0c89d9121..efa48f8339 100644 --- a/core/src/mindustry/input/InputHandler.java +++ b/core/src/mindustry/input/InputHandler.java @@ -242,7 +242,10 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ player.clearUnit(); //make sure it's AI controlled, so players can't overwrite each other }else if(unit.isAI() && unit.team == player.team() && !unit.deactivated() && !unit.dead){ - player.unit(unit); + if(!net.client()){ + player.unit(unit); + } + Time.run(Fx.unitSpirit.lifetime, () -> Fx.unitControl.at(unit.x, unit.y, 0f, unit)); if(!player.dead()){ Fx.unitSpirit.at(player.x, player.y, 0f, unit);