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

@@ -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)){