Autogenerated interpolation

This commit is contained in:
Anuken
2020-05-24 14:00:53 -04:00
parent 1acb5fc56c
commit 7c06ba94c1
36 changed files with 252 additions and 183 deletions

View File

@@ -1,26 +1,23 @@
package mindustry.entities.comp;
import arc.util.io.*;
import mindustry.*;
import mindustry.annotations.Annotations.*;
import mindustry.gen.*;
import mindustry.net.*;
import java.nio.*;
@Component
abstract class SyncComp implements Posc{
@Import float x, y;
abstract class SyncComp implements Entityc{
transient long lastUpdated, updateSpacing;
transient Interpolator interpolator = new Interpolator();
void setNet(float x, float y){
set(x, y);
//TODO change interpolator API
interpolator.target.set(x, y);
interpolator.last.set(x, y);
interpolator.pos.set(0, 0);
interpolator.updateSpacing = 16;
interpolator.lastUpdated = 0;
}
//all these method bodies are internally generated
void snapSync(){}
void readSync(Reads read){}
void writeSync(Writes write){}
void readSyncManual(FloatBuffer buffer){}
void writeSyncManual(FloatBuffer buffer){}
void interpolate(){}
@Override
public void update(){
@@ -28,10 +25,4 @@ abstract class SyncComp implements Posc{
interpolate();
}
}
void interpolate(){
interpolator.update();
x = interpolator.pos.x;
y = interpolator.pos.y;
}
}