Multiplayer bugfixes
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
package mindustry.entities.comp;
|
||||
|
||||
import arc.graphics.g2d.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.ui.*;
|
||||
|
||||
import static mindustry.Vars.tilesize;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
@Component
|
||||
abstract class BlockUnitComp implements Unitc{
|
||||
@@ -29,6 +31,12 @@ abstract class BlockUnitComp implements Unitc{
|
||||
}
|
||||
}
|
||||
|
||||
@Replace
|
||||
@Override
|
||||
public TextureRegion icon(){
|
||||
return tile.block.icon(Cicon.full);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void killed(){
|
||||
tile.kill();
|
||||
|
||||
@@ -28,7 +28,7 @@ abstract class BuilderComp implements Unitc{
|
||||
|
||||
@Import float x, y, rotation;
|
||||
|
||||
Queue<BuildPlan> plans = new Queue<>();
|
||||
@SyncLocal Queue<BuildPlan> plans = new Queue<>();
|
||||
transient boolean building = true;
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,7 +19,7 @@ abstract class DecalComp implements Drawc, Timedc, Rotc, Posc{
|
||||
public void draw(){
|
||||
Draw.z(Layer.scorch);
|
||||
|
||||
Draw.mixcol(color, 1f);
|
||||
Draw.mixcol(color, color.a);
|
||||
Draw.alpha(1f - Mathf.curve(fin(), 0.98f));
|
||||
Draw.rect(region, x, y, rotation);
|
||||
Draw.reset();
|
||||
|
||||
@@ -32,6 +32,10 @@ abstract class EntityComp{
|
||||
return ((Object)this) == player || ((Object)this) instanceof Unitc && ((Unitc)((Object)this)).controller() == player;
|
||||
}
|
||||
|
||||
boolean isRemote(){
|
||||
return ((Object)this) instanceof Unitc && ((Unitc)((Object)this)).isPlayer() && !isLocal();
|
||||
}
|
||||
|
||||
boolean isNull(){
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ abstract class FlyingComp implements Posc, Velc, Healthc, Hitboxc{
|
||||
@Import float x, y;
|
||||
@Import Vec2 vel;
|
||||
|
||||
@SyncField(value = true, clamped = true) @SyncLocal float elevation;
|
||||
@SyncLocal float elevation;
|
||||
private transient boolean wasFlying;
|
||||
transient float drownTime;
|
||||
transient float splashTimer;
|
||||
|
||||
@@ -22,7 +22,7 @@ abstract class MinerComp implements Itemsc, Posc, Teamc, Rotc, Drawc, Unitc{
|
||||
@Import UnitType type;
|
||||
|
||||
transient float mineTimer;
|
||||
@Nullable Tile mineTile;
|
||||
@Nullable @SyncLocal Tile mineTile;
|
||||
|
||||
public boolean canMine(Item item){
|
||||
return type.mineTier >= item.hardness;
|
||||
|
||||
@@ -12,8 +12,8 @@ import mindustry.annotations.Annotations.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.core.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.net.Administration.*;
|
||||
@@ -37,10 +37,10 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra
|
||||
transient @Nullable NetConnection con;
|
||||
|
||||
@ReadOnly Team team = Team.sharded;
|
||||
@SyncLocal boolean admin, typing, shooting, boosting;
|
||||
@SyncLocal float mouseX, mouseY;
|
||||
String name = "noname";
|
||||
boolean admin, typing, shooting, boosting;
|
||||
Color color = new Color();
|
||||
float mouseX, mouseY;
|
||||
|
||||
transient float deathTimer;
|
||||
transient String lastText = "";
|
||||
@@ -63,9 +63,10 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra
|
||||
}
|
||||
|
||||
public TextureRegion icon(){
|
||||
//display default icon for dead players
|
||||
if(dead()) return core() == null ? UnitTypes.alpha.icon(Cicon.full) : ((CoreBlock)core().block).unitType.icon(Cicon.full);
|
||||
|
||||
return unit.type().icon(Cicon.full);
|
||||
return unit.icon();
|
||||
}
|
||||
|
||||
public void reset(){
|
||||
@@ -78,6 +79,11 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidController(){
|
||||
return isAdded();
|
||||
}
|
||||
|
||||
@Replace
|
||||
public float clipSize(){
|
||||
return unit.isNull() ? 20 : unit.type().hitsize * 2f;
|
||||
@@ -125,6 +131,14 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(){
|
||||
//clear unit upon removal
|
||||
if(!unit.isNull()){
|
||||
clearUnit();
|
||||
}
|
||||
}
|
||||
|
||||
public void team(Team team){
|
||||
this.team = team;
|
||||
unit.team(team);
|
||||
|
||||
@@ -22,8 +22,19 @@ abstract class SyncComp implements Entityc{
|
||||
|
||||
@Override
|
||||
public void update(){
|
||||
if(Vars.net.client() && !isLocal()){
|
||||
//interpolate the player if:
|
||||
//- this is a client and the entity is everything except the local player
|
||||
//- this is a server and the entity is a remote player
|
||||
if((Vars.net.client() && !isLocal()) || isRemote()){
|
||||
interpolate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(){
|
||||
//notify client of removal
|
||||
if(Vars.net.client()){
|
||||
Vars.netClient.addRemovedEntity(id());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package mindustry.entities.comp;
|
||||
|
||||
import arc.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
@@ -233,11 +234,15 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
|
||||
|
||||
//remove units spawned by the core
|
||||
if(spawnedByCore && !isPlayer()){
|
||||
Fx.unitDespawn.at(x, y, 0, this);
|
||||
remove();
|
||||
Call.unitDespawn(base());
|
||||
}
|
||||
}
|
||||
|
||||
/** @return a preview icon for this unit. */
|
||||
public TextureRegion icon(){
|
||||
return type.icon(Cicon.full);
|
||||
}
|
||||
|
||||
/** Actually destroys the unit, removing it and creating explosions. **/
|
||||
public void destroy(){
|
||||
float explosiveness = 2f + item().explosiveness * stack().amount;
|
||||
|
||||
Reference in New Issue
Block a user