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