Added backwards compatibility for legacy saves
This commit is contained in:
@@ -62,4 +62,8 @@ public class Fires{
|
||||
public static void remove(Tile tile){
|
||||
map.remove(tile.pos());
|
||||
}
|
||||
|
||||
public static void register(Firec fire){
|
||||
map.put(fire.tile().pos(), fire);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,6 +73,10 @@ public class Puddles{
|
||||
map.remove(tile.pos());
|
||||
}
|
||||
|
||||
public static void register(Puddlec puddle){
|
||||
map.put(puddle.tile().pos(), puddle);
|
||||
}
|
||||
|
||||
/** Reacts two liquids together at a location. */
|
||||
private static float reactPuddle(Liquid dest, Liquid liquid, float amount, Tile tile, float x, float y){
|
||||
if((dest.flammability > 0.3f && liquid.temperature > 0.7f) ||
|
||||
|
||||
@@ -95,4 +95,8 @@ abstract class FireComp implements Timedc, Posc, Firec{
|
||||
Fires.remove(tile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterRead(){
|
||||
Fires.register(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ abstract class HealthComp implements Entityc{
|
||||
}
|
||||
|
||||
boolean damaged(){
|
||||
return health <= maxHealth - 0.0001f;
|
||||
return health < maxHealth - 0.001f;
|
||||
}
|
||||
|
||||
void damage(float amount){
|
||||
|
||||
@@ -18,7 +18,7 @@ import static mindustry.entities.Puddles.maxLiquid;
|
||||
|
||||
@EntityDef(value = {Puddlec.class}, pooled = true)
|
||||
@Component
|
||||
abstract class PuddleComp implements Posc, DrawLayerFloorOverc{
|
||||
abstract class PuddleComp implements Posc, DrawLayerFloorOverc, Puddlec{
|
||||
private static final int maxGeneration = 2;
|
||||
private static final Color tmp = new Color();
|
||||
private static final Rect rect = new Rect();
|
||||
@@ -112,8 +112,18 @@ abstract class PuddleComp implements Posc, DrawLayerFloorOverc{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float clipSize(){
|
||||
return 20;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(){
|
||||
Puddles.remove(tile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterRead(){
|
||||
Puddles.register(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,8 +61,7 @@ abstract class TileComp implements Posc, Teamc, Healthc, Tilec, Timerc{
|
||||
return this;
|
||||
}
|
||||
|
||||
@CallSuper
|
||||
public void write(Writes write){
|
||||
public final void writeBase(Writes write){
|
||||
write.f(health());
|
||||
write.b(tile.rotation());
|
||||
write.b(tile.getTeamID());
|
||||
@@ -72,22 +71,38 @@ abstract class TileComp implements Posc, Teamc, Healthc, Tilec, Timerc{
|
||||
if(cons != null) cons.write(write);
|
||||
}
|
||||
|
||||
@CallSuper
|
||||
@Override
|
||||
public void read(Reads read, byte revision){
|
||||
public final void readBase(Reads read){
|
||||
health(read.f());
|
||||
byte rotation = read.b();
|
||||
byte team = read.b();
|
||||
|
||||
tile.setTeam(Team.get(team));
|
||||
tile.rotation(rotation);
|
||||
|
||||
tile.rotation(read.b());
|
||||
tile.setTeam(Team.get(read.b()));
|
||||
if(items != null) items.read(read);
|
||||
if(power != null) power.read(read);
|
||||
if(liquids != null) liquids.read(read);
|
||||
if(cons != null) cons.read(read);
|
||||
}
|
||||
|
||||
public void writeAll(Writes write){
|
||||
writeBase(write);
|
||||
write(write);
|
||||
}
|
||||
|
||||
public void readAll(Reads read, byte revision){
|
||||
readBase(read);
|
||||
read(read, revision);
|
||||
}
|
||||
|
||||
@CallSuper
|
||||
@Override
|
||||
public void write(Writes write){
|
||||
//overriden by subclasses!
|
||||
}
|
||||
|
||||
@CallSuper
|
||||
@Override
|
||||
public void read(Reads read, byte revision){
|
||||
//overriden by subclasses!
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyBoost(float intensity, float duration){
|
||||
timeScale = Math.max(timeScale, intensity);
|
||||
@@ -144,7 +159,6 @@ abstract class TileComp implements Posc, Teamc, Healthc, Tilec, Timerc{
|
||||
}
|
||||
|
||||
/** Returns the version of this TileEntity IO code.*/
|
||||
//TODO implement
|
||||
@Override
|
||||
public byte version(){
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user