Multi-tread support for tanks
This commit is contained in:
@@ -11,6 +11,7 @@ import mindustry.entities.*;
|
||||
import mindustry.entities.abilities.*;
|
||||
import mindustry.entities.bullet.*;
|
||||
import mindustry.entities.effect.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
@@ -72,7 +73,7 @@ public class UnitTypes{
|
||||
public static @EntityDef({Unitc.class, BuildingTetherc.class, Payloadc.class}) UnitType manifold, assemblyDrone;
|
||||
|
||||
//tank
|
||||
public static @EntityDef({Unitc.class, Tankc.class}) UnitType vanquish;
|
||||
public static @EntityDef({Unitc.class, Tankc.class}) UnitType vanquish, conquer;
|
||||
|
||||
//endregion
|
||||
|
||||
@@ -2436,7 +2437,7 @@ public class UnitTypes{
|
||||
health = 9000;
|
||||
armor = 20f;
|
||||
areaDamage = 12f;
|
||||
treadRect = new Rect(22f, 16f, 28f, 130f);
|
||||
treadRects = new Rect[]{new Rect(22, 16, 28, 130)};
|
||||
|
||||
weapons.add(new Weapon("vanquish-weapon"){{
|
||||
layerOffset = 0.0001f;
|
||||
@@ -2499,6 +2500,20 @@ public class UnitTypes{
|
||||
}
|
||||
}};
|
||||
|
||||
conquer = new TankUnitType("conquer"){{
|
||||
hitSize = 44f;
|
||||
treadPullOffset = 1;
|
||||
speed = 0.48f;
|
||||
health = 20000;
|
||||
armor = 25f;
|
||||
areaDamage = 22f;
|
||||
rotateSpeed = 0.9f;
|
||||
treadRects = new Rect[]{new Rect(27, 152, 56, 73), new Rect(24, 51, 29, 17), new Rect(59, 18, 39, 19)};
|
||||
decals.add(new UnitDecal("conquer-glow", 0, 0, 0, -1, Pal.turretHeat.cpy()){{
|
||||
blending = Blending.additive;
|
||||
}});
|
||||
}};
|
||||
|
||||
//endregion
|
||||
//region erekir - mech
|
||||
|
||||
|
||||
@@ -32,9 +32,10 @@ abstract class TankComp implements Posc, Flyingc, Hitboxc, Unitc, ElevationMovec
|
||||
//dust
|
||||
if(walked && !headless){
|
||||
treadEffectTime += Time.delta;
|
||||
if(treadEffectTime >= 6f){
|
||||
if(treadEffectTime >= 6f && type.treadRects.length > 0){
|
||||
var treadRegion = type.treadRegion;
|
||||
var treadRect = type.treadRect;
|
||||
//first rect should always be at the back
|
||||
var treadRect = type.treadRects[0];
|
||||
|
||||
float xOffset = (treadRegion.width/2f - (treadRect.x + treadRect.width/2f)) / 4f;
|
||||
float yOffset = (treadRegion.height/2f - (treadRect.y + treadRect.height/2f)) / 4f;
|
||||
|
||||
@@ -9,6 +9,7 @@ public class UnitDecal{
|
||||
public float x, y, rotation;
|
||||
public float layer = Layer.flyingUnit + 1f;
|
||||
public float xScale = 1f, yScale = 1f;
|
||||
public Blending blending = Blending.normal;
|
||||
public Color color = Color.white;
|
||||
|
||||
public UnitDecal(String region, float x, float y, float rotation, float layer, Color color){
|
||||
|
||||
@@ -119,7 +119,7 @@ public class UnitType extends UnlockableContent{
|
||||
public boolean mechStepParticles = false;
|
||||
public Color mechLegColor = Pal.darkMetal;
|
||||
|
||||
public Rect treadRect = new Rect();
|
||||
public Rect[] treadRects = {};
|
||||
public int treadFrames = 18;
|
||||
public int treadPullOffset = 0;
|
||||
|
||||
@@ -176,7 +176,8 @@ public class UnitType extends UnlockableContent{
|
||||
public Seq<Weapon> weapons = new Seq<>();
|
||||
public TextureRegion baseRegion, legRegion, region, shadowRegion, cellRegion,
|
||||
softShadowRegion, jointRegion, footRegion, legBaseRegion, baseJointRegion, outlineRegion, treadRegion;
|
||||
public TextureRegion[] wreckRegions, segmentRegions, segmentOutlineRegions, treadRegions;
|
||||
public TextureRegion[] wreckRegions, segmentRegions, segmentOutlineRegions;
|
||||
public TextureRegion[][] treadRegions;
|
||||
|
||||
protected float buildTime = -1f;
|
||||
protected @Nullable ItemStack[] totalRequirements, cachedRequirements, firstRequirements;
|
||||
@@ -524,9 +525,11 @@ public class UnitType extends UnlockableContent{
|
||||
footRegion = Core.atlas.find(name + "-foot");
|
||||
treadRegion = Core.atlas.find(name + "-treads");
|
||||
if(treadRegion.found()){
|
||||
treadRegions = new TextureRegion[treadFrames];
|
||||
for(int i = 0; i < treadFrames; i++){
|
||||
treadRegions[i] = Core.atlas.find(name + "-treads" + i);
|
||||
treadRegions = new TextureRegion[treadRects.length][treadFrames];
|
||||
for(int r = 0; r < treadRects.length; r++){
|
||||
for(int i = 0; i < treadFrames; i++){
|
||||
treadRegions[r][i] = Core.atlas.find(name + "-treads" + r + "-" + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
legBaseRegion = Core.atlas.find(name + "-leg-base", name + "-leg");
|
||||
@@ -767,10 +770,12 @@ public class UnitType extends UnlockableContent{
|
||||
if(decals.size > 0){
|
||||
float base = unit.rotation - 90;
|
||||
for(var d : decals){
|
||||
Draw.z(d.layer);
|
||||
Draw.blend(d.blending);
|
||||
Draw.z(d.layer <= 0f ? z : d.layer);
|
||||
Draw.scl(d.xScale, d.yScale);
|
||||
Draw.color(d.color);
|
||||
Draw.rect(d.region, unit.x + Angles.trnsx(base, d.x, d.y), unit.y + Angles.trnsy(base, d.x, d.y), base + d.rotation);
|
||||
Draw.blend();
|
||||
}
|
||||
Draw.reset();
|
||||
Draw.z(z);
|
||||
@@ -995,13 +1000,16 @@ public class UnitType extends UnlockableContent{
|
||||
|
||||
if(treadRegion.found()){
|
||||
int frame = (int)(unit.treadTime()) % treadFrames;
|
||||
var region = treadRegions[frame];
|
||||
float xOffset = treadRegion.width/2f - (treadRect.x + treadRect.width/2f);
|
||||
float yOffset = treadRegion.height/2f - (treadRect.y + treadRect.height/2f);
|
||||
for(int i = 0; i < treadRects.length; i ++){
|
||||
var region = treadRegions[i][frame];
|
||||
var treadRect = treadRects[i];
|
||||
float xOffset = treadRegion.width/2f - (treadRect.x + treadRect.width/2f);
|
||||
float yOffset = treadRegion.height/2f - (treadRect.y + treadRect.height/2f);
|
||||
|
||||
for(int i : Mathf.signs){
|
||||
Tmp.v1.set(xOffset * i, yOffset).rotate(unit.rotation - 90);
|
||||
Draw.rect(region, unit.x + Tmp.v1.x / 4f, unit.y + Tmp.v1.y / 4f, treadRect.width / 4f, region.height / 4f, unit.rotation - 90);
|
||||
for(int side : Mathf.signs){
|
||||
Tmp.v1.set(xOffset * side, yOffset).rotate(unit.rotation - 90);
|
||||
Draw.rect(region, unit.x + Tmp.v1.x / 4f, unit.y + Tmp.v1.y / 4f, treadRect.width / 4f, region.height / 4f, unit.rotation - 90);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user