chargeShootEffect / Effect startDelay
This commit is contained in:
@@ -30,6 +30,8 @@ public class Effect{
|
||||
public float lifetime = 50f;
|
||||
/** Clip size. */
|
||||
public float clip;
|
||||
/** Time delay before the effect starts */
|
||||
public float startDelay;
|
||||
/** Amount added to rotation */
|
||||
public float baseRotation;
|
||||
/** If true, parent unit is data are followed. */
|
||||
@@ -58,6 +60,11 @@ public class Effect{
|
||||
all.add(this);
|
||||
}
|
||||
|
||||
public Effect startDelay(float d){
|
||||
startDelay = d;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void init(){}
|
||||
|
||||
public Effect followParent(boolean follow){
|
||||
@@ -168,21 +175,29 @@ public class Effect{
|
||||
effect.init();
|
||||
}
|
||||
|
||||
EffectState entity = EffectState.create();
|
||||
entity.effect = effect;
|
||||
entity.rotation = effect.baseRotation + rotation;
|
||||
entity.data = data;
|
||||
entity.lifetime = effect.lifetime;
|
||||
entity.set(x, y);
|
||||
entity.color.set(color);
|
||||
if(effect.followParent && data instanceof Posc p){
|
||||
entity.parent = p;
|
||||
entity.rotWithParent = effect.rotWithParent;
|
||||
if(effect.startDelay <= 0f){
|
||||
inst(effect, x, y, rotation, color, data);
|
||||
}else{
|
||||
Time.runTask(effect.startDelay, () -> inst(effect, x, y, rotation, color, data));
|
||||
}
|
||||
entity.add();
|
||||
}
|
||||
}
|
||||
|
||||
private static void inst(Effect effect, float x, float y, float rotation, Color color, Object data){
|
||||
EffectState entity = EffectState.create();
|
||||
entity.effect = effect;
|
||||
entity.rotation = effect.baseRotation + rotation;
|
||||
entity.data = data;
|
||||
entity.lifetime = effect.lifetime;
|
||||
entity.set(x, y);
|
||||
entity.color.set(color);
|
||||
if(effect.followParent && data instanceof Posc p){
|
||||
entity.parent = p;
|
||||
entity.rotWithParent = effect.rotWithParent;
|
||||
}
|
||||
entity.add();
|
||||
}
|
||||
|
||||
public static void decal(TextureRegion region, float x, float y, float rotation){
|
||||
decal(region, x, y, rotation, 3600f, Pal.rubble);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user