diff --git a/core/src/mindustry/content/Fx.java b/core/src/mindustry/content/Fx.java index 7af54291dc..5b3da08336 100644 --- a/core/src/mindustry/content/Fx.java +++ b/core/src/mindustry/content/Fx.java @@ -228,7 +228,7 @@ public class Fx{ unitLandSmall = new Effect(30, e -> { color(Tmp.c1.set(e.color).mul(1.1f)); - randLenVectors(e.id, 6, 12f * e.finpow(), (x, y) -> { + randLenVectors(e.id, (int)(6 * e.rotation), 12f * e.finpow() * e.rotation, (x, y) -> { Fill.circle(e.x + x, e.y + y, e.fout() * 3f + 0.1f); }); }).ground(), @@ -1183,7 +1183,7 @@ public class Fx{ ripple = new Effect(30, e -> { color(Tmp.c1.set(e.color).mul(1.5f)); stroke(e.fout() + 0.4f); - Lines.circle(e.x, e.y, 2f + e.fin() * 4f); + Lines.circle(e.x, e.y, (2f + e.fin() * 4f) * e.rotation); }).ground(), bubble = new Effect(20, e -> { diff --git a/core/src/mindustry/content/UnitTypes.java b/core/src/mindustry/content/UnitTypes.java index 7bb74a4aa4..b2a6156c4d 100644 --- a/core/src/mindustry/content/UnitTypes.java +++ b/core/src/mindustry/content/UnitTypes.java @@ -212,8 +212,9 @@ public class UnitTypes implements ContentList{ immunities = ObjectSet.with(StatusEffects.burning, StatusEffects.melting); legCount = 4; legLength = 9f; - legTrns = 2f; + legTrns = 0.8f; legMoveSpace = 1.4f; + legBend = 1f; weapons.add(new Weapon("eruption"){{ shootY = 3f; @@ -247,8 +248,10 @@ public class UnitTypes implements ContentList{ rotateShooting = false; legExtension = -15; legBaseOffset = 10f; - landShake = 0f; + landShake = 2f; legSpeed = 0.1f; + legBend = 0.3f; + rippleScale = 2f; for(boolean b : Mathf.booleans){ weapons.add( diff --git a/core/src/mindustry/entities/Leg.java b/core/src/mindustry/entities/Leg.java index 1bfb23ad9b..248c5d2af0 100644 --- a/core/src/mindustry/entities/Leg.java +++ b/core/src/mindustry/entities/Leg.java @@ -5,4 +5,6 @@ import arc.math.geom.*; public class Leg{ public final Vec2 joint = new Vec2(), base = new Vec2(); public int group; + public boolean moving; + public float stage; } diff --git a/core/src/mindustry/entities/Puddles.java b/core/src/mindustry/entities/Puddles.java index 305ddb1498..9d10b84213 100644 --- a/core/src/mindustry/entities/Puddles.java +++ b/core/src/mindustry/entities/Puddles.java @@ -39,7 +39,7 @@ public class Puddles{ Puddlec p = map.get(tile.pos()); if(generation == 0 && p != null && p.lastRipple() <= Time.time() - 40f){ - Fx.ripple.at((tile.worldx() + source.worldx()) / 2f, (tile.worldy() + source.worldy()) / 2f, tile.floor().liquidDrop.color); + Fx.ripple.at((tile.worldx() + source.worldx()) / 2f, (tile.worldy() + source.worldy()) / 2f, 1f, tile.floor().liquidDrop.color); p.lastRipple(Time.time()); } return; @@ -59,7 +59,7 @@ public class Puddles{ p.accepting(Math.max(amount, p.accepting())); if(generation == 0 && p.lastRipple() <= Time.time() - 40f && p.amount() >= maxLiquid / 2f){ - Fx.ripple.at((tile.worldx() + source.worldx()) / 2f, (tile.worldy() + source.worldy()) / 2f, p.liquid().color); + Fx.ripple.at((tile.worldx() + source.worldx()) / 2f, (tile.worldy() + source.worldy()) / 2f, 1f, p.liquid().color); p.lastRipple(Time.time()); } }else{ diff --git a/core/src/mindustry/entities/comp/FlyingComp.java b/core/src/mindustry/entities/comp/FlyingComp.java index c0b4865ed7..f79fd3c3a1 100644 --- a/core/src/mindustry/entities/comp/FlyingComp.java +++ b/core/src/mindustry/entities/comp/FlyingComp.java @@ -70,7 +70,7 @@ abstract class FlyingComp implements Posc, Velc, Healthc, Hitboxc{ if(isGrounded() && floor.isLiquid){ if((splashTimer += Mathf.dst(deltaX(), deltaY())) >= 7f){ - floor.walkEffect.at(x, y, 0, floor.mapColor); + floor.walkEffect.at(x, y, 1f, floor.mapColor); splashTimer = 0f; } } @@ -79,7 +79,7 @@ abstract class FlyingComp implements Posc, Velc, Healthc, Hitboxc{ drownTime += Time.delta() * 1f / floor.drownTime; drownTime = Mathf.clamp(drownTime); if(Mathf.chanceDelta(0.05f)){ - floor.drownUpdateEffect.at(x, y, 0f, floor.mapColor); + floor.drownUpdateEffect.at(x, y, 1f, floor.mapColor); } //TODO is the netClient check necessary? diff --git a/core/src/mindustry/entities/comp/LegsComp.java b/core/src/mindustry/entities/comp/LegsComp.java index c957a26943..c3992e9593 100644 --- a/core/src/mindustry/entities/comp/LegsComp.java +++ b/core/src/mindustry/entities/comp/LegsComp.java @@ -1,14 +1,12 @@ package mindustry.entities.comp; import arc.math.*; -import arc.math.geom.*; import arc.util.*; import mindustry.*; import mindustry.annotations.Annotations.*; import mindustry.content.*; import mindustry.entities.*; import mindustry.gen.*; -import mindustry.graphics.*; import mindustry.type.*; import mindustry.world.blocks.environment.*; @@ -19,7 +17,7 @@ abstract class LegsComp implements Posc, Rotc, Hitboxc, Flyingc, Unitc, Elevatio transient Leg[] legs = {}; transient float totalLength; - transient int lastGroup; + transient float moveSpace; transient float baseRotation; @Override @@ -49,32 +47,29 @@ abstract class LegsComp implements Posc, Rotc, Hitboxc, Flyingc, Unitc, Elevatio } float moveSpeed = type.legSpeed; - int div = Math.max(legs.length / 2, 2); - float moveSpace = legLength / 1.6f / (div / 2f) * type.legMoveSpace; + int div = Math.max(legs.length / type.legGroupSize, 2); + moveSpace = legLength / 1.6f / (div / 2f) * type.legMoveSpace; totalLength += Mathf.dst(deltaX(), deltaY()); - - //float movespace = 360f / legs.length / 4f; - float stepMult = 0.8f; - float trns = legLength/2f*stepMult * 1.3f;//Mathf.dst(deltaX(), deltaY()) * 12.5f * div/1.5f * type.legTrns; - - //trns = moveSpace * 0.7f; - //trns = 0; + float trns = vel().len() * 12.5f * div/1.5f * type.legTrns; + trns = moveSpace * 0.85f * type.legTrns; //rotation + offset vector - Vec2 posOffset = Tmp.v4.trns(rot, trns); - float approach = Mathf.dst(deltaX(), deltaY()); + Tmp.v4.trns(rot, trns); for(int i = 0; i < legs.length; i++){ - Leg l = legs[i]; float dstRot = legAngle(rot, i); + float rot2 = Angles.moveToward(dstRot, rot + (Angles.angleDist(dstRot, rot) < 90f ? 180f : 0), type.legBend * 360f / legs.length / 4f); boolean side = i < legs.length/2; - //float rot2 = Angles.moveToward(dstRot, rot + (Angles.angleDist(dstRot, rot) < 90f ? 180f : 0), movespace); + Leg l = legs[i]; - int stage = (int)((totalLength + i*type.legPairOffset) / moveSpace); + float stageF = (totalLength + i*type.legPairOffset) / moveSpace; + int stage = (int)stageF; int group = stage % div; boolean move = i % div == group; + l.moving = move; + l.stage = stageF % 1f; if(l.group != group){ @@ -82,9 +77,9 @@ abstract class LegsComp implements Posc, Rotc, Hitboxc, Flyingc, Unitc, Elevatio if(!move && i % div == l.group){ Floor floor = Vars.world.floorWorld(l.base.x, l.base.y); if(floor.isLiquid){ - floor.walkEffect.at(l.base.x, l.base.y, 0, floor.mapColor); + floor.walkEffect.at(l.base.x, l.base.y, type.rippleScale, floor.mapColor); }else{ - Fx.unitLandSmall.at(l.base.x, l.base.y, 0.5f, floor.mapColor); + Fx.unitLandSmall.at(l.base.x, l.base.y, type.rippleScale, floor.mapColor); } //shake when legs contact ground @@ -97,27 +92,19 @@ abstract class LegsComp implements Posc, Rotc, Hitboxc, Flyingc, Unitc, Elevatio l.group = group; } - Vec2 offset = Tmp.v5.trns(dstRot, type.legBaseOffset).add(x, y); - //leg destination - Vec2 footDest = Tmp.v1.trns(dstRot - Mathf.sign(i % 2 == 0) * 0, legLength*stepMult).add(offset).add(posOffset); - //joint destination - //Tmp.v2.trns(rot2, legLength / 2f + type.legBaseOffset).add(x, y).add(offset); - + Tmp.v1.trns(dstRot - Mathf.sign(i % 2 == 0) * 0f, legLength + type.legBaseOffset).add(x, y).add(Tmp.v4); + //join destination + Tmp.v2.trns(rot2, legLength / 2f + type.legBaseOffset).add(x, y).add(Tmp.v4); if(move){ - l.base.lerpDelta(footDest, moveSpeed); - //l.joint.lerpDelta(Tmp.v2, moveSpeed / 4f); + float moveFract = stageF % 1f; + + l.base.lerpDelta(Tmp.v1, moveFract); + l.joint.lerpDelta(Tmp.v2, moveFract / 2f); } - Vec2 result = Tmp.v2; - InverseKinematics.solve(legLength/2f, legLength/2f, Tmp.v6.set(l.base).sub(offset), side, result); - result.add(offset); - - // if() - - //l.joint.lerpDelta(Tmp.v2, moveSpeed / 4f); - l.joint.set(result); + l.joint.lerpDelta(Tmp.v2, moveSpeed / 4f); } } @@ -126,14 +113,4 @@ abstract class LegsComp implements Posc, Rotc, Hitboxc, Flyingc, Unitc, Elevatio return rotation + 360f / legs.length * index + (360f / legs.length / 2f); } - /* - @Replace - public boolean isGrounded(){ - return true; - } - - @Replace - public boolean isFlying(){ - return false; - }*/ } diff --git a/core/src/mindustry/entities/comp/PuddleComp.java b/core/src/mindustry/entities/comp/PuddleComp.java index 531edba276..f2cd086d7e 100644 --- a/core/src/mindustry/entities/comp/PuddleComp.java +++ b/core/src/mindustry/entities/comp/PuddleComp.java @@ -73,7 +73,7 @@ abstract class PuddleComp implements Posc, Puddlec, Drawc{ unit.apply(liquid.effect, 60 * 2); if(unit.vel().len() > 0.1){ - Fx.ripple.at(unit.x(), unit.y(), liquid.color); + Fx.ripple.at(unit.x(), unit.y(), unit.type().rippleScale, liquid.color); } } } diff --git a/core/src/mindustry/type/UnitType.java b/core/src/mindustry/type/UnitType.java index 57602a15d3..b4c96589b7 100644 --- a/core/src/mindustry/type/UnitType.java +++ b/core/src/mindustry/type/UnitType.java @@ -34,7 +34,7 @@ public class UnitType extends UnlockableContent{ public @NonNull Prov constructor; public @NonNull Prov defaultController = () -> !flying ? new GroundAI() : new FlyingAI(); public float speed = 1.1f, boostMultiplier = 1f, rotateSpeed = 5f, baseRotateSpeed = 5f; - public float drag = 0.3f, accel = 0.5f, landShake = 0f; + public float drag = 0.3f, accel = 0.5f, landShake = 0f, rippleScale = 1f; public float health = 200f, range = -1, armor = 0f; public boolean targetAir = true, targetGround = true; public boolean faceTarget = true, rotateShooting = true, isCounted = true, lowAltitude = false; @@ -45,8 +45,8 @@ public class UnitType extends UnlockableContent{ public float baseElevation = 0f; //TODO document - public int legCount = 4; - public float legLength = 10f, legSpeed = 0.1f, legTrns = 1f, legBaseOffset = 0f, legMoveSpace = 1f, legExtension = 0, legPairOffset = 0; + public int legCount = 4, legGroupSize = 2; + public float legLength = 10f, legSpeed = 0.1f, legTrns = 1f, legBaseOffset = 0f, legMoveSpace = 1f, legExtension = 0, legPairOffset = 0, legBend = 0f; public int itemCapacity = 30; public int drillTier = -1; @@ -361,6 +361,7 @@ public class UnitType extends UnlockableContent{ int flips = Mathf.sign(flip); Vec2 position = legOffset.trns(angle, legBaseOffset).add(unit); + Tmp.v1.set(leg.base).sub(leg.joint).inv().setLength(legExtension); if(debug){ @@ -372,6 +373,14 @@ public class UnitType extends UnlockableContent{ Draw.reset(); }else{ + if(leg.moving && baseElevation > 0){ + float scl = baseElevation; + float elev = Mathf.slope(1f - leg.stage) * scl; + Draw.color(shadowColor); + Draw.rect(footRegion, leg.base.x + shadowTX * elev, leg.base.y + shadowTY * elev, position.angleTo(leg.base)); + Draw.color(); + } + Draw.rect(footRegion, leg.base.x, leg.base.y, position.angleTo(leg.base)); Lines.stroke(legRegion.getHeight() * Draw.scl * flips);