Entity IO fixes

This commit is contained in:
Anuken
2020-05-14 17:40:49 -04:00
parent 12f4d5a9a4
commit 6d23963e98
29 changed files with 226 additions and 109 deletions

View File

@@ -58,7 +58,7 @@ abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Draw
remove();
}
@Override
@Replace
public float clipSize(){
return type.drawSize;
}

View File

@@ -25,7 +25,7 @@ abstract class DecalComp implements Drawc, Timedc, Rotc, Posc{
Draw.color();
}
@Override
@Replace
public float clipSize(){
return region.getWidth()*2;
}

View File

@@ -6,7 +6,9 @@ import mindustry.gen.*;
@Component
abstract class DrawComp implements Posc{
abstract float clipSize();
float clipSize(){
return Float.MAX_VALUE;
}
void draw(){

View File

@@ -17,7 +17,7 @@ abstract class EffectComp implements Posc, Drawc, Timedc, Rotc, Childc{
effect.render(id(), color, time(), rotation(), x(), y(), data);
}
@Override
@Replace
public float clipSize(){
return effect.size;
}

View File

@@ -62,7 +62,7 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra
}
}
@Override
@Replace
public float clipSize(){
return 20;
}

View File

@@ -114,7 +114,7 @@ abstract class PuddleComp implements Posc, Puddlec, Drawc{
}
}
@Override
@Replace
public float clipSize(){
return 20;
}

View File

@@ -20,7 +20,7 @@ import static mindustry.Vars.content;
@Component
abstract class StatusComp implements Posc, Flyingc{
private Array<StatusEntry> statuses = new Array<>();
private Bits applied = new Bits(content.getBy(ContentType.status).size);
private transient Bits applied = new Bits(content.getBy(ContentType.status).size);
@ReadOnly transient float speedMultiplier, damageMultiplier, armorMultiplier;
@@ -145,31 +145,4 @@ abstract class StatusComp implements Posc, Flyingc{
boolean hasEffect(StatusEffect effect){
return applied.get(effect.id);
}
//TODO autogen io code
void writeSave(DataOutput stream) throws IOException{
stream.writeByte(statuses.size);
for(StatusEntry entry : statuses){
stream.writeByte(entry.effect.id);
stream.writeFloat(entry.time);
}
}
void readSave(DataInput stream, byte version) throws IOException{
for(StatusEntry effect : statuses){
Pools.free(effect);
}
statuses.clear();
byte amount = stream.readByte();
for(int i = 0; i < amount; i++){
byte id = stream.readByte();
float time = stream.readFloat();
StatusEntry entry = Pools.obtain(StatusEntry.class, StatusEntry::new);
entry.set(content.getByID(ContentType.status, id), time);
statuses.add(entry);
}
}
}

View File

@@ -9,7 +9,7 @@ import mindustry.net.*;
abstract class SyncComp implements Posc{
@Import float x, y;
Interpolator interpolator = new Interpolator();
transient Interpolator interpolator = new Interpolator();
void setNet(float x, float y){
set(x, y);

View File

@@ -22,7 +22,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
@Import float x, y, rotation, elevation, maxHealth;
private UnitController controller;
private transient UnitController controller;
private UnitType type;
public void moveAt(Vec2 vector){
@@ -43,7 +43,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
return type.hasWeapons();
}
@Override
@Replace
public float clipSize(){
return type.region.getWidth() * 2f;
}

View File

@@ -20,7 +20,7 @@ abstract class WeaponsComp implements Teamc, Posc, Rotc{
static int sequenceNum = 0;
/** weapon mount array, never null */
@ReadOnly WeaponMount[] mounts = {};
@ReadOnly transient WeaponMount[] mounts = {};
@ReadOnly transient float range, aimX, aimY;
@ReadOnly transient boolean isRotate, isShooting;