Support for unit missiles

This commit is contained in:
Anuken
2021-12-07 16:58:11 -05:00
parent f5e9df1265
commit 0b7d8f371e
16 changed files with 276 additions and 77 deletions

View File

@@ -20,6 +20,7 @@ import mindustry.entities.units.*;
import mindustry.game.EventType.*;
import mindustry.game.*;
import mindustry.gen.*;
import mindustry.graphics.*;
import mindustry.logic.*;
import mindustry.type.*;
import mindustry.ui.*;
@@ -46,6 +47,8 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
boolean spawnedByCore;
double flag;
transient @Nullable Trail trail;
transient float shadowAlpha = -1f;
transient Seq<Ability> abilities = new Seq<>(0);
transient float healTime;
@@ -339,6 +342,11 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
public void remove(){
team.data().updateCount(type, -1);
controller.removed(self());
//make sure trail doesn't just go poof
if(trail != null && trail.size() > 0){
Fx.trailFade.at(x, y, trail.width(), team.color, trail.copy());
}
}
@Override
@@ -390,6 +398,16 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
}
}
if(trail != null){
trail.length = type.trailLength;
float scale = elevation();
float offset = type.engineOffset/2f + type.engineOffset/2f*scale;
float cx = x + Angles.trnsx(rotation + 180, offset), cy = y + Angles.trnsy(rotation + 180, offset);
trail.update(cx, cy);
}
drag = type.drag * (isGrounded() ? (floorOn().dragMultiplier) : 1f) * dragMultiplier * state.rules.dragMultiplier;
//apply knockback based on spawns