Internal refactoring & cleanup
This commit is contained in:
@@ -3,9 +3,13 @@ package mindustry.entities.comp;
|
||||
import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.util.*;
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.entities.EntityCollisions.*;
|
||||
import mindustry.gen.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
@Component
|
||||
abstract class VelComp implements Posc{
|
||||
@Import float x, y;
|
||||
@@ -22,12 +26,35 @@ abstract class VelComp implements Posc{
|
||||
vel.scl(Mathf.clamp(1f - drag * Time.delta));
|
||||
}
|
||||
|
||||
/** @return function to use for check solid state. if null, no checking is done. */
|
||||
@Nullable
|
||||
SolidPred solidity(){
|
||||
return null;
|
||||
}
|
||||
|
||||
/** @return whether this entity can move through a location*/
|
||||
boolean canPass(int tileX, int tileY){
|
||||
SolidPred s = solidity();
|
||||
return s == null || !s.solid(tileX, tileY);
|
||||
}
|
||||
|
||||
/** @return whether this entity can exist on its current location*/
|
||||
boolean canPassOn(){
|
||||
return canPass(tileX(), tileY());
|
||||
}
|
||||
|
||||
boolean moving(){
|
||||
return !vel.isZero(0.01f);
|
||||
}
|
||||
|
||||
void move(float cx, float cy){
|
||||
x += cx;
|
||||
y += cy;
|
||||
SolidPred check = solidity();
|
||||
|
||||
if(check != null){
|
||||
collisions.move(self(), cx, cy, check);
|
||||
}else{
|
||||
x += cx;
|
||||
y += cy;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user