mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-07 00:38:26 +07:00
Better physics
This commit is contained in:
@ -268,11 +268,12 @@ public class Blocks implements ContentList{
|
||||
}};
|
||||
|
||||
ice = new Floor("ice"){{
|
||||
dragMultiplier = 0.6f;
|
||||
dragMultiplier = 0.35f;
|
||||
attributes.set(Attribute.water, 0.4f);
|
||||
}};
|
||||
|
||||
iceSnow = new Floor("ice-snow"){{
|
||||
dragMultiplier = 0.6f;
|
||||
variants = 3;
|
||||
attributes.set(Attribute.water, 0.3f);
|
||||
}};
|
||||
|
@ -22,8 +22,8 @@ public class UnitTypes implements ContentList{
|
||||
public void load(){
|
||||
|
||||
dagger = new UnitDef("dagger"){{
|
||||
speed = 0.2f;
|
||||
drag = 0.2f;
|
||||
speed = 1f;
|
||||
drag = 0.3f;
|
||||
hitsize = 8f;
|
||||
mass = 1.75f;
|
||||
health = 130;
|
||||
@ -37,7 +37,7 @@ public class UnitTypes implements ContentList{
|
||||
}};
|
||||
|
||||
vanguard = new UnitDef("vanguard"){{
|
||||
speed = 0.3f;
|
||||
speed = 1.3f;
|
||||
drag = 0.1f;
|
||||
hitsize = 8f;
|
||||
mass = 1.75f;
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -504,11 +504,11 @@ public class DesktopInput extends InputHandler{
|
||||
Vec2 movement = Tmp.v1.set(speed * xa, speed * ya).limit(speed);
|
||||
|
||||
if(omni){
|
||||
unit.vel().add(movement);
|
||||
unit.moveAt(movement);
|
||||
unit.lookAt(Angles.mouseAngle(unit.x(), unit.y()));
|
||||
}else{
|
||||
if(!unit.vel().isZero(0.01f)) unit.rotation(unit.vel().angle());
|
||||
unit.vel().add(Tmp.v2.trns(unit.rotation(), movement.len()));
|
||||
unit.moveAt(Tmp.v2.trns(unit.rotation(), movement.len()));
|
||||
if(!movement.isZero()) unit.vel().rotateTo(movement.angle(), unit.type().rotateSpeed * Time.delta());
|
||||
}
|
||||
|
||||
|
@ -162,7 +162,7 @@ public class Conveyor extends Block implements Autotiler{
|
||||
}
|
||||
|
||||
if(entity.len * itemSpace < 0.9f){
|
||||
unit.applyImpulse((tx * speed + centerx) * entity.delta(), (ty * speed + centery) * entity.delta());
|
||||
unit.impulse((tx * speed + centerx) * entity.delta(), (ty * speed + centery) * entity.delta());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,3 @@
|
||||
org.gradle.daemon=true
|
||||
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
||||
archash=b2996f736d5b6870913f5d8b5496fe6033069ac8
|
||||
archash=0328073f1993cd1d72a237781c3cc1f82395234b
|
||||
|
Reference in New Issue
Block a user