Better physics
This commit is contained in:
@@ -4,6 +4,7 @@ import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.util.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.world.blocks.*;
|
||||
|
||||
@@ -30,6 +31,19 @@ abstract class FlyingComp implements Posc, Velc, Healthc, Hitboxc{
|
||||
return isGrounded();
|
||||
}
|
||||
|
||||
void moveAt(Vec2 vector){
|
||||
Floor on = isFlying() ? Blocks.air.asFloor() : floorOn();
|
||||
Vec2 t = Tmp.v3.set(vector).scl(floorSpeedMultiplier()); //target vector
|
||||
float mag = Tmp.v3.len();
|
||||
vel.x = Mathf.approach(vel.x, t.x, mag);
|
||||
vel.y = Mathf.approach(vel.y, t.y, mag);
|
||||
}
|
||||
|
||||
float floorSpeedMultiplier(){
|
||||
Floor on = isFlying() ? Blocks.air.asFloor() : floorOn();
|
||||
return on.speedMultiplier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(){
|
||||
Floor floor = floorOn();
|
||||
|
||||
@@ -7,7 +7,7 @@ import mindustry.gen.*;
|
||||
abstract class MassComp implements Velc{
|
||||
float mass = 1f;
|
||||
|
||||
public void applyImpulse(float x, float y){
|
||||
public void impulse(float x, float y){
|
||||
vel().add(x / mass, y / mass);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,6 +83,8 @@ abstract class UnitComp implements Healthc, Velc, Statusc, Teamc, Itemsc, Hitbox
|
||||
|
||||
@Override
|
||||
public void update(){
|
||||
drag(type.drag * (isGrounded() ? (floorOn().dragMultiplier) : 1f));
|
||||
|
||||
//apply knockback based on spawns
|
||||
//TODO move elsewhere
|
||||
if(team() != state.rules.waveTeam){
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package mindustry.entities.def;
|
||||
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.world.blocks.*;
|
||||
|
||||
import static mindustry.Vars.collisions;
|
||||
|
||||
@@ -29,5 +31,11 @@ abstract class WaterMoveComp implements Posc, Velc, Hitboxc, Flyingc{
|
||||
public boolean canDrown(){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Replace
|
||||
public float floorSpeedMultiplier(){
|
||||
Floor on = isFlying() ? Blocks.air.asFloor() : floorOn();
|
||||
return on.isDeep() ? 1.3f : 1f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user