Effect Rotate With Parent (#5999)

* Effect Rotate With Parent

* Use Rotc

* Wording

* Base Rotation

* Rotate effect rotation with parent.
This commit is contained in:
Matthew Peng
2021-09-27 08:55:56 -07:00
committed by GitHub
parent 6fb7f4fe26
commit 083c21ea3f
4 changed files with 41 additions and 11 deletions

View File

@@ -30,8 +30,12 @@ public class Effect{
public float lifetime = 50f;
/** Clip size. */
public float clip;
/** Amount added to rotation */
public float baseRotation;
/** If true, parent unit is data are followed. */
public boolean followParent;
/** If this and followParent are true, the effect will offset and rotate with the parent's rotation. */
public boolean rotWithParent;
public float layer = Layer.effect;
public float layerDuration;
@@ -61,11 +65,21 @@ public class Effect{
return this;
}
public Effect rotWithParent(boolean follow){
rotWithParent = follow;
return this;
}
public Effect layer(float l){
layer = l;
return this;
}
public Effect baseRotation(float d){
baseRotation = d;
return this;
}
public Effect layer(float l, float duration){
layer = l;
this.layerDuration = duration;
@@ -156,12 +170,15 @@ public class Effect{
EffectState entity = EffectState.create();
entity.effect = effect;
entity.rotation = rotation;
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;
if(effect.followParent && data instanceof Posc p){
entity.parent = p;
entity.rotWithParent = effect.rotWithParent;
}
entity.add();
}
}