Various sync fixes

This commit is contained in:
Anuken
2020-05-24 17:01:17 -04:00
parent d202c6ebdd
commit 3051598b92
14 changed files with 71 additions and 79 deletions

View File

@@ -17,7 +17,7 @@ abstract class FlyingComp implements Posc, Velc, Healthc, Hitboxc{
@Import float x, y;
@Import Vec2 vel;
float elevation;
@SyncField(value = true, clamped = true) @SyncLocal float elevation;
private transient boolean wasFlying;
transient float drownTime;
transient float splashTimer;

View File

@@ -7,7 +7,7 @@ import mindustry.gen.*;
@Component
abstract class LegsComp implements Posc, Flyingc, Hitboxc, Unitc, Legsc, ElevationMovec{
@SyncField(false) float baseRotation;
@SyncField(false) @SyncLocal float baseRotation;
transient float walkTime;
@Override

View File

@@ -18,6 +18,7 @@ import mindustry.net.Administration.*;
import mindustry.net.*;
import mindustry.net.Packets.*;
import mindustry.ui.*;
import mindustry.world.*;
import mindustry.world.blocks.storage.CoreBlock.*;
import static mindustry.Vars.*;
@@ -32,7 +33,7 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra
@ReadOnly Team team = Team.sharded;
String name = "noname";
boolean admin, typing, shooting;
boolean admin, typing, shooting, boosting;
Color color = new Color();
float mouseX, mouseY;
@@ -71,7 +72,7 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra
public void afterSync(){
unit.aim(mouseX, mouseY);
//this is only necessary when the thing being controlled isn't synced
unit.isShooting(shooting);
unit.controlWeapons(shooting, shooting);
//extra precaution, necessary for non-synced things
unit.controller(this);
}
@@ -89,14 +90,24 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra
y(unit.y());
unit.team(team);
deathTimer = 0;
//update some basic state to sync things
if(unit.type().canBoost){
Tile tile = unit.tileOn();
unit.elevation(Mathf.approachDelta(unit.elevation(), (tile != null && tile.solid()) || boosting ? 1f : 0f, 0.08f));
}
}else if(core != null){
//have a small delay before death to prevent the camera from jumping around too quickly
//(this is not for balance)
deathTimer += Time.delta();
if(deathTimer >= deathDelay){
core.requestSpawn((Playerc)this);
deathTimer = 0;
}
}
textFadeTime -= Time.delta() / (60 * 5);
}
public void team(Team team){

View File

@@ -12,7 +12,7 @@ import static mindustry.Vars.world;
@Component
abstract class PosComp implements Position{
@SyncField(true) float x, y;
@SyncField(true) @SyncLocal float x, y;
void set(float x, float y){
this.x = x;

View File

@@ -5,5 +5,5 @@ import mindustry.gen.*;
@Component
abstract class RotComp implements Entityc{
@SyncField(false) float rotation;
@SyncField(false) @SyncLocal float rotation;
}

View File

@@ -9,7 +9,8 @@ import mindustry.gen.*;
abstract class VelComp implements Posc{
@Import float x, y;
final Vec2 vel = new Vec2();
//TODO @SyncLocal this? does it even need to be sent?
transient final Vec2 vel = new Vec2();
transient float drag = 0f;
//velocity needs to be called first, as it affects delta and lastPosition