This commit is contained in:
Anuken
2020-09-03 15:22:27 -04:00
parent 686d922119
commit 90247e3b27
4 changed files with 20 additions and 6 deletions

View File

@@ -124,7 +124,7 @@ const BlockBuildBeginEvent = Packages.mindustry.game.EventType.BlockBuildBeginEv
const ResearchEvent = Packages.mindustry.game.EventType.ResearchEvent const ResearchEvent = Packages.mindustry.game.EventType.ResearchEvent
const UnlockEvent = Packages.mindustry.game.EventType.UnlockEvent const UnlockEvent = Packages.mindustry.game.EventType.UnlockEvent
const StateChangeEvent = Packages.mindustry.game.EventType.StateChangeEvent 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 GameOverEvent = Packages.mindustry.game.EventType.GameOverEvent
const ConfigEvent = Packages.mindustry.game.EventType.ConfigEvent const ConfigEvent = Packages.mindustry.game.EventType.ConfigEvent
const DepositEvent = Packages.mindustry.game.EventType.DepositEvent const DepositEvent = Packages.mindustry.game.EventType.DepositEvent

View File

@@ -32,6 +32,11 @@ public class ShrapnelBulletType extends BulletType{
Damage.collideLaser(b, length); Damage.collideLaser(b, length);
} }
@Override
public float range(){
return length;
}
@Override @Override
public void draw(Bullet b){ public void draw(Bullet b){
float realLength = b.fdata; float realLength = b.fdata;

View File

@@ -34,6 +34,7 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra
@Import float x, y; @Import float x, y;
@NonNull @ReadOnly Unit unit = Nulls.unit; @NonNull @ReadOnly Unit unit = Nulls.unit;
transient private Unit lastReadUnit = Nulls.unit;
transient @Nullable NetConnection con; transient @Nullable NetConnection con;
@ReadOnly Team team = Team.sharded; @ReadOnly Team team = Team.sharded;
@@ -54,13 +55,11 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra
return unit instanceof Minerc; return unit instanceof Minerc;
} }
public @Nullable public @Nullable CoreBuild closestCore(){
CoreBuild closestCore(){
return state.teams.closestCore(x, y, team); return state.teams.closestCore(x, y, team);
} }
public @Nullable public @Nullable CoreBuild core(){
CoreBuild core(){
return team.core(); return team.core();
} }
@@ -93,6 +92,12 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra
@Override @Override
public void afterSync(){ public void afterSync(){
//simulate a unit change after sync
Unit set = unit;
unit = lastReadUnit;
unit(set);
lastReadUnit = unit;
unit.aim(mouseX, mouseY); unit.aim(mouseX, mouseY);
//this is only necessary when the thing being controlled isn't synced //this is only necessary when the thing being controlled isn't synced
unit.controlWeapons(shooting, shooting); unit.controlWeapons(shooting, shooting);
@@ -165,6 +170,7 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra
public void unit(Unit unit){ public void unit(Unit unit){
if(unit == null) throw new IllegalArgumentException("Unit cannot be null. Use clearUnit() instead."); if(unit == null) throw new IllegalArgumentException("Unit cannot be null. Use clearUnit() instead.");
if(this.unit == unit) return; if(this.unit == unit) return;
if(this.unit != Nulls.unit){ if(this.unit != Nulls.unit){
//un-control the old unit //un-control the old unit
this.unit.controller(this.unit.type().createController()); this.unit.controller(this.unit.type().createController());

View File

@@ -242,7 +242,10 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
player.clearUnit(); player.clearUnit();
//make sure it's AI controlled, so players can't overwrite each other //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){ }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)); Time.run(Fx.unitSpirit.lifetime, () -> Fx.unitControl.at(unit.x, unit.y, 0f, unit));
if(!player.dead()){ if(!player.dead()){
Fx.unitSpirit.at(player.x, player.y, 0f, unit); Fx.unitSpirit.at(player.x, player.y, 0f, unit);