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 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

View File

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

View File

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

View File

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