Tank animations & FX

This commit is contained in:
Anuken
2021-12-12 20:05:37 -05:00
parent 0d33768f58
commit 53b55a9f0e
11 changed files with 119 additions and 19 deletions

View File

@@ -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();