less (less) terrible physics
This commit is contained in:
@@ -25,7 +25,7 @@ allprojects {
|
|||||||
appName = 'Mindustry'
|
appName = 'Mindustry'
|
||||||
gdxVersion = '1.9.8'
|
gdxVersion = '1.9.8'
|
||||||
roboVMVersion = '2.3.0'
|
roboVMVersion = '2.3.0'
|
||||||
uCoreVersion = 'f5ae8c0d58b6b7b42e95e57114220b11beb43fb3'
|
uCoreVersion = '1042ca8a3959a1354f5249acc89e396035a3f266'
|
||||||
|
|
||||||
getVersionString = {
|
getVersionString = {
|
||||||
String buildVersion = getBuildVersion()
|
String buildVersion = getBuildVersion()
|
||||||
|
|||||||
@@ -495,6 +495,8 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
|||||||
spawner = -1;
|
spawner = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
avoidOthers(1f);
|
||||||
|
|
||||||
Tile tile = world.tileWorld(x, y);
|
Tile tile = world.tileWorld(x, y);
|
||||||
|
|
||||||
boostHeat = Mathf.lerpDelta(boostHeat, (tile != null && tile.solid()) || (isBoosting && ((!movement.isZero() && moved) || !isLocal)) ? 1f : 0f, 0.08f);
|
boostHeat = Mathf.lerpDelta(boostHeat, (tile != null && tile.solid()) || (isBoosting && ((!movement.isZero() && moved) || !isLocal)) ? 1f : 0f, 0.08f);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package io.anuke.mindustry.entities;
|
|||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
|
import com.badlogic.gdx.math.Rectangle;
|
||||||
import com.badlogic.gdx.math.Vector2;
|
import com.badlogic.gdx.math.Vector2;
|
||||||
import io.anuke.mindustry.content.blocks.Blocks;
|
import io.anuke.mindustry.content.blocks.Blocks;
|
||||||
import io.anuke.mindustry.entities.traits.*;
|
import io.anuke.mindustry.entities.traits.*;
|
||||||
@@ -39,6 +40,9 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
|
|||||||
/**Maximum absolute value of a velocity vector component.*/
|
/**Maximum absolute value of a velocity vector component.*/
|
||||||
public static final float maxAbsVelocity = 127f / velocityPercision;
|
public static final float maxAbsVelocity = 127f / velocityPercision;
|
||||||
|
|
||||||
|
private static final Rectangle queryRect = new Rectangle();
|
||||||
|
private static final Vector2 moveVector = new Vector2();
|
||||||
|
|
||||||
public final UnitInventory inventory = new UnitInventory(this);
|
public final UnitInventory inventory = new UnitInventory(this);
|
||||||
public float rotation;
|
public float rotation;
|
||||||
public float hitTime;
|
public float hitTime;
|
||||||
@@ -182,6 +186,18 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
|
|||||||
return status.hasEffect(effect);
|
return status.hasEffect(effect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void avoidOthers(float scaling){
|
||||||
|
getHitbox(queryRect);
|
||||||
|
queryRect.setSize(queryRect.getWidth() * scaling);
|
||||||
|
|
||||||
|
Units.getNearby(queryRect, t -> {
|
||||||
|
if(t == this || t.getCarrier() == this || getCarrier() == t || t.isFlying() != isFlying()) return;
|
||||||
|
float dst = distanceTo(t);
|
||||||
|
moveVector.set(x, y).sub(t.getX(), t.getY()).setLength(1f * (1f - (dst / queryRect.getWidth())));
|
||||||
|
applyImpulse(moveVector.x, moveVector.y);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public TileEntity getClosestCore(){
|
public TileEntity getClosestCore(){
|
||||||
TeamData data = state.teams.get(team);
|
TeamData data = state.teams.get(team);
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ import static io.anuke.mindustry.Vars.*;
|
|||||||
|
|
||||||
/**Base class for AI units.*/
|
/**Base class for AI units.*/
|
||||||
public abstract class BaseUnit extends Unit implements ShooterTrait{
|
public abstract class BaseUnit extends Unit implements ShooterTrait{
|
||||||
|
|
||||||
protected static int timerIndex = 0;
|
protected static int timerIndex = 0;
|
||||||
|
|
||||||
protected static final int timerTarget = timerIndex++;
|
protected static final int timerTarget = timerIndex++;
|
||||||
@@ -305,11 +306,10 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!Net.client()){
|
avoidOthers(1.2f);
|
||||||
|
|
||||||
if(spawner != -1 && (world.tile(spawner) == null || world.tile(spawner).entity == null)){
|
if(spawner != -1 && (world.tile(spawner) == null || world.tile(spawner).entity == null)){
|
||||||
damage(health);
|
damage(health);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(squad != null){
|
if(squad != null){
|
||||||
|
|||||||
@@ -121,10 +121,6 @@ public abstract class GroundUnit extends BaseUnit{
|
|||||||
|
|
||||||
stuckTime = !vec.set(x, y).sub(lastPosition()).isZero(0.0001f) ? 0f : stuckTime + Timers.delta();
|
stuckTime = !vec.set(x, y).sub(lastPosition()).isZero(0.0001f) ? 0f : stuckTime + Timers.delta();
|
||||||
|
|
||||||
if(!velocity.isZero(0.0001f) && (Units.invalidateTarget(target, this) || (distanceTo(target) > getWeapon().getAmmo().getRange()))){
|
|
||||||
rotation = Mathf.slerpDelta(rotation, velocity.angle(), type.rotatespeed);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!velocity.isZero()){
|
if(!velocity.isZero()){
|
||||||
baseRotation = Mathf.slerpDelta(baseRotation, velocity.angle(), 0.05f);
|
baseRotation = Mathf.slerpDelta(baseRotation, velocity.angle(), 0.05f);
|
||||||
}
|
}
|
||||||
@@ -249,6 +245,8 @@ public abstract class GroundUnit extends BaseUnit{
|
|||||||
if((tile == null || tile.solid() || tile.floor().drownTime > 0) || stuckTime > 10f){
|
if((tile == null || tile.solid() || tile.floor().drownTime > 0) || stuckTime > 10f){
|
||||||
baseRotation += Mathf.sign(id % 2 - 0.5f) * Timers.delta() * 3f;
|
baseRotation += Mathf.sign(id % 2 - 0.5f) * Timers.delta() * 3f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rotation = Mathf.slerpDelta(rotation, velocity.angle(), type.rotatespeed);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void circle(float circleLength){
|
protected void circle(float circleLength){
|
||||||
@@ -272,7 +270,10 @@ public abstract class GroundUnit extends BaseUnit{
|
|||||||
|
|
||||||
if(tile == targetTile) return;
|
if(tile == targetTile) return;
|
||||||
|
|
||||||
|
float angle = angleTo(targetTile);
|
||||||
|
|
||||||
velocity.add(vec.trns(angleTo(targetTile), type.speed));
|
velocity.add(vec.trns(angleTo(targetTile), type.speed));
|
||||||
|
rotation = Mathf.slerpDelta(rotation, angle, type.rotatespeed);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveAwayFromCore(){
|
protected void moveAwayFromCore(){
|
||||||
@@ -293,6 +294,9 @@ public abstract class GroundUnit extends BaseUnit{
|
|||||||
|
|
||||||
if(tile == targetTile || core == null || distanceTo(core) < 90f) return;
|
if(tile == targetTile || core == null || distanceTo(core) < 90f) return;
|
||||||
|
|
||||||
|
float angle = angleTo(targetTile);
|
||||||
|
|
||||||
velocity.add(vec.trns(angleTo(targetTile), type.speed));
|
velocity.add(vec.trns(angleTo(targetTile), type.speed));
|
||||||
|
rotation = Mathf.slerpDelta(rotation, angle, type.rotatespeed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -296,8 +296,6 @@ public class Sectors{
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user