Time.delta cleanup / Basic mobile input

This commit is contained in:
Anuken
2020-07-19 12:21:21 -04:00
parent f9ed74c15a
commit a074010eb7
91 changed files with 414 additions and 247 deletions

View File

@@ -181,7 +181,7 @@ public class BlockIndexer{
for(int y = -tileRange + ty; y <= tileRange + ty; y++){
if(!Mathf.within(x * tilesize, y * tilesize, wx, wy, range)) continue;
Building other = world.ent(x, y);
Building other = world.build(x, y);
if(other == null) continue;
@@ -247,7 +247,7 @@ public class BlockIndexer{
for(int tx = rx * quadrantSize; tx < (rx + 1) * quadrantSize && tx < world.width(); tx++){
for(int ty = ry * quadrantSize; ty < (ry + 1) * quadrantSize && ty < world.height(); ty++){
Building e = world.ent(tx, ty);
Building e = world.build(tx, ty);
if(e == null) continue;
@@ -388,7 +388,7 @@ public class BlockIndexer{
outer:
for(int x = quadrantX * quadrantSize; x < world.width() && x < (quadrantX + 1) * quadrantSize; x++){
for(int y = quadrantY * quadrantSize; y < world.height() && y < (quadrantY + 1) * quadrantSize; y++){
Building result = world.ent(x, y);
Building result = world.build(x, y);
//when a targetable block is found, mark this quadrant as occupied and stop searching
if(result != null && result.team() == team){
bits.set(quadrantX, quadrantY);

View File

@@ -167,12 +167,12 @@ public class Pathfinder implements Runnable{
}
}
public Tile getTargetTile(Tile tile, Team team, Position target){
public @Nullable Tile getTargetTile(Tile tile, Team team, Position target){
return getTargetTile(tile, team, getTarget(target));
}
/** Gets next tile to travel to. Main thread only. */
public Tile getTargetTile(Tile tile, Team team, PathTarget target){
public @Nullable Tile getTargetTile(Tile tile, Team team, PathTarget target){
if(tile == null) return null;
if(fieldMap[team.id] == null){

View File

@@ -69,7 +69,7 @@ public class BuilderAI extends AIController{
float length = circleLength <= 0.001f ? 1f : Mathf.clamp((unit.dst(target) - circleLength) / 100f, -1f, 1f);
vec.setLength(unit.type().speed * Time.delta() * length);
vec.setLength(unit.type().speed * Time.delta * length);
if(length < -0.5f){
vec.rotate(180f);
}else if(length < 0){

View File

@@ -61,7 +61,7 @@ public class FlyingAI extends AIController{
vec.rotate((circleLength - vec.len()) / circleLength * 180f);
}
vec.setLength(speed * Time.delta());
vec.setLength(speed * Time.delta);
unit.moveAt(vec);
}
@@ -73,7 +73,7 @@ public class FlyingAI extends AIController{
float length = circleLength <= 0.001f ? 1f : Mathf.clamp((unit.dst(target) - circleLength) / 100f, -1f, 1f);
vec.setLength(unit.type().speed * Time.delta() * length);
vec.setLength(unit.type().speed * Time.delta * length);
if(length < -0.5f){
vec.rotate(180f);
}else if(length < 0){
@@ -95,7 +95,7 @@ public class FlyingAI extends AIController{
vec.setAngle(Mathf.slerpDelta(unit.vel().angle(), vec.angle(), 0.6f));
}
vec.setLength(unit.type().speed * Time.delta());
vec.setLength(unit.type().speed * Time.delta);
unit.moveAt(vec);
}

View File

@@ -136,10 +136,10 @@ public class MusicControl{
silenced = false;
}else if(current == music && music != null){
//fade in the playing track
fade = Mathf.clamp(fade + Time.delta()/finTime);
fade = Mathf.clamp(fade + Time.delta /finTime);
}else if(current != null){
//fade out the current track
fade = Mathf.clamp(fade - Time.delta()/foutTime);
fade = Mathf.clamp(fade - Time.delta /foutTime);
if(fade <= 0.01f){
//stop current track when it hits 0 volume

View File

@@ -27,9 +27,9 @@ public class SoundLoop{
}else{
//fade the sound in or out
if(play){
volume = Mathf.clamp(volume + fadeSpeed * Time.delta());
volume = Mathf.clamp(volume + fadeSpeed * Time.delta);
}else{
volume = Mathf.clamp(volume - fadeSpeed * Time.delta());
volume = Mathf.clamp(volume - fadeSpeed * Time.delta);
if(volume <= 0.001f){
sound.stop(id);
id = -1;

View File

@@ -416,18 +416,18 @@ public class Bullets implements ContentList{
@Override
public void update(Bullet b){
if(Mathf.chance(0.04 * Time.delta())){
if(Mathf.chance(0.04 * Time.delta)){
Tile tile = world.tileWorld(b.x, b.y);
if(tile != null){
Fires.create(tile);
}
}
if(Mathf.chance(0.1 * Time.delta())){
if(Mathf.chance(0.1 * Time.delta)){
Fx.fireballsmoke.at(b.x, b.y);
}
if(Mathf.chance(0.1 * Time.delta())){
if(Mathf.chance(0.1 * Time.delta)){
Fx.ballfire.at(b.x, b.y);
}
}

View File

@@ -416,14 +416,7 @@ public class Control implements ApplicationListener, Loadable{
//just a regular reminder
if(!OS.prop("user.name").equals("anuke") && !OS.hasEnv("iknowwhatimdoing")){
if(mobile){
Runnable[] run = {null};
run[0] = () -> {
ui.showInfo("[scarlet]6.0 doesn't work on mobile.[] Don't play it.", run[0]);
};
}else{
ui.showInfo("[scarlet]6.0 is not supposed to be played.[] Go do something else.");
}
ui.showInfo("[scarlet]6.0 is not supposed to be played.[] Go do something else.");
}
//play tutorial on stop
@@ -449,7 +442,7 @@ public class Control implements ApplicationListener, Loadable{
if(countdown[0] <= 0){
exit.run();
}
return Core.bundle.format("uiscale.reset", (int)((countdown[0] -= Time.delta()) / 60f));
return Core.bundle.format("uiscale.reset", (int)((countdown[0] -= Time.delta) / 60f));
}).pad(10f).expand().center();
dialog.buttons.defaults().size(200f, 60f);
@@ -486,7 +479,6 @@ public class Control implements ApplicationListener, Loadable{
music.update();
loops.update();
Time.updateGlobal();
if(Core.input.keyTap(Binding.fullscreen)){
boolean full = settings.getBool("fullscreen");
@@ -528,6 +520,7 @@ public class Control implements ApplicationListener, Loadable{
}
}else{
//this runs in the menu
if(!state.isPaused()){
Time.update();
}

View File

@@ -244,7 +244,7 @@ public class Logic implements ApplicationListener{
for(WeatherEntry entry : state.rules.weather){
//update cooldown
entry.cooldown -= Time.delta();
entry.cooldown -= Time.delta;
//create new event when not active
if(entry.cooldown < 0 && !entry.weather.isActive()){
@@ -356,7 +356,7 @@ public class Logic implements ApplicationListener{
if(state.rules.waves && state.rules.waveTimer && !state.gameOver){
if(!isWaitingWave()){
state.wavetime = Math.max(state.wavetime - Time.delta(), 0);
state.wavetime = Math.max(state.wavetime - Time.delta, 0);
}
}

View File

@@ -476,7 +476,7 @@ public class NetClient implements ApplicationListener{
}else if(!connecting){
net.disconnect();
}else{ //...must be connecting
timeoutTime += Time.delta();
timeoutTime += Time.delta;
if(timeoutTime > dataTimeout){
Log.err("Failed to load data!");
ui.loadfrag.hide();

View File

@@ -63,7 +63,7 @@ public class Renderer implements ApplicationListener{
camerascale = Mathf.lerpDelta(camerascale, targetscale, 0.1f);
if(landTime > 0){
landTime -= Time.delta();
landTime -= Time.delta;
landscale = Interp.pow5In.apply(minZoomScl, Scl.scl(4f), 1f - landTime / Fx.coreLand.lifetime);
camerascale = landscale;
weatherAlpha = 0f;
@@ -172,8 +172,8 @@ public class Renderer implements ApplicationListener{
if(shaketime > 0){
float intensity = shakeIntensity * (settings.getInt("screenshake", 4) / 4f) * scale;
camera.position.add(Mathf.range(intensity), Mathf.range(intensity));
shakeIntensity -= 0.25f * Time.delta();
shaketime -= Time.delta();
shakeIntensity -= 0.25f * Time.delta;
shaketime -= Time.delta;
shakeIntensity = Mathf.clamp(shakeIntensity, 0f, 100f);
}else{
shakeIntensity = 0f;

View File

@@ -110,14 +110,14 @@ public class World{
}
@Nullable
public Building ent(int x, int y){
public Building build(int x, int y){
Tile tile = tile(x, y);
if(tile == null) return null;
return tile.build;
}
@Nullable
public Building ent(int pos){
public Building build(int pos){
Tile tile = tile(pos);
if(tile == null) return null;
return tile.build;
@@ -134,8 +134,8 @@ public class World{
}
@Nullable
public Building entWorld(float x, float y){
return ent(Math.round(x / tilesize), Math.round(y / tilesize));
public Building buildWorld(float x, float y){
return build(Math.round(x / tilesize), Math.round(y / tilesize));
}
public int toTile(float coord){

View File

@@ -104,7 +104,7 @@ public class WaveInfoDialog extends BaseDialog{
m.button("-", () -> {
}).update(t -> {
if(t.getClickListener().isPressed()){
updateTimer += Time.delta();
updateTimer += Time.delta;
if(updateTimer >= updatePeriod){
start = Math.max(start - 1, 0);
updateTimer = 0f;
@@ -118,7 +118,7 @@ public class WaveInfoDialog extends BaseDialog{
m.button("+", () -> {
}).update(t -> {
if(t.getClickListener().isPressed()){
updateTimer += Time.delta();
updateTimer += Time.delta;
if(updateTimer >= updatePeriod){
start++;
updateTimer = 0f;

View File

@@ -86,7 +86,7 @@ public class Damage{
collidedBlocks.clear();
tr.trns(angle, length);
Intc2 collider = (cx, cy) -> {
Building tile = world.ent(cx, cy);
Building tile = world.build(cx, cy);
if(tile != null && !collidedBlocks.contains(tile.pos()) && tile.team() != team && tile.collide(hitter)){
tile.collision(hitter);
collidedBlocks.add(tile.pos());
@@ -159,7 +159,7 @@ public class Damage{
tmpBuilding = null;
world.raycastEachWorld(x, y, x + tr.x, y + tr.y, (cx, cy) -> {
Building tile = world.ent(cx, cy);
Building tile = world.build(cx, cy);
if(tile != null && tile.team != hitter.team){
tmpBuilding = tile;
//TODO return tile

View File

@@ -52,9 +52,9 @@ public class Fires{
public static void extinguish(Tile tile, float intensity){
if(tile != null && map.containsKey(tile.pos())){
Fire fire = map.get(tile.pos());
fire.time(fire.time() + intensity * Time.delta());
fire.time(fire.time + intensity * Time.delta);
Fx.steam.at(fire);
if(fire.time() >= fire.lifetime()){
if(fire.time >= fire.lifetime){
Events.fire(Trigger.fireExtinguish);
}
}

View File

@@ -24,8 +24,8 @@ public class Predict{
* @return the intercept location
*/
public static Vec2 intercept(float srcx, float srcy, float dstx, float dsty, float dstvx, float dstvy, float v){
dstvx /= Time.delta();
dstvy /= Time.delta();
dstvx /= Time.delta;
dstvy /= Time.delta;
float tx = dstx - srcx,
ty = dsty - srcy;
@@ -58,8 +58,8 @@ public class Predict{
ddy += ((Hitboxc)dst).deltaY();
}
if(src instanceof Hitboxc){
ddx -= ((Hitboxc)src).deltaX()/(Time.delta());
ddy -= ((Hitboxc)src).deltaY()/(Time.delta());
ddx -= ((Hitboxc)src).deltaX()/(Time.delta);
ddy -= ((Hitboxc)src).deltaY()/(Time.delta);
}
return intercept(src.getX(), src.getY(), dst.getX(), dst.getY(), ddx, ddy, v);
}
@@ -68,7 +68,7 @@ public class Predict{
* See {@link #intercept(float, float, float, float, float, float, float)}.
*/
public static Vec2 intercept(Hitboxc src, Hitboxc dst, float v){
return intercept(src.getX(), src.getY(), dst.getX(), dst.getY(), dst.deltaX() - src.deltaX()/(2f*Time.delta()), dst.deltaY() - src.deltaX()/(2f*Time.delta()), v);
return intercept(src.getX(), src.getY(), dst.getX(), dst.getY(), dst.deltaX() - src.deltaX()/(2f* Time.delta), dst.deltaY() - src.deltaX()/(2f* Time.delta), v);
}
private static Vec2 quad(float a, float b, float c){

View File

@@ -50,7 +50,7 @@ public class ForceFieldAbility implements Ability{
@Override
public void update(Unit unit){
if(unit.shield < max){
unit.shield += Time.delta() * regen;
unit.shield += Time.delta * regen;
}
if(unit.shield > 0){

View File

@@ -22,7 +22,7 @@ public class HealFieldAbility implements Ability{
@Override
public void update(Unit unit){
unit.timer1 += Time.delta();
unit.timer1 += Time.delta;
if(unit.timer1 >= reload){
wasHealed = false;

View File

@@ -23,7 +23,7 @@ public class ShieldFieldAbility implements Ability{
@Override
public void update(Unit unit){
unit.timer1 += Time.delta();
unit.timer1 += Time.delta;
if(unit.timer1 >= reload){
applied = false;

View File

@@ -24,7 +24,7 @@ public class StatusFieldAbility implements Ability{
@Override
public void update(Unit unit){
unit.timer2 += Time.delta();
unit.timer2 += Time.delta;
if(unit.timer2 >= reload){

View File

@@ -196,7 +196,7 @@ public abstract class BulletType extends Content{
}
if(weaveMag > 0){
b.vel.rotate(Mathf.sin(Mathf.randomSeed(b.id, 10f) + b.time, weaveScale, weaveMag) * Time.delta());
b.vel.rotate(Mathf.sin(Mathf.randomSeed(b.id, 10f) + b.time, weaveScale, weaveMag) * Time.delta);
}
if(trailChance > 0){
@@ -241,7 +241,7 @@ public abstract class BulletType extends Content{
bullet.owner = owner;
bullet.team = team;
bullet.vel.trns(angle, speed * velocityScl);
bullet.set(x - bullet.vel.x * Time.delta(), y - bullet.vel.y * Time.delta());
bullet.set(x - bullet.vel.x * Time.delta, y - bullet.vel.y * Time.delta);
bullet.lifetime = lifetime * lifetimeScl;
bullet.data = data;
bullet.drag = drag;

View File

@@ -114,9 +114,9 @@ abstract class BuilderComp implements Unitc{
BuildEntity entity = tile.bc();
if(current.breaking){
entity.deconstruct(base(), core, 1f / entity.buildCost * Time.delta() * type().buildSpeed * state.rules.buildSpeedMultiplier);
entity.deconstruct(base(), core, 1f / entity.buildCost * Time.delta * type().buildSpeed * state.rules.buildSpeedMultiplier);
}else{
if(entity.construct(base(), core, 1f / entity.buildCost * Time.delta() * type().buildSpeed * state.rules.buildSpeedMultiplier, current.hasConfig)){
if(entity.construct(base(), core, 1f / entity.buildCost * Time.delta * type().buildSpeed * state.rules.buildSpeedMultiplier, current.hasConfig)){
if(current.hasConfig){
Call.tileConfig(null, tile.build, current.config);
}

View File

@@ -201,14 +201,14 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
}
public Building nearby(int dx, int dy){
return world.ent(tile.x + dx, tile.y + dy);
return world.build(tile.x + dx, tile.y + dy);
}
public Building nearby(int rotation){
if(rotation == 0) return world.ent(tile.x + 1, tile.y);
if(rotation == 1) return world.ent(tile.x, tile.y + 1);
if(rotation == 2) return world.ent(tile.x - 1, tile.y);
if(rotation == 3) return world.ent(tile.x, tile.y - 1);
if(rotation == 0) return world.build(tile.x + 1, tile.y);
if(rotation == 1) return world.build(tile.x, tile.y + 1);
if(rotation == 2) return world.build(tile.x - 1, tile.y);
if(rotation == 3) return world.build(tile.x, tile.y - 1);
return null;
}
@@ -290,7 +290,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
/** Scaled delta. */
public float delta(){
return Time.delta() * timeScale;
return Time.delta * timeScale;
}
/** Efficiency * delta. */
@@ -305,7 +305,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
/** Call when nothing is happening to the entity. This increments the internal sleep timer. */
public void sleep(){
sleepTime += Time.delta();
sleepTime += Time.delta;
if(!sleeping && sleepTime >= timeToSleep){
remove();
sleeping = true;
@@ -518,14 +518,14 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
Liquid other = next.liquids().current();
if((other.flammability > 0.3f && liquid.temperature > 0.7f) || (liquid.flammability > 0.3f && other.temperature > 0.7f)){
damage(1 * Time.delta());
next.damage(1 * Time.delta());
if(Mathf.chance(0.1 * Time.delta())){
damage(1 * Time.delta);
next.damage(1 * Time.delta);
if(Mathf.chance(0.1 * Time.delta)){
Fx.fire.at(fx, fy);
}
}else if((liquid.temperature > 0.7f && other.temperature < 0.55f) || (other.temperature > 0.7f && liquid.temperature < 0.55f)){
liquids.remove(liquid, Math.min(liquids.get(liquid), 0.7f * Time.delta()));
if(Mathf.chance(0.2f * Time.delta())){
liquids.remove(liquid, Math.min(liquids.get(liquid), 0.7f * Time.delta));
if(Mathf.chance(0.2f * Time.delta)){
Fx.steam.at(fx, fy);
}
}
@@ -797,7 +797,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
int range = 10;
tempTiles.clear();
Geometry.circle(tileX(), tileY(), range, (x, y) -> {
Building other = world.ent(x, y);
Building other = world.build(x, y);
if(other != null && other.block instanceof PowerNode && ((PowerNode)other.block).linkValid(other, base()) && !PowerNode.insulated(other, base())
&& !other.proximity().contains(this.<Building>base()) &&
!(block.outputsPower && proximity.contains(p -> p.power() != null && p.power().graph == other.power().graph))){
@@ -926,60 +926,63 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
table.row();
table.table(bars -> {
bars.defaults().growX().height(18f).pad(4);
//only display everything else if the team is the same
if(team == player.team()){
table.table(bars -> {
bars.defaults().growX().height(18f).pad(4);
displayBars(bars);
}).growX();
table.row();
table.table(this::displayConsumption).growX();
displayBars(bars);
}).growX();
table.row();
table.table(this::displayConsumption).growX();
boolean displayFlow = (block.category == Category.distribution || block.category == Category.liquid) && Core.settings.getBool("flow");
boolean displayFlow = (block.category == Category.distribution || block.category == Category.liquid) && Core.settings.getBool("flow");
if(displayFlow){
String ps = " " + StatUnit.perSecond.localized();
if(displayFlow){
String ps = " " + StatUnit.perSecond.localized();
if(items != null){
table.row();
table.left();
table.table(l -> {
Bits current = new Bits();
if(items != null){
table.row();
table.left();
table.table(l -> {
Bits current = new Bits();
Runnable rebuild = () -> {
l.clearChildren();
Runnable rebuild = () -> {
l.clearChildren();
l.left();
for(Item item : content.items()){
if(items.hasFlowItem(item)){
l.image(item.icon(Cicon.small)).padRight(3f);
l.label(() -> items.getFlowRate(item) < 0 ? "..." : Strings.fixed(items.getFlowRate(item), 1) + ps).color(Color.lightGray);
l.row();
}
}
};
rebuild.run();
l.update(() -> {
for(Item item : content.items()){
if(items.hasFlowItem(item) && !current.get(item.id)){
current.set(item.id);
rebuild.run();
}
}
});
}).left();
}
if(liquids != null){
table.row();
table.table(l -> {
l.left();
for(Item item : content.items()){
if(items.hasFlowItem(item)){
l.image(item.icon(Cicon.small)).padRight(3f);
l.label(() -> items.getFlowRate(item) < 0 ? "..." : Strings.fixed(items.getFlowRate(item), 1) + ps).color(Color.lightGray);
l.row();
}
}
};
rebuild.run();
l.update(() -> {
for(Item item : content.items()){
if(items.hasFlowItem(item) && !current.get(item.id)){
current.set(item.id);
rebuild.run();
}
}
l.image(() -> liquids.current().icon(Cicon.small)).padRight(3f);
l.label(() -> liquids.getFlowRate() < 0 ? "..." : Strings.fixed(liquids.getFlowRate(), 2) + ps).color(Color.lightGray);
});
}).left();
}
}
if(liquids != null){
table.row();
table.table(l -> {
l.left();
l.image(() -> liquids.current().icon(Cicon.small)).padRight(3f);
l.label(() -> liquids.getFlowRate() < 0 ? "..." : Strings.fixed(liquids.getFlowRate(), 2) + ps).color(Color.lightGray);
});
}
table.marginBottom(-5);
}
table.marginBottom(-5);
}
public void displayConsumption(Table table){
@@ -1065,7 +1068,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
Point2[] nearby = Edges.getEdges(block.size);
for(Point2 point : nearby){
Building other = world.ent(tile.x + point.x, tile.y + point.y);
Building other = world.build(tile.x + point.x, tile.y + point.y);
//remove this tile from all nearby tile's proximities
if(other != null){
tmpTiles.add(other);
@@ -1084,7 +1087,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
Point2[] nearby = Edges.getEdges(block.size);
for(Point2 point : nearby){
Building other = world.ent(tile.x + point.x, tile.y + point.y);
Building other = world.build(tile.x + point.x, tile.y + point.y);
if(other == null || !(other.tile.interactable(team))) continue;
@@ -1175,7 +1178,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
@Final
@Override
public void update(){
timeScaleDuration -= Time.delta();
timeScaleDuration -= Time.delta;
if(timeScaleDuration <= 0f || !block.canOverdrive){
timeScale = 1f;
}

View File

@@ -111,7 +111,7 @@ abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Draw
if(type.collidesTiles && type.collides && type.collidesGround){
world.raycastEach(world.toTile(lastX()), world.toTile(lastY()), tileX(), tileY(), (x, y) -> {
Building tile = world.ent(x, y);
Building tile = world.build(x, y);
if(tile == null) return false;
if(tile.collide(base()) && type.collides(base(), tile) && !tile.dead() && (type.collidesTeam || tile.team != team)){

View File

@@ -26,19 +26,19 @@ abstract class FireComp implements Timedc, Posc, Firec{
@Override
public void update(){
if(Mathf.chance(0.1 * Time.delta())){
if(Mathf.chance(0.1 * Time.delta)){
Fx.fire.at(x + Mathf.range(4f), y + Mathf.range(4f));
}
if(Mathf.chance(0.05 * Time.delta())){
if(Mathf.chance(0.05 * Time.delta)){
Fx.fireSmoke.at(x + Mathf.range(4f), y + Mathf.range(4f));
}
if(Mathf.chance(0.001 * Time.delta())){
if(Mathf.chance(0.001 * Time.delta)){
Sounds.fire.at(this);
}
time = Mathf.clamp(time + Time.delta(), 0, lifetime());
time = Mathf.clamp(time + Time.delta, 0, lifetime());
if(Vars.net.client()){
return;
@@ -55,7 +55,7 @@ abstract class FireComp implements Timedc, Posc, Firec{
float flammability = baseFlammability + puddleFlammability;
if(!damage && flammability <= 0){
time += Time.delta() * 8;
time += Time.delta * 8;
}
if(baseFlammability < 0 || block != tile.block()){
@@ -64,20 +64,20 @@ abstract class FireComp implements Timedc, Posc, Firec{
}
if(damage){
lifetime += Mathf.clamp(flammability / 8f, 0f, 0.6f) * Time.delta();
lifetime += Mathf.clamp(flammability / 8f, 0f, 0.6f) * Time.delta;
}
if(flammability > 1f && Mathf.chance(spreadChance * Time.delta() * Mathf.clamp(flammability / 5f, 0.3f, 2f))){
if(flammability > 1f && Mathf.chance(spreadChance * Time.delta * Mathf.clamp(flammability / 5f, 0.3f, 2f))){
Point2 p = Geometry.d4[Mathf.random(3)];
Tile other = world.tile(tile.x + p.x, tile.y + p.y);
Fires.create(other);
if(Mathf.chance(fireballChance * Time.delta() * Mathf.clamp(flammability / 10f))){
if(Mathf.chance(fireballChance * Time.delta * Mathf.clamp(flammability / 10f))){
Bullets.fireball.createNet(Team.derelict, x, y, Mathf.random(360f), -1f, 1, 1);
}
}
if(Mathf.chance(0.1 * Time.delta())){
if(Mathf.chance(0.1 * Time.delta)){
Puddlec p = Puddles.get(tile);
puddleFlammability = p != null ? p.getFlammability() / 3f : 0;

View File

@@ -44,8 +44,8 @@ abstract class FlyingComp implements Posc, Velc, Healthc, Hitboxc{
}
void wobble(){
x += Mathf.sin(Time.time() + id() * 99, 25f, 0.05f) * Time.delta() * elevation;
y += Mathf.cos(Time.time() + id() * 99, 25f, 0.05f) * Time.delta() * elevation;
x += Mathf.sin(Time.time() + id() * 99, 25f, 0.05f) * Time.delta * elevation;
y += Mathf.cos(Time.time() + id() * 99, 25f, 0.05f) * Time.delta * elevation;
}
void moveAt(Vec2 vector, float acceleration){
@@ -81,7 +81,7 @@ abstract class FlyingComp implements Posc, Velc, Healthc, Hitboxc{
}
if(canDrown() && floor.isLiquid && floor.drownTime > 0){
drownTime += Time.delta() * 1f / floor.drownTime;
drownTime += Time.delta * 1f / floor.drownTime;
drownTime = Mathf.clamp(drownTime);
if(Mathf.chanceDelta(0.05f)){
floor.drownUpdateEffect.at(x, y, 1f, floor.mapColor);

View File

@@ -24,7 +24,7 @@ abstract class HealthComp implements Entityc{
@Override
public void update(){
hitTime -= Time.delta() / hitDuration;
hitTime -= Time.delta / hitDuration;
}
void killed(){
@@ -82,11 +82,11 @@ abstract class HealthComp implements Entityc{
}
void damageContinuous(float amount){
damage(amount * Time.delta(), hitTime <= -10 + hitDuration);
damage(amount * Time.delta, hitTime <= -10 + hitDuration);
}
void damageContinuousPierce(float amount){
damagePierce(amount * Time.delta(), hitTime <= -20 + hitDuration);
damagePierce(amount * Time.delta, hitTime <= -20 + hitDuration);
}
void clampHealth(){

View File

@@ -14,6 +14,6 @@ abstract class MechComp implements Posc, Flyingc, Hitboxc, Unitc, Mechc, Elevati
public void update(){
float len = deltaLen();
baseRotation = Angles.moveToward(baseRotation, deltaAngle(), type().baseRotateSpeed * Mathf.clamp(len / type().speed));
walkTime += Time.delta()*len;
walkTime += Time.delta *len;
}
}

View File

@@ -58,7 +58,7 @@ abstract class MinerComp implements Itemsc, Posc, Teamc, Rotc, Drawc, Unitc{
}else{
Item item = mineTile.drop();
rotation(Mathf.slerpDelta(rotation(), angleTo(mineTile.worldx(), mineTile.worldy()), 0.4f));
mineTimer += Time.delta()*type.mineSpeed;
mineTimer += Time.delta *type.mineSpeed;
if(mineTimer >= 50f + item.hardness*10f){
mineTimer = 0;
@@ -76,7 +76,7 @@ abstract class MinerComp implements Itemsc, Posc, Teamc, Rotc, Drawc, Unitc{
}
}
if(Mathf.chance(0.06 * Time.delta())){
if(Mathf.chance(0.06 * Time.delta)){
Fx.pulverizeSmall.at(mineTile.worldx() + Mathf.range(tilesize / 2f), mineTile.worldy() + Mathf.range(tilesize / 2f), 0f, item.color);
}
}

View File

@@ -119,7 +119,7 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra
}else if(core != null){
//have a small delay before death to prevent the camera from jumping around too quickly
//(this is not for balance)
deathTimer += Time.delta();
deathTimer += Time.delta;
if(deathTimer >= deathDelay){
//request spawn - this happens serverside only
core.requestSpawn(base());
@@ -127,7 +127,7 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra
}
}
textFadeTime -= Time.delta() / (60 * 5);
textFadeTime -= Time.delta / (60 * 5);
}

View File

@@ -43,13 +43,13 @@ abstract class PuddleComp implements Posc, Puddlec, Drawc{
//update code
float addSpeed = accepting > 0 ? 3f : 0f;
amount -= Time.delta() * (1f - liquid.viscosity) / (5f + addSpeed);
amount -= Time.delta * (1f - liquid.viscosity) / (5f + addSpeed);
amount += accepting;
accepting = 0f;
if(amount >= maxLiquid / 1.5f && generation < maxGeneration){
float deposited = Math.min((amount - maxLiquid / 1.5f) / 4f, 0.3f) * Time.delta();
float deposited = Math.min((amount - maxLiquid / 1.5f) / 4f, 0.3f) * Time.delta;
for(Point2 point : Geometry.d4){
Tile other = world.tile(tile.x + point.x, tile.y + point.y);
if(other != null && other.block() == Blocks.air){
@@ -87,7 +87,7 @@ abstract class PuddleComp implements Posc, Puddlec, Drawc{
updateTime = 40f;
}
updateTime -= Time.delta();
updateTime -= Time.delta;
}
@Override

View File

@@ -52,7 +52,7 @@ abstract class ShieldComp implements Healthc, Posc{
@Override
public void update(){
shieldAlpha -= Time.delta() / 15f;
shieldAlpha -= Time.delta / 15f;
if(shieldAlpha < 0) shieldAlpha = 0f;
}
}

View File

@@ -117,7 +117,7 @@ abstract class StatusComp implements Posc, Flyingc{
while(index < statuses.size){
StatusEntry entry = statuses.get(index++);
entry.time = Math.max(entry.time - Time.delta(), 0);
entry.time = Math.max(entry.time - Time.delta, 0);
applied.set(entry.effect.id);
if(entry.time <= 0 && !entry.effect.permanent){

View File

@@ -13,7 +13,7 @@ abstract class TimedComp implements Entityc, Scaled{
@MethodPriority(100)
@Override
public void update(){
time = Math.min(time + Time.delta(), lifetime);
time = Math.min(time + Time.delta, lifetime);
if(time >= lifetime){
remove();

View File

@@ -103,7 +103,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
}
public void lookAt(float angle){
rotation = Angles.moveToward(rotation, angle, type.rotateSpeed * Time.delta());
rotation = Angles.moveToward(rotation, angle, type.rotateSpeed * Time.delta);
}
public void lookAt(Position pos){
@@ -176,7 +176,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
float relativeSize = state.rules.dropZoneRadius + bounds()/2f + 1f;
for(Tile spawn : spawner.getSpawns()){
if(within(spawn.worldx(), spawn.worldy(), relativeSize)){
vel().add(Tmp.v1.set(this).sub(spawn.worldx(), spawn.worldy()).setLength(0.1f + 1f - dst(spawn) / relativeSize).scl(0.45f * Time.delta()));
vel().add(Tmp.v1.set(this).sub(spawn.worldx(), spawn.worldy()).setLength(0.1f + 1f - dst(spawn) / relativeSize).scl(0.45f * Time.delta));
}
}
}
@@ -204,7 +204,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
}
//move down
elevation -= type.fallSpeed * Time.delta();
elevation -= type.fallSpeed * Time.delta;
if(isGrounded()){
destroy();

View File

@@ -17,8 +17,8 @@ abstract class VelComp implements Posc{
@MethodPriority(-1)
@Override
public void update(){
move(vel.x * Time.delta(), vel.y * Time.delta());
vel.scl(1f - drag * Time.delta());
move(vel.x * Time.delta, vel.y * Time.delta);
vel.scl(1f - drag * Time.delta);
}
boolean moving(){

View File

@@ -42,7 +42,7 @@ abstract class WaterMoveComp implements Posc, Velc, Hitboxc, Flyingc, Unitc{
Floor floor = floorOn();
Color color = Tmp.c1.set(floor.mapColor).mul(1.5f);
trailColor.lerp(color, Mathf.clamp(Time.delta() * 0.04f));
trailColor.lerp(color, Mathf.clamp(Time.delta * 0.04f));
tleft.draw(trailColor, type.trailScl);
tright.draw(trailColor, type.trailScl);

View File

@@ -47,6 +47,10 @@ abstract class WeaponsComp implements Teamc, Posc, Rotc{
}
}
void controlWeapons(boolean rotateShoot){
controlWeapons(rotateShoot, rotateShoot);
}
void controlWeapons(boolean rotate, boolean shoot){
for(WeaponMount mount : mounts){
mount.rotate = rotate;
@@ -82,11 +86,11 @@ abstract class WeaponsComp implements Teamc, Posc, Rotc{
public void update(){
for(WeaponMount mount : mounts){
Weapon weapon = mount.weapon;
mount.reload = Math.max(mount.reload - Time.delta() * reloadMultiplier, 0);
mount.reload = Math.max(mount.reload - Time.delta * reloadMultiplier, 0);
//flip weapon shoot side for alternating weapons at half reload
if(weapon.otherSide != -1 && weapon.alternate && mount.side == weapon.flipSprite &&
mount.reload + Time.delta() > weapon.reload/2f && mount.reload <= weapon.reload/2f){
mount.reload + Time.delta > weapon.reload/2f && mount.reload <= weapon.reload/2f){
mounts[weapon.otherSide].side = !mounts[weapon.otherSide].side;
mount.side = !mount.side;
}
@@ -97,7 +101,7 @@ abstract class WeaponsComp implements Teamc, Posc, Rotc{
axisY = this.y + Angles.trnsy(rotation - 90, weapon.x, weapon.y);
mount.targetRotation = Angles.angle(axisX, axisY, mount.aimX, mount.aimY) - rotation;
mount.rotation = Angles.moveToward(mount.rotation, mount.targetRotation, weapon.rotateSpeed * Time.delta());
mount.rotation = Angles.moveToward(mount.rotation, mount.targetRotation, weapon.rotateSpeed * Time.delta);
}else{
mount.rotation = 0;
mount.targetRotation = angleTo(mount.aimX, mount.aimY);

View File

@@ -86,7 +86,7 @@ public class Saves{
}
if(state.isGame() && !state.gameOver && current != null && current.isAutosave() && !state.rules.tutorial){
time += Time.delta();
time += Time.delta;
if(time > Core.settings.getInt("saveinterval") * 60){
saving = true;

View File

@@ -345,7 +345,7 @@ public class Schematics implements Loadable{
boolean found = false;
for(int cx = x; cx <= x2; cx++){
for(int cy = y; cy <= y2; cy++){
Building linked = world.ent(cx, cy);
Building linked = world.build(cx, cy);
if(linked != null &&linked.block().isVisible() && !(linked.block() instanceof BuildBlock)){
int top = linked.block().size/2;
@@ -373,7 +373,7 @@ public class Schematics implements Loadable{
IntSet counted = new IntSet();
for(int cx = ox; cx <= ox2; cx++){
for(int cy = oy; cy <= oy2; cy++){
Building tile = world.ent(cx, cy);
Building tile = world.build(cx, cy);
if(tile != null && !counted.contains(tile.pos()) && !(tile.block() instanceof BuildBlock)
&& (tile.block().isVisible() || (tile.block() instanceof CoreBlock))){

View File

@@ -84,10 +84,10 @@ public class SectorInfo{
/** Update averages of various stats.
* Called every frame. */
public void update(){
internalTimeSpent += Time.delta();
internalTimeSpent += Time.delta;
//time spent exceeds turn duration!
if(internalTimeSpent >= turnDuration && internalTimeSpent - Time.delta() < turnDuration){
if(internalTimeSpent >= turnDuration && internalTimeSpent - Time.delta < turnDuration){
universe.displayTimeEnd();
}

View File

@@ -63,7 +63,7 @@ public class Universe{
/** Update planet rotations, global time and relevant state. */
public void update(){
secondCounter += Time.delta() / 60f;
secondCounter += Time.delta / 60f;
if(secondCounter >= 1){
seconds += (int)secondCounter;

View File

@@ -116,7 +116,7 @@ public class LoadRenderer implements Disposable{
//preview : no frametime
if(preview){
testprogress += Time.delta() / (60f * 3);
testprogress += Time.delta / (60f * 3);
progress = testprogress;
if(input.keyTap(KeyCode.space)){
testprogress = 0;

View File

@@ -206,7 +206,7 @@ public class MenuRenderer implements Disposable{
}
public void render(){
time += Time.delta();
time += Time.delta;
float scaling = Math.max(Scl.scl(4f), Math.max(Core.graphics.getWidth() / ((width - 1f) * tilesize), Core.graphics.getHeight() / ((height - 1f) * tilesize)));
camera.position.set(width * tilesize / 2f, height * tilesize / 2f);
camera.resize(Core.graphics.getWidth() / scaling,

View File

@@ -129,7 +129,7 @@ public class OverlayRenderer{
//draw selected block
if(input.block == null && !Core.scene.hasMouse()){
Vec2 vec = Core.input.mouseWorld(input.getMouseX(), input.getMouseY());
Building tile = world.entWorld(vec.x, vec.y);
Building tile = world.buildWorld(vec.x, vec.y);
if(tile != null && tile.team() == player.team()){
tile.drawSelect();
@@ -152,7 +152,7 @@ public class OverlayRenderer{
Lines.circle(v.x, v.y, 6 + Mathf.absin(Time.time(), 5f, 1f));
Draw.reset();
Building tile = world.entWorld(v.x, v.y);
Building tile = world.buildWorld(v.x, v.y);
if(tile != null && tile.interactable(player.team()) && tile.acceptStack(player.unit().item(), player.unit().stack.amount, player.unit()) > 0){
Lines.stroke(3f, Pal.gray);
Lines.square(tile.x, tile.y, tile.block().size * tilesize / 2f + 3 + Mathf.absin(Time.time(), 5f, 1f));

View File

@@ -186,7 +186,7 @@ public class DesktopInput extends InputHandler{
if(!(scene.getKeyboardFocus() instanceof TextField) && !scene.hasDialog()){
//move camera around
float camSpeed = !Core.input.keyDown(Binding.boost) ? 3f : 8f;
Core.camera.position.add(Tmp.v1.setZero().add(Core.input.axis(Binding.move_x), Core.input.axis(Binding.move_y)).nor().scl(Time.delta() * camSpeed));
Core.camera.position.add(Tmp.v1.setZero().add(Core.input.axis(Binding.move_x), Core.input.axis(Binding.move_y)).nor().scl(Time.delta * camSpeed));
if(Core.input.keyDown(Binding.mouse_move)){
Core.camera.position.x += Mathf.clamp((Core.input.mouseX() - Core.graphics.getWidth() / 2f) * 0.005f, -1, 1) * camSpeed;
@@ -592,17 +592,18 @@ public class DesktopInput extends InputHandler{
}else{
unit.moveAt(Tmp.v2.trns(unit.rotation, movement.len()));
if(!movement.isZero() && legs){
unit.vel().rotateTo(movement.angle(), unit.type().rotateSpeed * Time.delta());
unit.vel.rotateTo(movement.angle(), unit.type().rotateSpeed * Time.delta);
}
}
unit.aim(unit.type().faceTarget ? Core.input.mouseWorld() : Tmp.v1.trns(unit.rotation(), Core.input.mouseWorld().dst(unit)).add(unit.x(), unit.y()));
unit.aim(unit.type().faceTarget ? Core.input.mouseWorld() : Tmp.v1.trns(unit.rotation, Core.input.mouseWorld().dst(unit)).add(unit.x, unit.y));
unit.controlWeapons(true, player.shooting && !boosted);
player.boosting = Core.input.keyDown(Binding.boost) && !movement.isZero();
player.mouseX = unit.aimX();
player.mouseY = unit.aimY();
//update payload input
if(unit instanceof Payloadc){
Payloadc pay = (Payloadc)unit;
@@ -611,7 +612,7 @@ public class DesktopInput extends InputHandler{
if(target != null){
Call.pickupUnitPayload(player, target);
}else if(!pay.hasPayload()){
Building tile = world.entWorld(pay.x(), pay.y());
Building tile = world.buildWorld(pay.x(), pay.y());
if(tile != null && tile.team() == unit.team){
Call.pickupBlockPayload(player, tile);
@@ -625,6 +626,7 @@ public class DesktopInput extends InputHandler{
}
}
//update commander inut
if(unit instanceof Commanderc){
if(Core.input.keyTap(Binding.command)){
Call.unitCommand(player);

View File

@@ -322,7 +322,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
if(controlledType != null){
Unit unit = Units.closest(player.team(), player.x, player.y, u -> !u.isPlayer() && u.type() == controlledType);
if(unit == null && controlledType == UnitTypes.block){
unit = world.entWorld(player.x, player.y) instanceof ControlBlock ? ((ControlBlock)world.entWorld(player.x, player.y)).unit() : null;
unit = world.buildWorld(player.x, player.y) instanceof ControlBlock ? ((ControlBlock)world.buildWorld(player.x, player.y)).unit() : null;
}
if(unit != null){
@@ -798,7 +798,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
}
Building entAt(float x, float y){
return world.ent(tileX(x), tileY(y));
return world.build(tileX(x), tileY(y));
}
/** Returns the tile at the specified MOUSE coordinates. */
@@ -856,7 +856,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
}
}
Building tile = world.entWorld(Core.input.mouseWorld().x, Core.input.mouseWorld().y);
Building tile = world.buildWorld(Core.input.mouseWorld().x, Core.input.mouseWorld().y);
if(tile instanceof ControlBlock && tile.team() == player.team()){
return ((ControlBlock)tile).unit();
}

View File

@@ -1,7 +1,6 @@
package mindustry.input;
import arc.*;
import arc.struct.*;
import arc.func.*;
import arc.graphics.g2d.*;
import arc.input.GestureDetector.*;
@@ -11,15 +10,17 @@ import arc.math.geom.*;
import arc.scene.*;
import arc.scene.ui.ImageButton.*;
import arc.scene.ui.layout.*;
import arc.struct.*;
import arc.util.*;
import mindustry.*;
import mindustry.content.*;
import mindustry.entities.*;
import mindustry.gen.*;
import mindustry.entities.units.*;
import mindustry.game.EventType.*;
import mindustry.game.*;
import mindustry.gen.*;
import mindustry.graphics.*;
import mindustry.type.*;
import mindustry.ui.*;
import mindustry.world.*;
@@ -33,7 +34,7 @@ public class MobileInput extends InputHandler implements GestureListener{
private final float edgePan = Scl.scl(60f);
//gesture data
private Vec2 vector = new Vec2();
private Vec2 vector = new Vec2(), movement = new Vec2(), targetPos = new Vec2();
private float lastZoom = -1;
/** Position where the player started dragging a line. */
@@ -62,7 +63,7 @@ public class MobileInput extends InputHandler implements GestureListener{
/** Down tracking for panning.*/
private boolean down = false;
private Teamc target;
private Teamc target, moveTarget;
//region utility methods
@@ -74,16 +75,15 @@ public class MobileInput extends InputHandler implements GestureListener{
player.miner().mineTile(null);
target = unit;
}else{
Building tile = world.entWorld(x, y);
Building tile = world.buildWorld(x, y);
if(tile != null && player.team().isEnemy(tile.team())){
player.miner().mineTile(null);
target = tile;
//TODO implement healing
}//else if(tile != null && player.unit().canHeal && tile.entity != null && tile.team() == player.team() && tile.entity.damaged()){
/// player.miner().mineTile(null);
// target = tile.entity;
// }
}else if(tile != null && player.unit().type().canHeal && tile.team == player.team() && tile.damaged()){
player.miner().mineTile(null);
target = tile;
}
}
}
@@ -505,27 +505,40 @@ public class MobileInput extends InputHandler implements GestureListener{
@Override
public boolean longPress(float x, float y){
if(state.isMenu() || mode == none || player.dead()) return false;
if(state.isMenu()|| player.dead()) return false;
//get tile on cursor
Tile cursor = tileAt(x, y);
//ignore off-screen taps
if(cursor == null || Core.scene.hasMouse(x, y) || schematicMode) return false;
if(Core.scene.hasMouse(x, y) || schematicMode) return false;
//remove request if it's there
//long pressing enables line mode otherwise
lineStartX = cursor.x;
lineStartY = cursor.y;
lastLineX = cursor.x;
lastLineY = cursor.y;
lineMode = true;
//handle long tap when player isn't building
if(mode == none){
if(mode == breaking){
Fx.tapBlock.at(cursor.worldx(), cursor.worldy(), 1f);
}else if(block != null){
updateLine(lineStartX, lineStartY, cursor.x, cursor.y);
Fx.tapBlock.at(cursor.worldx() + block.offset(), cursor.worldy() + block.offset(), block.size);
//control a unit/block
Unit on = selectedUnit();
if(on != null){
Call.unitControl(player, on);
}
}else{
//ignore off-screen taps
if(cursor == null) return false;
//remove request if it's there
//long pressing enables line mode otherwise
lineStartX = cursor.x;
lineStartY = cursor.y;
lastLineX = cursor.x;
lastLineY = cursor.y;
lineMode = true;
if(mode == breaking){
Fx.tapBlock.at(cursor.worldx(), cursor.worldy(), 1f);
}else if(block != null){
updateLine(lineStartX, lineStartY, cursor.x, cursor.y);
Fx.tapBlock.at(cursor.worldx() + block.offset(), cursor.worldy() + block.offset(), block.size);
}
}
return false;
@@ -584,7 +597,7 @@ public class MobileInput extends InputHandler implements GestureListener{
if(!Core.settings.getBool("keyboard")){
//move camera around
float camSpeed = 6f;
Core.camera.position.add(Tmp.v1.setZero().add(Core.input.axis(Binding.move_x), Core.input.axis(Binding.move_y)).nor().scl(Time.delta() * camSpeed));
Core.camera.position.add(Tmp.v1.setZero().add(Core.input.axis(Binding.move_x), Core.input.axis(Binding.move_y)).nor().scl(Time.delta * camSpeed));
}
if(Core.settings.getBool("keyboard")){
@@ -597,6 +610,10 @@ public class MobileInput extends InputHandler implements GestureListener{
}
}
if(!player.dead() && !state.isPaused()){
updateMovement(player.unit());
}
//reset state when not placing
if(mode == none){
lineMode = false;
@@ -755,5 +772,137 @@ public class MobileInput extends InputHandler implements GestureListener{
return true;
}
//endregion
//region movement
protected void updateMovement(Unit unit){
Rect rect = Tmp.r3;
UnitType type = unit.type();
boolean flying = type.flying;
boolean omni = !(unit instanceof WaterMovec);
boolean legs = unit.isGrounded();
boolean allowHealing = type.canHeal;
boolean validHealTarget = allowHealing && target instanceof Building && ((Building)target).isValid() && target.team() == unit.team &&
((Building)target).damaged() && target.within(unit, type.range);
boolean boosted = (unit instanceof Mechc && unit.isFlying());
//reset target if:
// - in the editor, or...
// - it's both an invalid standard target and an invalid heal target
if((Units.invalidateTarget(target, unit, type.range) && !validHealTarget) || state.isEditor()){
target = null;
}
targetPos.set(Core.camera.position);
float attractDst = 15f;
float strafePenalty = legs ? 1f : Mathf.lerp(1f, type.strafePenalty, Angles.angleDist(unit.vel.angle(), unit.rotation) / 180f);
float speed = type.speed * Mathf.lerp(1f, type.canBoost ? type.boostMultiplier : 1f, unit.elevation()) * strafePenalty;
float range = unit.hasWeapons() ? unit.range() : 0f;
float bulletSpeed = unit.hasWeapons() ? type.weapons.first().bullet.speed : 0f;
float mouseAngle = unit.angleTo(unit.aimX(), unit.aimY());
boolean aimCursor = omni && player.shooting && type.hasWeapons() && type.faceTarget && !boosted && type.rotateShooting;
if(aimCursor){
unit.lookAt(mouseAngle);
}else{
if(unit.moving()){
unit.lookAt(unit.vel.angle());
}
}
if(moveTarget != null){
targetPos.set(moveTarget);
attractDst = 0f;
if(unit.within(moveTarget, 2f * Time.delta)){
handleTapTarget(moveTarget);
moveTarget = null;
}
}
movement.set(targetPos).sub(player).limit(speed);
movement.setAngle(Mathf.slerp(movement.angle(), unit.vel.angle(), 0.05f));
//pathfind for ground units
if(!flying && !type.canBoost && !(unit instanceof WaterMovec)){
Tile on = unit.tileOn();
if(on != null && !on.solid()){
Tile to = pathfinder.getTargetTile(unit.tileOn(), unit.team, targetPos);
if(to != null){
movement.set(to).sub(unit).setLength(speed);
}
}
}
if(player.within(targetPos, attractDst)){
movement.setZero();
}
float expansion = 3f;
unit.hitbox(rect);
rect.x -= expansion;
rect.y -= expansion;
rect.width += expansion * 2f;
rect.height += expansion * 2f;
player.boosting = collisions.overlapsTile(rect) || !unit.within(targetPos, 85f);
if(omni){
unit.moveAt(movement);
}else{
unit.moveAt(Tmp.v2.trns(unit.rotation, movement.len()));
if(!movement.isZero() && legs){
unit.vel.rotateTo(movement.angle(), type.rotateSpeed * Time.delta);
}
}
if(flying){
//hovering effect
unit.x += Mathf.sin(Time.time(), 25f, 0.08f);
unit.y += Mathf.cos(Time.time(), 25f, 0.08f);
}
//update shooting if not building + not mining
if(!player.builder().isBuilding() && player.miner().mineTile() == null){
//autofire
if(target == null){
player.shooting = false;
if(Core.settings.getBool("autotarget")){
target = Units.closestTarget(unit.team, unit.x, unit.y, range, u -> u.team != Team.derelict, u -> u.team != Team.derelict);
if(allowHealing && target == null){
target = Geometry.findClosest(unit.x, unit.y, indexer.getDamaged(Team.sharded));
if(target != null && !unit.within(target, range)){
target = null;
}
}
if(target != null && player.isMiner()){
player.miner().mineTile(null);
}
}
}else{
Vec2 intercept = Predict.intercept(unit, target, bulletSpeed);
player.mouseX = intercept.x;
player.mouseY = intercept.y;
player.shooting = true;
unit.aim(player.mouseX, player.mouseY);
}
}
unit.controlWeapons(player.shooting && !boosted);
}
protected void handleTapTarget(Teamc target){
}
//endregion
}

View File

@@ -159,7 +159,7 @@ public class TypeIO{
Unit unit = Groups.unit.getByID(id);
return unit == null ? Nulls.unit : unit;
}else if(type == 1){ //block
Building tile = world.ent(id);
Building tile = world.build(id);
return tile instanceof ControlBlock ? ((ControlBlock)tile).unit() : Nulls.unit;
}
return Nulls.unit;
@@ -178,7 +178,7 @@ public class TypeIO{
}
public static Building readBuilding(Reads read){
return world.ent(read.i());
return world.build(read.i());
}
public static void writeTile(Writes write, Tile tile){

View File

@@ -52,7 +52,7 @@ public class StatusEffect extends MappableContent{
if(damage > 0){
unit.damageContinuousPierce(damage);
}else if(damage < 0){ //heal unit
unit.heal(damage * Time.delta());
unit.heal(damage * Time.delta);
}
if(effect != Fx.none && Mathf.chanceDelta(effectChance)){

View File

@@ -18,6 +18,7 @@ import mindustry.content.*;
import mindustry.ctype.*;
import mindustry.entities.*;
import mindustry.entities.abilities.*;
import mindustry.entities.bullet.*;
import mindustry.entities.units.*;
import mindustry.game.*;
import mindustry.gen.*;
@@ -32,7 +33,7 @@ public class UnitType extends UnlockableContent{
public static final float shadowTX = -12, shadowTY = -13, shadowColor = Color.toFloatBits(0, 0, 0, 0.22f);
private static final Vec2 legOffset = new Vec2();
//TODO document
/** If true, the unit is always at elevation 1. */
public boolean flying;
public @NonNull Prov<? extends Unit> constructor;
public @NonNull Prov<? extends UnitController> defaultController = () -> !flying ? new GroundAI() : new FlyingAI();
@@ -75,6 +76,8 @@ public class UnitType extends UnlockableContent{
public int parts = 0;
public int trailLength = 3;
public float trailX = 4f, trailY = -3f, trailScl = 1f;
/** Whether the unit can heal blocks. Initialized in init() */
public boolean canHeal = false;
public ObjectSet<StatusEffect> immunities = new ObjectSet<>();
public Sound deathSound = Sounds.bang;
@@ -155,6 +158,8 @@ public class UnitType extends UnlockableContent{
}
}
canHeal = weapons.contains(w -> w.bullet instanceof HealBulletType);
//add mirrored weapon variants
Seq<Weapon> mapped = new Seq<>();
for(Weapon w : weapons){

View File

@@ -127,7 +127,7 @@ public abstract class Weather extends MappableContent{
opacity = Mathf.lerpDelta(opacity, 1f, 0.004f);
}
life -= Time.delta();
life -= Time.delta;
weather.update(base());

View File

@@ -17,7 +17,7 @@ public class MultiReqImage extends Stack{
public void act(float delta){
super.act(delta);
time += Time.delta() / 60f;
time += Time.delta / 60f;
displays.each(req -> req.visible(false));

View File

@@ -62,7 +62,7 @@ public class DatabaseDialog extends BaseDialog{
image.addListener(listener);
if(!Vars.mobile && unlocked(unlock)){
image.addListener(new HandCursorListener());
image.update(() -> image.getColor().lerp(!listener.isOver() ? Color.lightGray : Color.white, 0.4f * Time.delta()));
image.update(() -> image.getColor().lerp(!listener.isOver() ? Color.lightGray : Color.white, 0.4f * Time.delta));
}
if(unlocked(unlock)){

View File

@@ -416,7 +416,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
stable.update(() -> {
if(selected != null){
if(launching){
stable.getColor().sub(0, 0, 0, 0.05f * Time.delta());
stable.getColor().sub(0, 0, 0, 0.05f * Time.delta);
}else{
//fade out UI when not facing selected sector
Tmp.v31.set(selected.tile.v).rotate(Vec3.Y, -planets.planet.getRotation()).scl(-1f).nor();

View File

@@ -110,13 +110,13 @@ public class BlockInventoryFragment extends Fragment{
hide();
}else{
if(tile.items.total() == 0){
emptyTime += Time.delta();
emptyTime += Time.delta;
}else{
emptyTime = 0f;
}
if(holding && lastItem != null){
holdTime += Time.delta();
holdTime += Time.delta;
if(holdTime >= holdWithdraw){
int amount = Math.min(tile.items.get(lastItem), player.unit().maxAccepted(lastItem));
@@ -140,7 +140,7 @@ public class BlockInventoryFragment extends Fragment{
shrinkHoldTimes[i] = 0f;
dirty |= !had;
}else if(had){
shrinkHoldTimes[i] += Time.delta();
shrinkHoldTimes[i] += Time.delta;
dirty |= shrinkHoldTimes[i] >= holdShrink;
}
}

View File

@@ -164,7 +164,7 @@ public class ChatFragment extends Table{
Draw.color();
if(fadetime > 0 && !shown)
fadetime -= Time.delta() / 180f;
fadetime -= Time.delta / 180f;
}
private void sendMessage(){

View File

@@ -257,7 +257,7 @@ public class HudFragment extends Fragment{
coreAttackOpacity[0] = Mathf.lerpDelta(coreAttackOpacity[0], 0f, 0.1f);
}
coreAttackTime[0] -= Time.delta();
coreAttackTime[0] -= Time.delta;
return coreAttackOpacity[0] > 0;
});

View File

@@ -90,7 +90,7 @@ public class PlacementFragment extends Fragment{
scrollPositions.put(currentCategory, blockPane.getScrollY());
if(Core.input.keyDown(Binding.pick) && player.isBuilder()){ //mouse eyedropper select
Building tile = world.entWorld(Core.input.mouseWorld().x, Core.input.mouseWorld().y);
Building tile = world.buildWorld(Core.input.mouseWorld().x, Core.input.mouseWorld().y);
Block tryRecipe = tile == null ? null : tile.block();
Object tryConfig = tile == null ? null : tile.config();
@@ -449,7 +449,7 @@ public class PlacementFragment extends Fragment{
//check tile being hovered over
Tile hoverTile = world.tileWorld(Core.input.mouseWorld().x, Core.input.mouseWorld().y);
if(hoverTile != null){
//if the tile has an entity, display it
//if the tile has a building, display it
if(hoverTile.build != null){
hoverTile.build.updateFlow(true);
return hoverTile.build;

View File

@@ -436,10 +436,10 @@ public class Tile implements Position, QuadTreeObject, Displayable{
}
public Building getNearbyEntity(int rotation){
if(rotation == 0) return world.ent(x + 1, y);
if(rotation == 1) return world.ent(x, y + 1);
if(rotation == 2) return world.ent(x - 1, y);
if(rotation == 3) return world.ent(x, y - 1);
if(rotation == 0) return world.build(x + 1, y);
if(rotation == 1) return world.build(x, y + 1);
if(rotation == 2) return world.build(x - 1, y);
if(rotation == 3) return world.build(x, y - 1);
return null;
}
@@ -558,7 +558,7 @@ public class Tile implements Position, QuadTreeObject, Displayable{
tileSet.clear();
for(Point2 edge : Edges.getEdges(size)){
Building other = world.ent(x + edge.x, y + edge.y);
Building other = world.build(x + edge.x, y + edge.y);
if(other != null){
tileSet.add(other);
}
@@ -582,7 +582,7 @@ public class Tile implements Position, QuadTreeObject, Displayable{
}else{
//since the entity won't update proximity for us, update proximity for all nearby tiles manually
for(Point2 p : Geometry.d4){
Building tile = world.ent(x + p.x, y + p.y);
Building tile = world.build(x + p.x, y + p.y);
if(tile != null && !tile.tile().changing){
tile.onProximityUpdate();
}

View File

@@ -126,7 +126,7 @@ public class ForceProjector extends Block{
}
if(hit > 0f){
hit -= 1f / 5f * Time.delta();
hit -= 1f / 5f * Time.delta;
}
float realRadius = realRadius();

View File

@@ -73,7 +73,7 @@ public class OverdriveProjector extends Block{
@Override
public void updateTile(){
heat = Mathf.lerpDelta(heat, consValid() ? 1f : 0f, 0.08f);
charge += heat * Time.delta();
charge += heat * Time.delta;
if(hasBoost){
phaseHeat = Mathf.lerpDelta(phaseHeat, Mathf.num(cons().optionalValid()), 0.1f);

View File

@@ -78,7 +78,7 @@ public class Wall extends Block{
Draw.blend();
Draw.reset();
hit = Mathf.clamp(hit - Time.delta() / 10f);
hit = Mathf.clamp(hit - Time.delta / 10f);
}
}

View File

@@ -60,7 +60,7 @@ public class LaserTurret extends PowerTurret{
bullet.time(0f);
heat = 1f;
recoil = recoilAmount;
bulletLife -= Time.delta() / Math.max(efficiency(), 0.00001f);
bulletLife -= Time.delta / Math.max(efficiency(), 0.00001f);
if(bulletLife <= 0f){
bullet = null;
}
@@ -68,7 +68,7 @@ public class LaserTurret extends PowerTurret{
Liquid liquid = liquids().current();
float maxUsed = consumes.<ConsumeLiquidBase>get(ConsumeType.liquid).amount;
float used = (cheating() ? maxUsed * Time.delta() : Math.min(liquids.get(liquid), maxUsed * Time.delta())) * liquid.heatCapacity * coolantMultiplier;
float used = (cheating() ? maxUsed * Time.delta : Math.min(liquids.get(liquid), maxUsed * Time.delta)) * liquid.heatCapacity * coolantMultiplier;
reload -= used;
liquids.remove(liquid, used);

View File

@@ -249,7 +249,7 @@ public abstract class Turret extends Block{
Liquid liquid = liquids.current();
float used = Math.min(Math.min(liquids.get(liquid), maxUsed * Time.delta()), Math.max(0, ((reloadTime - reload) / coolantMultiplier) / liquid.heatCapacity)) * baseReloadSpeed();
float used = Math.min(Math.min(liquids.get(liquid), maxUsed * Time.delta), Math.max(0, ((reloadTime - reload) / coolantMultiplier) / liquid.heatCapacity)) * baseReloadSpeed();
reload += used * liquid.heatCapacity * coolantMultiplier;
liquids.remove(liquid, used);

View File

@@ -98,7 +98,7 @@ public class MassDriver extends Block{
@Override
public void updateTile(){
Building link = world.ent(this.link);
Building link = world.build(this.link);
boolean hasLink = linkValid();
//reload regardless of state

View File

@@ -61,7 +61,7 @@ public class OverflowGate extends Block{
return;
}
time += 1f / speed * Time.delta();
time += 1f / speed * Time.delta;
Building target = getTileTarget(lastItem, lastInput, false);
if(target != null && (time >= 1f)){

View File

@@ -41,7 +41,7 @@ public class PayloadConveyor extends Block{
super.drawPlace(x, y, rotation, valid);
for(int i = 0; i < 4; i++){
Building other = world.ent(x + Geometry.d4x[i] * size, y + Geometry.d4y[i] * size);
Building other = world.build(x + Geometry.d4x[i] * size, y + Geometry.d4y[i] * size);
if(other != null && other.block().outputsPayload && other.block().size == size){
Drawf.selected(other.tileX(), other.tileY(), other.block(), Pal.accent);
}

View File

@@ -60,7 +60,7 @@ public class StackConveyor extends Block implements Autotiler{
return (otherblock.hasItems || otherblock.outputsItems() || otherblock.acceptsItems) &&
(notLookingAt(tile, rotation, otherx, othery, otherrot, otherblock) ||
(otherblock instanceof StackConveyor && facing(otherx, othery, otherrot, tile.x, tile.y))) &&
!(world.ent(otherx, othery) instanceof StackConveyorEntity && ((StackConveyorEntity)world.ent(otherx, othery)).state == stateUnload);
!(world.build(otherx, othery) instanceof StackConveyorEntity && ((StackConveyorEntity)world.build(otherx, othery)).state == stateUnload);
}
}
return otherblock.outputsItems() && blendsArmored(tile, rotation, otherx, othery, otherrot, otherblock) && otherblock instanceof StackConveyor;
@@ -84,7 +84,7 @@ public class StackConveyor extends Block implements Autotiler{
@Override
public boolean rotatedOutput(int x, int y){
Building tile = world.ent(x, y);
Building tile = world.build(x, y);
if(tile instanceof StackConveyorEntity){
return ((StackConveyorEntity)tile).state != stateUnload;
}

View File

@@ -26,7 +26,7 @@ public class LiquidBridge extends ItemBridge{
checkIncoming();
Building other = world.ent(link);
Building other = world.build(link);
if(other == null || !linkValid(tile, other.tile())){
dumpLiquid(liquids.current());
}else{

View File

@@ -26,7 +26,7 @@ public class LiquidExtendingBridge extends ExtendingItemBridge{
checkIncoming();
Building other = world.ent(link);
Building other = world.build(link);
if(other == null || !linkValid(tile, other.tile())){
dumpLiquid(liquids.current());
}else{

View File

@@ -159,7 +159,7 @@ public class NuclearReactor extends PowerGenerator{
if(heat > flashThreshold){
float flash = 1f + ((heat - flashThreshold) / (1f - flashThreshold)) * 5.4f;
flash += flash * Time.delta();
flash += flash * Time.delta;
Draw.color(Color.red, Color.yellow, Mathf.absin(flash, 9f, 1f));
Draw.alpha(0.6f);
Draw.rect(lightsRegion, x, y);

View File

@@ -197,7 +197,7 @@ public class PowerGraph{
lastPowerNeeded = powerNeeded;
lastPowerProduced = powerProduced;
powerBalance.add((lastPowerProduced - lastPowerNeeded) / Time.delta());
powerBalance.add((lastPowerProduced - lastPowerNeeded) / Time.delta);
if(!(consumers.size == 0 && producers.size == 0 && batteries.size == 0)){

View File

@@ -41,7 +41,7 @@ public class PowerNode extends PowerBlock{
outputsPower = false;
config(Integer.class, (entity, value) -> {
PowerModule power = entity.power;
Building other = world.ent(value);
Building other = world.build(value);
boolean contains = power.links.contains(value), valid = other != null && other.power() != null;
if(contains){
@@ -183,7 +183,7 @@ public class PowerNode extends PowerBlock{
}
Geometry.circle(tile.x, tile.y, (int)(laserRange + 2), (x, y) -> {
Building other = world.ent(x, y);
Building other = world.build(x, y);
if(valid.get(other) && !tempTileEnts.contains(other)){
tempTileEnts.add(other);
}
@@ -252,7 +252,7 @@ public class PowerNode extends PowerBlock{
public static void insulators(int x, int y, int x2, int y2, Cons<Building> iterator){
world.raycastEach(x, y, x2, y2, (wx, wy) -> {
Building tile = world.ent(wx, wy);
Building tile = world.build(wx, wy);
if(tile != null && tile.block().insulated){
iterator.get(tile);
}
@@ -273,7 +273,7 @@ public class PowerNode extends PowerBlock{
tempTileEnts.clear();
Geometry.circle(tile.x, tile.y, (int)(laserRange + 2), (x, y) -> {
Building other = world.ent(x, y);
Building other = world.build(x, y);
if(valid.get(other)){
if(!insulated(this, other)){
tempTileEnts.add(other);
@@ -346,7 +346,7 @@ public class PowerNode extends PowerBlock{
for(int x = (int)(tile.x - laserRange - 2); x <= tile.x + laserRange + 2; x++){
for(int y = (int)(tile.y - laserRange - 2); y <= tile.y + laserRange + 2; y++){
Building link = world.ent(x, y);
Building link = world.build(x, y);
if(link != this && linkValid(this, link, false)){
boolean linked = linked(link);
@@ -370,7 +370,7 @@ public class PowerNode extends PowerBlock{
Draw.z(Layer.power);
for(int i = 0; i < power.links.size; i++){
Building link = world.ent(power.links.get(i));
Building link = world.build(power.links.get(i));
if(!linkValid(this, link)) continue;

View File

@@ -43,9 +43,8 @@ public class SolidPump extends Pump{
@Override
public void setBars(){
super.setBars();
bars.add("efficiency", (SolidPumpEntity entity) -> new Bar(() ->
Core.bundle.formatFloat("bar.pumpspeed",
entity.lastPump / Time.delta() * 60, 1),
bars.add("efficiency", (SolidPumpEntity entity) -> new Bar(() -> Core.bundle.formatFloat("bar.pumpspeed",
entity.lastPump / Time.delta * 60, 1),
() -> Pal.ammo,
() -> entity.warmup));
}

View File

@@ -96,15 +96,15 @@ public class RepairPoint extends Block{
if(target != null && (target.dead() || target.dst(tile) > repairRadius || target.health() >= target.maxHealth())){
target = null;
}else if(target != null && consValid()){
target.heal(repairSpeed * Time.delta() * strength * efficiency());
target.heal(repairSpeed * Time.delta * strength * efficiency());
rotation = Mathf.slerpDelta(rotation, angleTo(target), 0.5f);
targetIsBeingRepaired = true;
}
if(target != null && targetIsBeingRepaired){
strength = Mathf.lerpDelta(strength, 1f, 0.08f * Time.delta());
strength = Mathf.lerpDelta(strength, 1f, 0.08f * Time.delta);
}else{
strength = Mathf.lerpDelta(strength, 0f, 0.07f * Time.delta());
strength = Mathf.lerpDelta(strength, 0f, 0.07f * Time.delta);
}
if(timer(timerTarget, 20)){