Improved controls / Re-added engine sprite

This commit is contained in:
Anuken
2020-02-16 13:16:18 -05:00
parent e677538c53
commit 7a8bd82f8e
10 changed files with 93 additions and 38 deletions
@@ -59,7 +59,8 @@ abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Draw
@Replace
@Override
public boolean collides(Hitboxc other){
return type.collides && (other instanceof Teamc && ((Teamc)other).team() != team()) && !(other instanceof Flyingc && ((Flyingc)other).isFlying() && !type.collidesAir);
return type.collides && (other instanceof Teamc && ((Teamc)other).team() != team())
&& !(other instanceof Flyingc && ((((Flyingc)other).isFlying() && !type.collidesAir) || (((Flyingc)other).isGrounded() && !type.collidesGround)));
}
@MethodPriority(100)
@@ -12,7 +12,7 @@ import static mindustry.Vars.net;
@Component
abstract class FlyingComp implements Posc, Velc, Healthc, Hitboxc{
@Import float x, y;
@Import float x, y, drag;
@Import Vec2 vel;
float elevation;
@@ -31,11 +31,24 @@ abstract class FlyingComp implements Posc, Velc, Healthc, Hitboxc{
return isGrounded();
}
void wobble(){
x += Mathf.sin(Time.time() + id() * 99, 25f, 0.05f) * Time.delta() * elevation;
y += Mathf.cos(Time.time() + id() * 99, 25f, 0.05f) * Time.delta() * elevation;
}
void moveAt(Vec2 vector){
moveAt(vector, 1f);
}
void moveAt(Vec2 vector, float acceleration){
Vec2 t = Tmp.v3.set(vector).scl(floorSpeedMultiplier()); //target vector
float mag = Tmp.v3.len();
vel.x = Mathf.approach(vel.x, t.x, mag);
vel.y = Mathf.approach(vel.y, t.y, mag);
Tmp.v1.set(t).sub(vel).limit(acceleration * vector.len()); //delta vector
vel.add(Tmp.v1);
//float mag = Tmp.v3.len() * acceleration;
//vel.lerp(t, Tmp.v3.len() * acceleration);
//vel.x = Mathf.approach(vel.x, t.x, mag);
//vel.y = Mathf.approach(vel.y, t.y, mag);
}
float floorSpeedMultiplier(){
@@ -47,6 +60,10 @@ abstract class FlyingComp implements Posc, Velc, Healthc, Hitboxc{
public void update(){
Floor floor = floorOn();
if(isFlying() && !net.client()){
wobble();
}
if(isGrounded() && floor.isLiquid){
if((splashTimer += Mathf.dst(deltaX(), deltaY())) >= 7f){
floor.walkEffect.at(x, y, 0, floor.color);
@@ -144,6 +144,7 @@ abstract class UnitComp implements Healthc, Velc, Statusc, Teamc, Itemsc, Hitbox
@Override
public void draw(){
type.drawEngine(this);
type.drawBody(this);
type.drawWeapons(this);
if(type.drawCell) type.drawCell(this);