Tank animations & FX
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
package mindustry.entities.comp;
|
||||
|
||||
import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.util.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.blocks.environment.*;
|
||||
@@ -11,14 +13,36 @@ import static mindustry.Vars.*;
|
||||
|
||||
@Component
|
||||
abstract class TankComp implements Posc, Flyingc, Hitboxc, Unitc, ElevationMovec{
|
||||
@Import float x, y, hitSize;
|
||||
@Import float x, y, hitSize, rotation;
|
||||
@Import UnitType type;
|
||||
|
||||
transient private float treadEffectTime;
|
||||
|
||||
transient float treadTime;
|
||||
transient boolean walked;
|
||||
|
||||
@Override
|
||||
public void update(){
|
||||
//dust
|
||||
if(walked && !headless){
|
||||
treadEffectTime += Time.delta;
|
||||
if(treadEffectTime >= 6f){
|
||||
var treadRegion = type.treadRegion;
|
||||
var treadRect = type.treadRect;
|
||||
|
||||
float xOffset = (treadRegion.width/2f - (treadRect.x + treadRect.width/2f)) / 4f;
|
||||
float yOffset = (treadRegion.height/2f - (treadRect.y + treadRect.height/2f)) / 4f;
|
||||
|
||||
for(int i : Mathf.signs){
|
||||
Tmp.v1.set(xOffset * i, yOffset - treadRect.height / 2f / 4f).rotate(rotation - 90);
|
||||
|
||||
Effect.floorDustAngle(type.treadEffect, Tmp.v1.x + x, Tmp.v1.y + y, rotation + 180f);
|
||||
}
|
||||
|
||||
treadEffectTime = 0f;
|
||||
}
|
||||
}
|
||||
|
||||
//trigger animation only when walking manually
|
||||
if(walked || net.client()){
|
||||
float len = deltaLen();
|
||||
|
||||
Reference in New Issue
Block a user