From a074010eb737408c988fd2967bc08189c794d074 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sun, 19 Jul 2020 12:21:21 -0400 Subject: [PATCH] Time.delta cleanup / Basic mobile input --- .../resources/revisions/BlockUnitUnit/1.json | 1 + .../BuilderCommanderMechMinerUnit/1.json | 1 + .../revisions/BuilderLegsUnit/1.json | 1 + .../revisions/BuilderMechUnit/1.json | 1 + .../revisions/BuilderMinerPayloadUnit/1.json | 1 + .../revisions/BuilderMinerTrailUnit/1.json | 1 + .../revisions/BuilderMinerUnit/1.json | 1 + .../revisions/CommanderUnitWaterMove/1.json | 1 + .../main/resources/revisions/LegsUnit/1.json | 1 + .../main/resources/revisions/MechUnit/1.json | 1 + .../main/resources/revisions/MinerUnit/1.json | 1 + .../resources/revisions/UnitEntity/1.json | 1 + core/src/mindustry/ai/BlockIndexer.java | 6 +- core/src/mindustry/ai/Pathfinder.java | 4 +- core/src/mindustry/ai/types/BuilderAI.java | 2 +- core/src/mindustry/ai/types/FlyingAI.java | 6 +- core/src/mindustry/audio/MusicControl.java | 4 +- core/src/mindustry/audio/SoundLoop.java | 4 +- core/src/mindustry/content/Bullets.java | 6 +- core/src/mindustry/core/Control.java | 13 +- core/src/mindustry/core/Logic.java | 4 +- core/src/mindustry/core/NetClient.java | 2 +- core/src/mindustry/core/Renderer.java | 6 +- core/src/mindustry/core/World.java | 8 +- core/src/mindustry/editor/WaveInfoDialog.java | 4 +- core/src/mindustry/entities/Damage.java | 4 +- core/src/mindustry/entities/Fires.java | 4 +- core/src/mindustry/entities/Predict.java | 10 +- .../entities/abilities/ForceFieldAbility.java | 2 +- .../entities/abilities/HealFieldAbility.java | 2 +- .../abilities/ShieldFieldAbility.java | 2 +- .../abilities/StatusFieldAbility.java | 2 +- .../mindustry/entities/bullet/BulletType.java | 4 +- .../mindustry/entities/comp/BuilderComp.java | 4 +- .../mindustry/entities/comp/BuildingComp.java | 123 +++++------ .../mindustry/entities/comp/BulletComp.java | 2 +- .../src/mindustry/entities/comp/FireComp.java | 18 +- .../mindustry/entities/comp/FlyingComp.java | 6 +- .../mindustry/entities/comp/HealthComp.java | 6 +- .../src/mindustry/entities/comp/MechComp.java | 2 +- .../mindustry/entities/comp/MinerComp.java | 4 +- .../mindustry/entities/comp/PlayerComp.java | 4 +- .../mindustry/entities/comp/PuddleComp.java | 6 +- .../mindustry/entities/comp/ShieldComp.java | 2 +- .../mindustry/entities/comp/StatusComp.java | 2 +- .../mindustry/entities/comp/TimedComp.java | 2 +- .../src/mindustry/entities/comp/UnitComp.java | 6 +- core/src/mindustry/entities/comp/VelComp.java | 4 +- .../entities/comp/WaterMoveComp.java | 2 +- .../mindustry/entities/comp/WeaponsComp.java | 10 +- core/src/mindustry/game/Saves.java | 2 +- core/src/mindustry/game/Schematics.java | 4 +- core/src/mindustry/game/SectorInfo.java | 4 +- core/src/mindustry/game/Universe.java | 2 +- core/src/mindustry/graphics/LoadRenderer.java | 2 +- core/src/mindustry/graphics/MenuRenderer.java | 2 +- .../mindustry/graphics/OverlayRenderer.java | 4 +- core/src/mindustry/input/DesktopInput.java | 10 +- core/src/mindustry/input/InputHandler.java | 6 +- core/src/mindustry/input/MobileInput.java | 201 +++++++++++++++--- core/src/mindustry/io/TypeIO.java | 4 +- core/src/mindustry/type/StatusEffect.java | 2 +- core/src/mindustry/type/UnitType.java | 7 +- core/src/mindustry/type/Weather.java | 2 +- core/src/mindustry/ui/MultiReqImage.java | 2 +- .../mindustry/ui/dialogs/DatabaseDialog.java | 2 +- .../mindustry/ui/dialogs/PlanetDialog.java | 2 +- .../ui/fragments/BlockInventoryFragment.java | 6 +- .../mindustry/ui/fragments/ChatFragment.java | 2 +- .../mindustry/ui/fragments/HudFragment.java | 2 +- .../ui/fragments/PlacementFragment.java | 4 +- core/src/mindustry/world/Tile.java | 12 +- .../world/blocks/defense/ForceProjector.java | 2 +- .../blocks/defense/OverdriveProjector.java | 2 +- .../mindustry/world/blocks/defense/Wall.java | 2 +- .../blocks/defense/turrets/LaserTurret.java | 4 +- .../world/blocks/defense/turrets/Turret.java | 2 +- .../world/blocks/distribution/MassDriver.java | 2 +- .../blocks/distribution/OverflowGate.java | 2 +- .../blocks/distribution/PayloadConveyor.java | 2 +- .../blocks/distribution/StackConveyor.java | 4 +- .../world/blocks/liquid/LiquidBridge.java | 2 +- .../blocks/liquid/LiquidExtendingBridge.java | 2 +- .../world/blocks/power/NuclearReactor.java | 2 +- .../world/blocks/power/PowerGraph.java | 2 +- .../world/blocks/power/PowerNode.java | 12 +- .../world/blocks/production/SolidPump.java | 5 +- .../world/blocks/units/RepairPoint.java | 6 +- .../src/mindustry/server/ServerControl.java | 2 +- .../java/power/ItemLiquidGeneratorTests.java | 4 +- tests/src/test/java/power/PowerTests.java | 4 +- 91 files changed, 414 insertions(+), 247 deletions(-) create mode 100644 annotations/src/main/resources/revisions/BlockUnitUnit/1.json create mode 100644 annotations/src/main/resources/revisions/BuilderCommanderMechMinerUnit/1.json create mode 100644 annotations/src/main/resources/revisions/BuilderLegsUnit/1.json create mode 100644 annotations/src/main/resources/revisions/BuilderMechUnit/1.json create mode 100644 annotations/src/main/resources/revisions/BuilderMinerPayloadUnit/1.json create mode 100644 annotations/src/main/resources/revisions/BuilderMinerTrailUnit/1.json create mode 100644 annotations/src/main/resources/revisions/BuilderMinerUnit/1.json create mode 100644 annotations/src/main/resources/revisions/CommanderUnitWaterMove/1.json create mode 100644 annotations/src/main/resources/revisions/LegsUnit/1.json create mode 100644 annotations/src/main/resources/revisions/MechUnit/1.json create mode 100644 annotations/src/main/resources/revisions/MinerUnit/1.json create mode 100644 annotations/src/main/resources/revisions/UnitEntity/1.json diff --git a/annotations/src/main/resources/revisions/BlockUnitUnit/1.json b/annotations/src/main/resources/revisions/BlockUnitUnit/1.json new file mode 100644 index 0000000000..dd8fdb2784 --- /dev/null +++ b/annotations/src/main/resources/revisions/BlockUnitUnit/1.json @@ -0,0 +1 @@ +{version:1,fields:[{name:ammo,type:float,size:4},{name:armor,type:float,size:4},{name:controller,type:mindustry.entities.units.UnitController,size:-1},{name:elevation,type:float,size:4},{name:health,type:float,size:4},{name:isShooting,type:boolean,size:1},{name:mounts,type:"mindustry.entities.units.WeaponMount[]",size:-1},{name:rotation,type:float,size:4},{name:shield,type:float,size:4},{name:spawnedByCore,type:boolean,size:1},{name:stack,type:mindustry.type.ItemStack,size:-1},{name:statuses,type:arc.struct.Seq,size:-1},{name:team,type:mindustry.game.Team,size:-1},{name:type,type:mindustry.type.UnitType,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/BuilderCommanderMechMinerUnit/1.json b/annotations/src/main/resources/revisions/BuilderCommanderMechMinerUnit/1.json new file mode 100644 index 0000000000..6ed4e60191 --- /dev/null +++ b/annotations/src/main/resources/revisions/BuilderCommanderMechMinerUnit/1.json @@ -0,0 +1 @@ +{version:1,fields:[{name:ammo,type:float,size:4},{name:armor,type:float,size:4},{name:baseRotation,type:float,size:4},{name:controller,type:mindustry.entities.units.UnitController,size:-1},{name:elevation,type:float,size:4},{name:health,type:float,size:4},{name:isShooting,type:boolean,size:1},{name:mineTile,type:mindustry.world.Tile,size:-1},{name:mounts,type:"mindustry.entities.units.WeaponMount[]",size:-1},{name:plans,type:arc.struct.Queue,size:-1},{name:rotation,type:float,size:4},{name:shield,type:float,size:4},{name:spawnedByCore,type:boolean,size:1},{name:stack,type:mindustry.type.ItemStack,size:-1},{name:statuses,type:arc.struct.Seq,size:-1},{name:team,type:mindustry.game.Team,size:-1},{name:type,type:mindustry.type.UnitType,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/BuilderLegsUnit/1.json b/annotations/src/main/resources/revisions/BuilderLegsUnit/1.json new file mode 100644 index 0000000000..885ef84f29 --- /dev/null +++ b/annotations/src/main/resources/revisions/BuilderLegsUnit/1.json @@ -0,0 +1 @@ +{version:1,fields:[{name:ammo,type:float,size:4},{name:armor,type:float,size:4},{name:controller,type:mindustry.entities.units.UnitController,size:-1},{name:elevation,type:float,size:4},{name:health,type:float,size:4},{name:isShooting,type:boolean,size:1},{name:mounts,type:"mindustry.entities.units.WeaponMount[]",size:-1},{name:plans,type:arc.struct.Queue,size:-1},{name:rotation,type:float,size:4},{name:shield,type:float,size:4},{name:spawnedByCore,type:boolean,size:1},{name:stack,type:mindustry.type.ItemStack,size:-1},{name:statuses,type:arc.struct.Seq,size:-1},{name:team,type:mindustry.game.Team,size:-1},{name:type,type:mindustry.type.UnitType,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/BuilderMechUnit/1.json b/annotations/src/main/resources/revisions/BuilderMechUnit/1.json new file mode 100644 index 0000000000..a5d726ded8 --- /dev/null +++ b/annotations/src/main/resources/revisions/BuilderMechUnit/1.json @@ -0,0 +1 @@ +{version:1,fields:[{name:ammo,type:float,size:4},{name:armor,type:float,size:4},{name:baseRotation,type:float,size:4},{name:controller,type:mindustry.entities.units.UnitController,size:-1},{name:elevation,type:float,size:4},{name:health,type:float,size:4},{name:isShooting,type:boolean,size:1},{name:mounts,type:"mindustry.entities.units.WeaponMount[]",size:-1},{name:plans,type:arc.struct.Queue,size:-1},{name:rotation,type:float,size:4},{name:shield,type:float,size:4},{name:spawnedByCore,type:boolean,size:1},{name:stack,type:mindustry.type.ItemStack,size:-1},{name:statuses,type:arc.struct.Seq,size:-1},{name:team,type:mindustry.game.Team,size:-1},{name:type,type:mindustry.type.UnitType,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/BuilderMinerPayloadUnit/1.json b/annotations/src/main/resources/revisions/BuilderMinerPayloadUnit/1.json new file mode 100644 index 0000000000..de89770ab4 --- /dev/null +++ b/annotations/src/main/resources/revisions/BuilderMinerPayloadUnit/1.json @@ -0,0 +1 @@ +{version:1,fields:[{name:ammo,type:float,size:4},{name:armor,type:float,size:4},{name:controller,type:mindustry.entities.units.UnitController,size:-1},{name:elevation,type:float,size:4},{name:health,type:float,size:4},{name:isShooting,type:boolean,size:1},{name:mineTile,type:mindustry.world.Tile,size:-1},{name:mounts,type:"mindustry.entities.units.WeaponMount[]",size:-1},{name:payloads,type:arc.struct.Seq,size:-1},{name:plans,type:arc.struct.Queue,size:-1},{name:rotation,type:float,size:4},{name:shield,type:float,size:4},{name:spawnedByCore,type:boolean,size:1},{name:stack,type:mindustry.type.ItemStack,size:-1},{name:statuses,type:arc.struct.Seq,size:-1},{name:team,type:mindustry.game.Team,size:-1},{name:type,type:mindustry.type.UnitType,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/BuilderMinerTrailUnit/1.json b/annotations/src/main/resources/revisions/BuilderMinerTrailUnit/1.json new file mode 100644 index 0000000000..3a92a12856 --- /dev/null +++ b/annotations/src/main/resources/revisions/BuilderMinerTrailUnit/1.json @@ -0,0 +1 @@ +{version:1,fields:[{name:ammo,type:float,size:4},{name:armor,type:float,size:4},{name:controller,type:mindustry.entities.units.UnitController,size:-1},{name:elevation,type:float,size:4},{name:health,type:float,size:4},{name:isShooting,type:boolean,size:1},{name:mineTile,type:mindustry.world.Tile,size:-1},{name:mounts,type:"mindustry.entities.units.WeaponMount[]",size:-1},{name:plans,type:arc.struct.Queue,size:-1},{name:rotation,type:float,size:4},{name:shield,type:float,size:4},{name:spawnedByCore,type:boolean,size:1},{name:stack,type:mindustry.type.ItemStack,size:-1},{name:statuses,type:arc.struct.Seq,size:-1},{name:team,type:mindustry.game.Team,size:-1},{name:type,type:mindustry.type.UnitType,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/BuilderMinerUnit/1.json b/annotations/src/main/resources/revisions/BuilderMinerUnit/1.json new file mode 100644 index 0000000000..3a92a12856 --- /dev/null +++ b/annotations/src/main/resources/revisions/BuilderMinerUnit/1.json @@ -0,0 +1 @@ +{version:1,fields:[{name:ammo,type:float,size:4},{name:armor,type:float,size:4},{name:controller,type:mindustry.entities.units.UnitController,size:-1},{name:elevation,type:float,size:4},{name:health,type:float,size:4},{name:isShooting,type:boolean,size:1},{name:mineTile,type:mindustry.world.Tile,size:-1},{name:mounts,type:"mindustry.entities.units.WeaponMount[]",size:-1},{name:plans,type:arc.struct.Queue,size:-1},{name:rotation,type:float,size:4},{name:shield,type:float,size:4},{name:spawnedByCore,type:boolean,size:1},{name:stack,type:mindustry.type.ItemStack,size:-1},{name:statuses,type:arc.struct.Seq,size:-1},{name:team,type:mindustry.game.Team,size:-1},{name:type,type:mindustry.type.UnitType,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/CommanderUnitWaterMove/1.json b/annotations/src/main/resources/revisions/CommanderUnitWaterMove/1.json new file mode 100644 index 0000000000..dd8fdb2784 --- /dev/null +++ b/annotations/src/main/resources/revisions/CommanderUnitWaterMove/1.json @@ -0,0 +1 @@ +{version:1,fields:[{name:ammo,type:float,size:4},{name:armor,type:float,size:4},{name:controller,type:mindustry.entities.units.UnitController,size:-1},{name:elevation,type:float,size:4},{name:health,type:float,size:4},{name:isShooting,type:boolean,size:1},{name:mounts,type:"mindustry.entities.units.WeaponMount[]",size:-1},{name:rotation,type:float,size:4},{name:shield,type:float,size:4},{name:spawnedByCore,type:boolean,size:1},{name:stack,type:mindustry.type.ItemStack,size:-1},{name:statuses,type:arc.struct.Seq,size:-1},{name:team,type:mindustry.game.Team,size:-1},{name:type,type:mindustry.type.UnitType,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/LegsUnit/1.json b/annotations/src/main/resources/revisions/LegsUnit/1.json new file mode 100644 index 0000000000..dd8fdb2784 --- /dev/null +++ b/annotations/src/main/resources/revisions/LegsUnit/1.json @@ -0,0 +1 @@ +{version:1,fields:[{name:ammo,type:float,size:4},{name:armor,type:float,size:4},{name:controller,type:mindustry.entities.units.UnitController,size:-1},{name:elevation,type:float,size:4},{name:health,type:float,size:4},{name:isShooting,type:boolean,size:1},{name:mounts,type:"mindustry.entities.units.WeaponMount[]",size:-1},{name:rotation,type:float,size:4},{name:shield,type:float,size:4},{name:spawnedByCore,type:boolean,size:1},{name:stack,type:mindustry.type.ItemStack,size:-1},{name:statuses,type:arc.struct.Seq,size:-1},{name:team,type:mindustry.game.Team,size:-1},{name:type,type:mindustry.type.UnitType,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/MechUnit/1.json b/annotations/src/main/resources/revisions/MechUnit/1.json new file mode 100644 index 0000000000..66897ee06f --- /dev/null +++ b/annotations/src/main/resources/revisions/MechUnit/1.json @@ -0,0 +1 @@ +{version:1,fields:[{name:ammo,type:float,size:4},{name:armor,type:float,size:4},{name:baseRotation,type:float,size:4},{name:controller,type:mindustry.entities.units.UnitController,size:-1},{name:elevation,type:float,size:4},{name:health,type:float,size:4},{name:isShooting,type:boolean,size:1},{name:mounts,type:"mindustry.entities.units.WeaponMount[]",size:-1},{name:rotation,type:float,size:4},{name:shield,type:float,size:4},{name:spawnedByCore,type:boolean,size:1},{name:stack,type:mindustry.type.ItemStack,size:-1},{name:statuses,type:arc.struct.Seq,size:-1},{name:team,type:mindustry.game.Team,size:-1},{name:type,type:mindustry.type.UnitType,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/MinerUnit/1.json b/annotations/src/main/resources/revisions/MinerUnit/1.json new file mode 100644 index 0000000000..9d58b6775a --- /dev/null +++ b/annotations/src/main/resources/revisions/MinerUnit/1.json @@ -0,0 +1 @@ +{version:1,fields:[{name:ammo,type:float,size:4},{name:armor,type:float,size:4},{name:controller,type:mindustry.entities.units.UnitController,size:-1},{name:elevation,type:float,size:4},{name:health,type:float,size:4},{name:isShooting,type:boolean,size:1},{name:mineTile,type:mindustry.world.Tile,size:-1},{name:mounts,type:"mindustry.entities.units.WeaponMount[]",size:-1},{name:rotation,type:float,size:4},{name:shield,type:float,size:4},{name:spawnedByCore,type:boolean,size:1},{name:stack,type:mindustry.type.ItemStack,size:-1},{name:statuses,type:arc.struct.Seq,size:-1},{name:team,type:mindustry.game.Team,size:-1},{name:type,type:mindustry.type.UnitType,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/UnitEntity/1.json b/annotations/src/main/resources/revisions/UnitEntity/1.json new file mode 100644 index 0000000000..dd8fdb2784 --- /dev/null +++ b/annotations/src/main/resources/revisions/UnitEntity/1.json @@ -0,0 +1 @@ +{version:1,fields:[{name:ammo,type:float,size:4},{name:armor,type:float,size:4},{name:controller,type:mindustry.entities.units.UnitController,size:-1},{name:elevation,type:float,size:4},{name:health,type:float,size:4},{name:isShooting,type:boolean,size:1},{name:mounts,type:"mindustry.entities.units.WeaponMount[]",size:-1},{name:rotation,type:float,size:4},{name:shield,type:float,size:4},{name:spawnedByCore,type:boolean,size:1},{name:stack,type:mindustry.type.ItemStack,size:-1},{name:statuses,type:arc.struct.Seq,size:-1},{name:team,type:mindustry.game.Team,size:-1},{name:type,type:mindustry.type.UnitType,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]} \ No newline at end of file diff --git a/core/src/mindustry/ai/BlockIndexer.java b/core/src/mindustry/ai/BlockIndexer.java index c07a5802a2..5931068c48 100644 --- a/core/src/mindustry/ai/BlockIndexer.java +++ b/core/src/mindustry/ai/BlockIndexer.java @@ -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); diff --git a/core/src/mindustry/ai/Pathfinder.java b/core/src/mindustry/ai/Pathfinder.java index fed6acd16f..222cc7df74 100644 --- a/core/src/mindustry/ai/Pathfinder.java +++ b/core/src/mindustry/ai/Pathfinder.java @@ -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){ diff --git a/core/src/mindustry/ai/types/BuilderAI.java b/core/src/mindustry/ai/types/BuilderAI.java index 68953a8d7b..a606592b26 100644 --- a/core/src/mindustry/ai/types/BuilderAI.java +++ b/core/src/mindustry/ai/types/BuilderAI.java @@ -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){ diff --git a/core/src/mindustry/ai/types/FlyingAI.java b/core/src/mindustry/ai/types/FlyingAI.java index a85a657fa3..e71de21f7e 100644 --- a/core/src/mindustry/ai/types/FlyingAI.java +++ b/core/src/mindustry/ai/types/FlyingAI.java @@ -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); } diff --git a/core/src/mindustry/audio/MusicControl.java b/core/src/mindustry/audio/MusicControl.java index c1bd7d0866..afb48a8d59 100644 --- a/core/src/mindustry/audio/MusicControl.java +++ b/core/src/mindustry/audio/MusicControl.java @@ -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 diff --git a/core/src/mindustry/audio/SoundLoop.java b/core/src/mindustry/audio/SoundLoop.java index cfdf380753..99d6837251 100644 --- a/core/src/mindustry/audio/SoundLoop.java +++ b/core/src/mindustry/audio/SoundLoop.java @@ -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; diff --git a/core/src/mindustry/content/Bullets.java b/core/src/mindustry/content/Bullets.java index e41674b754..6a002dd42a 100644 --- a/core/src/mindustry/content/Bullets.java +++ b/core/src/mindustry/content/Bullets.java @@ -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); } } diff --git a/core/src/mindustry/core/Control.java b/core/src/mindustry/core/Control.java index 1fd8a248da..f22adfe8e5 100644 --- a/core/src/mindustry/core/Control.java +++ b/core/src/mindustry/core/Control.java @@ -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(); } diff --git a/core/src/mindustry/core/Logic.java b/core/src/mindustry/core/Logic.java index 82afbd483f..1371ec72a0 100644 --- a/core/src/mindustry/core/Logic.java +++ b/core/src/mindustry/core/Logic.java @@ -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); } } diff --git a/core/src/mindustry/core/NetClient.java b/core/src/mindustry/core/NetClient.java index 74e57ac4dc..01f663f8ab 100644 --- a/core/src/mindustry/core/NetClient.java +++ b/core/src/mindustry/core/NetClient.java @@ -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(); diff --git a/core/src/mindustry/core/Renderer.java b/core/src/mindustry/core/Renderer.java index a60dbbefc6..5b0b0a00ef 100644 --- a/core/src/mindustry/core/Renderer.java +++ b/core/src/mindustry/core/Renderer.java @@ -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; diff --git a/core/src/mindustry/core/World.java b/core/src/mindustry/core/World.java index fb9d5585eb..09d70ed31a 100644 --- a/core/src/mindustry/core/World.java +++ b/core/src/mindustry/core/World.java @@ -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){ diff --git a/core/src/mindustry/editor/WaveInfoDialog.java b/core/src/mindustry/editor/WaveInfoDialog.java index e64cd2659d..7f1867f92a 100644 --- a/core/src/mindustry/editor/WaveInfoDialog.java +++ b/core/src/mindustry/editor/WaveInfoDialog.java @@ -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; diff --git a/core/src/mindustry/entities/Damage.java b/core/src/mindustry/entities/Damage.java index 7e2f977871..a8d743a320 100644 --- a/core/src/mindustry/entities/Damage.java +++ b/core/src/mindustry/entities/Damage.java @@ -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 diff --git a/core/src/mindustry/entities/Fires.java b/core/src/mindustry/entities/Fires.java index 6d329e8f50..e24d34dac4 100644 --- a/core/src/mindustry/entities/Fires.java +++ b/core/src/mindustry/entities/Fires.java @@ -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); } } diff --git a/core/src/mindustry/entities/Predict.java b/core/src/mindustry/entities/Predict.java index ef2cd43ad0..03c41e5778 100644 --- a/core/src/mindustry/entities/Predict.java +++ b/core/src/mindustry/entities/Predict.java @@ -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){ diff --git a/core/src/mindustry/entities/abilities/ForceFieldAbility.java b/core/src/mindustry/entities/abilities/ForceFieldAbility.java index 57841d6886..bdfa3a9cb5 100644 --- a/core/src/mindustry/entities/abilities/ForceFieldAbility.java +++ b/core/src/mindustry/entities/abilities/ForceFieldAbility.java @@ -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){ diff --git a/core/src/mindustry/entities/abilities/HealFieldAbility.java b/core/src/mindustry/entities/abilities/HealFieldAbility.java index df3903ffa5..3e12e96963 100644 --- a/core/src/mindustry/entities/abilities/HealFieldAbility.java +++ b/core/src/mindustry/entities/abilities/HealFieldAbility.java @@ -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; diff --git a/core/src/mindustry/entities/abilities/ShieldFieldAbility.java b/core/src/mindustry/entities/abilities/ShieldFieldAbility.java index 15f9fc9147..f7726e8e92 100644 --- a/core/src/mindustry/entities/abilities/ShieldFieldAbility.java +++ b/core/src/mindustry/entities/abilities/ShieldFieldAbility.java @@ -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; diff --git a/core/src/mindustry/entities/abilities/StatusFieldAbility.java b/core/src/mindustry/entities/abilities/StatusFieldAbility.java index ad7bef4b12..641e068a0f 100644 --- a/core/src/mindustry/entities/abilities/StatusFieldAbility.java +++ b/core/src/mindustry/entities/abilities/StatusFieldAbility.java @@ -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){ diff --git a/core/src/mindustry/entities/bullet/BulletType.java b/core/src/mindustry/entities/bullet/BulletType.java index 460aa9608c..5977a9ed22 100644 --- a/core/src/mindustry/entities/bullet/BulletType.java +++ b/core/src/mindustry/entities/bullet/BulletType.java @@ -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; diff --git a/core/src/mindustry/entities/comp/BuilderComp.java b/core/src/mindustry/entities/comp/BuilderComp.java index b518906f67..2ea4da78fe 100644 --- a/core/src/mindustry/entities/comp/BuilderComp.java +++ b/core/src/mindustry/entities/comp/BuilderComp.java @@ -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); } diff --git a/core/src/mindustry/entities/comp/BuildingComp.java b/core/src/mindustry/entities/comp/BuildingComp.java index 58e81fe2bd..d46ed55d05 100644 --- a/core/src/mindustry/entities/comp/BuildingComp.java +++ b/core/src/mindustry/entities/comp/BuildingComp.java @@ -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.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; } diff --git a/core/src/mindustry/entities/comp/BulletComp.java b/core/src/mindustry/entities/comp/BulletComp.java index 3b0be13cd7..c94216c923 100644 --- a/core/src/mindustry/entities/comp/BulletComp.java +++ b/core/src/mindustry/entities/comp/BulletComp.java @@ -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)){ diff --git a/core/src/mindustry/entities/comp/FireComp.java b/core/src/mindustry/entities/comp/FireComp.java index 74f5199ab6..075a96416b 100644 --- a/core/src/mindustry/entities/comp/FireComp.java +++ b/core/src/mindustry/entities/comp/FireComp.java @@ -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; diff --git a/core/src/mindustry/entities/comp/FlyingComp.java b/core/src/mindustry/entities/comp/FlyingComp.java index e0727661a0..ef53b1fece 100644 --- a/core/src/mindustry/entities/comp/FlyingComp.java +++ b/core/src/mindustry/entities/comp/FlyingComp.java @@ -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); diff --git a/core/src/mindustry/entities/comp/HealthComp.java b/core/src/mindustry/entities/comp/HealthComp.java index 7d95d22964..609f3da46f 100644 --- a/core/src/mindustry/entities/comp/HealthComp.java +++ b/core/src/mindustry/entities/comp/HealthComp.java @@ -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(){ diff --git a/core/src/mindustry/entities/comp/MechComp.java b/core/src/mindustry/entities/comp/MechComp.java index 0c0a6f4962..60e9a7dbde 100644 --- a/core/src/mindustry/entities/comp/MechComp.java +++ b/core/src/mindustry/entities/comp/MechComp.java @@ -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; } } diff --git a/core/src/mindustry/entities/comp/MinerComp.java b/core/src/mindustry/entities/comp/MinerComp.java index 781d9ebb83..23b566c534 100644 --- a/core/src/mindustry/entities/comp/MinerComp.java +++ b/core/src/mindustry/entities/comp/MinerComp.java @@ -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); } } diff --git a/core/src/mindustry/entities/comp/PlayerComp.java b/core/src/mindustry/entities/comp/PlayerComp.java index 8caf31c46c..4f4800daa7 100644 --- a/core/src/mindustry/entities/comp/PlayerComp.java +++ b/core/src/mindustry/entities/comp/PlayerComp.java @@ -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); } diff --git a/core/src/mindustry/entities/comp/PuddleComp.java b/core/src/mindustry/entities/comp/PuddleComp.java index 572ebe43e6..35ab03416c 100644 --- a/core/src/mindustry/entities/comp/PuddleComp.java +++ b/core/src/mindustry/entities/comp/PuddleComp.java @@ -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 diff --git a/core/src/mindustry/entities/comp/ShieldComp.java b/core/src/mindustry/entities/comp/ShieldComp.java index 421bf1295f..5125faa96e 100644 --- a/core/src/mindustry/entities/comp/ShieldComp.java +++ b/core/src/mindustry/entities/comp/ShieldComp.java @@ -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; } } diff --git a/core/src/mindustry/entities/comp/StatusComp.java b/core/src/mindustry/entities/comp/StatusComp.java index 668aa4ddf1..bf61535026 100644 --- a/core/src/mindustry/entities/comp/StatusComp.java +++ b/core/src/mindustry/entities/comp/StatusComp.java @@ -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){ diff --git a/core/src/mindustry/entities/comp/TimedComp.java b/core/src/mindustry/entities/comp/TimedComp.java index 15dbb737d6..f6a0225bd5 100644 --- a/core/src/mindustry/entities/comp/TimedComp.java +++ b/core/src/mindustry/entities/comp/TimedComp.java @@ -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(); diff --git a/core/src/mindustry/entities/comp/UnitComp.java b/core/src/mindustry/entities/comp/UnitComp.java index 1a8fcf6861..292a9c49dc 100644 --- a/core/src/mindustry/entities/comp/UnitComp.java +++ b/core/src/mindustry/entities/comp/UnitComp.java @@ -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(); diff --git a/core/src/mindustry/entities/comp/VelComp.java b/core/src/mindustry/entities/comp/VelComp.java index 6e3a31c76b..b01e6322ce 100644 --- a/core/src/mindustry/entities/comp/VelComp.java +++ b/core/src/mindustry/entities/comp/VelComp.java @@ -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(){ diff --git a/core/src/mindustry/entities/comp/WaterMoveComp.java b/core/src/mindustry/entities/comp/WaterMoveComp.java index 43f12491d1..3cc371eade 100644 --- a/core/src/mindustry/entities/comp/WaterMoveComp.java +++ b/core/src/mindustry/entities/comp/WaterMoveComp.java @@ -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); diff --git a/core/src/mindustry/entities/comp/WeaponsComp.java b/core/src/mindustry/entities/comp/WeaponsComp.java index bfb0d74f91..b05800d702 100644 --- a/core/src/mindustry/entities/comp/WeaponsComp.java +++ b/core/src/mindustry/entities/comp/WeaponsComp.java @@ -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); diff --git a/core/src/mindustry/game/Saves.java b/core/src/mindustry/game/Saves.java index c54107b646..681887e685 100644 --- a/core/src/mindustry/game/Saves.java +++ b/core/src/mindustry/game/Saves.java @@ -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; diff --git a/core/src/mindustry/game/Schematics.java b/core/src/mindustry/game/Schematics.java index 5ddc9bb9da..c02b60cece 100644 --- a/core/src/mindustry/game/Schematics.java +++ b/core/src/mindustry/game/Schematics.java @@ -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))){ diff --git a/core/src/mindustry/game/SectorInfo.java b/core/src/mindustry/game/SectorInfo.java index 9101bfc4b4..4192831910 100644 --- a/core/src/mindustry/game/SectorInfo.java +++ b/core/src/mindustry/game/SectorInfo.java @@ -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(); } diff --git a/core/src/mindustry/game/Universe.java b/core/src/mindustry/game/Universe.java index 105e2e4da8..33f14eb1e7 100644 --- a/core/src/mindustry/game/Universe.java +++ b/core/src/mindustry/game/Universe.java @@ -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; diff --git a/core/src/mindustry/graphics/LoadRenderer.java b/core/src/mindustry/graphics/LoadRenderer.java index afbab1b6e2..12ffe9af40 100644 --- a/core/src/mindustry/graphics/LoadRenderer.java +++ b/core/src/mindustry/graphics/LoadRenderer.java @@ -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; diff --git a/core/src/mindustry/graphics/MenuRenderer.java b/core/src/mindustry/graphics/MenuRenderer.java index f45e93daf1..bc72220c77 100644 --- a/core/src/mindustry/graphics/MenuRenderer.java +++ b/core/src/mindustry/graphics/MenuRenderer.java @@ -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, diff --git a/core/src/mindustry/graphics/OverlayRenderer.java b/core/src/mindustry/graphics/OverlayRenderer.java index d191574f1b..8b7f940197 100644 --- a/core/src/mindustry/graphics/OverlayRenderer.java +++ b/core/src/mindustry/graphics/OverlayRenderer.java @@ -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)); diff --git a/core/src/mindustry/input/DesktopInput.java b/core/src/mindustry/input/DesktopInput.java index c1b53eae85..76f983965d 100644 --- a/core/src/mindustry/input/DesktopInput.java +++ b/core/src/mindustry/input/DesktopInput.java @@ -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); diff --git a/core/src/mindustry/input/InputHandler.java b/core/src/mindustry/input/InputHandler.java index 8cf7b0466f..d2faceeeb8 100644 --- a/core/src/mindustry/input/InputHandler.java +++ b/core/src/mindustry/input/InputHandler.java @@ -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(); } diff --git a/core/src/mindustry/input/MobileInput.java b/core/src/mindustry/input/MobileInput.java index 75c468f1fd..a418e64f99 100644 --- a/core/src/mindustry/input/MobileInput.java +++ b/core/src/mindustry/input/MobileInput.java @@ -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 } diff --git a/core/src/mindustry/io/TypeIO.java b/core/src/mindustry/io/TypeIO.java index 1eb49bfe2b..5330f89af2 100644 --- a/core/src/mindustry/io/TypeIO.java +++ b/core/src/mindustry/io/TypeIO.java @@ -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){ diff --git a/core/src/mindustry/type/StatusEffect.java b/core/src/mindustry/type/StatusEffect.java index 5cc9a15308..1172b4d06c 100644 --- a/core/src/mindustry/type/StatusEffect.java +++ b/core/src/mindustry/type/StatusEffect.java @@ -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)){ diff --git a/core/src/mindustry/type/UnitType.java b/core/src/mindustry/type/UnitType.java index 1941cca601..5cb29f133c 100644 --- a/core/src/mindustry/type/UnitType.java +++ b/core/src/mindustry/type/UnitType.java @@ -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 constructor; public @NonNull Prov 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 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 mapped = new Seq<>(); for(Weapon w : weapons){ diff --git a/core/src/mindustry/type/Weather.java b/core/src/mindustry/type/Weather.java index 6ea132e428..a1d23a0a76 100644 --- a/core/src/mindustry/type/Weather.java +++ b/core/src/mindustry/type/Weather.java @@ -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()); diff --git a/core/src/mindustry/ui/MultiReqImage.java b/core/src/mindustry/ui/MultiReqImage.java index 715f629088..53308eb51c 100644 --- a/core/src/mindustry/ui/MultiReqImage.java +++ b/core/src/mindustry/ui/MultiReqImage.java @@ -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)); diff --git a/core/src/mindustry/ui/dialogs/DatabaseDialog.java b/core/src/mindustry/ui/dialogs/DatabaseDialog.java index 3a12350a19..fa15d4aba8 100644 --- a/core/src/mindustry/ui/dialogs/DatabaseDialog.java +++ b/core/src/mindustry/ui/dialogs/DatabaseDialog.java @@ -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)){ diff --git a/core/src/mindustry/ui/dialogs/PlanetDialog.java b/core/src/mindustry/ui/dialogs/PlanetDialog.java index 7e63b4533f..4d008d96e4 100644 --- a/core/src/mindustry/ui/dialogs/PlanetDialog.java +++ b/core/src/mindustry/ui/dialogs/PlanetDialog.java @@ -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(); diff --git a/core/src/mindustry/ui/fragments/BlockInventoryFragment.java b/core/src/mindustry/ui/fragments/BlockInventoryFragment.java index 262fdf6585..4ec5a83e5f 100644 --- a/core/src/mindustry/ui/fragments/BlockInventoryFragment.java +++ b/core/src/mindustry/ui/fragments/BlockInventoryFragment.java @@ -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; } } diff --git a/core/src/mindustry/ui/fragments/ChatFragment.java b/core/src/mindustry/ui/fragments/ChatFragment.java index d7fd20fa68..c1e780e144 100644 --- a/core/src/mindustry/ui/fragments/ChatFragment.java +++ b/core/src/mindustry/ui/fragments/ChatFragment.java @@ -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(){ diff --git a/core/src/mindustry/ui/fragments/HudFragment.java b/core/src/mindustry/ui/fragments/HudFragment.java index 1032a7e749..eb5f94dbae 100644 --- a/core/src/mindustry/ui/fragments/HudFragment.java +++ b/core/src/mindustry/ui/fragments/HudFragment.java @@ -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; }); diff --git a/core/src/mindustry/ui/fragments/PlacementFragment.java b/core/src/mindustry/ui/fragments/PlacementFragment.java index 671b6d4f8a..ba8dd336e1 100644 --- a/core/src/mindustry/ui/fragments/PlacementFragment.java +++ b/core/src/mindustry/ui/fragments/PlacementFragment.java @@ -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; diff --git a/core/src/mindustry/world/Tile.java b/core/src/mindustry/world/Tile.java index 1153fe09cb..15bb4cc4c5 100644 --- a/core/src/mindustry/world/Tile.java +++ b/core/src/mindustry/world/Tile.java @@ -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(); } diff --git a/core/src/mindustry/world/blocks/defense/ForceProjector.java b/core/src/mindustry/world/blocks/defense/ForceProjector.java index a2570b8385..44243f9fb6 100644 --- a/core/src/mindustry/world/blocks/defense/ForceProjector.java +++ b/core/src/mindustry/world/blocks/defense/ForceProjector.java @@ -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(); diff --git a/core/src/mindustry/world/blocks/defense/OverdriveProjector.java b/core/src/mindustry/world/blocks/defense/OverdriveProjector.java index f21bc14d08..d0279dc4ad 100644 --- a/core/src/mindustry/world/blocks/defense/OverdriveProjector.java +++ b/core/src/mindustry/world/blocks/defense/OverdriveProjector.java @@ -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); diff --git a/core/src/mindustry/world/blocks/defense/Wall.java b/core/src/mindustry/world/blocks/defense/Wall.java index 09ca13b6c5..0a4cae8de7 100644 --- a/core/src/mindustry/world/blocks/defense/Wall.java +++ b/core/src/mindustry/world/blocks/defense/Wall.java @@ -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); } } diff --git a/core/src/mindustry/world/blocks/defense/turrets/LaserTurret.java b/core/src/mindustry/world/blocks/defense/turrets/LaserTurret.java index 4eee57f8f0..a7554b49f8 100644 --- a/core/src/mindustry/world/blocks/defense/turrets/LaserTurret.java +++ b/core/src/mindustry/world/blocks/defense/turrets/LaserTurret.java @@ -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.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); diff --git a/core/src/mindustry/world/blocks/defense/turrets/Turret.java b/core/src/mindustry/world/blocks/defense/turrets/Turret.java index 728e91f11d..9e01b91c3a 100644 --- a/core/src/mindustry/world/blocks/defense/turrets/Turret.java +++ b/core/src/mindustry/world/blocks/defense/turrets/Turret.java @@ -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); diff --git a/core/src/mindustry/world/blocks/distribution/MassDriver.java b/core/src/mindustry/world/blocks/distribution/MassDriver.java index eeb4b639a5..4e023a6216 100644 --- a/core/src/mindustry/world/blocks/distribution/MassDriver.java +++ b/core/src/mindustry/world/blocks/distribution/MassDriver.java @@ -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 diff --git a/core/src/mindustry/world/blocks/distribution/OverflowGate.java b/core/src/mindustry/world/blocks/distribution/OverflowGate.java index 2fa2417c4b..2c80b29a1e 100644 --- a/core/src/mindustry/world/blocks/distribution/OverflowGate.java +++ b/core/src/mindustry/world/blocks/distribution/OverflowGate.java @@ -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)){ diff --git a/core/src/mindustry/world/blocks/distribution/PayloadConveyor.java b/core/src/mindustry/world/blocks/distribution/PayloadConveyor.java index cc790e7042..d4a56458ff 100644 --- a/core/src/mindustry/world/blocks/distribution/PayloadConveyor.java +++ b/core/src/mindustry/world/blocks/distribution/PayloadConveyor.java @@ -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); } diff --git a/core/src/mindustry/world/blocks/distribution/StackConveyor.java b/core/src/mindustry/world/blocks/distribution/StackConveyor.java index abd62e28bf..1868e02662 100644 --- a/core/src/mindustry/world/blocks/distribution/StackConveyor.java +++ b/core/src/mindustry/world/blocks/distribution/StackConveyor.java @@ -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; } diff --git a/core/src/mindustry/world/blocks/liquid/LiquidBridge.java b/core/src/mindustry/world/blocks/liquid/LiquidBridge.java index c0eb7d44bd..f8de48a4ff 100644 --- a/core/src/mindustry/world/blocks/liquid/LiquidBridge.java +++ b/core/src/mindustry/world/blocks/liquid/LiquidBridge.java @@ -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{ diff --git a/core/src/mindustry/world/blocks/liquid/LiquidExtendingBridge.java b/core/src/mindustry/world/blocks/liquid/LiquidExtendingBridge.java index 538354ded9..8ceef95d12 100644 --- a/core/src/mindustry/world/blocks/liquid/LiquidExtendingBridge.java +++ b/core/src/mindustry/world/blocks/liquid/LiquidExtendingBridge.java @@ -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{ diff --git a/core/src/mindustry/world/blocks/power/NuclearReactor.java b/core/src/mindustry/world/blocks/power/NuclearReactor.java index 51db86567f..ec8abc9176 100644 --- a/core/src/mindustry/world/blocks/power/NuclearReactor.java +++ b/core/src/mindustry/world/blocks/power/NuclearReactor.java @@ -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); diff --git a/core/src/mindustry/world/blocks/power/PowerGraph.java b/core/src/mindustry/world/blocks/power/PowerGraph.java index 093206ad56..e0447dbad5 100644 --- a/core/src/mindustry/world/blocks/power/PowerGraph.java +++ b/core/src/mindustry/world/blocks/power/PowerGraph.java @@ -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)){ diff --git a/core/src/mindustry/world/blocks/power/PowerNode.java b/core/src/mindustry/world/blocks/power/PowerNode.java index 3a40d185bb..a3b79498e5 100644 --- a/core/src/mindustry/world/blocks/power/PowerNode.java +++ b/core/src/mindustry/world/blocks/power/PowerNode.java @@ -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 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; diff --git a/core/src/mindustry/world/blocks/production/SolidPump.java b/core/src/mindustry/world/blocks/production/SolidPump.java index 64f6570d63..5c83b4fcec 100644 --- a/core/src/mindustry/world/blocks/production/SolidPump.java +++ b/core/src/mindustry/world/blocks/production/SolidPump.java @@ -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)); } diff --git a/core/src/mindustry/world/blocks/units/RepairPoint.java b/core/src/mindustry/world/blocks/units/RepairPoint.java index 0e10c0b32c..b7108d4524 100644 --- a/core/src/mindustry/world/blocks/units/RepairPoint.java +++ b/core/src/mindustry/world/blocks/units/RepairPoint.java @@ -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)){ diff --git a/server/src/mindustry/server/ServerControl.java b/server/src/mindustry/server/ServerControl.java index d24037002b..6e9050291a 100644 --- a/server/src/mindustry/server/ServerControl.java +++ b/server/src/mindustry/server/ServerControl.java @@ -40,7 +40,7 @@ public class ServerControl implements ApplicationListener{ protected static String[] tags = {"&lc&fb[D]", "&lg&fb[I]", "&ly&fb[W]", "&lr&fb[E]", ""}; protected static DateTimeFormatter dateTime = DateTimeFormatter.ofPattern("MM-dd-yyyy HH:mm:ss"), - autosaveDate = DateTimeFormatter.ofPattern("MM_dd_yyyy_HH_mm_ss"); + autosaveDate = DateTimeFormatter.ofPattern("MM-dd-yyyy_HH-mm-ss"); private final CommandHandler handler = new CommandHandler(""); private final Fi logFolder = Core.settings.getDataDirectory().child("logs/"); diff --git a/tests/src/test/java/power/ItemLiquidGeneratorTests.java b/tests/src/test/java/power/ItemLiquidGeneratorTests.java index 0896892b8b..89765f2e00 100644 --- a/tests/src/test/java/power/ItemLiquidGeneratorTests.java +++ b/tests/src/test/java/power/ItemLiquidGeneratorTests.java @@ -83,7 +83,7 @@ public class ItemLiquidGeneratorTests extends PowerTestFixture{ final float baseEfficiency = liquid.flammability; final float expectedEfficiency = Math.min(1.0f, availableLiquidAmount / maximumLiquidUsage) * baseEfficiency; final float expectedConsumptionPerTick = Math.min(maximumLiquidUsage, availableLiquidAmount); - final float expectedRemainingLiquidAmount = Math.max(0.0f, availableLiquidAmount - expectedConsumptionPerTick * Time.delta()); + final float expectedRemainingLiquidAmount = Math.max(0.0f, availableLiquidAmount - expectedConsumptionPerTick * Time.delta); createGenerator(inputType); assertTrue(entity.acceptLiquid(null, liquid, availableLiquidAmount), inputType + " | " + parameterDescription + ": Liquids which will be declined by the generator don't need to be tested - The code won't be called for those cases."); @@ -170,7 +170,7 @@ public class ItemLiquidGeneratorTests extends PowerTestFixture{ float expectedEfficiency = entity.productionEfficiency; float currentDuration = 0.0f; - while((currentDuration += Time.delta()) <= fakeItemDuration){ + while((currentDuration += Time.delta) <= fakeItemDuration){ entity.updateTile(); assertEquals(expectedEfficiency, entity.productionEfficiency, "Duration: " + currentDuration); } diff --git a/tests/src/test/java/power/PowerTests.java b/tests/src/test/java/power/PowerTests.java index 41f851b804..bbe37653e3 100644 --- a/tests/src/test/java/power/PowerTests.java +++ b/tests/src/test/java/power/PowerTests.java @@ -61,8 +61,8 @@ public class PowerTests extends PowerTestFixture{ powerGraph.add(producerTile.build); powerGraph.add(directConsumerTile.build); - assertEquals(producedPower * Time.delta(), powerGraph.getPowerProduced(), Mathf.FLOAT_ROUNDING_ERROR); - assertEquals(requiredPower * Time.delta(), powerGraph.getPowerNeeded(), Mathf.FLOAT_ROUNDING_ERROR); + assertEquals(producedPower * Time.delta, powerGraph.getPowerProduced(), Mathf.FLOAT_ROUNDING_ERROR); + assertEquals(requiredPower * Time.delta, powerGraph.getPowerNeeded(), Mathf.FLOAT_ROUNDING_ERROR); // Update and check for the expected power status of the consumer powerGraph.update();