Fixed low-FPS movement getting broken

This commit is contained in:
Anuken
2018-11-16 17:28:42 -05:00
parent a7c8526f3e
commit 7f391dacbd
5 changed files with 8 additions and 9 deletions

View File

@@ -11,7 +11,7 @@ public class ThreadHandler{
public ThreadHandler(){ public ThreadHandler(){
Timers.setDeltaProvider(() -> { Timers.setDeltaProvider(() -> {
float result = Gdx.graphics.getDeltaTime() * 60f; float result = Gdx.graphics.getDeltaTime() * 60f;
return Math.min(Float.isNaN(result) || Float.isInfinite(result) ? 1f : result, 15f); return Float.isNaN(result) || Float.isInfinite(result) ? 1f : Math.min(result, 60f / 10f);
}); });
} }

View File

@@ -293,7 +293,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
float x = snappedX(), y = snappedY(); float x = snappedX(), y = snappedY();
if(!movement.isZero() && moved && !state.isPaused()){ if(!movement.isZero() && moved && !state.isPaused()){
walktime += Timers.delta() * movement.len() / 0.7f * getFloorOn().speedMultiplier; walktime += movement.len() / 0.7f * getFloorOn().speedMultiplier;
baseRotation = Mathf.slerpDelta(baseRotation, movement.angle(), 0.13f); baseRotation = Mathf.slerpDelta(baseRotation, movement.angle(), 0.13f);
} }
@@ -608,11 +608,11 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
pointerY = vec.y; pointerY = vec.y;
updateShooting(); updateShooting();
movement.limit(speed * Timers.delta()); movement.limit(speed).scl(Timers.delta());
if(getCarrier() == null){ if(getCarrier() == null){
if(!ui.chatfrag.chatOpen()){ if(!ui.chatfrag.chatOpen()){
velocity.add(movement); velocity.add(movement.x, movement.y);
} }
float prex = x, prey = y; float prex = x, prey = y;
updateVelocityStatus(); updateVelocityStatus();

View File

@@ -233,7 +233,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
status.update(this); status.update(this);
velocity.limit(getMaxVelocity()).scl(status.getSpeedMultiplier()); velocity.limit(getMaxVelocity()).scl(1f + (status.getSpeedMultiplier()-1f) * Timers.delta());
if(isFlying()){ if(isFlying()){
x += velocity.x * Timers.delta(); x += velocity.x * Timers.delta();

View File

@@ -238,7 +238,7 @@ public abstract class GroundUnit extends BaseUnit{
} }
protected void patrol(){ protected void patrol(){
vec.trns(baseRotation, type.speed); vec.trns(baseRotation, type.speed * Timers.delta());
velocity.add(vec.x, vec.y); velocity.add(vec.x, vec.y);
vec.trns(baseRotation, type.hitsizeTile); vec.trns(baseRotation, type.hitsizeTile);
Tile tile = world.tileWorld(x + vec.x, y + vec.y); Tile tile = world.tileWorld(x + vec.x, y + vec.y);

View File

@@ -11,12 +11,12 @@ import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.blocks.SelectionTrait; import io.anuke.mindustry.world.blocks.SelectionTrait;
import io.anuke.ucore.graphics.Draw; import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.scene.ui.layout.Table; import io.anuke.ucore.scene.ui.layout.Table;
import io.anuke.ucore.util.Log;
import java.io.DataInput; import java.io.DataInput;
import java.io.DataOutput; import java.io.DataOutput;
import java.io.IOException; import java.io.IOException;
import static io.anuke.mindustry.Vars.*;
import static io.anuke.mindustry.Vars.content;
public class SortedUnloader extends Unloader implements SelectionTrait{ public class SortedUnloader extends Unloader implements SelectionTrait{
protected float speed = 1f; protected float speed = 1f;
@@ -38,7 +38,6 @@ public class SortedUnloader extends Unloader implements SelectionTrait{
SortedUnloaderEntity entity = tile.entity(); SortedUnloaderEntity entity = tile.entity();
if(tile.entity.timer.get(timerUnload, speed) && tile.entity.items.total() == 0){ if(tile.entity.timer.get(timerUnload, speed) && tile.entity.items.total() == 0){
Log.info(threads.getFrameID());
for(Tile other : tile.entity.proximity()){ for(Tile other : tile.entity.proximity()){
if(other.getTeam() == tile.getTeam() && other.block() instanceof StorageBlock && entity.items.total() == 0 && if(other.getTeam() == tile.getTeam() && other.block() instanceof StorageBlock && entity.items.total() == 0 &&
((entity.sortItem == null && other.entity.items.total() > 0) || ((StorageBlock) other.block()).hasItem(other, entity.sortItem))){ ((entity.sortItem == null && other.entity.items.total() > 0) || ((StorageBlock) other.block()).hasItem(other, entity.sortItem))){