Tank animations & FX
This commit is contained in:
@@ -166,6 +166,22 @@ public class Effect{
|
||||
shake(intensity, duration, loc.getX(), loc.getY());
|
||||
}
|
||||
|
||||
public static void floorDust(float x, float y, float size){
|
||||
Tile tile = world.tileWorld(x, y);
|
||||
if(tile != null){
|
||||
Color color = tile.floor().mapColor;
|
||||
Fx.unitLand.at(x, y, size, color);
|
||||
}
|
||||
}
|
||||
|
||||
public static void floorDustAngle(Effect effect, float x, float y, float angle){
|
||||
Tile tile = world.tileWorld(x, y);
|
||||
if(tile != null){
|
||||
Color color = tile.floor().mapColor;
|
||||
effect.at(x, y, angle, color);
|
||||
}
|
||||
}
|
||||
|
||||
public static void create(Effect effect, float x, float y, float rotation, Color color, Object data){
|
||||
if(headless || effect == Fx.none || !Core.settings.getBool("effects")) return;
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ public class EntityCollisions{
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends Hitboxc> void updatePhysics(EntityGroup<T> group){
|
||||
QuadTree tree = group.tree();
|
||||
var tree = group.tree();
|
||||
tree.clear();
|
||||
|
||||
group.each(s -> {
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
package mindustry.entities.comp;
|
||||
|
||||
import arc.graphics.*;
|
||||
import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.util.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.environment.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
@@ -52,11 +49,7 @@ abstract class MechComp implements Posc, Flyingc, Hitboxc, Unitc, Mechc, Elevati
|
||||
}
|
||||
|
||||
if(type.mechStepParticles){
|
||||
Tile tile = world.tileWorld(cx, cy);
|
||||
if(tile != null){
|
||||
Color color = tile.floor().mapColor;
|
||||
Fx.unitLand.at(cx, cy, hitSize/8f, color);
|
||||
}
|
||||
Effect.floorDust(cx, cy, hitSize/8f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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