Auto-despawn core units
This commit is contained in:
@@ -54,6 +54,21 @@ public class Fx{
|
||||
reset();
|
||||
}),
|
||||
|
||||
unitDespawn = new Effect(100f, e -> {
|
||||
if(!(e.data instanceof Unitc)) return;
|
||||
|
||||
Unitc select = (Unitc)e.data;
|
||||
float scl = e.fout(Interp.pow2Out);
|
||||
float p = Draw.scl;
|
||||
Draw.scl *= scl;
|
||||
|
||||
mixcol(Pal.accent, 1f);
|
||||
rect(select.type().icon(Cicon.full), select.x(), select.y(), select.rotation() - 90f);
|
||||
reset();
|
||||
|
||||
Draw.scl = p;
|
||||
}),
|
||||
|
||||
unitSpirit = new Effect(17f, e -> {
|
||||
if(!(e.data instanceof Position)) return;
|
||||
Position to = e.data();
|
||||
|
||||
@@ -24,6 +24,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
|
||||
|
||||
private transient UnitController controller;
|
||||
private UnitType type;
|
||||
boolean spawnedByCore;
|
||||
|
||||
public void moveAt(Vec2 vector){
|
||||
moveAt(vector, type.accel);
|
||||
@@ -171,6 +172,12 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
|
||||
}
|
||||
|
||||
controller.update();
|
||||
|
||||
//remove units spawned by the core
|
||||
if(spawnedByCore && !(controller instanceof Playerc)){
|
||||
Fx.unitDespawn.at(x, y, 0, this);
|
||||
remove();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -49,6 +49,7 @@ public class CoreBlock extends StorageBlock{
|
||||
unit.set(entity);
|
||||
unit.impulse(0f, 8f);
|
||||
unit.controller(player);
|
||||
unit.spawnedByCore(true);
|
||||
unit.add();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user