Sync unit velocity / Sync separator seed / 127.x Compat break

This commit is contained in:
Anuken
2021-07-06 11:41:05 -04:00
parent 5693605f31
commit 01a3c772e7
25 changed files with 50 additions and 22 deletions

View File

@@ -44,6 +44,13 @@ abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Draw
}
}
//bullets always considered local
@Override
@Replace
public boolean isLocal(){
return true;
}
@Override
public void add(){
type.init(self());

View File

@@ -16,8 +16,8 @@ abstract class ShieldComp implements Healthc, Posc{
/** Absorbs health damage. */
float shield;
/** Subtracts an amount from damage. */
float armor;
/** Subtracts an amount from damage. No need to save. */
transient float armor;
/** Shield opacity. */
transient float shieldAlpha = 0f;

View File

@@ -13,20 +13,24 @@ import static mindustry.Vars.*;
abstract class VelComp implements Posc{
@Import float x, y;
//TODO @SyncLocal this? does it even need to be sent?
transient final Vec2 vel = new Vec2();
@SyncLocal Vec2 vel = new Vec2();
transient float drag = 0f;
//velocity needs to be called first, as it affects delta and lastPosition
@MethodPriority(-1)
@Override
public void update(){
float px = x, py = y;
move(vel.x * Time.delta, vel.y * Time.delta);
if(Mathf.equal(px, x)) vel.x = 0;
if(Mathf.equal(py, y)) vel.y = 0;
//do not update velocity on the client at all, unless it's non-interpolated
//velocity conflicts with interpolation.
if(!net.client() || isLocal()){
float px = x, py = y;
move(vel.x * Time.delta, vel.y * Time.delta);
if(Mathf.equal(px, x)) vel.x = 0;
if(Mathf.equal(py, y)) vel.y = 0;
vel.scl(Math.max(1f - drag * Time.delta, 0));
vel.scl(Math.max(1f - drag * Time.delta, 0));
}
}
/** @return function to use for check solid state. if null, no checking is done. */