From b40beb0d1dfe062315bb6eceb8355b47088e6c5c Mon Sep 17 00:00:00 2001 From: Anuken Date: Mon, 8 Apr 2019 09:03:18 -0400 Subject: [PATCH] Source reformat --- .travis.yml | 15 +- android/AndroidManifest.xml | 42 +-- android/build.gradle | 90 +++--- android/project.properties | 1 - .../io/anuke/mindustry/AndroidLauncher.java | 13 +- annotations/build.gradle | 4 +- .../io/anuke/annotations/Annotations.java | 13 +- .../java/io/anuke/annotations/ClassEntry.java | 2 - .../io/anuke/annotations/MethodEntry.java | 4 +- .../RemoteMethodAnnotationProcessor.java | 23 +- .../annotations/RemoteReadGenerator.java | 19 +- .../annotations/RemoteWriteGenerator.java | 21 +- .../SerializeAnnotationProcessor.java | 25 +- .../StructAnnotationProcessor.java | 33 +-- .../main/java/io/anuke/annotations/Utils.java | 4 +- build.gradle | 11 +- .../sprites/blocks/environment/pack.json | 12 +- .../blocks/environment/pack_fallback.json | 12 +- core/assets-raw/sprites/pack.json | 12 +- core/assets-raw/sprites/pack_fallback.json | 12 +- .../sprites_replacement/editor/pack.json | 12 +- core/assets/bundles/bundle.properties | 4 +- core/assets/bundles/bundle_ko.properties | 13 - core/src/io/anuke/mindustry/Mindustry.java | 6 +- core/src/io/anuke/mindustry/Vars.java | 116 ++++---- .../io/anuke/mindustry/ai/BlockIndexer.java | 57 ++-- .../src/io/anuke/mindustry/ai/Pathfinder.java | 16 +- .../io/anuke/mindustry/ai/WaveSpawner.java | 14 +- .../io/anuke/mindustry/content/Blocks.java | 132 ++++----- .../io/anuke/mindustry/content/Bullets.java | 42 +-- core/src/io/anuke/mindustry/content/Fx.java | 55 ++-- .../src/io/anuke/mindustry/content/Mechs.java | 15 +- .../mindustry/content/StatusEffects.java | 2 +- .../io/anuke/mindustry/content/TechTree.java | 7 +- .../io/anuke/mindustry/content/UnitTypes.java | 6 +- .../src/io/anuke/mindustry/content/Zones.java | 10 +- .../anuke/mindustry/core/ContentLoader.java | 42 ++- core/src/io/anuke/mindustry/core/Control.java | 28 +- .../io/anuke/mindustry/core/GameState.java | 20 +- core/src/io/anuke/mindustry/core/Logic.java | 14 +- .../io/anuke/mindustry/core/NetClient.java | 45 ++- .../io/anuke/mindustry/core/NetServer.java | 75 +++-- .../src/io/anuke/mindustry/core/Platform.java | 52 ++-- .../src/io/anuke/mindustry/core/Renderer.java | 41 +-- core/src/io/anuke/mindustry/core/UI.java | 44 ++- core/src/io/anuke/mindustry/core/World.java | 54 ++-- .../io/anuke/mindustry/editor/EditorTile.java | 7 +- .../io/anuke/mindustry/editor/EditorTool.java | 8 +- .../io/anuke/mindustry/editor/MapEditor.java | 20 +- .../mindustry/editor/MapEditorDialog.java | 112 ++++---- .../mindustry/editor/MapGenerateDialog.java | 12 +- .../anuke/mindustry/editor/MapLoadDialog.java | 8 +- .../anuke/mindustry/editor/MapRenderer.java | 26 +- .../anuke/mindustry/editor/MapSaveDialog.java | 6 +- .../io/anuke/mindustry/editor/MapView.java | 39 ++- .../mindustry/editor/WaveInfoDialog.java | 32 +-- .../editor/generation/DistortFilter.java | 6 +- .../editor/generation/FilterOption.java | 10 +- .../editor/generation/GenerateFilter.java | 8 +- .../editor/generation/NoiseFilter.java | 12 +- .../editor/generation/OreFilter.java | 13 +- .../editor/generation/RiverNoiseFilter.java | 12 +- .../editor/generation/ScatterFilter.java | 8 +- .../editor/generation/TerrainFilter.java | 18 +- .../io/anuke/mindustry/entities/Damage.java | 31 +- .../mindustry/entities/EntityCollisions.java | 13 +- .../anuke/mindustry/entities/EntityDraw.java | 2 +- .../anuke/mindustry/entities/EntityGroup.java | 2 +- .../anuke/mindustry/entities/EntityQuery.java | 2 +- .../io/anuke/mindustry/entities/Predict.java | 7 +- .../io/anuke/mindustry/entities/Units.java | 64 ++--- .../entities/bullet/ArtilleryBulletType.java | 4 +- .../entities/bullet/BasicBulletType.java | 2 +- .../mindustry/entities/bullet/Bullet.java | 28 +- .../mindustry/entities/bullet/BulletType.java | 42 ++- .../entities/bullet/FlakBulletType.java | 4 +- .../entities/bullet/LiquidBulletType.java | 6 +- .../entities/bullet/MassDriverBolt.java | 6 +- .../entities/bullet/MissileBulletType.java | 8 +- .../mindustry/entities/effect/Decal.java | 8 +- .../anuke/mindustry/entities/effect/Fire.java | 31 +- .../entities/effect/GroundEffectEntity.java | 10 +- .../entities/effect/ItemTransfer.java | 10 +- .../mindustry/entities/effect/Lightning.java | 43 ++- .../mindustry/entities/effect/Puddle.java | 47 ++-- .../entities/effect/RubbleDecal.java | 2 +- .../entities/effect/ScorchDecal.java | 4 +- .../entities/impl/DestructibleEntity.java | 6 +- .../entities/traits/BuilderTrait.java | 92 +++--- .../mindustry/entities/traits/Saveable.java | 4 +- .../mindustry/entities/traits/SolidTrait.java | 9 +- .../mindustry/entities/traits/SyncTrait.java | 18 +- .../entities/traits/TargetTrait.java | 4 +- .../entities/traits/VelocityTrait.java | 2 +- .../mindustry/entities/type/BaseUnit.java | 18 +- .../mindustry/entities/type/FlyingUnit.java | 12 +- .../mindustry/entities/type/GroundUnit.java | 18 +- .../anuke/mindustry/entities/type/Player.java | 27 +- .../mindustry/entities/type/TileEntity.java | 39 ++- .../anuke/mindustry/entities/type/Unit.java | 42 ++- .../mindustry/entities/type/base/Drone.java | 27 +- .../entities/type/base/Revenant.java | 2 +- .../mindustry/entities/units/Statuses.java | 7 +- .../mindustry/entities/units/UnitDrops.java | 5 +- core/src/io/anuke/mindustry/game/Content.java | 4 +- .../io/anuke/mindustry/game/ContentList.java | 4 +- .../io/anuke/mindustry/game/DefaultWaves.java | 266 +++++++++--------- .../io/anuke/mindustry/game/Difficulty.java | 8 +- .../io/anuke/mindustry/game/EventType.java | 24 +- .../io/anuke/mindustry/game/GlobalData.java | 16 +- .../anuke/mindustry/game/MappableContent.java | 2 +- .../io/anuke/mindustry/game/RulePreset.java | 2 +- core/src/io/anuke/mindustry/game/Rules.java | 40 +-- core/src/io/anuke/mindustry/game/Saves.java | 8 +- .../io/anuke/mindustry/game/SpawnGroup.java | 27 +- core/src/io/anuke/mindustry/game/Stats.java | 26 +- core/src/io/anuke/mindustry/game/Teams.java | 15 +- .../mindustry/game/UnlockableContent.java | 16 +- core/src/io/anuke/mindustry/game/Version.java | 10 +- .../mindustry/graphics/BlockRenderer.java | 34 +-- .../mindustry/graphics/FloorRenderer.java | 29 +- .../mindustry/graphics/IndexedRenderer.java | 64 ++--- .../io/anuke/mindustry/graphics/Layer.java | 12 +- .../mindustry/graphics/MinimapRenderer.java | 10 +- .../mindustry/graphics/OverlayRenderer.java | 2 +- .../io/anuke/mindustry/graphics/Shaders.java | 10 +- .../io/anuke/mindustry/graphics/Shapes.java | 7 +- .../src/io/anuke/mindustry/input/Binding.java | 25 +- .../anuke/mindustry/input/DesktopInput.java | 29 +- .../anuke/mindustry/input/InputHandler.java | 52 ++-- .../io/anuke/mindustry/input/MobileInput.java | 43 ++- .../io/anuke/mindustry/input/PlaceUtils.java | 10 +- .../io/anuke/mindustry/io/BundleLoader.java | 4 +- .../src/io/anuke/mindustry/io/Changelogs.java | 10 +- .../io/anuke/mindustry/io/Contributors.java | 4 +- core/src/io/anuke/mindustry/io/MapIO.java | 49 ++-- .../anuke/mindustry/io/SaveFileVersion.java | 27 +- core/src/io/anuke/mindustry/io/SaveIO.java | 8 +- core/src/io/anuke/mindustry/io/TypeIO.java | 53 ++-- .../anuke/mindustry/io/versions/Save16.java | 4 +- core/src/io/anuke/mindustry/maps/Map.java | 22 +- core/src/io/anuke/mindustry/maps/Maps.java | 14 +- .../maps/generators/BasicGenerator.java | 2 +- .../mindustry/maps/generators/Generator.java | 3 +- .../maps/generators/MapGenerator.java | 12 +- .../maps/generators/RandomGenerator.java | 10 +- .../anuke/mindustry/net/Administration.java | 16 +- core/src/io/anuke/mindustry/net/Net.java | 66 ++--- .../io/anuke/mindustry/net/NetConnection.java | 4 +- .../src/io/anuke/mindustry/net/NetworkIO.java | 8 +- core/src/io/anuke/mindustry/net/Packets.java | 8 +- .../io/anuke/mindustry/net/Registrator.java | 12 +- .../io/anuke/mindustry/net/Streamable.java | 6 +- .../src/io/anuke/mindustry/type/Category.java | 20 +- .../io/anuke/mindustry/type/ContentType.java | 4 +- core/src/io/anuke/mindustry/type/Item.java | 24 +- .../io/anuke/mindustry/type/ItemStack.java | 10 +- .../src/io/anuke/mindustry/type/ItemType.java | 4 +- core/src/io/anuke/mindustry/type/Liquid.java | 16 +- core/src/io/anuke/mindustry/type/Loadout.java | 8 +- core/src/io/anuke/mindustry/type/Mech.java | 13 +- .../io/anuke/mindustry/type/StatusEffect.java | 25 +- core/src/io/anuke/mindustry/type/Weapon.java | 38 +-- core/src/io/anuke/mindustry/type/Zone.java | 17 +- core/src/io/anuke/mindustry/ui/Bar.java | 7 +- .../io/anuke/mindustry/ui/BorderImage.java | 6 +- .../io/anuke/mindustry/ui/ContentDisplay.java | 26 +- core/src/io/anuke/mindustry/ui/GridImage.java | 8 +- .../io/anuke/mindustry/ui/ItemDisplay.java | 6 +- core/src/io/anuke/mindustry/ui/ItemImage.java | 6 +- .../io/anuke/mindustry/ui/ItemsDisplay.java | 2 +- core/src/io/anuke/mindustry/ui/Links.java | 14 +- .../io/anuke/mindustry/ui/LiquidDisplay.java | 4 +- .../src/io/anuke/mindustry/ui/MenuButton.java | 2 +- core/src/io/anuke/mindustry/ui/Minimap.java | 7 +- .../io/anuke/mindustry/ui/MobileButton.java | 2 +- core/src/io/anuke/mindustry/ui/ReqImage.java | 4 +- .../src/io/anuke/mindustry/ui/TreeLayout.java | 8 +- .../mindustry/ui/dialogs/AboutDialog.java | 14 +- .../mindustry/ui/dialogs/AdminsDialog.java | 2 +- .../mindustry/ui/dialogs/BansDialog.java | 5 +- .../ui/dialogs/ContentInfoDialog.java | 2 +- .../mindustry/ui/dialogs/ControlsDialog.java | 2 +- .../ui/dialogs/CustomGameDialog.java | 11 +- .../ui/dialogs/CustomRulesDialog.java | 6 +- .../mindustry/ui/dialogs/DatabaseDialog.java | 8 +- .../mindustry/ui/dialogs/DeployDialog.java | 4 +- .../mindustry/ui/dialogs/DiscordDialog.java | 2 +- .../mindustry/ui/dialogs/FileChooser.java | 8 +- .../mindustry/ui/dialogs/FloatingDialog.java | 24 +- .../mindustry/ui/dialogs/GameOverDialog.java | 4 +- .../mindustry/ui/dialogs/JoinDialog.java | 19 +- .../mindustry/ui/dialogs/LanguageDialog.java | 4 +- .../mindustry/ui/dialogs/LoadDialog.java | 16 +- .../mindustry/ui/dialogs/MapsDialog.java | 8 +- .../mindustry/ui/dialogs/MinimapDialog.java | 2 +- .../mindustry/ui/dialogs/PausedDialog.java | 10 +- .../mindustry/ui/dialogs/SaveDialog.java | 14 +- .../ui/dialogs/SettingsMenuDialog.java | 2 +- .../mindustry/ui/dialogs/TechTreeDialog.java | 14 +- .../mindustry/ui/dialogs/ZoneInfoDialog.java | 9 +- .../ui/fragments/BackgroundFragment.java | 8 +- .../ui/fragments/BlockConfigFragment.java | 2 +- .../ui/fragments/BlockInventoryFragment.java | 15 +- .../mindustry/ui/fragments/ChatFragment.java | 2 +- .../mindustry/ui/fragments/HudFragment.java | 43 ++- .../ui/fragments/LoadingFragment.java | 5 +- .../mindustry/ui/fragments/MenuFragment.java | 22 +- .../ui/fragments/OverlayFragment.java | 4 +- .../ui/fragments/PlacementFragment.java | 26 +- .../ui/fragments/PlayerListFragment.java | 4 +- core/src/io/anuke/mindustry/world/Block.java | 64 ++--- .../anuke/mindustry/world/BlockStorage.java | 23 +- core/src/io/anuke/mindustry/world/Build.java | 36 ++- .../io/anuke/mindustry/world/CachedTile.java | 11 +- core/src/io/anuke/mindustry/world/Edges.java | 16 +- .../io/anuke/mindustry/world/ItemBuffer.java | 8 +- .../mindustry/world/LegacyColorMapper.java | 6 +- core/src/io/anuke/mindustry/world/Pos.java | 12 +- core/src/io/anuke/mindustry/world/Tile.java | 25 +- .../mindustry/world/blocks/BlockPart.java | 6 +- .../mindustry/world/blocks/BuildBlock.java | 18 +- .../anuke/mindustry/world/blocks/Floor.java | 20 +- .../mindustry/world/blocks/ItemSelection.java | 2 +- .../mindustry/world/blocks/LiquidBlock.java | 2 +- .../io/anuke/mindustry/world/blocks/Rock.java | 4 +- .../mindustry/world/blocks/StaticWall.java | 8 +- .../mindustry/world/blocks/TreeBlock.java | 3 +- .../world/blocks/defense/DeflectorWall.java | 10 +- .../mindustry/world/blocks/defense/Door.java | 10 +- .../world/blocks/defense/ForceProjector.java | 38 +-- .../world/blocks/defense/MendProjector.java | 20 +- .../blocks/defense/OverdriveProjector.java | 20 +- .../world/blocks/defense/ShockMine.java | 4 +- .../world/blocks/defense/SurgeWall.java | 4 +- .../blocks/defense/turrets/BurstTurret.java | 2 +- .../blocks/defense/turrets/ChargeTurret.java | 6 +- .../blocks/defense/turrets/CooledTurret.java | 6 +- .../blocks/defense/turrets/ItemTurret.java | 10 +- .../blocks/defense/turrets/LaserTurret.java | 6 +- .../blocks/defense/turrets/LiquidTurret.java | 14 +- .../world/blocks/defense/turrets/Turret.java | 29 +- .../distribution/BufferedItemBridge.java | 2 +- .../world/blocks/distribution/Conduit.java | 8 +- .../world/blocks/distribution/Conveyor.java | 56 ++-- .../distribution/ExtendingItemBridge.java | 24 +- .../world/blocks/distribution/ItemBridge.java | 31 +- .../world/blocks/distribution/Junction.java | 4 +- .../blocks/distribution/LiquidBridge.java | 2 +- .../blocks/distribution/LiquidJunction.java | 2 +- .../world/blocks/distribution/MassDriver.java | 45 ++- .../blocks/distribution/OverflowGate.java | 10 +- .../world/blocks/distribution/Router.java | 8 +- .../world/blocks/distribution/Sorter.java | 18 +- .../world/blocks/power/ImpactReactor.java | 20 +- .../world/blocks/power/NuclearReactor.java | 4 +- .../world/blocks/power/PowerGenerator.java | 11 +- .../world/blocks/power/PowerGraph.java | 23 +- .../world/blocks/power/PowerNode.java | 38 ++- .../world/blocks/power/SolarGenerator.java | 2 +- .../world/blocks/power/ThermalGenerator.java | 2 +- .../world/blocks/production/Cultivator.java | 12 +- .../world/blocks/production/Drill.java | 26 +- .../blocks/production/GenericCrafter.java | 8 +- .../blocks/production/GenericSmelter.java | 6 +- .../world/blocks/production/Incinerator.java | 4 +- .../world/blocks/production/Pump.java | 7 +- .../world/blocks/production/SolidPump.java | 4 +- .../world/blocks/sandbox/ItemVoid.java | 3 +- .../world/blocks/sandbox/LiquidSource.java | 4 +- .../world/blocks/storage/CoreBlock.java | 18 +- .../world/blocks/storage/LaunchPad.java | 6 +- .../world/blocks/storage/Unloader.java | 8 +- .../mindustry/world/blocks/units/MechPad.java | 32 +-- .../world/blocks/units/RepairPoint.java | 24 +- .../world/blocks/units/UnitFactory.java | 36 +-- .../mindustry/world/consumers/Consume.java | 20 +- .../world/consumers/ConsumeItemFilter.java | 6 +- .../world/consumers/ConsumeItems.java | 2 +- .../world/consumers/ConsumeLiquid.java | 2 +- .../world/consumers/ConsumeLiquidBase.java | 8 +- .../world/consumers/ConsumeLiquidFilter.java | 2 +- .../world/consumers/ConsumePower.java | 4 +- .../mindustry/world/consumers/Consumers.java | 8 +- .../anuke/mindustry/world/meta/Attribute.java | 8 +- .../anuke/mindustry/world/meta/BlockBars.java | 5 +- .../anuke/mindustry/world/meta/BlockFlag.java | 8 +- .../anuke/mindustry/world/meta/BlockStat.java | 5 +- .../mindustry/world/meta/BlockStats.java | 22 +- .../mindustry/world/meta/StatCategory.java | 2 +- .../world/meta/values/AmmoListValue.java | 8 +- .../world/meta/values/BooleanValue.java | 2 +- .../world/meta/values/LiquidFilterValue.java | 4 +- .../world/meta/values/NumberValue.java | 6 +- .../world/meta/values/StringValue.java | 2 +- .../mindustry/world/modules/BlockModule.java | 7 +- .../world/modules/ConsumeModule.java | 4 +- .../mindustry/world/modules/ItemModule.java | 10 +- .../mindustry/world/modules/LiquidModule.java | 9 +- .../mindustry/world/modules/PowerModule.java | 14 +- desktop/build.gradle | 5 +- desktop/packr_minimize.json | 39 ++- .../anuke/mindustry/desktop/CrashHandler.java | 13 +- .../mindustry/desktop/DesktopPlatform.java | 7 +- ios/build.gradle | 10 +- .../AppIcon.appiconset/Contents.json | 152 +++++----- ios/data/Assets.xcassets/Contents.json | 6 +- ios/robovm.xml | 94 +++---- ios/src/io/anuke/mindustry/IOSLauncher.java | 20 +- net/src/io/anuke/net/ByteSerializer.java | 10 +- net/src/io/anuke/net/FrameworkSerializer.java | 22 +- net/src/io/anuke/net/KryoClient.java | 13 +- net/src/io/anuke/net/KryoCore.java | 2 +- net/src/io/anuke/net/KryoServer.java | 10 +- server/build.gradle | 16 +- .../anuke/mindustry/server/CrashHandler.java | 11 +- .../mindustry/server/MindustryServer.java | 4 +- .../anuke/mindustry/server/ServerControl.java | 54 ++-- settings.gradle | 4 +- tests/src/test/java/ApplicationTests.java | 16 +- tests/src/test/java/WorldTests.java | 40 ++- tests/src/test/java/ZoneTests.java | 5 +- tests/src/test/java/power/FakeGraphics.java | 4 +- .../java/power/ItemLiquidGeneratorTests.java | 14 +- .../src/test/java/power/PowerTestFixture.java | 21 +- tests/src/test/java/power/PowerTests.java | 93 +++--- tools/build.gradle | 88 +++--- .../io/anuke/mindustry/BundleLauncher.java | 20 +- tools/src/io/anuke/mindustry/Generators.java | 36 ++- tools/src/io/anuke/mindustry/Image.java | 38 +-- tools/src/io/anuke/mindustry/ImagePacker.java | 16 +- 331 files changed, 2822 insertions(+), 3274 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8231bc68f7..4cf6a09aac 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,10 @@ - jdk: -- openjdk8 + - openjdk8 script: -- "git clone --depth=1 --branch=master https://github.com/Anuken/Arc ../Arc" -- "./gradlew test" -- "./gradlew desktop:dist -Pbuildversion=${TRAVIS_TAG:1}" -- "./gradlew server:dist -Pbuildversion=${TRAVIS_TAG:1}" + - "git clone --depth=1 --branch=master https://github.com/Anuken/Arc ../Arc" + - "./gradlew test" + - "./gradlew desktop:dist -Pbuildversion=${TRAVIS_TAG:1}" + - "./gradlew server:dist -Pbuildversion=${TRAVIS_TAG:1}" deploy: provider: releases @@ -14,8 +13,8 @@ deploy: api_key: secure: Cv5wFtWt62/A24EvSEQvMow7gKPbZ3oATEFPuSghhB2TQz1dA40Zee3Qvk4LFlpLrhYo4K0ZSczCZRGpR+hCd8+Dpww52bheYEvWuh3ZQfvu/fXtEx2j5PwP1qMpmIgSxETV/gkD7l9FImdh0VzktYiAvQfmi0bEocG9/D4QwjFpNat7iwBdcMiw1MvAygpdIWRsjiw0RKlB2mWarmoHhQ7Gu7qlU3j50uaEvcrtmU0pBUPggNQwQRv32i9NPvNFxrqqlUjDLIS8JFea99zCkp8BwYqbEvBIMzd+Qip1/stLJJA3+cDUClbsDtg8rAVetzpOrdLEEBmqShFe5MDl2yEHcsgpN9CFsyTaUfvB3P3rVjizvycMm42IsUkXQiarm5xTQ/TIA8Rd8AHiSKuweNCg1Fd5SFaRtKy8JVLXuxyfUccmyje6hhz2L4lS2Wfj3mAG7sqZUCXhWP79EKdGkiPOjKv4CwXEKmuH3BMVqPlNUZJr9Eg3sV1FG0h2l+MVOOnR635qdUbb49sYojYxVruMLX0BH1c4ZCu230m8CUoWA1Em1QNI75ya7+9Y5T6AsgWDVpBvdUo9fWNbdp+VQ0GskFQsJD5wtnxbcbHeFiERAgGBm7z6qt9u9LrQpBH+dsW52ADvYsu3L4nQEa+sdMHwTTwmGY+iUvsxu0DqxGg= file: - - "desktop/build/libs/desktop-release.jar" - - "server/build/libs/server-release.jar" + - "desktop/build/libs/desktop-release.jar" + - "server/build/libs/server-release.jar" on: repo: Anuken/Mindustry tags: true diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml index 6517abd237..05700dfe47 100644 --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml @@ -1,11 +1,11 @@ + package="io.anuke.mindustry"> - - - - + + + + - + + android:name="io.anuke.mindustry.AndroidLauncher" + android:label="@string/app_name" + android:screenOrientation="user" + android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout"> - - + + @@ -33,7 +33,7 @@ - + @@ -41,28 +41,28 @@ - + - - - + + + - - - + + + + android:theme="@style/GdxTheme"/> diff --git a/android/build.gradle b/android/build.gradle index 40582c5c7d..d87fbc2d69 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,30 +1,30 @@ -buildscript { - repositories { +buildscript{ + repositories{ mavenLocal() mavenCentral() google() - maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } + maven{ url "https://oss.sonatype.org/content/repositories/snapshots/" } jcenter() } - - dependencies { + + dependencies{ classpath 'com.android.tools.build:gradle:3.3.2' } } apply plugin: "com.android.application" -configurations { natives } +configurations{ natives } -repositories { - mavenCentral() +repositories{ + mavenCentral() jcenter() - maven { - url "https://maven.google.com" + maven{ + url "https://maven.google.com" } } -dependencies { +dependencies{ implementation project(":core") implementation project(":net") @@ -46,14 +46,14 @@ task deploy(type: Copy){ from "build/outputs/apk/release/android-release.apk" into "../deploy/" - rename ("android-release.apk", appName + "-android-" + getVersionString() + ".apk") + rename("android-release.apk", appName + "-android-" + getVersionString() + ".apk") } -android { +android{ buildToolsVersion '28.0.3' compileSdkVersion 28 - sourceSets { - main { + sourceSets{ + main{ manifest.srcFile 'AndroidManifest.xml' java.srcDirs = ['src'] aidl.srcDirs = ['src'] @@ -65,11 +65,11 @@ android { androidTest.setRoot('tests') } - packagingOptions { + packagingOptions{ exclude 'META-INF/robovm/ios/robovm.xml' } - defaultConfig { + defaultConfig{ def vfile = file('../core/assets/version.properties') def code = 0 @@ -93,16 +93,16 @@ android { versionName versionNameResult } - compileOptions { + compileOptions{ sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } flavorDimensions "google" - signingConfigs { - release { - if(project.hasProperty("RELEASE_STORE_FILE")) { + signingConfigs{ + release{ + if(project.hasProperty("RELEASE_STORE_FILE")){ storeFile file(RELEASE_STORE_FILE) storePassword RELEASE_STORE_PASSWORD keyAlias RELEASE_KEY_ALIAS @@ -113,8 +113,8 @@ android { } } - buildTypes { - release { + buildTypes{ + release{ signingConfig signingConfigs.release } } @@ -122,22 +122,22 @@ android { // called every time gradle gets executed, takes the native dependencies of // the natives configuration, and extracts them to the proper libs/ folders // so they get packed with the APK. -task copyAndroidNatives() { +task copyAndroidNatives(){ file("libs/armeabi/").mkdirs() file("libs/armeabi-v7a/").mkdirs() file("libs/arm64-v8a/").mkdirs() file("libs/x86_64/").mkdirs() file("libs/x86/").mkdirs() - configurations.natives.files.each { jar -> + configurations.natives.files.each{ jar -> def outputDir = null - if (jar.name.endsWith("natives-arm64-v8a.jar")) outputDir = file("libs/arm64-v8a") - if (jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a") - if (jar.name.endsWith("natives-armeabi.jar")) outputDir = file("libs/armeabi") - if (jar.name.endsWith("natives-x86_64.jar")) outputDir = file("libs/x86_64") - if (jar.name.endsWith("natives-x86.jar")) outputDir = file("libs/x86") - if (outputDir != null) { - copy { + if(jar.name.endsWith("natives-arm64-v8a.jar")) outputDir = file("libs/arm64-v8a") + if(jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a") + if(jar.name.endsWith("natives-armeabi.jar")) outputDir = file("libs/armeabi") + if(jar.name.endsWith("natives-x86_64.jar")) outputDir = file("libs/x86_64") + if(jar.name.endsWith("natives-x86.jar")) outputDir = file("libs/x86") + if(outputDir != null){ + copy{ from zipTree(jar) into outputDir include "*.so" @@ -146,21 +146,21 @@ task copyAndroidNatives() { } } -task run(type: Exec) { +task run(type: Exec){ def path def localProperties = project.file("../local.properties") - if (localProperties.exists()) { + if(localProperties.exists()){ Properties properties = new Properties() - localProperties.withInputStream { instr -> + localProperties.withInputStream{ instr -> properties.load(instr) } def sdkDir = properties.getProperty('sdk.dir') - if (sdkDir) { + if(sdkDir){ path = sdkDir - } else { + }else{ path = "$System.env.ANDROID_HOME" } - } else { + }else{ path = "$System.env.ANDROID_HOME" } @@ -169,19 +169,19 @@ task run(type: Exec) { } // sets up the Android Idea project, using the old Ant based build. -idea { - module { +idea{ + module{ sourceDirs += file("src") scopes = [COMPILE: [plus: [project.configurations.compile]]] - iml { - withXml { + iml{ + withXml{ def node = it.asNode() def builder = NodeBuilder.newInstance() builder.current = node - builder.component(name: "FacetManager") { - facet(type: "android", name: "Android") { - configuration { + builder.component(name: "FacetManager"){ + facet(type: "android", name: "Android"){ + configuration{ option(name: "UPDATE_PROPERTY_FILES", value: "true") } } diff --git a/android/project.properties b/android/project.properties index 4ab125693c..f13bd4b19c 100644 --- a/android/project.properties +++ b/android/project.properties @@ -9,6 +9,5 @@ # # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt - # Project target. target=android-19 diff --git a/android/src/io/anuke/mindustry/AndroidLauncher.java b/android/src/io/anuke/mindustry/AndroidLauncher.java index b7f142e9f8..087f392f7d 100644 --- a/android/src/io/anuke/mindustry/AndroidLauncher.java +++ b/android/src/io/anuke/mindustry/AndroidLauncher.java @@ -18,18 +18,15 @@ import io.anuke.arc.function.Consumer; import io.anuke.arc.scene.ui.layout.Unit; import io.anuke.arc.util.Strings; import io.anuke.arc.util.serialization.Base64Coder; -import io.anuke.net.KryoClient; -import io.anuke.net.KryoServer; import io.anuke.mindustry.core.Platform; import io.anuke.mindustry.game.Saves.SaveSlot; import io.anuke.mindustry.io.SaveIO; import io.anuke.mindustry.net.Net; import io.anuke.mindustry.ui.dialogs.FileChooser; +import io.anuke.net.KryoClient; +import io.anuke.net.KryoServer; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; +import java.io.*; import java.util.ArrayList; import static io.anuke.mindustry.Vars.*; @@ -59,7 +56,7 @@ public class AndroidLauncher extends AndroidApplication{ int len = s.length(); byte[] data = new byte[len / 2]; for(int i = 0; i < len; i += 2){ - data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4) + data[i / 2] = (byte)((Character.digit(s.charAt(i), 16) << 4) + Character.digit(s.charAt(i + 1), 16)); } String result = new String(Base64Coder.encode(data)); @@ -184,7 +181,7 @@ public class AndroidLauncher extends AndroidApplication{ } private boolean isTablet(Context context){ - TelephonyManager manager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); + TelephonyManager manager = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE); return manager != null && manager.getPhoneType() == TelephonyManager.PHONE_TYPE_NONE; } } diff --git a/annotations/build.gradle b/annotations/build.gradle index edc88bfb58..d894ed0abf 100644 --- a/annotations/build.gradle +++ b/annotations/build.gradle @@ -1,6 +1,6 @@ apply plugin: "java" sourceCompatibility = 1.8 -sourceSets.main.java.srcDirs = [ "src/main/java/" ] -sourceSets.main.resources.srcDirs = [ "src/main/resources/" ] +sourceSets.main.java.srcDirs = ["src/main/java/"] +sourceSets.main.resources.srcDirs = ["src/main/resources/"] diff --git a/annotations/src/main/java/io/anuke/annotations/Annotations.java b/annotations/src/main/java/io/anuke/annotations/Annotations.java index c36bf03ab9..7961a57b89 100644 --- a/annotations/src/main/java/io/anuke/annotations/Annotations.java +++ b/annotations/src/main/java/io/anuke/annotations/Annotations.java @@ -1,9 +1,6 @@ package io.anuke.annotations; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; +import java.lang.annotation.*; public class Annotations{ @@ -19,25 +16,25 @@ public class Annotations{ } - /** Marks a class as serializable.*/ + /** Marks a class as serializable. */ @Target(ElementType.TYPE) @Retention(RetentionPolicy.SOURCE) public @interface Serialize{ } - /** Marks a class as a special value type struct. Class name must end in 'Struct'.*/ + /** Marks a class as a special value type struct. Class name must end in 'Struct'. */ @Target(ElementType.TYPE) @Retention(RetentionPolicy.SOURCE) public @interface Struct{ } - /**Marks a field of a struct. Optional.*/ + /** Marks a field of a struct. Optional. */ @Target(ElementType.FIELD) @Retention(RetentionPolicy.SOURCE) public @interface StructField{ - /**Size of a struct field in bits. Not valid on booleans or floating point numbers.*/ + /** Size of a struct field in bits. Not valid on booleans or floating point numbers. */ int value(); } diff --git a/annotations/src/main/java/io/anuke/annotations/ClassEntry.java b/annotations/src/main/java/io/anuke/annotations/ClassEntry.java index 3da814be88..a9be2ec134 100644 --- a/annotations/src/main/java/io/anuke/annotations/ClassEntry.java +++ b/annotations/src/main/java/io/anuke/annotations/ClassEntry.java @@ -1,7 +1,5 @@ package io.anuke.annotations; -import io.anuke.annotations.MethodEntry; - import java.util.ArrayList; /** Represents a class witha list method entries to include in it. */ diff --git a/annotations/src/main/java/io/anuke/annotations/MethodEntry.java b/annotations/src/main/java/io/anuke/annotations/MethodEntry.java index 3566516372..d642671641 100644 --- a/annotations/src/main/java/io/anuke/annotations/MethodEntry.java +++ b/annotations/src/main/java/io/anuke/annotations/MethodEntry.java @@ -1,8 +1,6 @@ package io.anuke.annotations; -import io.anuke.annotations.Annotations.Loc; -import io.anuke.annotations.Annotations.PacketPriority; -import io.anuke.annotations.Annotations.Variant; +import io.anuke.annotations.Annotations.*; import javax.lang.model.element.ExecutableElement; diff --git a/annotations/src/main/java/io/anuke/annotations/RemoteMethodAnnotationProcessor.java b/annotations/src/main/java/io/anuke/annotations/RemoteMethodAnnotationProcessor.java index 1c5bb5301d..b9fbba57a8 100644 --- a/annotations/src/main/java/io/anuke/annotations/RemoteMethodAnnotationProcessor.java +++ b/annotations/src/main/java/io/anuke/annotations/RemoteMethodAnnotationProcessor.java @@ -1,18 +1,13 @@ package io.anuke.annotations; -import com.squareup.javapoet.FieldSpec; -import com.squareup.javapoet.JavaFile; -import com.squareup.javapoet.TypeSpec; +import com.squareup.javapoet.*; import io.anuke.annotations.Annotations.Loc; import io.anuke.annotations.Annotations.Remote; import io.anuke.annotations.IOFinder.ClassSerializer; import javax.annotation.processing.*; import javax.lang.model.SourceVersion; -import javax.lang.model.element.Element; -import javax.lang.model.element.ExecutableElement; -import javax.lang.model.element.Modifier; -import javax.lang.model.element.TypeElement; +import javax.lang.model.element.*; import javax.tools.Diagnostic.Kind; import java.util.*; import java.util.stream.Collectors; @@ -21,14 +16,14 @@ import java.util.stream.Collectors; /** The annotation processor for generating remote method call code. */ @SupportedSourceVersion(SourceVersion.RELEASE_8) @SupportedAnnotationTypes({ - "io.anuke.annotations.Annotations.Remote", - "io.anuke.annotations.Annotations.WriteClass", - "io.anuke.annotations.Annotations.ReadClass", +"io.anuke.annotations.Annotations.Remote", +"io.anuke.annotations.Annotations.WriteClass", +"io.anuke.annotations.Annotations.ReadClass", }) public class RemoteMethodAnnotationProcessor extends AbstractProcessor{ /** Maximum size of each event packet. */ public static final int maxPacketSize = 4096; - /** Warning on top of each autogenerated file.*/ + /** Warning on top of each autogenerated file. */ public static final String autogenWarning = "Autogenerated file. Do not modify!\n"; /** Name of the base package to put all the generated classes. */ private static final String packageName = "io.anuke.mindustry.gen"; @@ -37,7 +32,7 @@ public class RemoteMethodAnnotationProcessor extends AbstractProcessor{ private static final String readServerName = "RemoteReadServer"; /** Name of class that handles reading and invoking packets on the client. */ private static final String readClientName = "RemoteReadClient"; - /**Simple class name of generated class name.*/ + /** Simple class name of generated class name. */ private static final String callLocation = "Call"; /** Processing round number. */ @@ -115,7 +110,7 @@ public class RemoteMethodAnnotationProcessor extends AbstractProcessor{ //create and add entry MethodEntry method = new MethodEntry(entry.name, Utils.getMethodName(element), annotation.targets(), annotation.variants(), - annotation.called(), annotation.unreliable(), annotation.forward(), lastMethodID++, (ExecutableElement) element, annotation.priority()); + annotation.called(), annotation.unreliable(), annotation.forward(), lastMethodID++, (ExecutableElement)element, annotation.priority()); entry.methods.add(method); methods.add(method); @@ -140,7 +135,7 @@ public class RemoteMethodAnnotationProcessor extends AbstractProcessor{ TypeSpec.Builder hashBuilder = TypeSpec.classBuilder("MethodHash").addModifiers(Modifier.PUBLIC); hashBuilder.addJavadoc(autogenWarning); hashBuilder.addField(FieldSpec.builder(int.class, "HASH", Modifier.STATIC, Modifier.PUBLIC, Modifier.FINAL) - .initializer("$1L", Objects.hash(methods)).build()); + .initializer("$1L", Objects.hash(methods)).build()); //build and write resulting hash class TypeSpec spec = hashBuilder.build(); diff --git a/annotations/src/main/java/io/anuke/annotations/RemoteReadGenerator.java b/annotations/src/main/java/io/anuke/annotations/RemoteReadGenerator.java index 69dbe29f8b..d23bd592c9 100644 --- a/annotations/src/main/java/io/anuke/annotations/RemoteReadGenerator.java +++ b/annotations/src/main/java/io/anuke/annotations/RemoteReadGenerator.java @@ -3,9 +3,7 @@ package io.anuke.annotations; import com.squareup.javapoet.*; import io.anuke.annotations.IOFinder.ClassSerializer; -import javax.lang.model.element.Modifier; -import javax.lang.model.element.TypeElement; -import javax.lang.model.element.VariableElement; +import javax.lang.model.element.*; import javax.tools.Diagnostic.Kind; import java.io.IOException; import java.lang.reflect.Constructor; @@ -25,24 +23,23 @@ public class RemoteReadGenerator{ /** * Generates a class for reading remote invoke packets. - * * @param entries List of methods to use. * @param className Simple target class name. * @param packageName Full target package name. * @param needsPlayer Whether this read method requires a reference to the player sender. */ public void generateFor(List entries, String className, String packageName, boolean needsPlayer) - throws IllegalAccessException, InvocationTargetException, InstantiationException, NoSuchMethodException, IOException{ + throws IllegalAccessException, InvocationTargetException, InstantiationException, NoSuchMethodException, IOException{ TypeSpec.Builder classBuilder = TypeSpec.classBuilder(className).addModifiers(Modifier.PUBLIC); classBuilder.addJavadoc(RemoteMethodAnnotationProcessor.autogenWarning); //create main method builder MethodSpec.Builder readMethod = MethodSpec.methodBuilder("readPacket") - .addModifiers(Modifier.PUBLIC, Modifier.STATIC) - .addParameter(ByteBuffer.class, "buffer") //buffer to read form - .addParameter(int.class, "id") //ID of method type to read - .returns(void.class); + .addModifiers(Modifier.PUBLIC, Modifier.STATIC) + .addParameter(ByteBuffer.class, "buffer") //buffer to read form + .addParameter(int.class, "id") //ID of method type to read + .returns(void.class); if(needsPlayer){ //since the player type isn't loaded yet, creating a type def is necessary @@ -115,13 +112,13 @@ public class RemoteReadGenerator{ //execute the relevant method before the forward //if it throws a ValidateException, the method won't be forwarded - readBlock.addStatement("$N." + entry.element.getSimpleName() + "(" + varResult.toString() + ")", ((TypeElement) entry.element.getEnclosingElement()).getQualifiedName().toString()); + readBlock.addStatement("$N." + entry.element.getSimpleName() + "(" + varResult.toString() + ")", ((TypeElement)entry.element.getEnclosingElement()).getQualifiedName().toString()); //call forwarded method, don't forward on the client reader if(entry.forward && entry.where.isServer && needsPlayer){ //call forwarded method readBlock.addStatement(packageName + "." + entry.className + "." + entry.element.getSimpleName() + - "__forward(player.con.id" + (varResult.length() == 0 ? "" : ", ") + varResult.toString() + ")"); + "__forward(player.con.id" + (varResult.length() == 0 ? "" : ", ") + varResult.toString() + ")"); } readBlock.nextControlFlow("catch (java.lang.Exception e)"); diff --git a/annotations/src/main/java/io/anuke/annotations/RemoteWriteGenerator.java b/annotations/src/main/java/io/anuke/annotations/RemoteWriteGenerator.java index b7e0c32d1c..411f8ead86 100644 --- a/annotations/src/main/java/io/anuke/annotations/RemoteWriteGenerator.java +++ b/annotations/src/main/java/io/anuke/annotations/RemoteWriteGenerator.java @@ -4,10 +4,7 @@ import com.squareup.javapoet.*; import io.anuke.annotations.Annotations.Loc; import io.anuke.annotations.IOFinder.ClassSerializer; -import javax.lang.model.element.ExecutableElement; -import javax.lang.model.element.Modifier; -import javax.lang.model.element.TypeElement; -import javax.lang.model.element.VariableElement; +import javax.lang.model.element.*; import javax.tools.Diagnostic.Kind; import java.io.IOException; import java.nio.ByteBuffer; @@ -33,7 +30,7 @@ public class RemoteWriteGenerator{ //add temporary write buffer classBuilder.addField(FieldSpec.builder(ByteBuffer.class, "TEMP_BUFFER", Modifier.STATIC, Modifier.PRIVATE, Modifier.FINAL) - .initializer("ByteBuffer.allocate($1L)", RemoteMethodAnnotationProcessor.maxPacketSize).build()); + .initializer("ByteBuffer.allocate($1L)", RemoteMethodAnnotationProcessor.maxPacketSize).build()); //go through each method entry in this class for(MethodEntry methodEntry : entry.methods){ @@ -65,8 +62,8 @@ public class RemoteWriteGenerator{ //create builder MethodSpec.Builder method = MethodSpec.methodBuilder(elem.getSimpleName().toString() + (forwarded ? "__forward" : "")) //add except suffix when forwarding - .addModifiers(Modifier.STATIC, Modifier.SYNCHRONIZED) - .returns(void.class); + .addModifiers(Modifier.STATIC, Modifier.SYNCHRONIZED) + .returns(void.class); //forwarded methods aren't intended for use, and are not public if(!forwarded){ @@ -119,7 +116,7 @@ public class RemoteWriteGenerator{ //add the statement to call it method.addStatement("$N." + elem.getSimpleName() + "(" + results.toString() + ")", - ((TypeElement) elem.getEnclosingElement()).getQualifiedName().toString()); + ((TypeElement)elem.getEnclosingElement()).getQualifiedName().toString()); if(methodEntry.local != Loc.both){ method.endControlFlow(); @@ -170,7 +167,7 @@ public class RemoteWriteGenerator{ method.addStatement("TEMP_BUFFER.put(" + varName + " ? (byte)1 : 0)"); }else{ method.addStatement("TEMP_BUFFER.put" + - capName + "(" + varName + ")"); + capName + "(" + varName + ")"); } }else{ //else, try and find a serializer @@ -209,7 +206,7 @@ public class RemoteWriteGenerator{ //send the actual packet method.addStatement("io.anuke.mindustry.net.Net." + sendString + "packet, " + - (methodEntry.unreliable ? "io.anuke.mindustry.net.Net.SendMode.udp" : "io.anuke.mindustry.net.Net.SendMode.tcp") + ")"); + (methodEntry.unreliable ? "io.anuke.mindustry.net.Net.SendMode.udp" : "io.anuke.mindustry.net.Net.SendMode.tcp") + ")"); //end check for server/client @@ -221,7 +218,7 @@ public class RemoteWriteGenerator{ private String getCheckString(Loc loc){ return loc.isClient && loc.isServer ? "io.anuke.mindustry.net.Net.server() || io.anuke.mindustry.net.Net.client()" : - loc.isClient ? "io.anuke.mindustry.net.Net.client()" : - loc.isServer ? "io.anuke.mindustry.net.Net.server()" : "false"; + loc.isClient ? "io.anuke.mindustry.net.Net.client()" : + loc.isServer ? "io.anuke.mindustry.net.Net.server()" : "false"; } } diff --git a/annotations/src/main/java/io/anuke/annotations/SerializeAnnotationProcessor.java b/annotations/src/main/java/io/anuke/annotations/SerializeAnnotationProcessor.java index 6eb2efa6e9..358a52bbbf 100644 --- a/annotations/src/main/java/io/anuke/annotations/SerializeAnnotationProcessor.java +++ b/annotations/src/main/java/io/anuke/annotations/SerializeAnnotationProcessor.java @@ -5,13 +5,9 @@ import io.anuke.annotations.Annotations.Serialize; import javax.annotation.processing.*; import javax.lang.model.SourceVersion; -import javax.lang.model.element.Modifier; -import javax.lang.model.element.TypeElement; -import javax.lang.model.element.VariableElement; +import javax.lang.model.element.*; import javax.lang.model.util.ElementFilter; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; +import java.io.*; import java.lang.reflect.Field; import java.util.List; import java.util.Set; @@ -21,7 +17,7 @@ import java.util.Set; "io.anuke.annotations.Annotations.Serialize" }) public class SerializeAnnotationProcessor extends AbstractProcessor{ - /**Target class name.*/ + /** Target class name. */ private static final String className = "Serialization"; /** Name of the base package to put all the generated classes. */ private static final String packageName = "io.anuke.mindustry.gen"; @@ -58,8 +54,8 @@ public class SerializeAnnotationProcessor extends AbstractProcessor{ classBuilder.addField(jsonType, "bjson", Modifier.STATIC, Modifier.PRIVATE); classBuilder.addField(ubJsonReaderType, "bjsonReader", Modifier.STATIC, Modifier.PRIVATE); classBuilder.addStaticBlock(CodeBlock.builder() - .addStatement("bjson = new " + jsonType + "()") - .addStatement("bjsonReader = new " + ubJsonReaderType + "()") + .addStatement("bjson = new " + jsonType + "()") + .addStatement("bjsonReader = new " + ubJsonReaderType + "()") .build()); for(TypeElement elem : elements){ @@ -99,7 +95,8 @@ public class SerializeAnnotationProcessor extends AbstractProcessor{ List fields = ElementFilter.fieldsIn(Utils.elementUtils.getAllMembers(elem)); for(VariableElement field : fields){ - if(field.getModifiers().contains(Modifier.STATIC) || field.getModifiers().contains(Modifier.TRANSIENT) || field.getModifiers().contains(Modifier.PRIVATE)) continue; + if(field.getModifiers().contains(Modifier.STATIC) || field.getModifiers().contains(Modifier.TRANSIENT) || field.getModifiers().contains(Modifier.PRIVATE)) + continue; String name = field.getSimpleName().toString(); String typeName = Utils.typeUtils.erasure(field.asType()).toString().replace('$', '.'); @@ -109,11 +106,11 @@ public class SerializeAnnotationProcessor extends AbstractProcessor{ writeMethod.addStatement("stream.write" + capName + "(object." + name + ")"); readMethod.addStatement("object." + name + "= stream.read" + capName + "()"); - jsonWriteMethod.addStatement("json.writeValue(\"" + name + "\", object." + name +")"); + jsonWriteMethod.addStatement("json.writeValue(\"" + name + "\", object." + name + ")"); jsonReadMethod.addStatement("if(value.has(\"" + name + "\")) object." + name + "= value.get" + capName + "(\"" + name + "\")"); }else{ - writeMethod.addStatement("io.anuke.arc.Core.settings.getSerializer(" + typeName+ ".class).write(stream, object." + name + ")"); - readMethod.addStatement("object." + name + " = (" +typeName+")io.anuke.arc.Core.settings.getSerializer(" + typeName+ ".class).read(stream)"); + writeMethod.addStatement("io.anuke.arc.Core.settings.getSerializer(" + typeName + ".class).write(stream, object." + name + ")"); + readMethod.addStatement("object." + name + " = (" + typeName + ")io.anuke.arc.Core.settings.getSerializer(" + typeName + ".class).read(stream)"); } } @@ -123,7 +120,7 @@ public class SerializeAnnotationProcessor extends AbstractProcessor{ serializer.addMethod(writeMethod.build()); serializer.addMethod(readMethod.build()); - method.addStatement("io.anuke.arc.Core.settings.setSerializer($N, $L)", Utils.elementUtils.getBinaryName(elem).toString().replace('$', '.') + ".class", serializer.build()); + method.addStatement("io.anuke.arc.Core.settings.setSerializer($N, $L)", Utils.elementUtils.getBinaryName(elem).toString().replace('$', '.') + ".class", serializer.build()); name(writeMethod, "write" + simpleTypeName); name(readMethod, "read" + simpleTypeName); diff --git a/annotations/src/main/java/io/anuke/annotations/StructAnnotationProcessor.java b/annotations/src/main/java/io/anuke/annotations/StructAnnotationProcessor.java index 54b7d2b155..fa89b6e132 100644 --- a/annotations/src/main/java/io/anuke/annotations/StructAnnotationProcessor.java +++ b/annotations/src/main/java/io/anuke/annotations/StructAnnotationProcessor.java @@ -1,28 +1,25 @@ package io.anuke.annotations; -import com.squareup.javapoet.JavaFile; -import com.squareup.javapoet.MethodSpec; -import com.squareup.javapoet.TypeName; -import com.squareup.javapoet.TypeSpec; +import com.squareup.javapoet.*; import io.anuke.annotations.Annotations.Struct; import io.anuke.annotations.Annotations.StructField; import javax.annotation.processing.*; import javax.lang.model.SourceVersion; -import javax.lang.model.element.Modifier; -import javax.lang.model.element.TypeElement; -import javax.lang.model.element.VariableElement; +import javax.lang.model.element.*; import javax.lang.model.type.TypeKind; import javax.lang.model.util.ElementFilter; import javax.tools.Diagnostic.Kind; import java.util.List; import java.util.Set; -/**Generates ""value types"" classes that are packed into integer primitives of the most aproppriate size. - * It would be nice if Java didn't make crazy hacks like this necessary.*/ +/** + * Generates ""value types"" classes that are packed into integer primitives of the most aproppriate size. + * It would be nice if Java didn't make crazy hacks like this necessary. + */ @SupportedSourceVersion(SourceVersion.RELEASE_8) @SupportedAnnotationTypes({ - "io.anuke.annotations.Annotations.Struct" +"io.anuke.annotations.Annotations.Struct" }) public class StructAnnotationProcessor extends AbstractProcessor{ /** Name of the base package to put all the generated classes. */ @@ -57,7 +54,7 @@ public class StructAnnotationProcessor extends AbstractProcessor{ String structParam = structName.toLowerCase(); TypeSpec.Builder classBuilder = TypeSpec.classBuilder(structName) - .addModifiers(Modifier.FINAL, Modifier.PUBLIC); + .addModifiers(Modifier.FINAL, Modifier.PUBLIC); try{ List variables = ElementFilter.fieldsIn(elem.getEnclosedElements()); @@ -92,14 +89,14 @@ public class StructAnnotationProcessor extends AbstractProcessor{ //[get] field(structType) : fieldType MethodSpec.Builder getter = MethodSpec.methodBuilder(var.getSimpleName().toString()) - .addModifiers(Modifier.STATIC, Modifier.PUBLIC) - .returns(varType) - .addParameter(structType, structParam); + .addModifiers(Modifier.STATIC, Modifier.PUBLIC) + .returns(varType) + .addParameter(structType, structParam); //[set] field(structType, fieldType) : structType MethodSpec.Builder setter = MethodSpec.methodBuilder(var.getSimpleName().toString()) - .addModifiers(Modifier.STATIC, Modifier.PUBLIC) - .returns(structType) - .addParameter(structType, structParam).addParameter(varType, "value"); + .addModifiers(Modifier.STATIC, Modifier.PUBLIC) + .returns(structType) + .addParameter(structType, structParam).addParameter(varType, "value"); //[getter] if(varType == TypeName.BOOLEAN){ @@ -209,7 +206,7 @@ public class StructAnnotationProcessor extends AbstractProcessor{ throw new IllegalArgumentException("Too many fields, must fit in 64 bits. Curent size: " + size); } - /**returns a type's element size in bits.*/ + /** returns a type's element size in bits. */ static int typeSize(TypeKind kind) throws IllegalArgumentException{ switch(kind){ case BOOLEAN: diff --git a/annotations/src/main/java/io/anuke/annotations/Utils.java b/annotations/src/main/java/io/anuke/annotations/Utils.java index 551d953bc4..fa54f4c12d 100644 --- a/annotations/src/main/java/io/anuke/annotations/Utils.java +++ b/annotations/src/main/java/io/anuke/annotations/Utils.java @@ -14,11 +14,11 @@ public class Utils{ public static Messager messager; public static String getMethodName(Element element){ - return ((TypeElement) element.getEnclosingElement()).getQualifiedName().toString() + "." + element.getSimpleName(); + return ((TypeElement)element.getEnclosingElement()).getQualifiedName().toString() + "." + element.getSimpleName(); } public static boolean isPrimitive(String type){ return type.equals("boolean") || type.equals("byte") || type.equals("short") || type.equals("int") - || type.equals("long") || type.equals("float") || type.equals("double") || type.equals("char"); + || type.equals("long") || type.equals("float") || type.equals("double") || type.equals("char"); } } diff --git a/build.gradle b/build.gradle index c797a77b61..96d181bb8a 100644 --- a/build.gradle +++ b/build.gradle @@ -27,7 +27,7 @@ allprojects{ gdxVersion = '1.9.9' roboVMVersion = '2.3.6' arcHash = null - + debugged = { return new File(projectDir.parent, '../debug').exists() && !project.hasProperty("release") } @@ -89,7 +89,8 @@ allprojects{ try{ pfile.createNewFile() - }catch(Exception ignored){} + }catch(Exception ignored){ + } if(pfile.exists()){ props.load(new FileInputStream(pfile)) @@ -121,7 +122,7 @@ project(":desktop"){ dependencies{ compile project(":core") compile project(":net") - + if(debugged()) compile project(":debug") compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop" @@ -157,9 +158,9 @@ project(":ios"){ compile project(":core") compile project(":net") compileOnly project(":annotations") - + compile arcModule("backends:backend-robovm") - + compile "com.mobidevelop.robovm:robovm-rt:$roboVMVersion" compile "com.mobidevelop.robovm:robovm-cocoatouch:$roboVMVersion" compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios" diff --git a/core/assets-raw/sprites/blocks/environment/pack.json b/core/assets-raw/sprites/blocks/environment/pack.json index 91480ffa76..2612f17acc 100644 --- a/core/assets-raw/sprites/blocks/environment/pack.json +++ b/core/assets-raw/sprites/blocks/environment/pack.json @@ -1,8 +1,8 @@ { - duplicatePadding: true, - combineSubdirectories: true, - flattenPaths: true, - maxWidth: 2048, - maxHeight: 2048, - fast: true, + duplicatePadding: true, + combineSubdirectories: true, + flattenPaths: true, + maxWidth: 2048, + maxHeight: 2048, + fast: true } diff --git a/core/assets-raw/sprites/blocks/environment/pack_fallback.json b/core/assets-raw/sprites/blocks/environment/pack_fallback.json index fe8b100826..853c7fc32f 100644 --- a/core/assets-raw/sprites/blocks/environment/pack_fallback.json +++ b/core/assets-raw/sprites/blocks/environment/pack_fallback.json @@ -1,8 +1,8 @@ { - duplicatePadding: true, - combineSubdirectories: true, - flattenPaths: true, - maxWidth: 1024, - maxHeight: 1024, - fast: true, + duplicatePadding: true, + combineSubdirectories: true, + flattenPaths: true, + maxWidth: 1024, + maxHeight: 1024, + fast: true } diff --git a/core/assets-raw/sprites/pack.json b/core/assets-raw/sprites/pack.json index 91480ffa76..2612f17acc 100644 --- a/core/assets-raw/sprites/pack.json +++ b/core/assets-raw/sprites/pack.json @@ -1,8 +1,8 @@ { - duplicatePadding: true, - combineSubdirectories: true, - flattenPaths: true, - maxWidth: 2048, - maxHeight: 2048, - fast: true, + duplicatePadding: true, + combineSubdirectories: true, + flattenPaths: true, + maxWidth: 2048, + maxHeight: 2048, + fast: true } diff --git a/core/assets-raw/sprites/pack_fallback.json b/core/assets-raw/sprites/pack_fallback.json index fe8b100826..853c7fc32f 100644 --- a/core/assets-raw/sprites/pack_fallback.json +++ b/core/assets-raw/sprites/pack_fallback.json @@ -1,8 +1,8 @@ { - duplicatePadding: true, - combineSubdirectories: true, - flattenPaths: true, - maxWidth: 1024, - maxHeight: 1024, - fast: true, + duplicatePadding: true, + combineSubdirectories: true, + flattenPaths: true, + maxWidth: 1024, + maxHeight: 1024, + fast: true } diff --git a/core/assets-raw/sprites_replacement/editor/pack.json b/core/assets-raw/sprites_replacement/editor/pack.json index 91480ffa76..2612f17acc 100644 --- a/core/assets-raw/sprites_replacement/editor/pack.json +++ b/core/assets-raw/sprites_replacement/editor/pack.json @@ -1,8 +1,8 @@ { - duplicatePadding: true, - combineSubdirectories: true, - flattenPaths: true, - maxWidth: 2048, - maxHeight: 2048, - fast: true, + duplicatePadding: true, + combineSubdirectories: true, + flattenPaths: true, + maxWidth: 2048, + maxHeight: 2048, + fast: true } diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index 9102a1527b..f672a7cf6a 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -615,8 +615,8 @@ block.moss.name = Moss block.spore-moss.name = Spore Moss block.shalerocks.name = Shale Rocks block.scrap-wall.name = Scrap Wall -block.scrap-wall-large.name = Large Scrap Wall -block.scrap-wall-huge.name = Huge Scrap Wall +block.scrap-wall-large.name = Large Scrap Wall +block.scrap-wall-huge.name = Huge Scrap Wall block.scrap-wall-gigantic.name = Gigantic Scrap Wall block.thruster.name = Thruster block.kiln.name = Kiln diff --git a/core/assets/bundles/bundle_ko.properties b/core/assets/bundles/bundle_ko.properties index accc2f2e24..c1224e5c51 100644 --- a/core/assets/bundles/bundle_ko.properties +++ b/core/assets/bundles/bundle_ko.properties @@ -14,7 +14,6 @@ screenshot = 화면 캡쳐가 {0} 경로에 저장되었습니다. gameover = 게임 오버 gameover.pvp = [accent]{0}[] 팀이 승리했습니다! highscore = [accent]최고점수 달성! - stat.wave = 웨이브 성공:[accent]{0} stat.enemiesDestroyed = 파괴한 적 수:[accent]{0} stat.built = 건설한 건물 수:[accent]{0} @@ -22,10 +21,8 @@ stat.destroyed = 파괴된 건물 수:[accent]{0} stat.deconstructed = 파괴한 건물 수:[accent]{0} stat.delivered = 획득한 자원: stat.rank = 최종 기록: [accent]{0} - placeline = 블록을 선택하셨습니다.\n][accent]몇초간 설치 시작지점을 누르고[] 원하는 방향을 향해 드래그 하면 [accent]일렬로[] 설치할 수 있습니다.\n한번 해 보세요. removearea = 블록 제거모드를 선택하셨습니다.\n[accent]몇초간 제거 시작지점을 누르고[] 원하는 구역 끝을 향해 드래그 하면 [accent]직사각형[] 안에 있는 모든 건물을 제거할 수 있습니다.\n한번 해 보세요. - launcheditems = [accent]출격 아이템 map.delete = 정말로 "[accent]{0}[]" 맵을 삭제하시겠습니까?\n level.highscore = 최고 점수: [accent]{0} @@ -284,7 +281,6 @@ tutorial = 게임 방법 editor = 편집기 mapeditor = 맵 편집기 donate = 기부 - abandon = 포기 abandon.text = 이 구역과 모든 자원이 적에게 빼앗길 것입니다. locked = 잠김 @@ -306,7 +302,6 @@ zone.config.complete = 웨이브 {0} 달성:\n로드아웃 설정 잠금 해제 zone.resources = 자원 감지됨: add = 추가... boss.health = 보스 체력 - connectfail = [crimson]{0}[accent] 서버에 연결하지 못했습니다.[] error.unreachable = 서버에 연결하지 못했습니다.\n서버 주소가 정확히 입력되었나요? error.invalidaddress = 잘못된 주소입니다. @@ -316,7 +311,6 @@ error.alreadyconnected = 이미 접속중입니다. error.mapnotfound = 맵 파일을 찾을 수 없습니다! error.io = 네트워크 I/O 오류. error.any = 알 수 없는 네트워크 오류. - zone.groundZero.name = 그라운드 제로 zone.craters.name = 분화구 zone.frozenForest.name = 얼어붙은 숲 @@ -324,7 +318,6 @@ zone.ruinousShores.name = 파멸의 기슭 zone.stainedMountains.name = 얼룩진 산맥 zone.desolateRift.name = 황량한 강 zone.nuclearComplex.name = 핵 생산 단지 - settings.language = 언어 settings.reset = 설정 초기화 settings.rebind = 키 재설정 @@ -384,7 +377,6 @@ bar.heat = 발열 bar.power = 전력 bar.progress = 건설 진행 bar.spawned = 유닛: {0}/{1} - bullet.damage = [stat]{0}[lightgray] 데미지 bullet.splashdamage = [stat]{0}[lightgray] area 데미지 ~[stat] {1}[lightgray] 타일 bullet.incendiary = [stat]방화 @@ -396,7 +388,6 @@ bullet.freezing = [stat]동결 bullet.tarred = [stat]타르 bullet.multiplier = [stat]{0}[lightgray]x 탄약 배율 bullet.reload = [stat]{0}[lightgray]x 사격 속도 - unit.blocks = 블록 unit.powersecond = 전력/초 unit.liquidsecond = 액체/초 @@ -497,7 +488,6 @@ mode.pvp.description = 실제 플레이어와 PvP를 합니다. mode.attack.name = 공격 mode.attack.description = 일정 시간마다 적이 오는 단계가 없으며, 적의 기지를 파괴하는 것을 목표로 합니다. mode.custom = 커스텀 규칙 - rules.infiniteresources = 무한 자원 rules.wavetimer = 웨이브 타이머 rules.waves = 웨이브 @@ -512,7 +502,6 @@ rules.respawntime = 리스폰 시간:[LIGHT_GRAY] (초) rules.wavespacing = 웨이브 간격:[LIGHT_GRAY] (초) rules.buildcostmultiplier = 건설 소모 배율 rules.buildspeedmultiplier = 건설 속도 배율 - content.item.name = 아이템 content.liquid.name = 액체 content.unit.name = 유닛 @@ -597,7 +586,6 @@ mech.buildspeed = [LIGHT_GRAY]건설 속도: {0}% liquid.heatcapacity = [LIGHT_GRAY]발열 용량: {0} liquid.viscosity = [LIGHT_GRAY]점도: {0} liquid.temperature = [LIGHT_GRAY]온도: {0} - block.grass.name = 잔디 block.salt.name = 소금 block.sandrocks.name = 모래 바위 @@ -896,7 +884,6 @@ block.wraith-factory.description = 빠른 뺑소니 요격기 유닛을 생산 block.ghoul-factory.description = 중탄두 폭격기를 생산합니다. block.dagger-factory.description = 기본 지상 유닛을 생산합니다. block.titan-factory.description = 첨단 장갑 지상부대를 생산합니다. - block.fortress-factory.description = 중대포 지상부대를 생산합니다. block.revenant-factory.description = 중량의 레이저 포대를 가진 공중부대를 생산합니다. block.repair-point.description = 주변에서 가장 가까운 손상된 유닛을 지속적으로 치료합니다. diff --git a/core/src/io/anuke/mindustry/Mindustry.java b/core/src/io/anuke/mindustry/Mindustry.java index 44840a9aa4..195d2153f7 100644 --- a/core/src/io/anuke/mindustry/Mindustry.java +++ b/core/src/io/anuke/mindustry/Mindustry.java @@ -1,8 +1,6 @@ package io.anuke.mindustry; -import io.anuke.arc.ApplicationCore; -import io.anuke.arc.Core; -import io.anuke.arc.Events; +import io.anuke.arc.*; import io.anuke.arc.util.Log; import io.anuke.arc.util.Time; import io.anuke.mindustry.core.*; @@ -55,7 +53,7 @@ public class Mindustry extends ApplicationCore{ int fpsCap = Core.settings.getInt("fpscap", 125); if(fpsCap <= 120){ - long target = (1000 * 1000000)/fpsCap; //target in nanos + long target = (1000 * 1000000) / fpsCap; //target in nanos long elapsed = Time.timeSinceNanos(lastFrameTime); if(elapsed < target){ try{ diff --git a/core/src/io/anuke/mindustry/Vars.java b/core/src/io/anuke/mindustry/Vars.java index 1e736396cb..8b3a7d2de9 100644 --- a/core/src/io/anuke/mindustry/Vars.java +++ b/core/src/io/anuke/mindustry/Vars.java @@ -14,12 +14,8 @@ import io.anuke.mindustry.entities.effect.Puddle; import io.anuke.mindustry.entities.impl.EffectEntity; import io.anuke.mindustry.entities.traits.DrawTrait; import io.anuke.mindustry.entities.traits.SyncTrait; -import io.anuke.mindustry.entities.type.BaseUnit; -import io.anuke.mindustry.entities.type.Player; -import io.anuke.mindustry.entities.type.TileEntity; -import io.anuke.mindustry.game.GlobalData; -import io.anuke.mindustry.game.Team; -import io.anuke.mindustry.game.Version; +import io.anuke.mindustry.entities.type.*; +import io.anuke.mindustry.game.*; import io.anuke.mindustry.gen.Serialization; import io.anuke.mindustry.net.Net; import io.anuke.mindustry.world.blocks.defense.ForceProjector.ShieldEntity; @@ -30,95 +26,95 @@ import java.util.Locale; @SuppressWarnings("unchecked") public class Vars{ - /**IO buffer size.*/ + /** IO buffer size. */ public static final int bufferSize = 8192; - /**global charset*/ + /** global charset */ public static final Charset charset = Charset.forName("UTF-8"); - /**main application name, capitalized*/ + /** main application name, capitalized */ public static final String appName = "Mindustry"; - /**URL for itch.io donations.*/ + /** URL for itch.io donations. */ public static final String donationURL = "https://anuke.itch.io/mindustry/purchase"; - /**URL for discord invite.*/ + /** URL for discord invite. */ public static final String discordURL = "https://discord.gg/mindustry"; - /**URL for Github API for releases*/ + /** URL for Github API for releases */ public static final String releasesURL = "https://api.github.com/repos/Anuken/Mindustry/releases"; - /**URL for Github API for contributors*/ + /** URL for Github API for contributors */ public static final String contributorsURL = "https://api.github.com/repos/Anuken/Mindustry/contributors"; - /**URL for sending crash reports to*/ + /** URL for sending crash reports to */ public static final String crashReportURL = "http://mindustry.us.to/report"; - /**maximum distance between mine and core that supports automatic transferring*/ + /** maximum distance between mine and core that supports automatic transferring */ public static final float mineTransferRange = 220f; - /**team of the player by default*/ + /** team of the player by default */ public static final Team defaultTeam = Team.blue; - /**team of the enemy in waves/sectors*/ + /** team of the enemy in waves/sectors */ public static final Team waveTeam = Team.red; - /**how many times longer a boss wave takes*/ + /** how many times longer a boss wave takes */ public static final float bossWaveMultiplier = 3f; - /**how many times longer a launch wave takes*/ + /** how many times longer a launch wave takes */ public static final float launchWaveMultiplier = 2f; - /**max chat message length*/ + /** max chat message length */ public static final int maxTextLength = 150; - /**max player name length in bytes*/ + /** max player name length in bytes */ public static final int maxNameLength = 40; - /**displayed item size when ingame, TODO remove.*/ + /** displayed item size when ingame, TODO remove. */ public static final float itemSize = 5f; - /**extra padding around the world; units outside this bound will begin to self-destruct.*/ + /** extra padding around the world; units outside this bound will begin to self-destruct. */ public static final float worldBounds = 100f; - /**units outside of this bound will simply die instantly*/ + /** units outside of this bound will simply die instantly */ public static final float finalWorldBounds = worldBounds + 500; - /**ticks spent out of bound until self destruct.*/ - public static final float boundsCountdown = 60*7; - /**for map generator dialog*/ + /** ticks spent out of bound until self destruct. */ + public static final float boundsCountdown = 60 * 7; + /** for map generator dialog */ public static boolean updateEditorOnChange = false; - /**size of tiles in units*/ + /** size of tiles in units */ public static final int tilesize = 8; - /**all choosable player colors in join/host dialog*/ + /** all choosable player colors in join/host dialog */ public static final Color[] playerColors = { - Color.valueOf("82759a"), - Color.valueOf("c0c1c5"), - Color.valueOf("fff0e7"), - Color.valueOf("7d2953"), - Color.valueOf("ff074e"), - Color.valueOf("ff072a"), - Color.valueOf("ff76a6"), - Color.valueOf("a95238"), - Color.valueOf("ffa108"), - Color.valueOf("feeb2c"), - Color.valueOf("ffcaa8"), - Color.valueOf("008551"), - Color.valueOf("00e339"), - Color.valueOf("423c7b"), - Color.valueOf("4b5ef1"), - Color.valueOf("2cabfe"), + Color.valueOf("82759a"), + Color.valueOf("c0c1c5"), + Color.valueOf("fff0e7"), + Color.valueOf("7d2953"), + Color.valueOf("ff074e"), + Color.valueOf("ff072a"), + Color.valueOf("ff76a6"), + Color.valueOf("a95238"), + Color.valueOf("ffa108"), + Color.valueOf("feeb2c"), + Color.valueOf("ffcaa8"), + Color.valueOf("008551"), + Color.valueOf("00e339"), + Color.valueOf("423c7b"), + Color.valueOf("4b5ef1"), + Color.valueOf("2cabfe"), }; - /**default server port*/ + /** default server port */ public static final int port = 6567; - /**if true, UI is not drawn*/ + /** if true, UI is not drawn */ public static boolean disableUI; - /**if true, game is set up in mobile mode, even on desktop. used for debugging*/ + /** if true, game is set up in mobile mode, even on desktop. used for debugging */ public static boolean testMobile; - /**whether the game is running on a mobile device*/ + /** whether the game is running on a mobile device */ public static boolean mobile; - /**whether the game is running on an iOS device*/ + /** whether the game is running on an iOS device */ public static boolean ios; - /**whether the game is running on an Android device*/ + /** whether the game is running on an Android device */ public static boolean android; - /**whether the game is running on a headless server*/ + /** whether the game is running on a headless server */ public static boolean headless; - /**application data directory, equivalent to {@link io.anuke.arc.Settings#getDataDirectory()}*/ + /** application data directory, equivalent to {@link io.anuke.arc.Settings#getDataDirectory()} */ public static FileHandle dataDirectory; - /**data subdirectory used for screenshots*/ + /** data subdirectory used for screenshots */ public static FileHandle screenshotDirectory; - /**data subdirectory used for custom mmaps*/ + /** data subdirectory used for custom mmaps */ public static FileHandle customMapDirectory; - /**data subdirectory used for saves*/ + /** data subdirectory used for saves */ public static FileHandle saveDirectory; - /**map file extension*/ + /** map file extension */ public static final String mapExtension = "mmap"; - /**save file extension*/ + /** save file extension */ public static final String saveExtension = "msav"; - /**list of all locales that can be switched to*/ + /** list of all locales that can be switched to */ public static Locale[] locales; public static ContentLoader content; @@ -143,7 +139,7 @@ public class Vars{ public static EntityGroup fireGroup; public static EntityGroup[] unitGroups; - /**all local players, currently only has one player. may be used for local co-op in the future*/ + /** all local players, currently only has one player. may be used for local co-op in the future */ public static Player player; public static void init(){ diff --git a/core/src/io/anuke/mindustry/ai/BlockIndexer.java b/core/src/io/anuke/mindustry/ai/BlockIndexer.java index 1da77c3db6..6a66286118 100644 --- a/core/src/io/anuke/mindustry/ai/BlockIndexer.java +++ b/core/src/io/anuke/mindustry/ai/BlockIndexer.java @@ -17,31 +17,31 @@ import io.anuke.mindustry.world.meta.BlockFlag; import static io.anuke.mindustry.Vars.*; -/**Class used for indexing special target blocks for AI.*/ +/** Class used for indexing special target blocks for AI. */ @SuppressWarnings("unchecked") public class BlockIndexer{ - /**Size of one ore quadrant.*/ + /** Size of one ore quadrant. */ private final static int oreQuadrantSize = 20; - /**Size of one structure quadrant.*/ + /** Size of one structure quadrant. */ private final static int structQuadrantSize = 12; - /**Set of all ores that are being scanned.*/ + /** Set of all ores that are being scanned. */ private final ObjectSet scanOres = ObjectSet.with(Item.getAllOres().toArray(Item.class)); private final ObjectSet itemSet = new ObjectSet<>(); - /**Stores all ore quadtrants on the map.*/ + /** Stores all ore quadtrants on the map. */ private ObjectMap> ores; - /**Tags all quadrants.*/ + /** Tags all quadrants. */ private Bits[] structQuadrants; - /**Stores all damaged tile entities by team.*/ + /** Stores all damaged tile entities by team. */ private ObjectSet[] damagedTiles = new ObjectSet[Team.all.length]; - /**Maps teams to a map of flagged tiles by type.*/ + /** Maps teams to a map of flagged tiles by type. */ private ObjectSet[][] flagMap = new ObjectSet[Team.all.length][BlockFlag.all.length]; - /**Maps tile positions to their last known tile index data.*/ + /** Maps tile positions to their last known tile index data. */ private IntMap typeMap = new IntMap<>(); - /**Empty set used for returning.*/ + /** Empty set used for returning. */ private ObjectSet emptySet = new ObjectSet<>(); - /**Array used for returning and reusing.*/ + /** Array used for returning and reusing. */ private Array returnArray = new Array<>(); public BlockIndexer(){ @@ -72,7 +72,7 @@ public class BlockIndexer{ //create bitset for each team type that contains each quadrant structQuadrants = new Bits[Team.all.length]; for(int i = 0; i < Team.all.length; i++){ - structQuadrants[i] = new Bits(Mathf.ceil(world.width() / (float) structQuadrantSize) * Mathf.ceil(world.height() / (float) structQuadrantSize)); + structQuadrants[i] = new Bits(Mathf.ceil(world.width() / (float)structQuadrantSize) * Mathf.ceil(world.height() / (float)structQuadrantSize)); } for(int x = 0; x < world.width(); x++){ @@ -101,7 +101,7 @@ public class BlockIndexer{ return flagMap[team.ordinal()]; } - /**Returns all damaged tiles by team.*/ + /** Returns all damaged tiles by team. */ public ObjectSet getDamaged(Team team){ returnArray.clear(); @@ -123,12 +123,12 @@ public class BlockIndexer{ return set; } - /**Get all allied blocks with a flag.*/ + /** Get all allied blocks with a flag. */ public ObjectSet getAllied(Team team, BlockFlag type){ return flagMap[team.ordinal()][type.ordinal()]; } - /**Get all enemy blocks with a flag.*/ + /** Get all enemy blocks with a flag. */ public Array getEnemy(Team team, BlockFlag type){ returnArray.clear(); for(Team enemy : state.teams.enemiesOf(team)){ @@ -154,8 +154,8 @@ public class BlockIndexer{ TileEntity closest = null; float dst = 0; - for(int rx = Math.max((int) ((x - range) / tilesize / structQuadrantSize), 0); rx <= (int) ((x + range) / tilesize / structQuadrantSize) && rx < quadWidth(); rx++){ - for(int ry = Math.max((int) ((y - range) / tilesize / structQuadrantSize), 0); ry <= (int) ((y + range) / tilesize / structQuadrantSize) && ry < quadHeight(); ry++){ + for(int rx = Math.max((int)((x - range) / tilesize / structQuadrantSize), 0); rx <= (int)((x + range) / tilesize / structQuadrantSize) && rx < quadWidth(); rx++){ + for(int ry = Math.max((int)((y - range) / tilesize / structQuadrantSize), 0); ry <= (int)((y + range) / tilesize / structQuadrantSize) && ry < quadHeight(); ry++){ if(!getQuad(team, rx, ry)) continue; @@ -167,7 +167,8 @@ public class BlockIndexer{ other = other.target(); - if(other.entity == null || other.getTeam() != team || !pred.test(other) || !other.block().targetable) continue; + if(other.entity == null || other.getTeam() != team || !pred.test(other) || !other.block().targetable) + continue; TileEntity e = other.entity; @@ -194,7 +195,7 @@ public class BlockIndexer{ return ores.get(item, emptySet); } - /**Find the closest ore block relative to a position.*/ + /** Find the closest ore block relative to a position. */ public Tile findClosestOre(float xp, float yp, Item item){ Tile tile = Geometry.findClosest(xp, yp, world.indexer.getOrePositions(item)); @@ -214,7 +215,7 @@ public class BlockIndexer{ private void process(Tile tile){ if(tile.block().flags.size() > 0 && - tile.getTeam() != Team.none){ + tile.getTeam() != Team.none){ ObjectSet[] map = getFlagged(tile.getTeam()); for(BlockFlag flag : tile.block().flags){ @@ -235,13 +236,13 @@ public class BlockIndexer{ itemSet.clear(); Tile rounded = world.tile(Mathf.clamp(quadrantX * oreQuadrantSize + oreQuadrantSize / 2, 0, world.width() - 1), - Mathf.clamp(quadrantY * oreQuadrantSize + oreQuadrantSize / 2, 0, world.height() - 1)); + Mathf.clamp(quadrantY * oreQuadrantSize + oreQuadrantSize / 2, 0, world.height() - 1)); //find all items that this quadrant contains for(int x = quadrantX * structQuadrantSize; x < world.width() && x < (quadrantX + 1) * structQuadrantSize; x++){ for(int y = quadrantY * structQuadrantSize; y < world.height() && y < (quadrantY + 1) * structQuadrantSize; y++){ Tile result = world.tile(x, y); - if( result == null || result.drop() == null || !scanOres.contains(result.drop())) continue; + if(result == null || result.drop() == null || !scanOres.contains(result.drop())) continue; itemSet.add(result.drop()); } @@ -294,16 +295,16 @@ public class BlockIndexer{ } private boolean getQuad(Team team, int quadrantX, int quadrantY){ - int index = quadrantX + quadrantY * Mathf.ceil(world.width() / (float) structQuadrantSize); + int index = quadrantX + quadrantY * Mathf.ceil(world.width() / (float)structQuadrantSize); return structQuadrants[team.ordinal()].get(index); } private int quadWidth(){ - return Mathf.ceil(world.width() / (float) structQuadrantSize); + return Mathf.ceil(world.width() / (float)structQuadrantSize); } private int quadHeight(){ - return Mathf.ceil(world.height() / (float) structQuadrantSize); + return Mathf.ceil(world.height() / (float)structQuadrantSize); } private void scanOres(){ @@ -324,9 +325,9 @@ public class BlockIndexer{ //add position of quadrant to list when an ore is found if(tile.drop() != null && scanOres.contains(tile.drop()) && tile.block() == Blocks.air){ ores.get(tile.drop()).add(world.tile( - //make sure to clamp quadrant middle position, since it might go off bounds - Mathf.clamp(qx * oreQuadrantSize + oreQuadrantSize / 2, 0, world.width() - 1), - Mathf.clamp(qy * oreQuadrantSize + oreQuadrantSize / 2, 0, world.height() - 1))); + //make sure to clamp quadrant middle position, since it might go off bounds + Mathf.clamp(qx * oreQuadrantSize + oreQuadrantSize / 2, 0, world.width() - 1), + Mathf.clamp(qy * oreQuadrantSize + oreQuadrantSize / 2, 0, world.height() - 1))); } } } diff --git a/core/src/io/anuke/mindustry/ai/Pathfinder.java b/core/src/io/anuke/mindustry/ai/Pathfinder.java index 5fb4dbdf18..7710c48588 100644 --- a/core/src/io/anuke/mindustry/ai/Pathfinder.java +++ b/core/src/io/anuke/mindustry/ai/Pathfinder.java @@ -65,9 +65,9 @@ public class Pathfinder{ Tile other = world.tile(dx, dy); if(other == null) continue; - if(values[dx][dy] < value && (target == null || values[dx][dy]< tl) && - !other.solid() && - !(point.x != 0 && point.y != 0 && (world.solid(tile.x + point.x, tile.y) || world.solid(tile.x, tile.y + point.y)))){ //diagonal corner trap + if(values[dx][dy] < value && (target == null || values[dx][dy] < tl) && + !other.solid() && + !(point.x != 0 && point.y != 0 && (world.solid(tile.x + point.x, tile.y) || world.solid(tile.x, tile.y + point.y)))){ //diagonal corner trap target = other; tl = values[dx][dy]; } @@ -86,8 +86,10 @@ public class Pathfinder{ return (!tile.solid()) || (tile.breakable() && (tile.target().getTeam() != team)); } - /**Clears the frontier, increments the search and sets up all flow sources. - * This only occurs for active teams.*/ + /** + * Clears the frontier, increments the search and sets up all flow sources. + * This only occurs for active teams. + */ private void update(Tile tile, Team team){ //make sure team exists if(paths != null && paths[team.ordinal()] != null && paths[team.ordinal()].weights != null){ @@ -126,7 +128,7 @@ public class Pathfinder{ Tile tile = world.tile(x, y); if(state.teams.areEnemies(tile.getTeam(), team) - && tile.block().flags.contains(BlockFlag.target)){ + && tile.block().flags.contains(BlockFlag.target)){ path.frontier.addFirst(tile.pos()); path.weights[x][y] = 0; path.searches[x][y] = (short)path.search; @@ -162,7 +164,7 @@ public class Pathfinder{ Tile other = world.tile(dx, dy); if(other != null && (path.weights[dx][dy] > cost + other.cost || path.searches[dx][dy] < path.search) - && passable(other, team)){ + && passable(other, team)){ if(other.cost < 0) throw new IllegalArgumentException("Tile cost cannot be negative! " + other); path.frontier.addFirst(Pos.get(dx, dy)); path.weights[dx][dy] = cost + other.cost; diff --git a/core/src/io/anuke/mindustry/ai/WaveSpawner.java b/core/src/io/anuke/mindustry/ai/WaveSpawner.java index 7d5a153f56..298ca83747 100644 --- a/core/src/io/anuke/mindustry/ai/WaveSpawner.java +++ b/core/src/io/anuke/mindustry/ai/WaveSpawner.java @@ -16,9 +16,7 @@ import io.anuke.mindustry.game.SpawnGroup; import io.anuke.mindustry.net.Net; import io.anuke.mindustry.world.Pos; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; +import java.io.*; import static io.anuke.mindustry.Vars.*; @@ -56,7 +54,7 @@ public class WaveSpawner{ return groundSpawns.size; } - /**@return true if the player is near a ground spawn point.*/ + /** @return true if the player is near a ground spawn point. */ public boolean playerNear(){ return groundSpawns.count(g -> Mathf.dst(g.x * tilesize, g.y * tilesize, player.x, player.y) < maxShockwaveDst) > 0; } @@ -88,7 +86,7 @@ public class WaveSpawner{ for(GroundSpawn spawn : groundSpawns){ spawnX = spawn.x * tilesize; spawnY = spawn.y * tilesize; - spread = tilesize*2; + spread = tilesize * 2; for(int i = 0; i < spawned; i++){ Tmp.v1.rnd(spread); @@ -96,7 +94,7 @@ public class WaveSpawner{ BaseUnit unit = group.createUnit(waveTeam); unit.set(spawnX + Tmp.v1.x, spawnY + Tmp.v1.y); - Time.run(Math.min(i*5, 60*2), () -> shockwave(unit)); + Time.run(Math.min(i * 5, 60 * 2), () -> shockwave(unit)); } Time.run(20f, () -> Effects.effect(Fx.spawnShockwave, spawn.x * tilesize, spawn.y * tilesize)); //would be interesting to see player structures survive this without hacks @@ -125,7 +123,7 @@ public class WaveSpawner{ //hide spawnpoints, they have served their purpose world.tile(x, y).setBlock(Blocks.air); - Log.info("Add spawn "+ x + " " + y); + Log.info("Add spawn " + x + " " + y); } } } @@ -145,7 +143,7 @@ public class WaveSpawner{ groundSpawns.add(spawn); FlyerSpawn fspawn = new FlyerSpawn(); - fspawn.angle = Angles.angle(world.width()/2f, world.height()/2f, x, y); + fspawn.angle = Angles.angle(world.width() / 2f, world.height() / 2f, x, y); flySpawns.add(fspawn); } diff --git a/core/src/io/anuke/mindustry/content/Blocks.java b/core/src/io/anuke/mindustry/content/Blocks.java index 1b92195f9b..79175fdd5c 100644 --- a/core/src/io/anuke/mindustry/content/Blocks.java +++ b/core/src/io/anuke/mindustry/content/Blocks.java @@ -2,18 +2,12 @@ package io.anuke.mindustry.content; import io.anuke.arc.Core; import io.anuke.arc.graphics.Color; -import io.anuke.arc.graphics.g2d.Draw; -import io.anuke.arc.graphics.g2d.Lines; -import io.anuke.arc.graphics.g2d.TextureRegion; +import io.anuke.arc.graphics.g2d.*; import io.anuke.arc.math.Mathf; import io.anuke.mindustry.Vars; import io.anuke.mindustry.game.ContentList; -import io.anuke.mindustry.graphics.CacheLayer; -import io.anuke.mindustry.graphics.Pal; -import io.anuke.mindustry.graphics.Shaders; -import io.anuke.mindustry.type.Category; -import io.anuke.mindustry.type.ItemStack; -import io.anuke.mindustry.type.LiquidStack; +import io.anuke.mindustry.graphics.*; +import io.anuke.mindustry.type.*; import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.blocks.*; @@ -23,13 +17,8 @@ import io.anuke.mindustry.world.blocks.distribution.*; import io.anuke.mindustry.world.blocks.power.*; import io.anuke.mindustry.world.blocks.production.*; import io.anuke.mindustry.world.blocks.sandbox.*; -import io.anuke.mindustry.world.blocks.storage.CoreBlock; -import io.anuke.mindustry.world.blocks.storage.LaunchPad; -import io.anuke.mindustry.world.blocks.storage.Unloader; -import io.anuke.mindustry.world.blocks.storage.Vault; -import io.anuke.mindustry.world.blocks.units.MechPad; -import io.anuke.mindustry.world.blocks.units.RepairPoint; -import io.anuke.mindustry.world.blocks.units.UnitFactory; +import io.anuke.mindustry.world.blocks.storage.*; +import io.anuke.mindustry.world.blocks.units.*; import io.anuke.mindustry.world.consumers.ConsumeLiquidFilter; import io.anuke.mindustry.world.meta.Attribute; import io.anuke.mindustry.world.modules.LiquidModule; @@ -91,15 +80,25 @@ public class Blocks implements ContentList{ public void load(){ //region environment - air = new Floor("air"){{ + air = new Floor("air"){ + { alwaysReplace = true; hasShadow = false; } - public void draw(Tile tile){} - public void load(){} - public void init(){} - public boolean isHidden(){ return true; } + public void draw(Tile tile){ + } + + public void load(){ + } + + public void init(){ + } + + public boolean isHidden(){ + return true; + } + public TextureRegion[] variantRegions(){ if(variantRegions == null){ variantRegions = new TextureRegion[]{Core.atlas.find("clear")}; @@ -111,7 +110,8 @@ public class Blocks implements ContentList{ part = new BlockPart(); spawn = new Block("spawn"){ - public void drawShadow(Tile tile){} + public void drawShadow(Tile tile){ + } }; //Registers build blocks from size 1-6 @@ -593,10 +593,10 @@ public class Blocks implements ContentList{ separator = new Separator("separator"){{ requirements(Category.crafting, ItemStack.with(Items.copper, 60, Items.titanium, 50)); results = ItemStack.with( - Items.copper, 5, - Items.lead, 3, - Items.graphite, 2, - Items.titanium, 2 + Items.copper, 5, + Items.lead, 3, + Items.graphite, 2, + Items.titanium, 2 ); hasPower = true; craftTime = 35f; @@ -630,7 +630,7 @@ public class Blocks implements ContentList{ } int liquidRegion = reg("-liquid"); - int topRegion =reg("-top"); + int topRegion = reg("-top"); drawIcons = () -> new TextureRegion[]{Core.atlas.find(name), Core.atlas.find(name + "-top")}; @@ -638,7 +638,7 @@ public class Blocks implements ContentList{ GenericCrafterEntity entity = tile.entity(); Draw.rect(region, tile.drawx(), tile.drawy()); - Draw.rect(reg(frameRegions[(int) Mathf.absin(entity.totalProgress, 5f, 2.999f)]), tile.drawx(), tile.drawy()); + Draw.rect(reg(frameRegions[(int)Mathf.absin(entity.totalProgress, 5f, 2.999f)]), tile.drawx(), tile.drawy()); Draw.color(Color.CLEAR, tile.entity.liquids.current().color, tile.entity.liquids.total() / liquidCapacity); Draw.rect(reg(liquidRegion), tile.drawx(), tile.drawy()); Draw.color(); @@ -1244,10 +1244,10 @@ public class Blocks implements ContentList{ duo = new DoubleTurret("duo"){{ requirements(Category.turret, ItemStack.with(Items.copper, 70), true); ammo( - Items.copper, Bullets.standardCopper, - Items.graphite, Bullets.standardDense, - Items.pyratite, Bullets.standardIncendiary, - Items.silicon, Bullets.standardHoming + Items.copper, Bullets.standardCopper, + Items.graphite, Bullets.standardDense, + Items.pyratite, Bullets.standardIncendiary, + Items.silicon, Bullets.standardHoming ); reload = 20f; restitution = 0.03f; @@ -1262,8 +1262,8 @@ public class Blocks implements ContentList{ scatter = new BurstTurret("scatter"){{ requirements(Category.turret, ItemStack.with(Items.copper, 170, Items.lead, 90)); ammo( - Items.scrap, Bullets.flakScrap, - Items.lead, Bullets.flakLead + Items.scrap, Bullets.flakScrap, + Items.lead, Bullets.flakLead ); reload = 15f; range = 180f; @@ -1277,14 +1277,14 @@ public class Blocks implements ContentList{ inaccuracy = 17f; shootCone = 35f; - health = 260*size*size; + health = 260 * size * size; }}; scorch = new ItemTurret("scorch"){{ requirements(Category.turret, ItemStack.with(Items.copper, 50, Items.graphite, 45)); ammo( - Items.coal, Bullets.basicFlame, - Items.pyratite, Bullets.pyraFlame + Items.coal, Bullets.basicFlame, + Items.pyratite, Bullets.pyraFlame ); recoil = 0f; reload = 4f; @@ -1298,9 +1298,9 @@ public class Blocks implements ContentList{ hail = new ArtilleryTurret("hail"){{ requirements(Category.turret, ItemStack.with(Items.copper, 80, Items.graphite, 35)); ammo( - Items.graphite, Bullets.artilleryDense, - Items.silicon, Bullets.artilleryHoming, - Items.pyratite, Bullets.artlleryIncendiary + Items.graphite, Bullets.artilleryDense, + Items.silicon, Bullets.artilleryHoming, + Items.pyratite, Bullets.artlleryIncendiary ); reload = 60f; recoil = 2f; @@ -1313,10 +1313,10 @@ public class Blocks implements ContentList{ wave = new LiquidTurret("wave"){{ requirements(Category.turret, ItemStack.with(Items.metaglass, 90, Items.lead, 150)); ammo( - Liquids.water, Bullets.waterShot, - Liquids.slag, Bullets.slagShot, - Liquids.cryofluid, Bullets.cryoShot, - Liquids.oil, Bullets.oilShot + Liquids.water, Bullets.waterShot, + Liquids.slag, Bullets.slagShot, + Liquids.cryofluid, Bullets.cryoShot, + Liquids.oil, Bullets.oilShot ); size = 2; recoil = 0f; @@ -1325,7 +1325,7 @@ public class Blocks implements ContentList{ shootCone = 50f; shootEffect = Fx.shootLiquid; range = 110f; - health = 250*size*size; + health = 250 * size * size; drawer = (tile, entity) -> { Draw.rect(region, tile.drawx() + tr2.x, tile.drawy() + tr2.y, entity.rotation - 90); @@ -1356,7 +1356,7 @@ public class Blocks implements ContentList{ chargeBeginEffect = Fx.lancerLaserChargeBegin; heatColor = Color.RED; size = 2; - health = 280*size*size; + health = 280 * size * size; targetAir = false; }}; @@ -1380,9 +1380,9 @@ public class Blocks implements ContentList{ swarmer = new BurstTurret("swarmer"){{ requirements(Category.turret, ItemStack.with(Items.graphite, 70, Items.titanium, 70, Items.plastanium, 90, Items.silicon, 60)); ammo( - Items.blastCompound, Bullets.missileExplosive, - Items.pyratite, Bullets.missileIncendiary, - Items.surgealloy, Bullets.missileSurge + Items.blastCompound, Bullets.missileExplosive, + Items.pyratite, Bullets.missileIncendiary, + Items.surgealloy, Bullets.missileSurge ); reload = 50f; shots = 4; @@ -1391,17 +1391,17 @@ public class Blocks implements ContentList{ range = 140f; xRand = 6f; size = 2; - health = 300*size*size; + health = 300 * size * size; }}; salvo = new BurstTurret("salvo"){{ requirements(Category.turret, ItemStack.with(Items.copper, 210, Items.graphite, 190, Items.titanium, 120)); ammo( - Items.copper, Bullets.standardCopper, - Items.graphite, Bullets.standardDense, - Items.pyratite, Bullets.standardIncendiary, - Items.silicon, Bullets.standardHoming, - Items.thorium, Bullets.standardThorium + Items.copper, Bullets.standardCopper, + Items.graphite, Bullets.standardDense, + Items.pyratite, Bullets.standardIncendiary, + Items.silicon, Bullets.standardHoming, + Items.thorium, Bullets.standardThorium ); size = 2; @@ -1421,11 +1421,11 @@ public class Blocks implements ContentList{ ripple = new ArtilleryTurret("ripple"){{ requirements(Category.turret, ItemStack.with(Items.copper, 300, Items.graphite, 270, Items.titanium, 120)); ammo( - Items.graphite, Bullets.artilleryDense, - Items.silicon, Bullets.artilleryHoming, - Items.pyratite, Bullets.artlleryIncendiary, - Items.blastCompound, Bullets.artilleryExplosive, - Items.plastanium, Bullets.arilleryPlastic + Items.graphite, Bullets.artilleryDense, + Items.silicon, Bullets.artilleryHoming, + Items.pyratite, Bullets.artlleryIncendiary, + Items.blastCompound, Bullets.artilleryExplosive, + Items.plastanium, Bullets.arilleryPlastic ); size = 3; shots = 4; @@ -1446,9 +1446,9 @@ public class Blocks implements ContentList{ cyclone = new ItemTurret("cyclone"){{ requirements(Category.turret, ItemStack.with(Items.copper, 400, Items.titanium, 250, Items.plastanium, 160)); ammo( - Items.blastCompound, Bullets.flakExplosive, - Items.plastanium, Bullets.flakPlastic, - Items.surgealloy, Bullets.flakSurge + Items.blastCompound, Bullets.flakExplosive, + Items.plastanium, Bullets.flakPlastic, + Items.surgealloy, Bullets.flakSurge ); xRand = 4f; reload = 6f; @@ -1478,9 +1478,9 @@ public class Blocks implements ContentList{ spectre = new DoubleTurret("spectre"){{ requirements(Category.turret, ItemStack.with(Items.copper, 700, Items.graphite, 600, Items.surgealloy, 500, Items.plastanium, 350, Items.thorium, 500)); ammo( - Items.graphite, Bullets.standardDenseBig, - Items.pyratite, Bullets.standardIncendiaryBig, - Items.thorium, Bullets.standardThoriumBig + Items.graphite, Bullets.standardDenseBig, + Items.pyratite, Bullets.standardIncendiaryBig, + Items.thorium, Bullets.standardThoriumBig ); reload = 6f; coolantMultiplier = 0.5f; diff --git a/core/src/io/anuke/mindustry/content/Bullets.java b/core/src/io/anuke/mindustry/content/Bullets.java index 006cffb694..ae356cb001 100644 --- a/core/src/io/anuke/mindustry/content/Bullets.java +++ b/core/src/io/anuke/mindustry/content/Bullets.java @@ -1,20 +1,15 @@ package io.anuke.mindustry.content; -import io.anuke.mindustry.entities.Effects; import io.anuke.arc.graphics.Color; -import io.anuke.arc.graphics.g2d.CapStyle; -import io.anuke.arc.graphics.g2d.Draw; -import io.anuke.arc.graphics.g2d.Fill; -import io.anuke.arc.graphics.g2d.Lines; +import io.anuke.arc.graphics.g2d.*; import io.anuke.arc.math.Mathf; import io.anuke.arc.util.Time; import io.anuke.arc.util.Tmp; import io.anuke.mindustry.entities.Damage; -import io.anuke.mindustry.entities.type.Unit; +import io.anuke.mindustry.entities.Effects; import io.anuke.mindustry.entities.bullet.*; -import io.anuke.mindustry.entities.effect.Fire; -import io.anuke.mindustry.entities.effect.Lightning; -import io.anuke.mindustry.entities.effect.Puddle; +import io.anuke.mindustry.entities.effect.*; +import io.anuke.mindustry.entities.type.Unit; import io.anuke.mindustry.game.ContentList; import io.anuke.mindustry.graphics.Pal; import io.anuke.mindustry.graphics.Shapes; @@ -37,7 +32,7 @@ public class Bullets implements ContentList{ //standard standardCopper, standardDense, standardThorium, standardHoming, standardIncendiary, standardMechSmall, - standardGlaive, standardDenseBig, standardThoriumBig, standardIncendiaryBig, + standardGlaive, standardDenseBig, standardThoriumBig, standardIncendiaryBig, //electric lancerLaser, meltdownLaser, lightning, arc, damageLightning, @@ -562,7 +557,7 @@ public class Bullets implements ContentList{ public void hit(Bullet b, float hitx, float hity){ Effects.effect(hitEffect, colors[2], hitx, hity); if(Mathf.chance(0.4)){ - Fire.create(world.tileWorld(hitx+Mathf.range(5f), hity+Mathf.range(5f))); + Fire.create(world.tileWorld(hitx + Mathf.range(5f), hity + Mathf.range(5f))); } } @@ -586,6 +581,7 @@ public class Bullets implements ContentList{ fuseShot = new BulletType(0.01f, 70){ int rays = 3; float rayLength = 80f; + { hitEffect = Fx.hitFuse; lifetime = 13f; @@ -594,23 +590,23 @@ public class Bullets implements ContentList{ } @Override - public void init(Bullet b) { - for (int i = 0; i < rays; i++) { - Damage.collideLine(b, b.getTeam(), hitEffect, b.x, b.y, b.rot(), rayLength - Math.abs(i - (rays/2))*20f); + public void init(Bullet b){ + for(int i = 0; i < rays; i++){ + Damage.collideLine(b, b.getTeam(), hitEffect, b.x, b.y, b.rot(), rayLength - Math.abs(i - (rays / 2)) * 20f); } } @Override - public void draw(Bullet b) { + public void draw(Bullet b){ super.draw(b); Draw.color(Color.WHITE, Pal.surge, b.fin()); for(int i = 0; i < 7; i++){ Tmp.v1.trns(b.rot(), i * 8f); - float sl = Mathf.clamp(b.fout()-0.5f) * (80f - i *10); + float sl = Mathf.clamp(b.fout() - 0.5f) * (80f - i * 10); Shapes.tri(b.x + Tmp.v1.x, b.y + Tmp.v1.y, 4f, sl, b.rot() + 90); Shapes.tri(b.x + Tmp.v1.x, b.y + Tmp.v1.y, 4f, sl, b.rot() - 90); } - Shapes.tri(b.x, b.y, 13f, (rayLength+50) * b.fout(), b.rot()); + Shapes.tri(b.x, b.y, 13f, (rayLength + 50) * b.fout(), b.rot()); Shapes.tri(b.x, b.y, 13f, 10f * b.fout(), b.rot() + 180f); Draw.reset(); } @@ -665,14 +661,16 @@ public class Bullets implements ContentList{ } }; - arc = new BulletType(0.001f, 25){{ + arc = new BulletType(0.001f, 25){ + { lifetime = 1; despawnEffect = Fx.none; hitEffect = Fx.hitLancer; } @Override - public void draw(Bullet b){} + public void draw(Bullet b){ + } @Override public void init(Bullet b){ @@ -709,7 +707,8 @@ public class Bullets implements ContentList{ incendSpread = 10f; }}; - bombOil = new BombBulletType(2f, 3f, "shell"){{ + bombOil = new BombBulletType(2f, 3f, "shell"){ + { bulletWidth = 8f; bulletHeight = 12f; hitEffect = Fx.pulverize; @@ -728,7 +727,8 @@ public class Bullets implements ContentList{ } }; - explode = new BombBulletType(2f, 3f, "clear"){{ + explode = new BombBulletType(2f, 3f, "clear"){ + { hitEffect = Fx.pulverize; lifetime = 23f; speed = 1f; diff --git a/core/src/io/anuke/mindustry/content/Fx.java b/core/src/io/anuke/mindustry/content/Fx.java index 9c7d5c1cb7..8cd9ad826c 100644 --- a/core/src/io/anuke/mindustry/content/Fx.java +++ b/core/src/io/anuke/mindustry/content/Fx.java @@ -2,9 +2,7 @@ package io.anuke.mindustry.content; import io.anuke.arc.Core; import io.anuke.arc.graphics.Color; -import io.anuke.arc.graphics.g2d.Draw; -import io.anuke.arc.graphics.g2d.Fill; -import io.anuke.arc.graphics.g2d.Lines; +import io.anuke.arc.graphics.g2d.*; import io.anuke.arc.math.Angles; import io.anuke.arc.math.Mathf; import io.anuke.arc.util.Tmp; @@ -39,18 +37,19 @@ public class Fx implements ContentList{ @Override public void load(){ - none = new Effect(0, 0f, e -> {}); + none = new Effect(0, 0f, e -> { + }); unitSpawn = new Effect(30f, e -> { if(!(e.data instanceof BaseUnit)) return; Draw.alpha(e.fin()); - float scl = 1f + e.fout()*2f; + float scl = 1f + e.fout() * 2f; BaseUnit unit = (BaseUnit)e.data; Draw.rect(unit.getIconRegion(), e.x, e.y, - unit.getIconRegion().getWidth() * Draw.scl * scl, unit.getIconRegion().getWidth() * Draw.scl * scl, 180f); + unit.getIconRegion().getWidth() * Draw.scl * scl, unit.getIconRegion().getWidth() * Draw.scl * scl, 180f); Draw.reset(); }); @@ -74,7 +73,7 @@ public class Fx implements ContentList{ Lines.stroke(3f - e.fin() * 2f); Lines.square(e.x, e.y, tilesize / 2f * e.rotation + e.fin() * 3f); - Angles.randLenVectors(e.id, 3 + (int) (e.rotation * 3), e.rotation * 2f + (tilesize * e.rotation) * e.finpow(), (x, y) -> { + Angles.randLenVectors(e.id, 3 + (int)(e.rotation * 3), e.rotation * 2f + (tilesize * e.rotation) * e.finpow(), (x, y) -> { Fill.square(e.x + x, e.y + y, 1f + e.fout() * (3f + e.rotation)); }); Draw.reset(); @@ -113,7 +112,7 @@ public class Fx implements ContentList{ Lines.poly(e.x, e.y, 4, 5f + e.fin() * 60f); Draw.reset(); }); - + vtolHover = new Effect(40f, e -> { float len = e.finpow() * 10f; float ang = e.rotation + Mathf.randomSeedRange(e.id, 30f); @@ -179,7 +178,7 @@ public class Fx implements ContentList{ e.scaled(7f, s -> { Lines.stroke(0.5f + s.fout()); - Lines.circle(e.x, e.y, s.fin()*5f); + Lines.circle(e.x, e.y, s.fin() * 5f); }); @@ -198,7 +197,7 @@ public class Fx implements ContentList{ e.scaled(7f, s -> { Lines.stroke(0.5f + s.fout()); - Lines.circle(e.x, e.y, s.fin()*7f); + Lines.circle(e.x, e.y, s.fin() * 7f); }); @@ -273,7 +272,7 @@ public class Fx implements ContentList{ hitLaser = new Effect(8, e -> { Draw.color(Color.WHITE, Pal.heal, e.fin()); Lines.stroke(0.5f + e.fout()); - Lines.circle(e.x, e.y, e.fin()*5f); + Lines.circle(e.x, e.y, e.fin() * 5f); Draw.reset(); }); @@ -539,7 +538,7 @@ public class Fx implements ContentList{ Draw.color(Pal.accent); Angles.randLenVectors(e.id, 2, 1f + e.fin() * 2f, (x, y) -> { - Fill.square(e.x + x, e.y + y, e.fout() * 2.3f+0.5f); + Fill.square(e.x + x, e.y + y, e.fout() * 2.3f + 0.5f); }); Draw.color(); @@ -549,7 +548,7 @@ public class Fx implements ContentList{ float length = 20f * e.finpow(); float size = 7f * e.fout(); - Draw.rect(((Item) e.data).icon(Icon.large), e.x + Angles.trnsx(e.rotation, length), e.y + Angles.trnsy(e.rotation, length), size, size); + Draw.rect(((Item)e.data).icon(Icon.large), e.x + Angles.trnsx(e.rotation, length), e.y + Angles.trnsy(e.rotation, length), size, size); }); @@ -614,23 +613,23 @@ public class Fx implements ContentList{ dynamicExplosion = new Effect(30, e -> { float intensity = e.rotation; - e.scaled(5 + intensity*2, i -> { + e.scaled(5 + intensity * 2, i -> { Lines.stroke(3.1f * i.fout()); Lines.poly(e.x, e.y, (int)(20 * intensity), (3f + i.fin() * 14f) * intensity); }); Draw.color(Color.GRAY); - Angles.randLenVectors(e.id, e.finpow(), (int)(6 * intensity), 21f*intensity, (x, y, in, out) -> { - Fill.circle(e.x + x, e.y + y, out * (2f+intensity) * 3 + 0.5f); + Angles.randLenVectors(e.id, e.finpow(), (int)(6 * intensity), 21f * intensity, (x, y, in, out) -> { + Fill.circle(e.x + x, e.y + y, out * (2f + intensity) * 3 + 0.5f); Fill.circle(e.x + x / 2f, e.y + y / 2f, out * (intensity) * 3); }); Draw.color(Pal.lighterOrange, Pal.lightOrange, Color.GRAY, e.fin()); Lines.stroke((1.7f * e.fout()) * (1f + (intensity - 1f) / 2f)); - Angles.randLenVectors(e.id + 1, e.finpow(), (int)(9*intensity), 40f*intensity, (x, y, in, out) -> { - Lines.lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), 1f + out * 4 * (3f+intensity)); + Angles.randLenVectors(e.id + 1, e.finpow(), (int)(9 * intensity), 40f * intensity, (x, y, in, out) -> { + Lines.lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), 1f + out * 4 * (3f + intensity)); }); Draw.reset(); @@ -772,8 +771,8 @@ public class Fx implements ContentList{ float len = (2f + e.finpow() * 6f) * i; float lr = rot + e.fin() * 30f * i; Fill.rect(e.x + Angles.trnsx(lr, len) + Mathf.randomSeedRange(e.id + i + 7, 3f * e.fin()), - e.y + Angles.trnsy(lr, len) + Mathf.randomSeedRange(e.id + i + 8, 3f * e.fin()), - 1f, 2f, rot + e.fin() * 50f * i); + e.y + Angles.trnsy(lr, len) + Mathf.randomSeedRange(e.id + i + 8, 3f * e.fin()), + 1f, 2f, rot + e.fin() * 50f * i); Draw.color(); }); @@ -785,9 +784,9 @@ public class Fx implements ContentList{ float len = (2f + e.finpow() * 10f) * i; float lr = rot + e.fin() * 20f * i; Draw.rect(Core.atlas.find("casing"), - e.x + Angles.trnsx(lr, len) + Mathf.randomSeedRange(e.id + i + 7, 3f * e.fin()), - e.y + Angles.trnsy(lr, len) + Mathf.randomSeedRange(e.id + i + 8, 3f * e.fin()), - 2f, 3f, rot); + e.x + Angles.trnsx(lr, len) + Mathf.randomSeedRange(e.id + i + 7, 3f * e.fin()), + e.y + Angles.trnsy(lr, len) + Mathf.randomSeedRange(e.id + i + 8, 3f * e.fin()), + 2f, 3f, rot); } Draw.color(Color.LIGHT_GRAY, Color.GRAY, e.fin()); @@ -808,10 +807,10 @@ public class Fx implements ContentList{ float len = (4f + e.finpow() * 8f) * i; float lr = rot + Mathf.randomSeedRange(e.id + i + 6, 20f * e.fin()) * i; Draw.rect(Core.atlas.find("casing"), - e.x + Angles.trnsx(lr, len) + Mathf.randomSeedRange(e.id + i + 7, 3f * e.fin()), - e.y + Angles.trnsy(lr, len) + Mathf.randomSeedRange(e.id + i + 8, 3f * e.fin()), - 2.5f, 4f, - rot + e.fin() * 30f * i + Mathf.randomSeedRange(e.id + i + 9, 40f * e.fin())); + e.x + Angles.trnsx(lr, len) + Mathf.randomSeedRange(e.id + i + 7, 3f * e.fin()), + e.y + Angles.trnsy(lr, len) + Mathf.randomSeedRange(e.id + i + 8, 3f * e.fin()), + 2.5f, 4f, + rot + e.fin() * 30f * i + Mathf.randomSeedRange(e.id + i + 9, 40f * e.fin())); } Draw.color(Color.LIGHT_GRAY); @@ -1178,7 +1177,7 @@ public class Fx implements ContentList{ healBlock = new Effect(20, e -> { Draw.color(Pal.heal); Lines.stroke(2f * e.fout() + 0.5f); - Lines.square(e.x, e.y, 1f + (e.fin() * e.rotation * tilesize/2f-1f)); + Lines.square(e.x, e.y, 1f + (e.fin() * e.rotation * tilesize / 2f - 1f)); Draw.color(); }); diff --git a/core/src/io/anuke/mindustry/content/Mechs.java b/core/src/io/anuke/mindustry/content/Mechs.java index b717092a5d..6e34912855 100644 --- a/core/src/io/anuke/mindustry/content/Mechs.java +++ b/core/src/io/anuke/mindustry/content/Mechs.java @@ -21,7 +21,7 @@ import io.anuke.mindustry.type.Weapon; public class Mechs implements ContentList{ public static Mech alpha, delta, tau, omega, dart, javelin, trident, glaive; - /**These are not new mechs, just re-assignments for convenience.*/ + /** These are not new mechs, just re-assignments for convenience. */ public static Mech starterDesktop, starterMobile; @Override @@ -137,7 +137,7 @@ public class Mechs implements ContentList{ if(player.timer.get(Player.timerAbility, healReload)){ wasHealed = false; - rect.setSize(healRange*2f).setCenter(player.x, player.y); + rect.setSize(healRange * 2f).setCenter(player.x, player.y); Units.getNearby(player.getTeam(), rect, unit -> { if(unit.dst(player) <= healRange){ if(unit.health < unit.maxHealth()){ @@ -192,7 +192,7 @@ public class Mechs implements ContentList{ @Override public float spreadX(Player player){ - return player.shootHeat*2f; + return player.shootHeat * 2f; } @Override @@ -203,7 +203,7 @@ public class Mechs implements ContentList{ @Override public void updateAlt(Player player){ - float scl = 1f - player.shootHeat/2f; + float scl = 1f - player.shootHeat / 2f; player.velocity().scl(scl); } @@ -257,6 +257,7 @@ public class Mechs implements ContentList{ float minV = 3.6f; float maxV = 6f; TextureRegion shield; + { drillPower = -1; speed = 0.11f; @@ -292,7 +293,7 @@ public class Mechs implements ContentList{ @Override public void updateAlt(Player player){ float scl = scld(player); - if(Mathf.chance(Time.delta() * (0.15*scl))){ + if(Mathf.chance(Time.delta() * (0.15 * scl))){ Effects.effect(Fx.hitLancer, Pal.lancerLaser, player.x, player.y); Lightning.create(player.getTeam(), Pal.lancerLaser, 10f, player.x + player.velocity().x, player.y + player.velocity().y, player.rotation, 14); @@ -304,9 +305,9 @@ public class Mechs implements ContentList{ float scl = scld(player); if(scl < 0.01f) return; Draw.color(Pal.lancerLaser); - Draw.alpha(scl/2f); + Draw.alpha(scl / 2f); Draw.blend(Blending.additive); - Draw.rect(shield, player.x + Mathf.range(scl/2f), player.y + Mathf.range(scl/2f), player.rotation - 90); + Draw.rect(shield, player.x + Mathf.range(scl / 2f), player.y + Mathf.range(scl / 2f), player.rotation - 90); Draw.blend(); } diff --git a/core/src/io/anuke/mindustry/content/StatusEffects.java b/core/src/io/anuke/mindustry/content/StatusEffects.java index e9c87b39b6..f10340df75 100644 --- a/core/src/io/anuke/mindustry/content/StatusEffects.java +++ b/core/src/io/anuke/mindustry/content/StatusEffects.java @@ -1,7 +1,7 @@ package io.anuke.mindustry.content; -import io.anuke.mindustry.entities.Effects; import io.anuke.arc.math.Mathf; +import io.anuke.mindustry.entities.Effects; import io.anuke.mindustry.game.ContentList; import io.anuke.mindustry.type.StatusEffect; diff --git a/core/src/io/anuke/mindustry/content/TechTree.java b/core/src/io/anuke/mindustry/content/TechTree.java index b56bbf10d9..3c9388cfff 100644 --- a/core/src/io/anuke/mindustry/content/TechTree.java +++ b/core/src/io/anuke/mindustry/content/TechTree.java @@ -88,7 +88,6 @@ public class TechTree implements ContentList{ }); - node(copperWall, () -> { node(copperWallLarge); node(titaniumWall, () -> { @@ -172,7 +171,6 @@ public class TechTree implements ContentList{ }); - node(mechanicalPump, () -> { node(conduit, () -> { node(liquidJunction, () -> { @@ -275,12 +273,13 @@ public class TechTree implements ContentList{ for(int i = 0; i < requirements.length; i++){ requirements[i] = new ItemStack(block.buildRequirements[i].item, block.buildRequirements[i].amount * 5); } - + return new TechNode(block, requirements, children); } private TechNode node(Block block){ - return node(block, () -> {}); + return node(block, () -> { + }); } public static class TechNode{ diff --git a/core/src/io/anuke/mindustry/content/UnitTypes.java b/core/src/io/anuke/mindustry/content/UnitTypes.java index 1488f9a02c..217e8227ee 100644 --- a/core/src/io/anuke/mindustry/content/UnitTypes.java +++ b/core/src/io/anuke/mindustry/content/UnitTypes.java @@ -8,9 +8,9 @@ import io.anuke.mindustry.type.Weapon; public class UnitTypes implements ContentList{ public static UnitType - spirit, phantom, - wraith, ghoul, revenant, lich, reaper, - dagger, crawler, titan, fortress, eruptor, chaosArray, eradicator; + spirit, phantom, + wraith, ghoul, revenant, lich, reaper, + dagger, crawler, titan, fortress, eruptor, chaosArray, eradicator; @Override public void load(){ diff --git a/core/src/io/anuke/mindustry/content/Zones.java b/core/src/io/anuke/mindustry/content/Zones.java index 190c3229e9..bffdd42fae 100644 --- a/core/src/io/anuke/mindustry/content/Zones.java +++ b/core/src/io/anuke/mindustry/content/Zones.java @@ -4,9 +4,7 @@ import io.anuke.mindustry.game.ContentList; import io.anuke.mindustry.game.Rules; import io.anuke.mindustry.maps.generators.MapGenerator; import io.anuke.mindustry.maps.generators.MapGenerator.Decoration; -import io.anuke.mindustry.type.Item; -import io.anuke.mindustry.type.ItemStack; -import io.anuke.mindustry.type.Zone; +import io.anuke.mindustry.type.*; import io.anuke.mindustry.world.Block; public class Zones implements ContentList{ @@ -44,7 +42,7 @@ public class Zones implements ContentList{ }}; frozenForest = new Zone("frozenForest", new MapGenerator("frozenForest", 1) - .decor(new Decoration(Blocks.snow, Blocks.sporeCluster, 0.02))){{ + .decor(new Decoration(Blocks.snow, Blocks.sporeCluster, 0.02))){{ loadout = Loadouts.basicFoundation; baseLaunchCost = ItemStack.with(); startingItems = ItemStack.list(Items.copper, 400); @@ -89,8 +87,8 @@ public class Zones implements ContentList{ }};*/ stainedMountains = new Zone("stainedMountains", new MapGenerator("stainedMountains", 2) - .dist(0f, false) - .decor(new Decoration(Blocks.moss, Blocks.shaleBoulder, 0.02))){{ + .dist(0f, false) + .decor(new Decoration(Blocks.moss, Blocks.shaleBoulder, 0.02))){{ loadout = Loadouts.basicFoundation; baseLaunchCost = ItemStack.with(); startingItems = ItemStack.list(Items.copper, 400, Items.lead, 100); diff --git a/core/src/io/anuke/mindustry/core/ContentLoader.java b/core/src/io/anuke/mindustry/core/ContentLoader.java index 67bbf503ab..72df701ddc 100644 --- a/core/src/io/anuke/mindustry/core/ContentLoader.java +++ b/core/src/io/anuke/mindustry/core/ContentLoader.java @@ -1,8 +1,6 @@ package io.anuke.mindustry.core; -import io.anuke.arc.collection.Array; -import io.anuke.arc.collection.ObjectMap; -import io.anuke.arc.collection.ObjectSet; +import io.anuke.arc.collection.*; import io.anuke.arc.function.Consumer; import io.anuke.arc.graphics.Color; import io.anuke.arc.graphics.Pixmap; @@ -10,14 +8,10 @@ import io.anuke.arc.util.Log; import io.anuke.mindustry.content.*; import io.anuke.mindustry.entities.bullet.Bullet; import io.anuke.mindustry.entities.bullet.BulletType; -import io.anuke.mindustry.entities.effect.Fire; -import io.anuke.mindustry.entities.effect.Lightning; -import io.anuke.mindustry.entities.effect.Puddle; +import io.anuke.mindustry.entities.effect.*; import io.anuke.mindustry.entities.traits.TypeTrait; import io.anuke.mindustry.entities.type.Player; -import io.anuke.mindustry.game.Content; -import io.anuke.mindustry.game.ContentList; -import io.anuke.mindustry.game.MappableContent; +import io.anuke.mindustry.game.*; import io.anuke.mindustry.type.*; import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.LegacyColorMapper; @@ -58,7 +52,7 @@ public class ContentLoader{ verbose = true; } - /**Creates all content types.*/ + /** Creates all content types. */ public void load(){ if(loaded){ Log.info("Content already loaded, skipping."); @@ -69,7 +63,7 @@ public class ContentLoader{ for(ContentType type : ContentType.values()){ contentMap[type.ordinal()] = new Array<>(); - contentNameMap[type.ordinal()] = new ObjectMap<>(); + contentNameMap[type.ordinal()] = new ObjectMap<>(); } for(ContentList list : content){ @@ -82,13 +76,13 @@ public class ContentLoader{ for(Content c : contentMap[type.ordinal()]){ if(c instanceof MappableContent){ - String name = ((MappableContent) c).name; + String name = ((MappableContent)c).name; if(contentNameMap[type.ordinal()].containsKey(name)){ throw new IllegalArgumentException("Two content objects cannot have the same name! (issue: '" + name + "')"); } - contentNameMap[type.ordinal()].put(name, (MappableContent) c); + contentNameMap[type.ordinal()].put(name, (MappableContent)c); } - total ++; + total++; } } @@ -119,7 +113,7 @@ public class ContentLoader{ loaded = true; } - /**Initializes all content with the specified function.*/ + /** Initializes all content with the specified function. */ public void initialize(Consumer callable){ if(initialization.contains(callable)) return; @@ -132,7 +126,7 @@ public class ContentLoader{ initialization.add(callable); } - /**Loads block colors.*/ + /** Loads block colors. */ public void loadColors(){ Pixmap pixmap = new Pixmap(files.internal("sprites/block_colors.png")); for(int i = 0; i < 256; i++){ @@ -193,7 +187,7 @@ public class ContentLoader{ } public Array getBy(ContentType type){ - return (Array) contentMap[type.ordinal()]; + return (Array)contentMap[type.ordinal()]; } //utility methods, just makes things a bit shorter @@ -203,7 +197,7 @@ public class ContentLoader{ } public Block block(int id){ - return (Block) getByID(ContentType.block, id); + return (Block)getByID(ContentType.block, id); } public Array items(){ @@ -211,7 +205,7 @@ public class ContentLoader{ } public Item item(int id){ - return (Item) getByID(ContentType.item, id); + return (Item)getByID(ContentType.item, id); } public Array liquids(){ @@ -219,7 +213,7 @@ public class ContentLoader{ } public Liquid liquid(int id){ - return (Liquid) getByID(ContentType.liquid, id); + return (Liquid)getByID(ContentType.liquid, id); } public Array bullets(){ @@ -227,7 +221,7 @@ public class ContentLoader{ } public BulletType bullet(int id){ - return (BulletType) getByID(ContentType.bullet, id); + return (BulletType)getByID(ContentType.bullet, id); } public Array zones(){ @@ -250,5 +244,9 @@ public class ContentLoader{ TypeTrait.registerType(Lightning.class, Lightning::new); } - private class ImpendingDoomException extends RuntimeException{ ImpendingDoomException(String s){ super(s); }} + private class ImpendingDoomException extends RuntimeException{ + ImpendingDoomException(String s){ + super(s); + } + } } diff --git a/core/src/io/anuke/mindustry/core/Control.java b/core/src/io/anuke/mindustry/core/Control.java index c9b7a6b5f3..1de9fc48d4 100644 --- a/core/src/io/anuke/mindustry/core/Control.java +++ b/core/src/io/anuke/mindustry/core/Control.java @@ -1,8 +1,6 @@ package io.anuke.mindustry.core; -import io.anuke.arc.ApplicationListener; -import io.anuke.arc.Core; -import io.anuke.arc.Events; +import io.anuke.arc.*; import io.anuke.arc.graphics.Color; import io.anuke.arc.graphics.GL20; import io.anuke.arc.graphics.g2d.Draw; @@ -16,16 +14,10 @@ import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.entities.Effects; import io.anuke.mindustry.entities.EntityQuery; import io.anuke.mindustry.entities.type.Player; -import io.anuke.mindustry.game.Content; +import io.anuke.mindustry.game.*; import io.anuke.mindustry.game.EventType.*; -import io.anuke.mindustry.game.GlobalData; -import io.anuke.mindustry.game.Rules; -import io.anuke.mindustry.game.Saves; import io.anuke.mindustry.gen.Call; -import io.anuke.mindustry.input.Binding; -import io.anuke.mindustry.input.DesktopInput; -import io.anuke.mindustry.input.InputHandler; -import io.anuke.mindustry.input.MobileInput; +import io.anuke.mindustry.input.*; import io.anuke.mindustry.maps.Map; import io.anuke.mindustry.net.Net; import io.anuke.mindustry.type.Item; @@ -152,20 +144,20 @@ public class Control implements ApplicationListener{ if(e.breaking){ state.stats.buildingsDeconstructed++; }else{ - state.stats.buildingsBuilt ++; + state.stats.buildingsBuilt++; } } }); Events.on(BlockDestroyEvent.class, e -> { if(e.tile.getTeam() == player.getTeam()){ - state.stats.buildingsDestroyed ++; + state.stats.buildingsDestroyed++; } }); Events.on(UnitDestroyEvent.class, e -> { if(e.unit.getTeam() != player.getTeam()){ - state.stats.enemyUnitsDestroyed ++; + state.stats.enemyUnitsDestroyed++; } }); @@ -252,9 +244,9 @@ public class Control implements ApplicationListener{ Core.settings.save(); }).size(100f, 60f); dialog.cont.add("Reminder: The alpha version you are about to play is very unstable, and is [accent]not representative of the final v4 release.[]\n\n " + - "\nThere is currently[scarlet] no sound implemented[]; this is intentional.\n" + - "All current art and UI is unfinished, and will be changed before release. " + - "\n\n[accent]Saves may be corrupted without warning between updates.").wrap().width(400f); + "\nThere is currently[scarlet] no sound implemented[]; this is intentional.\n" + + "All current art and UI is unfinished, and will be changed before release. " + + "\n\n[accent]Saves may be corrupted without warning between updates.").wrap().width(400f); dialog.show(); }); } @@ -309,7 +301,7 @@ public class Control implements ApplicationListener{ Time.update(); } - if(!scene.hasDialog() && !(scene.root.getChildren().peek() instanceof Dialog) &&Core.input.keyTap(KeyCode.BACK)){ + if(!scene.hasDialog() && !(scene.root.getChildren().peek() instanceof Dialog) && Core.input.keyTap(KeyCode.BACK)){ Platform.instance.hide(); } } diff --git a/core/src/io/anuke/mindustry/core/GameState.java b/core/src/io/anuke/mindustry/core/GameState.java index 9765ae1786..2cedcda4bc 100644 --- a/core/src/io/anuke/mindustry/core/GameState.java +++ b/core/src/io/anuke/mindustry/core/GameState.java @@ -3,30 +3,28 @@ package io.anuke.mindustry.core; import io.anuke.arc.Events; import io.anuke.mindustry.entities.type.BaseUnit; import io.anuke.mindustry.game.EventType.StateChangeEvent; -import io.anuke.mindustry.game.Rules; -import io.anuke.mindustry.game.Stats; -import io.anuke.mindustry.game.Teams; +import io.anuke.mindustry.game.*; import io.anuke.mindustry.net.Net; import static io.anuke.mindustry.Vars.unitGroups; import static io.anuke.mindustry.Vars.waveTeam; public class GameState{ - /**Current wave number, can be anything in non-wave modes.*/ + /** Current wave number, can be anything in non-wave modes. */ public int wave = 1; - /**Wave countdown in ticks.*/ + /** Wave countdown in ticks. */ public float wavetime; - /**Whether the game is in game over state.*/ + /** Whether the game is in game over state. */ public boolean gameOver = false, launched = false; - /**The current game rules.*/ + /** The current game rules. */ public Rules rules = new Rules(); - /**Statistics for this save/game. Displayed after game over.*/ + /** Statistics for this save/game. Displayed after game over. */ public Stats stats = new Stats(); - /**Team data. Gets reset every new game.*/ + /** Team data. Gets reset every new game. */ public Teams teams = new Teams(); - /**Number of enemies in the game; only used clientside in servers.*/ + /** Number of enemies in the game; only used clientside in servers. */ public int enemies; - /**Current game state.*/ + /** Current game state. */ private State state = State.menu; public int enemies(){ diff --git a/core/src/io/anuke/mindustry/core/Logic.java b/core/src/io/anuke/mindustry/core/Logic.java index 565685ad57..a450acf61c 100644 --- a/core/src/io/anuke/mindustry/core/Logic.java +++ b/core/src/io/anuke/mindustry/core/Logic.java @@ -8,15 +8,9 @@ import io.anuke.arc.collection.ObjectSet.ObjectSetIterator; import io.anuke.arc.util.Time; import io.anuke.mindustry.content.Fx; import io.anuke.mindustry.core.GameState.State; -import io.anuke.mindustry.entities.Effects; -import io.anuke.mindustry.entities.Entities; -import io.anuke.mindustry.entities.EntityGroup; -import io.anuke.mindustry.entities.EntityQuery; +import io.anuke.mindustry.entities.*; import io.anuke.mindustry.entities.type.TileEntity; -import io.anuke.mindustry.game.EventType.GameOverEvent; -import io.anuke.mindustry.game.EventType.PlayEvent; -import io.anuke.mindustry.game.EventType.ResetEvent; -import io.anuke.mindustry.game.EventType.WaveEvent; +import io.anuke.mindustry.game.EventType.*; import io.anuke.mindustry.game.*; import io.anuke.mindustry.net.Net; import io.anuke.mindustry.type.Item; @@ -51,7 +45,7 @@ public class Logic implements ApplicationListener{ }); } - /**Handles the event of content being used by either the player or some block.*/ + /** Handles the event of content being used by either the player or some block. */ public void handleContent(UnlockableContent content){ if(!headless){ data.unlockContent(content); @@ -85,7 +79,7 @@ public class Logic implements ApplicationListener{ world.spawner.spawnEnemies(); state.wave++; state.wavetime = world.isZone() && world.getZone().isBossWave(state.wave) ? state.rules.waveSpacing * bossWaveMultiplier : - world.isZone() && world.getZone().isLaunchWave(state.wave) ? state.rules.waveSpacing * launchWaveMultiplier : state.rules.waveSpacing; + world.isZone() && world.getZone().isLaunchWave(state.wave) ? state.rules.waveSpacing * launchWaveMultiplier : state.rules.waveSpacing; Events.fire(new WaveEvent()); } diff --git a/core/src/io/anuke/mindustry/core/NetClient.java b/core/src/io/anuke/mindustry/core/NetClient.java index 5265ca09a4..eff6d94e79 100644 --- a/core/src/io/anuke/mindustry/core/NetClient.java +++ b/core/src/io/anuke/mindustry/core/NetClient.java @@ -1,17 +1,12 @@ package io.anuke.mindustry.core; -import io.anuke.annotations.Annotations.Loc; -import io.anuke.annotations.Annotations.PacketPriority; -import io.anuke.annotations.Annotations.Remote; -import io.anuke.annotations.Annotations.Variant; +import io.anuke.annotations.Annotations.*; import io.anuke.arc.ApplicationListener; import io.anuke.arc.Core; import io.anuke.arc.collection.IntSet; import io.anuke.arc.graphics.Color; import io.anuke.arc.math.RandomXS128; -import io.anuke.arc.util.Interval; -import io.anuke.arc.util.Log; -import io.anuke.arc.util.Time; +import io.anuke.arc.util.*; import io.anuke.arc.util.io.ReusableByteArrayInputStream; import io.anuke.arc.util.serialization.Base64Coder; import io.anuke.mindustry.Vars; @@ -25,11 +20,9 @@ import io.anuke.mindustry.entities.type.Player; import io.anuke.mindustry.game.Version; import io.anuke.mindustry.gen.Call; import io.anuke.mindustry.gen.RemoteReadClient; -import io.anuke.mindustry.net.Net; +import io.anuke.mindustry.net.*; import io.anuke.mindustry.net.Net.SendMode; -import io.anuke.mindustry.net.NetworkIO; import io.anuke.mindustry.net.Packets.*; -import io.anuke.mindustry.net.ValidateException; import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.modules.ItemModule; @@ -45,18 +38,18 @@ public class NetClient implements ApplicationListener{ public final static float viewScale = 2f; private Interval timer = new Interval(5); - /**Whether the client is currently connecting.*/ + /** Whether the client is currently connecting. */ private boolean connecting = false; - /**If true, no message will be shown on disconnect.*/ + /** If true, no message will be shown on disconnect. */ private boolean quiet = false; - /**Counter for data timeout.*/ + /** Counter for data timeout. */ private float timeoutTime = 0f; - /**Last sent client snapshot ID.*/ + /** Last sent client snapshot ID. */ private int lastSent; - /**List of entities that were removed, and need not be added while syncing.*/ + /** List of entities that were removed, and need not be added while syncing. */ private IntSet removed = new IntSet(); - /**Byte stream for reading in snapshots.*/ + /** Byte stream for reading in snapshots. */ private ReusableByteArrayInputStream byteStream = new ReusableByteArrayInputStream(); private DataInputStream dataStream = new DataInputStream(byteStream); @@ -210,7 +203,7 @@ public class NetClient implements ApplicationListener{ int id = input.readInt(); byte typeID = input.readByte(); - SyncTrait entity = (SyncTrait) group.getByID(id); + SyncTrait entity = (SyncTrait)group.getByID(id); boolean add = false; if(entity == null && id == player.id){ @@ -220,7 +213,7 @@ public class NetClient implements ApplicationListener{ //entity must not be added yet, so create it if(entity == null){ - entity = (SyncTrait) TypeTrait.getTypeByID(typeID).get(); //create entity from supplier + entity = (SyncTrait)TypeTrait.getTypeByID(typeID).get(); //create entity from supplier entity.resetID(id); if(!netClient.isEntityUsed(entity.getID())){ add = true; @@ -323,7 +316,7 @@ public class NetClient implements ApplicationListener{ Net.disconnect(); } - /**When set, any disconnects will be ignored and no dialogs will be shown.*/ + /** When set, any disconnects will be ignored and no dialogs will be shown. */ public void setQuiet(){ quiet = true; } @@ -349,13 +342,13 @@ public class NetClient implements ApplicationListener{ } Call.onClientShapshot(lastSent++, player.x, player.y, - player.pointerX, player.pointerY, player.rotation, player.baseRotation, - player.velocity().x, player.velocity().y, - player.getMineTile(), - player.isBoosting, player.isShooting, ui.chatfrag.chatOpen(), - requests, - Core.camera.position.x, Core.camera.position.y, - Core.camera.width * viewScale, Core.camera.height * viewScale); + player.pointerX, player.pointerY, player.rotation, player.baseRotation, + player.velocity().x, player.velocity().y, + player.getMineTile(), + player.isBoosting, player.isShooting, ui.chatfrag.chatOpen(), + requests, + Core.camera.position.x, Core.camera.position.y, + Core.camera.width * viewScale, Core.camera.height * viewScale); } if(timer.get(1, 60)){ diff --git a/core/src/io/anuke/mindustry/core/NetServer.java b/core/src/io/anuke/mindustry/core/NetServer.java index c6a4c7d9a5..22ed624e69 100644 --- a/core/src/io/anuke/mindustry/core/NetServer.java +++ b/core/src/io/anuke/mindustry/core/NetServer.java @@ -4,26 +4,19 @@ import io.anuke.annotations.Annotations.Loc; import io.anuke.annotations.Annotations.Remote; import io.anuke.arc.ApplicationListener; import io.anuke.arc.Events; -import io.anuke.arc.collection.Array; -import io.anuke.arc.collection.IntMap; -import io.anuke.arc.collection.ObjectSet; +import io.anuke.arc.collection.*; import io.anuke.arc.graphics.Color; import io.anuke.arc.graphics.Colors; import io.anuke.arc.math.Mathf; import io.anuke.arc.math.geom.Rectangle; import io.anuke.arc.math.geom.Vector2; -import io.anuke.arc.util.Log; -import io.anuke.arc.util.Structs; -import io.anuke.arc.util.Time; -import io.anuke.arc.util.Tmp; +import io.anuke.arc.util.*; import io.anuke.arc.util.io.ByteBufferOutput; import io.anuke.arc.util.io.CountableByteArrayOutputStream; import io.anuke.mindustry.content.Blocks; import io.anuke.mindustry.content.Mechs; import io.anuke.mindustry.core.GameState.State; -import io.anuke.mindustry.entities.Entities; -import io.anuke.mindustry.entities.EntityGroup; -import io.anuke.mindustry.entities.EntityQuery; +import io.anuke.mindustry.entities.*; import io.anuke.mindustry.entities.traits.BuilderTrait.BuildRequest; import io.anuke.mindustry.entities.traits.Entity; import io.anuke.mindustry.entities.traits.SyncTrait; @@ -33,44 +26,40 @@ import io.anuke.mindustry.game.Team; import io.anuke.mindustry.game.Version; import io.anuke.mindustry.gen.Call; import io.anuke.mindustry.gen.RemoteReadServer; -import io.anuke.mindustry.net.Administration; +import io.anuke.mindustry.net.*; import io.anuke.mindustry.net.Administration.PlayerInfo; -import io.anuke.mindustry.net.Net; -import io.anuke.mindustry.net.NetConnection; -import io.anuke.mindustry.net.NetworkIO; import io.anuke.mindustry.net.Packets.*; import io.anuke.mindustry.world.Tile; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.DataOutputStream; -import java.io.IOException; +import java.io.*; import java.nio.ByteBuffer; import java.util.zip.DeflaterOutputStream; import static io.anuke.mindustry.Vars.*; +import java.lang.StringBuilder; + public class NetServer implements ApplicationListener{ public final static int maxSnapshotSize = 430; private final static float serverSyncTime = 30, kickDuration = 30 * 1000; private final static Vector2 vector = new Vector2(); private final static Rectangle viewport = new Rectangle(); private final static Array returnArray = new Array<>(); - /**If a player goes away of their server-side coordinates by this distance, they get teleported back.*/ + /** If a player goes away of their server-side coordinates by this distance, they get teleported back. */ private final static float correctDist = 16f; public final Administration admins = new Administration(); - /**Maps connection IDs to players.*/ + /** Maps connection IDs to players. */ private IntMap connections = new IntMap<>(); private boolean closing = false; private ByteBuffer writeBuffer = ByteBuffer.allocate(127); private ByteBufferOutput outputBuffer = new ByteBufferOutput(writeBuffer); - /**Stream for writing player sync data to.*/ + /** Stream for writing player sync data to. */ private CountableByteArrayOutputStream syncStream = new CountableByteArrayOutputStream(); - /**Data stream for writing player sync data to.*/ + /** Data stream for writing player sync data to. */ private DataOutputStream dataStream = new DataOutputStream(syncStream); public NetServer(){ @@ -100,7 +89,7 @@ public class NetServer implements ApplicationListener{ NetConnection connection = Net.getConnection(id); if(connection == null || - admins.isIPBanned(connection.address)) return; + admins.isIPBanned(connection.address)) return; if(connection.hasBegunConnecting){ kick(id, KickReason.idInUse); @@ -215,7 +204,7 @@ public class NetServer implements ApplicationListener{ int count = 0; for(Player other : players){ if(other.getTeam() == team){ - count ++; + count++; } } return count; @@ -262,16 +251,16 @@ public class NetServer implements ApplicationListener{ @Remote(targets = Loc.client, unreliable = true) public static void onClientShapshot( - Player player, - int snapshotID, - float x, float y, - float pointerX, float pointerY, - float rotation, float baseRotation, - float xVelocity, float yVelocity, - Tile mining, - boolean boosting, boolean shooting, boolean chatting, - BuildRequest[] requests, - float viewX, float viewY, float viewWidth, float viewHeight + Player player, + int snapshotID, + float x, float y, + float pointerX, float pointerY, + float rotation, float baseRotation, + float xVelocity, float yVelocity, + Tile mining, + boolean boosting, boolean shooting, boolean chatting, + BuildRequest[] requests, + float viewX, float viewY, float viewWidth, float viewHeight ){ NetConnection connection = player.con; if(connection == null || snapshotID < connection.lastRecievedClientSnapshot) return; @@ -348,7 +337,7 @@ public class NetServer implements ApplicationListener{ if(!player.isAdmin){ Log.warn("ACCESS DENIED: Player {0} / {1} attempted to perform admin action without proper security access.", - player.name, player.con.address); + player.name, player.con.address); return; } @@ -394,7 +383,7 @@ public class NetServer implements ApplicationListener{ int used = 0; for(Team t : Team.all){ if(playerGroup.count(p -> p.getTeam() == t) > 0){ - used ++; + used++; } } return used < 2; @@ -472,7 +461,7 @@ public class NetServer implements ApplicationListener{ for(EntityGroup group : Entities.getAllGroups()){ if(group.isEmpty() || !(group.all().get(0) instanceof SyncTrait)) continue; //clipping is done by representatives - SyncTrait represent = (SyncTrait) group.all().get(0); + SyncTrait represent = (SyncTrait)group.all().get(0); //make sure mapping is enabled for this group if(!group.mappingEnabled()){ @@ -482,13 +471,13 @@ public class NetServer implements ApplicationListener{ returnArray.clear(); if(represent.isClipped()){ EntityQuery.getNearby(group, viewport, entity -> { - if(((SyncTrait) entity).isSyncing() && viewport.overlaps(Tmp.r3.setSize(((SyncTrait)entity).clipSize(), ((SyncTrait)entity).clipSize()).setCenter(entity.getX(), entity.getY()))){ + if(((SyncTrait)entity).isSyncing() && viewport.overlaps(Tmp.r3.setSize(((SyncTrait)entity).clipSize(), ((SyncTrait)entity).clipSize()).setCenter(entity.getX(), entity.getY()))){ returnArray.add(entity); } }); }else{ for(Entity entity : group.all()){ - if(((SyncTrait) entity).isSyncing()){ + if(((SyncTrait)entity).isSyncing()){ returnArray.add(entity); } } @@ -501,10 +490,10 @@ public class NetServer implements ApplicationListener{ for(Entity entity : returnArray){ //write all entities now dataStream.writeInt(entity.getID()); //write id - dataStream.writeByte(((SyncTrait) entity).getTypeID()); //write type ID - ((SyncTrait) entity).write(dataStream); //write entity + dataStream.writeByte(((SyncTrait)entity).getTypeID()); //write type ID + ((SyncTrait)entity).write(dataStream); //write entity - sent ++; + sent++; if(syncStream.position() > maxSnapshotSize){ dataStream.close(); @@ -579,7 +568,7 @@ public class NetServer implements ApplicationListener{ try{ //iterate through each player - for(int i = 0; i < playerGroup.size(); i ++){ + for(int i = 0; i < playerGroup.size(); i++){ Player player = playerGroup.all().get(i); if(player.isLocal) continue; diff --git a/core/src/io/anuke/mindustry/core/Platform.java b/core/src/io/anuke/mindustry/core/Platform.java index e8eb0c550e..381865907b 100644 --- a/core/src/io/anuke/mindustry/core/Platform.java +++ b/core/src/io/anuke/mindustry/core/Platform.java @@ -10,15 +10,17 @@ import io.anuke.arc.util.serialization.Base64Coder; import static io.anuke.mindustry.Vars.mobile; -public abstract class Platform { - /**Each separate game platform should set this instance to their own implementation.*/ - public static Platform instance = new Platform() {}; +public abstract class Platform{ + /** Each separate game platform should set this instance to their own implementation. */ + public static Platform instance = new Platform(){ + }; - /**Add a text input dialog that should show up after the field is tapped.*/ + /** Add a text input dialog that should show up after the field is tapped. */ public void addDialog(TextField field){ addDialog(field, 16); } - /**See addDialog().*/ + + /** See addDialog(). */ public void addDialog(TextField field, int maxLength){ if(!mobile) return; //this is mobile only, desktop doesn't need dialogs @@ -35,13 +37,17 @@ public abstract class Platform { Core.input.getTextInput(input); }); } - /**Update discord RPC.*/ - public void updateRPC(){} - /**Whether donating is supported.*/ + + /** Update discord RPC. */ + public void updateRPC(){ + } + + /** Whether donating is supported. */ public boolean canDonate(){ return false; } - /**Must be a base64 string 8 bytes in length.*/ + + /** Must be a base64 string 8 bytes in length. */ public String getUUID(){ String uuid = Core.settings.getString("uuid", ""); if(uuid.isEmpty()){ @@ -54,25 +60,31 @@ public abstract class Platform { } return uuid; } - /**Only used for iOS or android: open the share menu for a map or save.*/ - public void shareFile(FileHandle file){} - /**Show a file chooser. Desktop only. - * + /** Only used for iOS or android: open the share menu for a map or save. */ + public void shareFile(FileHandle file){ + } + + /** + * Show a file chooser. Desktop only. * @param text File chooser title text * @param content Description of the type of files to be loaded * @param cons Selection listener * @param open Whether to open or save files * @param filetype File extension to filter */ - public void showFileChooser(String text, String content, Consumer cons, boolean open, String filetype){} + public void showFileChooser(String text, String content, Consumer cons, boolean open, String filetype){ + } - /**Hide the app. Android only.*/ - public void hide(){} + /** Hide the app. Android only. */ + public void hide(){ + } - /**Forces the app into landscape mode. Currently Android only.*/ - public void beginForceLandscape(){} + /** Forces the app into landscape mode. Currently Android only. */ + public void beginForceLandscape(){ + } - /**Stops forcing the app into landscape orientation. Currently Android only.*/ - public void endForceLandscape(){} + /** Stops forcing the app into landscape orientation. Currently Android only. */ + public void endForceLandscape(){ + } } \ No newline at end of file diff --git a/core/src/io/anuke/mindustry/core/Renderer.java b/core/src/io/anuke/mindustry/core/Renderer.java index ca54b07dd0..9e4c6bfb2d 100644 --- a/core/src/io/anuke/mindustry/core/Renderer.java +++ b/core/src/io/anuke/mindustry/core/Renderer.java @@ -5,37 +5,22 @@ import io.anuke.arc.Core; import io.anuke.arc.files.FileHandle; import io.anuke.arc.function.Consumer; import io.anuke.arc.function.Predicate; -import io.anuke.arc.graphics.Camera; -import io.anuke.arc.graphics.Color; -import io.anuke.arc.graphics.Pixmap; -import io.anuke.arc.graphics.PixmapIO; -import io.anuke.arc.graphics.g2d.Draw; -import io.anuke.arc.graphics.g2d.Lines; -import io.anuke.arc.graphics.g2d.SpriteBatch; +import io.anuke.arc.graphics.*; +import io.anuke.arc.graphics.g2d.*; import io.anuke.arc.graphics.glutils.FrameBuffer; import io.anuke.arc.math.Mathf; import io.anuke.arc.math.geom.Rectangle; import io.anuke.arc.math.geom.Vector2; -import io.anuke.arc.util.BufferUtils; -import io.anuke.arc.util.ScreenUtils; -import io.anuke.arc.util.Time; -import io.anuke.arc.util.Tmp; +import io.anuke.arc.util.*; import io.anuke.arc.util.pooling.Pools; import io.anuke.mindustry.content.Fx; import io.anuke.mindustry.core.GameState.State; -import io.anuke.mindustry.entities.Effects; -import io.anuke.mindustry.entities.EntityDraw; -import io.anuke.mindustry.entities.EntityGroup; +import io.anuke.mindustry.entities.*; import io.anuke.mindustry.entities.effect.GroundEffectEntity; import io.anuke.mindustry.entities.effect.GroundEffectEntity.GroundEffect; import io.anuke.mindustry.entities.impl.EffectEntity; -import io.anuke.mindustry.entities.traits.BelowLiquidTrait; -import io.anuke.mindustry.entities.traits.DrawTrait; -import io.anuke.mindustry.entities.traits.Entity; -import io.anuke.mindustry.entities.type.BaseUnit; -import io.anuke.mindustry.entities.type.Player; -import io.anuke.mindustry.entities.type.TileEntity; -import io.anuke.mindustry.entities.type.Unit; +import io.anuke.mindustry.entities.traits.*; +import io.anuke.mindustry.entities.type.*; import io.anuke.mindustry.game.Team; import io.anuke.mindustry.graphics.*; import io.anuke.mindustry.world.blocks.defense.ForceProjector.ShieldEntity; @@ -84,7 +69,7 @@ public class Renderer implements ApplicationListener{ entity.id++; entity.set(x, y); if(data instanceof Entity){ - entity.setParent((Entity) data); + entity.setParent((Entity)data); } effectGroup.add(entity); }else{ @@ -96,7 +81,7 @@ public class Renderer implements ApplicationListener{ entity.data = data; entity.set(x, y); if(data instanceof Entity){ - entity.setParent((Entity) data); + entity.setParent((Entity)data); } groundEffectGroup.add(entity); } @@ -281,7 +266,7 @@ public class Renderer implements ApplicationListener{ EntityGroup group = unitGroups[team.ordinal()]; if(group.count(p -> p.isFlying() == flying) + - playerGroup.count(p -> p.isFlying() == flying && p.getTeam() == team) == 0 && flying) continue; + playerGroup.count(p -> p.isFlying() == flying && p.getTeam() == team) == 0 && flying) continue; drawAndInterpolate(unitGroups[team.ordinal()], u -> u.isFlying() == flying && !u.isDead(), Unit::drawUnder); drawAndInterpolate(playerGroup, p -> p.isFlying() == flying && p.getTeam() == team && !p.isDead(), Unit::drawUnder); @@ -329,7 +314,7 @@ public class Renderer implements ApplicationListener{ public void takeMapScreenshot(){ drawGroundShadows(); - int w = world.width()*tilesize, h = world.height()*tilesize; + int w = world.width() * tilesize, h = world.height() * tilesize; int memory = w * h * 4 / 1024 / 1024; if(memory >= 65){ @@ -348,8 +333,8 @@ public class Renderer implements ApplicationListener{ disableUI = true; camera.width = w; camera.height = h; - camera.position.x = w/2f + tilesize/2f; - camera.position.y = h/2f + tilesize/2f; + camera.position.x = w / 2f + tilesize / 2f; + camera.position.y = h / 2f + tilesize / 2f; Draw.flush(); buffer.begin(); draw(); @@ -361,7 +346,7 @@ public class Renderer implements ApplicationListener{ camera.position.set(px, py); buffer.begin(); byte[] lines = ScreenUtils.getFrameBufferPixels(0, 0, w, h, true); - for(int i = 0; i < lines.length; i+= 4){ + for(int i = 0; i < lines.length; i += 4){ lines[i + 3] = (byte)255; } buffer.end(); diff --git a/core/src/io/anuke/mindustry/core/UI.java b/core/src/io/anuke/mindustry/core/UI.java index 3f6a2090ff..0706a3d371 100644 --- a/core/src/io/anuke/mindustry/core/UI.java +++ b/core/src/io/anuke/mindustry/core/UI.java @@ -1,8 +1,6 @@ package io.anuke.mindustry.core; -import io.anuke.arc.ApplicationListener; -import io.anuke.arc.Core; -import io.anuke.arc.Events; +import io.anuke.arc.*; import io.anuke.arc.Graphics.Cursor; import io.anuke.arc.Graphics.Cursor.SystemCursor; import io.anuke.arc.freetype.FreeTypeFontGenerator; @@ -13,19 +11,13 @@ import io.anuke.arc.graphics.Colors; import io.anuke.arc.graphics.g2d.BitmapFont; import io.anuke.arc.input.KeyCode; import io.anuke.arc.math.Interpolation; -import io.anuke.arc.scene.Group; -import io.anuke.arc.scene.Scene; -import io.anuke.arc.scene.Skin; +import io.anuke.arc.scene.*; import io.anuke.arc.scene.actions.Actions; -import io.anuke.arc.scene.ui.Dialog; -import io.anuke.arc.scene.ui.TextField; +import io.anuke.arc.scene.ui.*; import io.anuke.arc.scene.ui.TextField.TextFieldFilter; -import io.anuke.arc.scene.ui.TooltipManager; import io.anuke.arc.scene.ui.layout.Table; import io.anuke.arc.scene.ui.layout.Unit; -import io.anuke.arc.util.Align; -import io.anuke.arc.util.Strings; -import io.anuke.arc.util.Time; +import io.anuke.arc.util.*; import io.anuke.mindustry.editor.MapEditorDialog; import io.anuke.mindustry.game.EventType.ResizeEvent; import io.anuke.mindustry.graphics.Pal; @@ -84,21 +76,21 @@ public class UI implements ApplicationListener{ Core.input.addProcessor(Core.scene); Dialog.setShowAction(() -> sequence( - alpha(0f), - originCenter(), - moveToAligned(Core.graphics.getWidth() / 2f, Core.graphics.getHeight() / 2f, Align.center), - scaleTo(0.0f, 1f), - parallel( - scaleTo(1f, 1f, 0.1f, Interpolation.fade), - fadeIn(0.1f, Interpolation.fade) - ) + alpha(0f), + originCenter(), + moveToAligned(Core.graphics.getWidth() / 2f, Core.graphics.getHeight() / 2f, Align.center), + scaleTo(0.0f, 1f), + parallel( + scaleTo(1f, 1f, 0.1f, Interpolation.fade), + fadeIn(0.1f, Interpolation.fade) + ) )); Dialog.setHideAction(() -> sequence( - parallel( - scaleTo(0.01f, 0.01f, 0.1f, Interpolation.fade), - fadeOut(0.1f, Interpolation.fade) - ) + parallel( + scaleTo(0.01f, 0.01f, 0.1f, Interpolation.fade), + fadeOut(0.1f, Interpolation.fade) + ) )); TooltipManager.getInstance().animations = false; @@ -126,11 +118,11 @@ public class UI implements ApplicationListener{ Core.graphics.restoreCursor(); } - + void generateFonts(Skin skin){ generator = new FreeTypeFontGenerator(Core.files.internal("fonts/font.ttf")); FreeTypeFontParameter param = new FreeTypeFontParameter(); - param.size = (int)(9*2 * Math.max(Unit.dp.scl(1f), 0.5f)); + param.size = (int)(9 * 2 * Math.max(Unit.dp.scl(1f), 0.5f)); param.shadowColor = Color.DARK_GRAY; param.shadowOffsetY = 2; param.incremental = true; diff --git a/core/src/io/anuke/mindustry/core/World.java b/core/src/io/anuke/mindustry/core/World.java index db18da815a..cca3314d2a 100644 --- a/core/src/io/anuke/mindustry/core/World.java +++ b/core/src/io/anuke/mindustry/core/World.java @@ -1,20 +1,14 @@ package io.anuke.mindustry.core; import io.anuke.annotations.Annotations.Nullable; -import io.anuke.arc.ApplicationListener; -import io.anuke.arc.Core; -import io.anuke.arc.Events; +import io.anuke.arc.*; import io.anuke.arc.collection.Array; import io.anuke.arc.collection.IntArray; import io.anuke.arc.math.Mathf; import io.anuke.arc.math.geom.Geometry; import io.anuke.arc.math.geom.Point2; -import io.anuke.arc.util.Log; -import io.anuke.arc.util.Structs; -import io.anuke.arc.util.Tmp; -import io.anuke.mindustry.ai.BlockIndexer; -import io.anuke.mindustry.ai.Pathfinder; -import io.anuke.mindustry.ai.WaveSpawner; +import io.anuke.arc.util.*; +import io.anuke.mindustry.ai.*; import io.anuke.mindustry.content.Blocks; import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.entities.EntityQuery; @@ -22,16 +16,10 @@ import io.anuke.mindustry.game.EventType.TileChangeEvent; import io.anuke.mindustry.game.EventType.WorldLoadEvent; import io.anuke.mindustry.game.Team; import io.anuke.mindustry.io.MapIO; -import io.anuke.mindustry.maps.Map; -import io.anuke.mindustry.maps.MapException; -import io.anuke.mindustry.maps.Maps; +import io.anuke.mindustry.maps.*; import io.anuke.mindustry.maps.generators.Generator; -import io.anuke.mindustry.type.ContentType; -import io.anuke.mindustry.type.ItemStack; -import io.anuke.mindustry.type.Zone; -import io.anuke.mindustry.world.Block; -import io.anuke.mindustry.world.Pos; -import io.anuke.mindustry.world.Tile; +import io.anuke.mindustry.type.*; +import io.anuke.mindustry.world.*; import static io.anuke.mindustry.Vars.*; @@ -97,11 +85,13 @@ public class World implements ApplicationListener{ return tiles == null ? 0 : tiles[0].length; } - public @Nullable Tile tile(int pos){ + public @Nullable + Tile tile(int pos){ return tiles == null ? null : tile(Pos.x(pos), Pos.y(pos)); } - public @Nullable Tile tile(int x, int y){ + public @Nullable + Tile tile(int x, int y){ if(tiles == null){ return null; } @@ -113,7 +103,8 @@ public class World implements ApplicationListener{ return tiles[x][y]; } - public @Nullable Tile tileWorld(float x, float y){ + public @Nullable + Tile tileWorld(float x, float y){ return tile(Math.round(x / tilesize), Math.round(y / tilesize)); } @@ -161,7 +152,7 @@ public class World implements ApplicationListener{ generating = true; } - /**Call to signal the beginning of loading the map with a custom set of tiles.*/ + /** Call to signal the beginning of loading the map with a custom set of tiles. */ public void beginMapLoad(Tile[][] tiles){ this.tiles = tiles; generating = true; @@ -185,7 +176,7 @@ public class World implements ApplicationListener{ addDarkness(tiles); - EntityQuery.resizeTree(-finalWorldBounds, -finalWorldBounds, tiles.length * tilesize + finalWorldBounds*2, tiles[0].length * tilesize + finalWorldBounds*2); + EntityQuery.resizeTree(-finalWorldBounds, -finalWorldBounds, tiles.length * tilesize + finalWorldBounds * 2, tiles[0].length * tilesize + finalWorldBounds * 2); generating = false; Events.fire(new WorldLoadEvent()); @@ -326,7 +317,7 @@ public class World implements ApplicationListener{ if(!(worldx == tile.x && worldy == tile.y)){ Tile toplace = world.tile(worldx, worldy); if(toplace != null){ - toplace.setLinked((byte) (dx + offsetx), (byte) (dy + offsety)); + toplace.setLinked((byte)(dx + offsetx), (byte)(dy + offsety)); toplace.setTeam(team); } } @@ -341,7 +332,7 @@ public class World implements ApplicationListener{ if(!Structs.inBounds(x, y, oldWidth, oldHeight)) return -1; x += shiftX; y += shiftY; - return y*newWidth + x; + return y * newWidth + x; } /** @@ -349,12 +340,11 @@ public class World implements ApplicationListener{ */ public Point2 raycastWorld(float x, float y, float x2, float y2){ return raycast(Math.round(x / tilesize), Math.round(y / tilesize), - Math.round(x2 / tilesize), Math.round(y2 / tilesize)); + Math.round(x2 / tilesize), Math.round(y2 / tilesize)); } /** * Input is in block coordinates, not world coordinates. - * * @return null if no collisions found, block position otherwise. */ public Point2 raycast(int x0f, int y0f, int x1, int y1){ @@ -422,7 +412,7 @@ public class World implements ApplicationListener{ } } - /**Loads raw map tile data into a Tile[][] array, setting up multiblocks, cliffs and ores. */ + /** Loads raw map tile data into a Tile[][] array, setting up multiblocks, cliffs and ores. */ void loadTileData(Tile[][] tiles){ prepareTiles(tiles); } @@ -471,10 +461,12 @@ public class World implements ApplicationListener{ } } - /**'Prepares' a tile array by:
+ /** + * 'Prepares' a tile array by:
* - setting up multiblocks
* - updating occlusion
- * Usually used before placing structures on a tile array.*/ + * Usually used before placing structures on a tile array. + */ public void prepareTiles(Tile[][] tiles){ //find multiblocks @@ -510,7 +502,7 @@ public class World implements ApplicationListener{ if(!(worldx == x && worldy == y)){ Tile toplace = world.tile(worldx, worldy); if(toplace != null){ - toplace.setLinked((byte) (dx + offsetx), (byte) (dy + offsety)); + toplace.setLinked((byte)(dx + offsetx), (byte)(dy + offsety)); toplace.setTeam(team); } } diff --git a/core/src/io/anuke/mindustry/editor/EditorTile.java b/core/src/io/anuke/mindustry/editor/EditorTile.java index c1ee9aef4a..f38b4309a4 100644 --- a/core/src/io/anuke/mindustry/editor/EditorTile.java +++ b/core/src/io/anuke/mindustry/editor/EditorTile.java @@ -8,10 +8,7 @@ import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.blocks.Floor; import io.anuke.mindustry.world.blocks.OreBlock; -import io.anuke.mindustry.world.modules.ConsumeModule; -import io.anuke.mindustry.world.modules.ItemModule; -import io.anuke.mindustry.world.modules.LiquidModule; -import io.anuke.mindustry.world.modules.PowerModule; +import io.anuke.mindustry.world.modules.*; import static io.anuke.mindustry.Vars.ui; @@ -49,7 +46,7 @@ public class EditorTile extends Tile{ @Override public void setBlock(Block type){ - Block previous =wall; + Block previous = wall; if(previous == type) return; super.setBlock(type); op(TileOp.get(x, y, (byte)OpType.block.ordinal(), previous.id, type.id)); diff --git a/core/src/io/anuke/mindustry/editor/EditorTool.java b/core/src/io/anuke/mindustry/editor/EditorTool.java index b5299f2901..19c289a498 100644 --- a/core/src/io/anuke/mindustry/editor/EditorTool.java +++ b/core/src/io/anuke/mindustry/editor/EditorTool.java @@ -7,12 +7,8 @@ import io.anuke.arc.input.KeyCode; import io.anuke.arc.util.Pack; import io.anuke.arc.util.Structs; import io.anuke.mindustry.content.Blocks; -import io.anuke.mindustry.world.Block; -import io.anuke.mindustry.world.Pos; -import io.anuke.mindustry.world.Tile; -import io.anuke.mindustry.world.blocks.BlockPart; -import io.anuke.mindustry.world.blocks.Floor; -import io.anuke.mindustry.world.blocks.OreBlock; +import io.anuke.mindustry.world.*; +import io.anuke.mindustry.world.blocks.*; public enum EditorTool{ pick{ diff --git a/core/src/io/anuke/mindustry/editor/MapEditor.java b/core/src/io/anuke/mindustry/editor/MapEditor.java index 6908829509..e74128be2b 100644 --- a/core/src/io/anuke/mindustry/editor/MapEditor.java +++ b/core/src/io/anuke/mindustry/editor/MapEditor.java @@ -68,7 +68,7 @@ public class MapEditor{ //adds missing blockparts public void checkLinkedTiles(){ //clear block parts first - for(int x = 0; x < width(); x ++){ + for(int x = 0; x < width(); x++){ for(int y = 0; y < height(); y++){ if(tiles[x][y].block() == Blocks.part){ tiles[x][y].setBlock(Blocks.air); @@ -78,8 +78,8 @@ public class MapEditor{ } //set up missing blockparts - for(int x = 0; x < width(); x ++){ - for(int y = 0; y < height(); y ++){ + for(int x = 0; x < width(); x++){ + for(int y = 0; y < height(); y++){ Block drawBlock = tiles[x][y].block(); if(drawBlock.isMultiblock()){ int offsetx = -(drawBlock.size - 1) / 2; @@ -92,7 +92,7 @@ public class MapEditor{ if(Structs.inBounds(worldx, worldy, width(), height()) && !(dx + offsetx == 0 && dy + offsety == 0)){ Tile tile = tiles[worldx][worldy]; tile.setBlock(Blocks.part); - tile.setLinkByte(Pack.byteByte((byte) (dx + offsetx + 8), (byte) (dy + offsety + 8))); + tile.setLinkByte(Pack.byteByte((byte)(dx + offsetx + 8), (byte)(dy + offsety + 8))); } } } @@ -107,7 +107,7 @@ public class MapEditor{ loading = false; } - /**Creates a 2-D array of EditorTiles with stone as the floor block.*/ + /** Creates a 2-D array of EditorTiles with stone as the floor block. */ public Tile[][] createTiles(int width, int height){ tiles = new Tile[width][height]; @@ -179,9 +179,9 @@ public class MapEditor{ boolean isfloor = drawBlock instanceof Floor && drawBlock != Blocks.air; if(drawBlock.isMultiblock()){ - - x = Mathf.clamp(x, (drawBlock.size-1)/2, width() - drawBlock.size/2 - 1); - y = Mathf.clamp(y, (drawBlock.size-1)/2, height() - drawBlock.size/2 - 1); + + x = Mathf.clamp(x, (drawBlock.size - 1) / 2, width() - drawBlock.size / 2 - 1); + y = Mathf.clamp(y, (drawBlock.size - 1) / 2, height() - drawBlock.size / 2 - 1); int offsetx = -(drawBlock.size - 1) / 2; int offsety = -(drawBlock.size - 1) / 2; @@ -197,7 +197,7 @@ public class MapEditor{ if(i == 1){ tile.setBlock(Blocks.part); - tile.setLinkByte(Pack.byteByte((byte) (dx + offsetx + 8), (byte) (dy + offsety + 8))); + tile.setLinkByte(Pack.byteByte((byte)(dx + offsetx + 8), (byte)(dy + offsety + 8))); }else{ byte link = tile.getLinkByte(); Block block = tile.block(); @@ -279,7 +279,7 @@ public class MapEditor{ clearOp(); Tile[][] previous = tiles; - int offsetX = -(width - width())/2, offsetY = -(height - height())/2; + int offsetX = -(width - width()) / 2, offsetY = -(height - height()) / 2; loading = true; tiles = new Tile[width][height]; diff --git a/core/src/io/anuke/mindustry/editor/MapEditorDialog.java b/core/src/io/anuke/mindustry/editor/MapEditorDialog.java index 58b3ba8564..47123c1947 100644 --- a/core/src/io/anuke/mindustry/editor/MapEditorDialog.java +++ b/core/src/io/anuke/mindustry/editor/MapEditorDialog.java @@ -85,49 +85,49 @@ public class MapEditorDialog extends Dialog implements Disposable{ t.row(); t.addImageTextButton("$editor.import", "icon-load-map", isize, () -> - createDialog("$editor.import", - "$editor.importmap", "$editor.importmap.description", "icon-load-map", (Runnable) loadDialog::show, - "$editor.importfile", "$editor.importfile.description", "icon-file", (Runnable) () -> - Platform.instance.showFileChooser("$editor.loadmap", "Map Files", file -> ui.loadAnd(() -> { - try{ - //TODO what if it's an image? users should be warned for their stupidity - editor.beginEdit(MapIO.readMap(file, true)); - }catch(Exception e){ - ui.showError(Core.bundle.format("editor.errorload", Strings.parseException(e, false))); - Log.err(e); - } - }), true, mapExtension), + createDialog("$editor.import", + "$editor.importmap", "$editor.importmap.description", "icon-load-map", (Runnable)loadDialog::show, + "$editor.importfile", "$editor.importfile.description", "icon-file", (Runnable)() -> + Platform.instance.showFileChooser("$editor.loadmap", "Map Files", file -> ui.loadAnd(() -> { + try{ + //TODO what if it's an image? users should be warned for their stupidity + editor.beginEdit(MapIO.readMap(file, true)); + }catch(Exception e){ + ui.showError(Core.bundle.format("editor.errorload", Strings.parseException(e, false))); + Log.err(e); + } + }), true, mapExtension), - "$editor.importimage", "$editor.importimage.description", "icon-file-image", (Runnable)() -> - Platform.instance.showFileChooser("$loadimage", "Image Files", file -> - ui.loadAnd(() -> { - try{ - Pixmap pixmap = new Pixmap(file); - Tile[][] tiles = editor.createTiles(pixmap.getWidth(), pixmap.getHeight()); - editor.load(() -> MapIO.readLegacyPixmap(pixmap, tiles)); - editor.beginEdit(tiles); - }catch (Exception e){ - ui.showError(Core.bundle.format("editor.errorload", Strings.parseException(e, false))); - Log.err(e); - } - }), true, "png"))); + "$editor.importimage", "$editor.importimage.description", "icon-file-image", (Runnable)() -> + Platform.instance.showFileChooser("$loadimage", "Image Files", file -> + ui.loadAnd(() -> { + try{ + Pixmap pixmap = new Pixmap(file); + Tile[][] tiles = editor.createTiles(pixmap.getWidth(), pixmap.getHeight()); + editor.load(() -> MapIO.readLegacyPixmap(pixmap, tiles)); + editor.beginEdit(tiles); + }catch(Exception e){ + ui.showError(Core.bundle.format("editor.errorload", Strings.parseException(e, false))); + Log.err(e); + } + }), true, "png"))); t.addImageTextButton("$editor.export", "icon-save-map", isize, () -> - Platform.instance.showFileChooser("$editor.savemap", "Map Files", file -> { - file = file.parent().child(file.nameWithoutExtension() + "." + mapExtension); - FileHandle result = file; - ui.loadAnd(() -> { - try{ - if(!editor.getTags().containsKey("name")){ - editor.getTags().put("name", result.nameWithoutExtension()); - } - MapIO.writeMap(result, editor.createMap(result), editor.tiles()); - }catch(Exception e){ - ui.showError(Core.bundle.format("editor.errorsave", Strings.parseException(e, false))); - Log.err(e); - } - }); - }, false, mapExtension)); + Platform.instance.showFileChooser("$editor.savemap", "Map Files", file -> { + file = file.parent().child(file.nameWithoutExtension() + "." + mapExtension); + FileHandle result = file; + ui.loadAnd(() -> { + try{ + if(!editor.getTags().containsKey("name")){ + editor.getTags().put("name", result.nameWithoutExtension()); + } + MapIO.writeMap(result, editor.createMap(result), editor.tiles()); + }catch(Exception e){ + ui.showError(Core.bundle.format("editor.errorsave", Strings.parseException(e, false))); + Log.err(e); + } + }); + }, false, mapExtension)); }); menu.cont.row(); @@ -146,14 +146,14 @@ public class MapEditorDialog extends Dialog implements Disposable{ }); loadDialog = new MapLoadDialog(map -> - ui.loadAnd(() -> { - try{ - editor.beginEdit(map); - }catch(Exception e){ - ui.showError(Core.bundle.format("editor.errorload", Strings.parseException(e, false))); - Log.err(e); - } - })); + ui.loadAnd(() -> { + try{ + editor.beginEdit(map); + }catch(Exception e){ + ui.showError(Core.bundle.format("editor.errorload", Strings.parseException(e, false))); + Log.err(e); + } + })); setFillParent(true); @@ -239,10 +239,10 @@ public class MapEditorDialog extends Dialog implements Disposable{ dialog.cont.defaults().size(360f, h).padBottom(5).padRight(5).padLeft(5); for(int i = 0; i < arguments.length; i += 4){ - String name = (String) arguments[i]; - String description = (String) arguments[i + 1]; - String iconname = (String) arguments[i + 2]; - Runnable listenable = (Runnable) arguments[i + 3]; + String name = (String)arguments[i]; + String description = (String)arguments[i + 1]; + String iconname = (String)arguments[i + 2]; + Runnable listenable = (Runnable)arguments[i + 3]; TextButton button = dialog.cont.addButton(name, () -> { listenable.run(); @@ -306,8 +306,8 @@ public class MapEditorDialog extends Dialog implements Disposable{ public void build(){ float amount = 10f, baseSize = 60f; - float size = mobile ? (int) (Math.min(Core.graphics.getHeight(), Core.graphics.getWidth()) / amount / Unit.dp.scl(1f)) : - Math.min(Core.graphics.getDisplayMode().height / amount, baseSize); + float size = mobile ? (int)(Math.min(Core.graphics.getHeight(), Core.graphics.getWidth()) / amount / Unit.dp.scl(1f)) : + Math.min(Core.graphics.getDisplayMode().height / amount, baseSize); clearChildren(); table(cont -> { @@ -374,7 +374,7 @@ public class MapEditorDialog extends Dialog implements Disposable{ tools.row(); tools.table("underline", t -> t.add("$editor.teams")) - .colspan(3).height(40).width(size * 3f + 3f).padBottom(3); + .colspan(3).height(40).width(size * 3f + 3f).padBottom(3); tools.row(); @@ -401,7 +401,7 @@ public class MapEditorDialog extends Dialog implements Disposable{ mid.table("underline", t -> { Slider slider = new Slider(0, MapEditor.brushSizes.length - 1, 1, false); - slider.moved(f -> editor.brushSize = MapEditor.brushSizes[(int) (float) f]); + slider.moved(f -> editor.brushSize = MapEditor.brushSizes[(int)(float)f]); t.top(); t.add("$editor.brush"); diff --git a/core/src/io/anuke/mindustry/editor/MapGenerateDialog.java b/core/src/io/anuke/mindustry/editor/MapGenerateDialog.java index 22484498bc..70226b724e 100644 --- a/core/src/io/anuke/mindustry/editor/MapGenerateDialog.java +++ b/core/src/io/anuke/mindustry/editor/MapGenerateDialog.java @@ -62,7 +62,7 @@ public class MapGenerateDialog extends FloatingDialog{ update(); }).size(160f, 64f); - buttons.addImageTextButton("$add", "icon-add", 14*2, this::showAdd).height(64f).width(140f); + buttons.addImageTextButton("$add", "icon-add", 14 * 2, this::showAdd).height(64f).width(140f); } void setup(){ @@ -120,24 +120,24 @@ public class MapGenerateDialog extends FloatingDialog{ t.table(b -> { b.left(); b.defaults().size(50f); - b.addImageButton("icon-refresh", 14*2, () -> { + b.addImageButton("icon-refresh", 14 * 2, () -> { filter.randomize(); update(); }); - b.addImageButton("icon-arrow-up", 10*2, () -> { + b.addImageButton("icon-arrow-up", 10 * 2, () -> { int idx = filters.indexOf(filter); filters.swap(idx, Math.max(0, idx - 1)); rebuildFilters(); update(); }); - b.addImageButton("icon-arrow-down", 10*2, () -> { + b.addImageButton("icon-arrow-down", 10 * 2, () -> { int idx = filters.indexOf(filter); - filters.swap(idx, Math.min(filters.size-1, idx + 1)); + filters.swap(idx, Math.min(filters.size - 1, idx + 1)); rebuildFilters(); update(); }); - b.addImageButton("icon-trash", 14*2, () -> { + b.addImageButton("icon-trash", 14 * 2, () -> { filters.remove(filter); rebuildFilters(); update(); diff --git a/core/src/io/anuke/mindustry/editor/MapLoadDialog.java b/core/src/io/anuke/mindustry/editor/MapLoadDialog.java index edca8d7868..de02642f9c 100644 --- a/core/src/io/anuke/mindustry/editor/MapLoadDialog.java +++ b/core/src/io/anuke/mindustry/editor/MapLoadDialog.java @@ -1,14 +1,12 @@ package io.anuke.mindustry.editor; +import io.anuke.arc.function.Consumer; +import io.anuke.arc.scene.ui.*; +import io.anuke.arc.scene.ui.layout.Table; import io.anuke.arc.util.Scaling; import io.anuke.mindustry.maps.Map; import io.anuke.mindustry.ui.BorderImage; import io.anuke.mindustry.ui.dialogs.FloatingDialog; -import io.anuke.arc.function.Consumer; -import io.anuke.arc.scene.ui.ButtonGroup; -import io.anuke.arc.scene.ui.ScrollPane; -import io.anuke.arc.scene.ui.TextButton; -import io.anuke.arc.scene.ui.layout.Table; import static io.anuke.mindustry.Vars.world; diff --git a/core/src/io/anuke/mindustry/editor/MapRenderer.java b/core/src/io/anuke/mindustry/editor/MapRenderer.java index a429e0dd9f..35dd3c803a 100644 --- a/core/src/io/anuke/mindustry/editor/MapRenderer.java +++ b/core/src/io/anuke/mindustry/editor/MapRenderer.java @@ -40,7 +40,7 @@ public class MapRenderer implements Disposable{ } } - chunks = new IndexedRenderer[(int) Math.ceil((float) width / chunksize)][(int) Math.ceil((float) height / chunksize)]; + chunks = new IndexedRenderer[(int)Math.ceil((float)width / chunksize)][(int)Math.ceil((float)height / chunksize)]; for(int x = 0; x < chunks.length; x++){ for(int y = 0; y < chunks[0].length; y++){ @@ -115,38 +115,38 @@ public class MapRenderer implements Disposable{ if(wall.rotate){ mesh.draw(idxWall, region, - wx * tilesize + wall.offset(), wy * tilesize + wall.offset(), - region.getWidth() * Draw.scl, region.getHeight() * Draw.scl, tile.getRotation() * 90 - 90); + wx * tilesize + wall.offset(), wy * tilesize + wall.offset(), + region.getWidth() * Draw.scl, region.getHeight() * Draw.scl, tile.getRotation() * 90 - 90); }else{ mesh.draw(idxWall, region, - wx * tilesize + wall.offset() + (tilesize - region.getWidth() * Draw.scl)/2f, - wy * tilesize + wall.offset() + (tilesize - region.getHeight() * Draw.scl)/2f, - region.getWidth() * Draw.scl, region.getHeight() * Draw.scl); + wx * tilesize + wall.offset() + (tilesize - region.getWidth() * Draw.scl) / 2f, + wy * tilesize + wall.offset() + (tilesize - region.getHeight() * Draw.scl) / 2f, + region.getWidth() * Draw.scl, region.getHeight() * Draw.scl); } }else{ - region = floor.editorVariantRegions()[Mathf.randomSeed(idxWall, 0, floor.editorVariantRegions().length-1)]; + region = floor.editorVariantRegions()[Mathf.randomSeed(idxWall, 0, floor.editorVariantRegions().length - 1)]; mesh.draw(idxWall, region, wx * tilesize, wy * tilesize, 8, 8); } - float offsetX = -(wall.size/3)*tilesize, offsetY = -(wall.size/3) * tilesize; + float offsetX = -(wall.size / 3) * tilesize, offsetY = -(wall.size / 3) * tilesize; if(wall.update || wall.destructible){ mesh.setColor(team.color); region = Core.atlas.find("block-border-editor"); }else if(!wall.synthetic() && wall != Blocks.air){ region = !Core.atlas.isFound(wall.editorIcon()) ? Core.atlas.find("clear-editor") : wall.editorIcon(); - offsetX = tilesize/2f - region.getWidth()/2f * Draw.scl; - offsetY = tilesize/2f - region.getHeight()/2f * Draw.scl; + offsetX = tilesize / 2f - region.getWidth() / 2f * Draw.scl; + offsetY = tilesize / 2f - region.getHeight() / 2f * Draw.scl; }else if(wall == Blocks.air && tile.ore() != null){ - region = tile.ore().editorVariantRegions()[Mathf.randomSeed(idxWall, 0, tile.ore().editorVariantRegions().length-1)]; + region = tile.ore().editorVariantRegions()[Mathf.randomSeed(idxWall, 0, tile.ore().editorVariantRegions().length - 1)]; }else{ region = Core.atlas.find("clear-editor"); } mesh.draw(idxDecal, region, - wx * tilesize + offsetX, wy * tilesize + offsetY, - region.getWidth() * Draw.scl, region.getHeight() * Draw.scl); + wx * tilesize + offsetX, wy * tilesize + offsetY, + region.getWidth() * Draw.scl, region.getHeight() * Draw.scl); mesh.setColor(Color.WHITE); } diff --git a/core/src/io/anuke/mindustry/editor/MapSaveDialog.java b/core/src/io/anuke/mindustry/editor/MapSaveDialog.java index bcac2914e9..57ed966a0a 100644 --- a/core/src/io/anuke/mindustry/editor/MapSaveDialog.java +++ b/core/src/io/anuke/mindustry/editor/MapSaveDialog.java @@ -1,11 +1,11 @@ package io.anuke.mindustry.editor; -import io.anuke.mindustry.core.Platform; -import io.anuke.mindustry.maps.Map; -import io.anuke.mindustry.ui.dialogs.FloatingDialog; import io.anuke.arc.function.Consumer; import io.anuke.arc.scene.ui.TextButton; import io.anuke.arc.scene.ui.TextField; +import io.anuke.mindustry.core.Platform; +import io.anuke.mindustry.maps.Map; +import io.anuke.mindustry.ui.dialogs.FloatingDialog; import static io.anuke.mindustry.Vars.ui; import static io.anuke.mindustry.Vars.world; diff --git a/core/src/io/anuke/mindustry/editor/MapView.java b/core/src/io/anuke/mindustry/editor/MapView.java index 9b4ccef3ff..4503304907 100644 --- a/core/src/io/anuke/mindustry/editor/MapView.java +++ b/core/src/io/anuke/mindustry/editor/MapView.java @@ -3,18 +3,14 @@ package io.anuke.mindustry.editor; import io.anuke.arc.Core; import io.anuke.arc.collection.Array; import io.anuke.arc.graphics.Color; -import io.anuke.arc.graphics.g2d.Draw; -import io.anuke.arc.graphics.g2d.Lines; -import io.anuke.arc.graphics.g2d.ScissorStack; +import io.anuke.arc.graphics.g2d.*; import io.anuke.arc.input.GestureDetector; import io.anuke.arc.input.GestureDetector.GestureListener; import io.anuke.arc.input.KeyCode; import io.anuke.arc.math.Mathf; import io.anuke.arc.math.geom.*; import io.anuke.arc.scene.Element; -import io.anuke.arc.scene.event.InputEvent; -import io.anuke.arc.scene.event.InputListener; -import io.anuke.arc.scene.event.Touchable; +import io.anuke.arc.scene.event.*; import io.anuke.arc.scene.ui.TextField; import io.anuke.arc.scene.ui.layout.Unit; import io.anuke.arc.util.Tmp; @@ -69,6 +65,7 @@ public class MapView extends Element implements GestureListener{ return false; } + @Override public boolean touchDown(InputEvent event, float x, float y, int pointer, KeyCode button){ if(pointer != 0){ @@ -196,7 +193,7 @@ public class MapView extends Element implements GestureListener{ super.act(delta); if(Core.scene.getKeyboardFocus() == null || !(Core.scene.getKeyboardFocus() instanceof TextField) && - !Core.input.keyDown(KeyCode.CONTROL_LEFT)){ + !Core.input.keyDown(KeyCode.CONTROL_LEFT)){ float ax = Core.input.axis(Binding.move_x); float ay = Core.input.axis(Binding.move_y); offsetx -= ax * 15f / zoom; @@ -224,7 +221,7 @@ public class MapView extends Element implements GestureListener{ } private Point2 project(float x, float y){ - float ratio = 1f / ((float) editor.width() / editor.height()); + float ratio = 1f / ((float)editor.width() / editor.height()); float size = Math.min(width, height); float sclwidth = size * zoom; float sclheight = size * zoom * ratio; @@ -232,26 +229,26 @@ public class MapView extends Element implements GestureListener{ y = (y - getHeight() / 2 + sclheight / 2 - offsety * zoom) / sclheight * editor.height(); if(editor.drawBlock.size % 2 == 0 && tool != EditorTool.eraser){ - return Tmp.g1.set((int) (x - 0.5f), (int) (y - 0.5f)); + return Tmp.g1.set((int)(x - 0.5f), (int)(y - 0.5f)); }else{ - return Tmp.g1.set((int) x, (int) y); + return Tmp.g1.set((int)x, (int)y); } } private Vector2 unproject(int x, int y){ - float ratio = 1f / ((float) editor.width() / editor.height()); + float ratio = 1f / ((float)editor.width() / editor.height()); float size = Math.min(width, height); float sclwidth = size * zoom; float sclheight = size * zoom * ratio; - float px = ((float) x / editor.width()) * sclwidth + offsetx * zoom - sclwidth / 2 + getWidth() / 2; - float py = ((float) (y) / editor.height()) * sclheight - + offsety * zoom - sclheight / 2 + getHeight() / 2; + float px = ((float)x / editor.width()) * sclwidth + offsetx * zoom - sclwidth / 2 + getWidth() / 2; + float py = ((float)(y) / editor.height()) * sclheight + + offsety * zoom - sclheight / 2 + getHeight() / 2; return vec.set(px, py); } @Override public void draw(){ - float ratio = 1f / ((float) editor.width() / editor.height()); + float ratio = 1f / ((float)editor.width() / editor.height()); float size = Math.min(width, height); float sclwidth = size * zoom; float sclheight = size * zoom * ratio; @@ -317,9 +314,9 @@ public class MapView extends Element implements GestureListener{ Vector2 v = unproject(p.x, p.y).add(x, y); float offset = (editor.drawBlock.size % 2 == 0 ? scaling / 2f : 0f); Lines.square( - v.x + scaling / 2f + offset, - v.y + scaling / 2f + offset, - scaling * editor.drawBlock.size / 2f); + v.x + scaling / 2f + offset, + v.y + scaling / 2f + offset, + scaling * editor.drawBlock.size / 2f); } } @@ -334,9 +331,9 @@ public class MapView extends Element implements GestureListener{ private boolean active(){ return Core.scene.getKeyboardFocus() != null - && Core.scene.getKeyboardFocus().isDescendantOf(ui.editor) - && ui.editor.isShown() && tool == EditorTool.zoom && - Core.scene.hit(Core.input.mouse().x, Core.input.mouse().y, true) == this; + && Core.scene.getKeyboardFocus().isDescendantOf(ui.editor) + && ui.editor.isShown() && tool == EditorTool.zoom && + Core.scene.hit(Core.input.mouse().x, Core.input.mouse().y, true) == this; } @Override diff --git a/core/src/io/anuke/mindustry/editor/WaveInfoDialog.java b/core/src/io/anuke/mindustry/editor/WaveInfoDialog.java index 8c407c7d5d..f27aad6897 100644 --- a/core/src/io/anuke/mindustry/editor/WaveInfoDialog.java +++ b/core/src/io/anuke/mindustry/editor/WaveInfoDialog.java @@ -7,9 +7,7 @@ import io.anuke.arc.input.KeyCode; import io.anuke.arc.math.Mathf; import io.anuke.arc.scene.ui.TextField.TextFieldFilter; import io.anuke.arc.scene.ui.layout.Table; -import io.anuke.arc.util.Align; -import io.anuke.arc.util.Strings; -import io.anuke.arc.util.Time; +import io.anuke.arc.util.*; import io.anuke.mindustry.Vars; import io.anuke.mindustry.content.StatusEffects; import io.anuke.mindustry.content.UnitTypes; @@ -47,7 +45,7 @@ public class WaveInfoDialog extends FloatingDialog{ }); keyDown(key -> { - if(key == KeyCode.ESCAPE || key == KeyCode.BACK) { + if(key == KeyCode.ESCAPE || key == KeyCode.BACK){ Core.app.post(this::hide); } }); @@ -74,7 +72,7 @@ public class WaveInfoDialog extends FloatingDialog{ dialog.hide(); }).disabled(b -> Core.app.getClipboard().getContents() == null || Core.app.getClipboard().getContents().isEmpty()); dialog.cont.row(); - dialog.cont.addButton("$settings.reset", () -> ui.showConfirm("$confirm", "$settings.clear.confirm", () ->{ + dialog.cont.addButton("$settings.reset", () -> ui.showConfirm("$confirm", "$settings.clear.confirm", () -> { groups = null; buildGroups(); dialog.hide(); @@ -100,7 +98,8 @@ public class WaveInfoDialog extends FloatingDialog{ cont.table("clear", m -> { m.add("$waves.preview").color(Color.LIGHT_GRAY).growX().center().get().setAlignment(Align.center, Align.center); m.row(); - m.addButton("-", () -> {}).update(t -> { + m.addButton("-", () -> { + }).update(t -> { if(t.getClickListener().isPressed()){ updateTimer += Time.delta(); if(updateTimer >= updatePeriod){ @@ -113,11 +112,12 @@ public class WaveInfoDialog extends FloatingDialog{ m.row(); m.pane(t -> preview = t).grow().get().setScrollingDisabled(true, false); m.row(); - m.addButton("+", () -> {}).update(t -> { + m.addButton("+", () -> { + }).update(t -> { if(t.getClickListener().isPressed()){ updateTimer += Time.delta(); if(updateTimer >= updatePeriod){ - start ++; + start++; updateTimer = 0f; updateWaves(); } @@ -146,10 +146,10 @@ public class WaveInfoDialog extends FloatingDialog{ t.row(); t.table(spawns -> { spawns.addField("" + (group.begin + 1), TextFieldFilter.digitsOnly, text -> { - if(Strings.canParsePostiveInt(text)){ - group.begin = Strings.parseInt(text) - 1; - updateWaves(); - } + if(Strings.canParsePostiveInt(text)){ + group.begin = Strings.parseInt(text) - 1; + updateWaves(); + } }).width(100f); spawns.add("$waves.to").padLeft(4).padRight(4); spawns.addField(group.end == never ? "" : (group.end + 1) + "", TextFieldFilter.digitsOnly, text -> { @@ -184,7 +184,7 @@ public class WaveInfoDialog extends FloatingDialog{ }).width(80f); a.add(" + "); - a.addField(Strings.fixed(Math.max((Mathf.isZero(group.unitScaling) ? 0 : 1f/group.unitScaling), 0), 2), TextFieldFilter.floatsOnly, text -> { + a.addField(Strings.fixed(Math.max((Mathf.isZero(group.unitScaling) ? 0 : 1f / group.unitScaling), 0), 2), TextFieldFilter.floatsOnly, text -> { if(Strings.canParsePositiveFloat(text)){ group.unitScaling = 1f / Strings.parseFloat(text); updateWaves(); @@ -228,7 +228,7 @@ public class WaveInfoDialog extends FloatingDialog{ dialog.hide(); buildGroups(); }).pad(2).margin(12f).fillX(); - if(++i % 3 == 0)dialog.cont.row(); + if(++i % 3 == 0) dialog.cont.row(); } dialog.show(); } @@ -239,10 +239,10 @@ public class WaveInfoDialog extends FloatingDialog{ Array groups = (this.groups == null ? DefaultWaves.get() : this.groups); - for(int i = start; i < displayed + start; i ++){ + for(int i = start; i < displayed + start; i++){ int wave = i; preview.table("underline", table -> { - table.add((wave+1) + "").color(Pal.accent).center().colspan(2).get().setAlignment(Align.center, Align.center); + table.add((wave + 1) + "").color(Pal.accent).center().colspan(2).get().setAlignment(Align.center, Align.center); table.row(); int[] spawned = new int[Vars.content.getBy(ContentType.unit).size]; diff --git a/core/src/io/anuke/mindustry/editor/generation/DistortFilter.java b/core/src/io/anuke/mindustry/editor/generation/DistortFilter.java index ebd969845b..f2233be7bf 100644 --- a/core/src/io/anuke/mindustry/editor/generation/DistortFilter.java +++ b/core/src/io/anuke/mindustry/editor/generation/DistortFilter.java @@ -11,14 +11,14 @@ public class DistortFilter extends GenerateFilter{ { options( - new SliderOption("scale", () -> scl, f -> scl = f, 1f, 400f), - new SliderOption("mag", () -> mag, f -> mag = f, 0.5f, 100f) + new SliderOption("scale", () -> scl, f -> scl = f, 1f, 400f), + new SliderOption("mag", () -> mag, f -> mag = f, 0.5f, 100f) ); } @Override public void apply(){ - DummyTile tile = in.tile(in.x / (in.scaling) + (noise(in.x, in.y, scl, mag)-mag/2f)/in.scaling, in.y / (in.scaling) + (noise(in.x, in.y+o, scl, mag)-mag/2f)/in.scaling); + DummyTile tile = in.tile(in.x / (in.scaling) + (noise(in.x, in.y, scl, mag) - mag / 2f) / in.scaling, in.y / (in.scaling) + (noise(in.x, in.y + o, scl, mag) - mag / 2f) / in.scaling); in.floor = content.block(tile.floor); if(!content.block(tile.block).synthetic() && !in.block.synthetic()) in.block = content.block(tile.block); diff --git a/core/src/io/anuke/mindustry/editor/generation/FilterOption.java b/core/src/io/anuke/mindustry/editor/generation/FilterOption.java index 8ebad34254..0973af4e29 100644 --- a/core/src/io/anuke/mindustry/editor/generation/FilterOption.java +++ b/core/src/io/anuke/mindustry/editor/generation/FilterOption.java @@ -20,7 +20,9 @@ public abstract class FilterOption{ public static final Predicate oresOnly = b -> b instanceof OreBlock && Core.atlas.isFound(b.icon(Icon.full)); public abstract void build(Table table); - public Runnable changed = () -> {}; + + public Runnable changed = () -> { + }; static class SliderOption extends FilterOption{ final String name; @@ -40,7 +42,7 @@ public abstract class FilterOption{ public void build(Table table){ table.add("$filter.option." + name); table.row(); - Slider slider = table.addSlider(min, max, (max-min)/200f, setter).growX().get(); + Slider slider = table.addSlider(min, max, (max - min) / 200f, setter).growX().get(); slider.setValue(getter.get()); if(updateEditorOnChange){ slider.changed(changed); @@ -65,14 +67,14 @@ public abstract class FilterOption{ @Override public void build(Table table){ - table.addButton(b -> b.addImage(supplier.get().icon(Icon.small)).update(i -> ((TextureRegionDrawable)i.getDrawable()).setRegion(supplier.get().icon(Icon.small))).size(8*3), () -> { + table.addButton(b -> b.addImage(supplier.get().icon(Icon.small)).update(i -> ((TextureRegionDrawable)i.getDrawable()).setRegion(supplier.get().icon(Icon.small))).size(8 * 3), () -> { FloatingDialog dialog = new FloatingDialog(""); dialog.setFillParent(false); int i = 0; for(Block block : Vars.content.blocks()){ if(!filter.test(block)) continue; - dialog.cont.addImage(block.icon(Icon.medium)).size(8*4).pad(3).get().clicked(() -> { + dialog.cont.addImage(block.icon(Icon.medium)).size(8 * 4).pad(3).get().clicked(() -> { consumer.accept(block); dialog.hide(); changed.run(); diff --git a/core/src/io/anuke/mindustry/editor/generation/GenerateFilter.java b/core/src/io/anuke/mindustry/editor/generation/GenerateFilter.java index b6bde0d4de..837787c779 100644 --- a/core/src/io/anuke/mindustry/editor/generation/GenerateFilter.java +++ b/core/src/io/anuke/mindustry/editor/generation/GenerateFilter.java @@ -11,7 +11,7 @@ import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.blocks.Floor; public abstract class GenerateFilter{ - protected float o = (float)(Math.random()*10000000.0); + protected float o = (float)(Math.random() * 10000000.0); protected long seed; protected GenerateInput in; @@ -20,15 +20,15 @@ public abstract class GenerateFilter{ protected abstract void apply(); protected float noise(float x, float y, float scl, float mag){ - return (float)in.noise.octaveNoise2D(1f, 0f, 1f/scl, x + o, y + o)*mag; + return (float)in.noise.octaveNoise2D(1f, 0f, 1f / scl, x + o, y + o) * mag; } protected float noise(float x, float y, float scl, float mag, float octaves, float persistence){ - return (float)in.noise.octaveNoise2D(octaves, persistence, 1f/scl, x + o, y + o)*mag; + return (float)in.noise.octaveNoise2D(octaves, persistence, 1f / scl, x + o, y + o) * mag; } protected float rnoise(float x, float y, float scl, float mag){ - return in.pnoise.getValue((int)(x + o), (int)(y + o), 1f/scl)*mag; + return in.pnoise.getValue((int)(x + o), (int)(y + o), 1f / scl) * mag; } public void randomize(){ diff --git a/core/src/io/anuke/mindustry/editor/generation/NoiseFilter.java b/core/src/io/anuke/mindustry/editor/generation/NoiseFilter.java index 580c6331a2..6a6871df91 100644 --- a/core/src/io/anuke/mindustry/editor/generation/NoiseFilter.java +++ b/core/src/io/anuke/mindustry/editor/generation/NoiseFilter.java @@ -14,12 +14,12 @@ public class NoiseFilter extends GenerateFilter{ { options( - new SliderOption("scale", () -> scl, f -> scl = f, 1f, 500f), - new SliderOption("threshold", () -> threshold, f -> threshold = f, 0f, 1f), - new SliderOption("octaves", () -> octaves, f -> octaves = f, 1f, 10f), - new SliderOption("falloff", () -> falloff, f -> falloff = f, 0f, 1f), - new BlockOption("floor", () -> floor, b -> floor = b, floorsOnly), - new BlockOption("wall", () -> block, b -> block = b, wallsOnly) + new SliderOption("scale", () -> scl, f -> scl = f, 1f, 500f), + new SliderOption("threshold", () -> threshold, f -> threshold = f, 0f, 1f), + new SliderOption("octaves", () -> octaves, f -> octaves = f, 1f, 10f), + new SliderOption("falloff", () -> falloff, f -> falloff = f, 0f, 1f), + new BlockOption("floor", () -> floor, b -> floor = b, floorsOnly), + new BlockOption("wall", () -> block, b -> block = b, wallsOnly) ); } diff --git a/core/src/io/anuke/mindustry/editor/generation/OreFilter.java b/core/src/io/anuke/mindustry/editor/generation/OreFilter.java index f0b4304884..999661a705 100644 --- a/core/src/io/anuke/mindustry/editor/generation/OreFilter.java +++ b/core/src/io/anuke/mindustry/editor/generation/OreFilter.java @@ -4,7 +4,8 @@ import io.anuke.mindustry.content.Blocks; import io.anuke.mindustry.editor.generation.FilterOption.SliderOption; import io.anuke.mindustry.world.Block; -import static io.anuke.mindustry.editor.generation.FilterOption.*; +import static io.anuke.mindustry.editor.generation.FilterOption.BlockOption; +import static io.anuke.mindustry.editor.generation.FilterOption.oresOnly; public class OreFilter extends GenerateFilter{ float scl = 40, threshold = 0.8f, octaves = 3f, falloff = 0.5f; @@ -12,11 +13,11 @@ public class OreFilter extends GenerateFilter{ { options( - new SliderOption("scale", () -> scl, f -> scl = f, 1f, 500f), - new SliderOption("threshold", () -> threshold, f -> threshold = f, 0f, 1f), - new SliderOption("octaves", () -> octaves, f -> octaves = f, 1f, 10f), - new SliderOption("falloff", () -> falloff, f -> falloff = f, 0f, 1f), - new BlockOption("ore", () -> ore, b -> ore = b, oresOnly) + new SliderOption("scale", () -> scl, f -> scl = f, 1f, 500f), + new SliderOption("threshold", () -> threshold, f -> threshold = f, 0f, 1f), + new SliderOption("octaves", () -> octaves, f -> octaves = f, 1f, 10f), + new SliderOption("falloff", () -> falloff, f -> falloff = f, 0f, 1f), + new BlockOption("ore", () -> ore, b -> ore = b, oresOnly) ); } diff --git a/core/src/io/anuke/mindustry/editor/generation/RiverNoiseFilter.java b/core/src/io/anuke/mindustry/editor/generation/RiverNoiseFilter.java index 629822dc8f..2cfb256b41 100644 --- a/core/src/io/anuke/mindustry/editor/generation/RiverNoiseFilter.java +++ b/core/src/io/anuke/mindustry/editor/generation/RiverNoiseFilter.java @@ -14,12 +14,12 @@ public class RiverNoiseFilter extends GenerateFilter{ { options( - new SliderOption("scale", () -> scl, f -> scl = f, 1f, 500f), - new SliderOption("threshold", () -> threshold, f -> threshold = f, 0f, 1f), - new SliderOption("threshold2", () -> threshold2, f -> threshold2 = f, 0f, 1f), - new BlockOption("block", () -> block, b -> block = b, wallsOnly), - new BlockOption("floor", () -> floor, b -> floor = b, floorsOnly), - new BlockOption("floor2", () -> floor2, b -> floor2 = b, floorsOnly) + new SliderOption("scale", () -> scl, f -> scl = f, 1f, 500f), + new SliderOption("threshold", () -> threshold, f -> threshold = f, 0f, 1f), + new SliderOption("threshold2", () -> threshold2, f -> threshold2 = f, 0f, 1f), + new BlockOption("block", () -> block, b -> block = b, wallsOnly), + new BlockOption("floor", () -> floor, b -> floor = b, floorsOnly), + new BlockOption("floor2", () -> floor2, b -> floor2 = b, floorsOnly) ); } diff --git a/core/src/io/anuke/mindustry/editor/generation/ScatterFilter.java b/core/src/io/anuke/mindustry/editor/generation/ScatterFilter.java index af6b09822e..4c05603006 100644 --- a/core/src/io/anuke/mindustry/editor/generation/ScatterFilter.java +++ b/core/src/io/anuke/mindustry/editor/generation/ScatterFilter.java @@ -14,16 +14,16 @@ public class ScatterFilter extends GenerateFilter{ { options( - new SliderOption("chance", () -> chance, f -> chance = f, 0f, 1f), - new BlockOption("floor", () -> floor, b -> floor = b, floorsOnly), - new BlockOption("block", () -> block, b -> block = b, wallsOnly) + new SliderOption("chance", () -> chance, f -> chance = f, 0f, 1f), + new BlockOption("floor", () -> floor, b -> floor = b, floorsOnly), + new BlockOption("block", () -> block, b -> block = b, wallsOnly) ); } @Override public void apply(){ - if(in.srcfloor == floor && in.srcblock == Blocks.air && chance() <= chance){ + if(in.srcfloor == floor && in.srcblock == Blocks.air && chance() <= chance){ in.block = block; } } diff --git a/core/src/io/anuke/mindustry/editor/generation/TerrainFilter.java b/core/src/io/anuke/mindustry/editor/generation/TerrainFilter.java index e0bf3234f3..ab8e07c3cb 100644 --- a/core/src/io/anuke/mindustry/editor/generation/TerrainFilter.java +++ b/core/src/io/anuke/mindustry/editor/generation/TerrainFilter.java @@ -15,20 +15,20 @@ public class TerrainFilter extends GenerateFilter{ { options( - new SliderOption("scale", () -> scl, f -> scl = f, 1f, 500f), - new SliderOption("mag", () -> magnitude, f -> magnitude = f, 0f, 2f), - new SliderOption("threshold", () -> threshold, f -> threshold = f, 0f, 1f), - new SliderOption("circle-scale", () -> circleScl, f -> circleScl = f, 0f, 3f), - new SliderOption("octaves", () -> octaves, f -> octaves = f, 1f, 10f), - new SliderOption("falloff", () -> falloff, f -> falloff = f, 0f, 1f), - new BlockOption("floor", () -> floor, b -> floor = b, floorsOnly), - new BlockOption("wall", () -> block, b -> block = b, wallsOnly) + new SliderOption("scale", () -> scl, f -> scl = f, 1f, 500f), + new SliderOption("mag", () -> magnitude, f -> magnitude = f, 0f, 2f), + new SliderOption("threshold", () -> threshold, f -> threshold = f, 0f, 1f), + new SliderOption("circle-scale", () -> circleScl, f -> circleScl = f, 0f, 3f), + new SliderOption("octaves", () -> octaves, f -> octaves = f, 1f, 10f), + new SliderOption("falloff", () -> falloff, f -> falloff = f, 0f, 1f), + new BlockOption("floor", () -> floor, b -> floor = b, floorsOnly), + new BlockOption("wall", () -> block, b -> block = b, wallsOnly) ); } @Override public void apply(){ - float noise = noise(in.x, in.y, scl, magnitude, octaves, falloff) + Mathf.dst((float) in.x / in.editor.width(), (float) in.y / in.editor.height(), 0.5f, 0.5f) * circleScl; + float noise = noise(in.x, in.y, scl, magnitude, octaves, falloff) + Mathf.dst((float)in.x / in.editor.width(), (float)in.y / in.editor.height(), 0.5f, 0.5f) * circleScl; in.floor = floor; in.ore = Blocks.air; diff --git a/core/src/io/anuke/mindustry/entities/Damage.java b/core/src/io/anuke/mindustry/entities/Damage.java index 59aac1504b..ea05ff7997 100644 --- a/core/src/io/anuke/mindustry/entities/Damage.java +++ b/core/src/io/anuke/mindustry/entities/Damage.java @@ -7,10 +7,7 @@ import io.anuke.arc.function.Consumer; import io.anuke.arc.function.Predicate; import io.anuke.arc.graphics.Color; import io.anuke.arc.math.Mathf; -import io.anuke.arc.math.geom.Geometry; -import io.anuke.arc.math.geom.Point2; -import io.anuke.arc.math.geom.Rectangle; -import io.anuke.arc.math.geom.Vector2; +import io.anuke.arc.math.geom.*; import io.anuke.arc.util.Time; import io.anuke.mindustry.content.Bullets; import io.anuke.mindustry.content.Fx; @@ -27,7 +24,7 @@ import io.anuke.mindustry.world.Tile; import static io.anuke.mindustry.Vars.*; -/**Utility class for damaging in an area.*/ +/** Utility class for damaging in an area. */ public class Damage{ private static Rectangle rect = new Rectangle(); private static Rectangle hitrect = new Rectangle(); @@ -35,19 +32,19 @@ public class Damage{ private static GridBits bits = new GridBits(30, 30); private static IntQueue propagation = new IntQueue(); - /**Creates a dynamic explosion based on specified parameters.*/ + /** Creates a dynamic explosion based on specified parameters. */ public static void dynamicExplosion(float x, float y, float flammability, float explosiveness, float power, float radius, Color color){ for(int i = 0; i < Mathf.clamp(power / 20, 0, 6); i++){ - int branches = 5 + Mathf.clamp((int) (power / 30), 1, 20); + int branches = 5 + Mathf.clamp((int)(power / 30), 1, 20); Time.run(i * 2f + Mathf.random(4f), () -> Lightning.create(Team.none, Pal.power, 3, - x, y, Mathf.random(360f), branches + Mathf.range(2))); + x, y, Mathf.random(360f), branches + Mathf.range(2))); } for(int i = 0; i < Mathf.clamp(flammability / 4, 0, 30); i++){ Time.run(i / 2f, () -> Call.createBullet(Bullets.fireball, x, y, Mathf.random(360f))); } - int waves = Mathf.clamp((int) (explosiveness / 4), 0, 30); + int waves = Mathf.clamp((int)(explosiveness / 4), 0, 30); for(int i = 0; i < waves; i++){ int f = i; @@ -67,7 +64,7 @@ public class Damage{ float shake = Math.min(explosiveness / 4f + 3f, 9f); Effects.shake(shake, shake, x, y); - Effects.effect(Fx.dynamicExplosion, x, y, radius/8f); + Effects.effect(Fx.dynamicExplosion, x, y, radius / 8f); } public static void createIncend(float x, float y, float range, int amount){ @@ -136,7 +133,7 @@ public class Damage{ Units.getNearbyEnemies(team, rect, cons); } - /**Damages all entities and blocks in a radius that are enemies of the team.*/ + /** Damages all entities and blocks in a radius that are enemies of the team. */ public static void damageUnits(Team team, float x, float y, float size, float damage, Predicate predicate, Consumer acceptor){ Consumer cons = entity -> { if(!predicate.test(entity)) return; @@ -157,17 +154,17 @@ public class Damage{ } } - /**Damages everything in a radius.*/ + /** Damages everything in a radius. */ public static void damage(float x, float y, float radius, float damage){ damage(null, x, y, radius, damage, false); } - /**Damages all entities and blocks in a radius that are enemies of the team.*/ + /** Damages all entities and blocks in a radius that are enemies of the team. */ public static void damage(Team team, float x, float y, float radius, float damage){ damage(team, x, y, radius, damage, false); } - /**Damages all entities and blocks in a radius that are enemies of the team.*/ + /** Damages all entities and blocks in a radius that are enemies of the team. */ public static void damage(Team team, float x, float y, float radius, float damage, boolean complete){ Consumer cons = entity -> { if(entity.getTeam() == team || entity.dst(x, y) > radius){ @@ -201,11 +198,11 @@ public class Damage{ public static void tileDamage(Team team, int startx, int starty, int radius, float baseDamage){ bits.clear(); propagation.clear(); - int bitOffset = bits.width()/2; + int bitOffset = bits.width() / 2; propagation.addFirst(PropCell.get((byte)0, (byte)0, (short)baseDamage)); //clamp radius to fit bits - radius = Math.min(radius, bits.width()/2); + radius = Math.min(radius, bits.width() / 2); while(!propagation.isEmpty()){ int prop = propagation.removeLast(); @@ -242,7 +239,7 @@ public class Damage{ } private static void completeDamage(Team team, float x, float y, float radius, float damage){ - int trad = (int) (radius / tilesize); + int trad = (int)(radius / tilesize); for(int dx = -trad; dx <= trad; dx++){ for(int dy = -trad; dy <= trad; dy++){ Tile tile = world.tile(Math.round(x / tilesize) + dx, Math.round(y / tilesize) + dy); diff --git a/core/src/io/anuke/mindustry/entities/EntityCollisions.java b/core/src/io/anuke/mindustry/entities/EntityCollisions.java index 4e7a47e832..dec2fd2291 100644 --- a/core/src/io/anuke/mindustry/entities/EntityCollisions.java +++ b/core/src/io/anuke/mindustry/entities/EntityCollisions.java @@ -3,10 +3,7 @@ package io.anuke.mindustry.entities; import io.anuke.arc.collection.Array; import io.anuke.arc.collection.IntSet; import io.anuke.arc.math.Mathf; -import io.anuke.arc.math.geom.Geometry; -import io.anuke.arc.math.geom.QuadTree; -import io.anuke.arc.math.geom.Rectangle; -import io.anuke.arc.math.geom.Vector2; +import io.anuke.arc.math.geom.*; import io.anuke.mindustry.entities.traits.Entity; import io.anuke.mindustry.entities.traits.SolidTrait; @@ -135,7 +132,7 @@ public class EntityCollisions{ for(Entity entity : group.all()){ if(entity instanceof SolidTrait){ - SolidTrait s = (SolidTrait) entity; + SolidTrait s = (SolidTrait)entity; s.lastPosition().set(s.getX(), s.getY()); tree.insert(s); } @@ -144,8 +141,8 @@ public class EntityCollisions{ private void checkCollide(Entity entity, Entity other){ - SolidTrait a = (SolidTrait) entity; - SolidTrait b = (SolidTrait) other; + SolidTrait a = (SolidTrait)entity; + SolidTrait b = (SolidTrait)other; a.hitbox(this.r1); b.hitbox(this.r2); @@ -228,7 +225,7 @@ public class EntityCollisions{ if(!(entity instanceof SolidTrait) || collided.contains(entity.getID())) continue; - SolidTrait solid = (SolidTrait) entity; + SolidTrait solid = (SolidTrait)entity; solid.hitbox(r1); r1.x += (solid.lastPosition().x - solid.getX()); diff --git a/core/src/io/anuke/mindustry/entities/EntityDraw.java b/core/src/io/anuke/mindustry/entities/EntityDraw.java index 60c67959ff..1308b4dd64 100644 --- a/core/src/io/anuke/mindustry/entities/EntityDraw.java +++ b/core/src/io/anuke/mindustry/entities/EntityDraw.java @@ -46,7 +46,7 @@ public class EntityDraw{ for(Entity e : group.all()){ if(!(e instanceof DrawTrait) || !toDraw.test((T)e) || !e.isAdded()) continue; - if(!clip || rect.setSize(((DrawTrait) e).drawSize()).setCenter(e.getX(), e.getY()).overlaps(viewport)){ + if(!clip || rect.setSize(((DrawTrait)e).drawSize()).setCenter(e.getX(), e.getY()).overlaps(viewport)){ cons.accept((T)e); } } diff --git a/core/src/io/anuke/mindustry/entities/EntityGroup.java b/core/src/io/anuke/mindustry/entities/EntityGroup.java index 2050535843..212bd6dfa8 100644 --- a/core/src/io/anuke/mindustry/entities/EntityGroup.java +++ b/core/src/io/anuke/mindustry/entities/EntityGroup.java @@ -180,7 +180,7 @@ public class EntityGroup{ return null; } - /**Returns the logic-only array for iteration.*/ + /** Returns the logic-only array for iteration. */ public Array all(){ return entityArray; } diff --git a/core/src/io/anuke/mindustry/entities/EntityQuery.java b/core/src/io/anuke/mindustry/entities/EntityQuery.java index 8e25527400..9358ca4f06 100644 --- a/core/src/io/anuke/mindustry/entities/EntityQuery.java +++ b/core/src/io/anuke/mindustry/entities/EntityQuery.java @@ -74,7 +74,7 @@ public class EntityQuery{ float cdist = 0f; Array entities = getNearby(group, x, y, range * 2f); for(int i = 0; i < entities.size; i++){ - T e = (T) entities.get(i); + T e = (T)entities.get(i); if(!pred.test(e)) continue; diff --git a/core/src/io/anuke/mindustry/entities/Predict.java b/core/src/io/anuke/mindustry/entities/Predict.java index 950ad58912..e4e103a64e 100644 --- a/core/src/io/anuke/mindustry/entities/Predict.java +++ b/core/src/io/anuke/mindustry/entities/Predict.java @@ -14,7 +14,6 @@ public class Predict{ /** * Calculates of intercept of a stationary and moving target. Do not call from multiple threads! - * * @param srcx X of shooter * @param srcy Y of shooter * @param dstx X of target @@ -28,7 +27,7 @@ public class Predict{ dstvx /= Time.delta(); dstvy /= Time.delta(); float tx = dstx - srcx, - ty = dsty - srcy; + ty = dsty - srcy; // Get quadratic equation components float a = dstvx * dstvx + dstvy * dstvy - v * v; @@ -57,8 +56,8 @@ public class Predict{ */ public static Vector2 intercept(TargetTrait src, TargetTrait dst, float v){ return intercept(src.getX(), src.getY(), dst.getX(), dst.getY(), - dst.getTargetVelocityX() - src.getTargetVelocityX(), - dst.getTargetVelocityY() - src.getTargetVelocityY(), v); + dst.getTargetVelocityX() - src.getTargetVelocityX(), + dst.getTargetVelocityY() - src.getTargetVelocityY(), v); } private static Vector2 quad(float a, float b, float c){ diff --git a/core/src/io/anuke/mindustry/entities/Units.java b/core/src/io/anuke/mindustry/entities/Units.java index 7c72ad9492..c913a6db6f 100644 --- a/core/src/io/anuke/mindustry/entities/Units.java +++ b/core/src/io/anuke/mindustry/entities/Units.java @@ -7,10 +7,7 @@ import io.anuke.arc.math.Mathf; import io.anuke.arc.math.geom.Geometry; import io.anuke.arc.math.geom.Rectangle; import io.anuke.mindustry.entities.traits.TargetTrait; -import io.anuke.mindustry.entities.type.Player; -import io.anuke.mindustry.entities.type.TileEntity; -import io.anuke.mindustry.entities.type.BaseUnit; -import io.anuke.mindustry.entities.type.Unit; +import io.anuke.mindustry.entities.type.*; import io.anuke.mindustry.game.Team; import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Tile; @@ -29,7 +26,6 @@ public class Units{ /** * Validates a target. - * * @param target The target to validate * @param team The team of the thing doing tha targeting * @param x The X position of the thing doign the targeting @@ -41,17 +37,17 @@ public class Units{ return target == null || (range != Float.MAX_VALUE && target.dst(x, y) > range) || target.getTeam() == team || !target.isValid(); } - /**See {@link #invalidateTarget(TargetTrait, Team, float, float, float)}*/ + /** See {@link #invalidateTarget(TargetTrait, Team, float, float, float)} */ public static boolean invalidateTarget(TargetTrait target, Team team, float x, float y){ return invalidateTarget(target, team, x, y, Float.MAX_VALUE); } - /**See {@link #invalidateTarget(TargetTrait, Team, float, float, float)}*/ + /** See {@link #invalidateTarget(TargetTrait, Team, float, float, float)} */ public static boolean invalidateTarget(TargetTrait target, Unit targeter){ return invalidateTarget(target, targeter.getTeam(), targeter.x, targeter.y, targeter.getWeapon().bullet.range()); } - /**Returns whether there are any entities on this tile.*/ + /** Returns whether there are any entities on this tile. */ public static boolean anyEntities(Tile tile){ Block type = tile.block(); rect.setSize(type.size * tilesize, type.size * tilesize); @@ -60,7 +56,7 @@ public class Units{ return anyEntities(rect); } - /**Can be called from any thread.*/ + /** Can be called from any thread. */ public static boolean anyEntities(Rectangle rect){ boolResult = false; @@ -78,7 +74,7 @@ public class Units{ return boolResult; } - /**Returns whether there are any entities on this tile, with the hitbox expanded.*/ + /** Returns whether there are any entities on this tile, with the hitbox expanded. */ public static boolean anyEntities(Tile tile, float expansion, Predicate pred){ Block type = tile.block(); rect.setSize(type.size * tilesize + expansion, type.size * tilesize + expansion); @@ -100,18 +96,18 @@ public class Units{ return value[0]; } - /**Returns the neareset damaged tile.*/ + /** Returns the neareset damaged tile. */ public static TileEntity findDamagedTile(Team team, float x, float y){ Tile tile = Geometry.findClosest(x, y, world.indexer.getDamaged(team)); return tile == null ? null : tile.entity; } - /**Returns the neareset ally tile in a range.*/ + /** Returns the neareset ally tile in a range. */ public static TileEntity findAllyTile(Team team, float x, float y, float range, Predicate pred){ return world.indexer.findTile(team, x, y, range, pred); } - /**Returns the neareset enemy tile in a range.*/ + /** Returns the neareset enemy tile in a range. */ public static TileEntity findEnemyTile(Team team, float x, float y, float range, Predicate pred){ if(team == Team.none) return null; @@ -124,7 +120,7 @@ public class Units{ return null; } - /**Iterates over all units on all teams, including players.*/ + /** Iterates over all units on all teams, including players. */ public static void allUnits(Consumer cons){ //check all unit groups first for(EntityGroup group : unitGroups){ @@ -141,17 +137,17 @@ public class Units{ } } - /**Returns the closest target enemy. First, units are checked, then tile entities.*/ + /** Returns the closest target enemy. First, units are checked, then tile entities. */ public static TargetTrait getClosestTarget(Team team, float x, float y, float range){ return getClosestTarget(team, x, y, range, Unit::isValid); } - /**Returns the closest target enemy. First, units are checked, then tile entities.*/ + /** Returns the closest target enemy. First, units are checked, then tile entities. */ public static TargetTrait getClosestTarget(Team team, float x, float y, float range, Predicate unitPred){ return getClosestTarget(team, x, y, range, unitPred, t -> true); } - /**Returns the closest target enemy. First, units are checked, then tile entities.*/ + /** Returns the closest target enemy. First, units are checked, then tile entities. */ public static TargetTrait getClosestTarget(Team team, float x, float y, float range, Predicate unitPred, Predicate tilePred){ Unit unit = getClosestEnemy(team, x, y, range, unitPred); if(unit != null){ @@ -161,7 +157,7 @@ public class Units{ } } - /**Returns the closest enemy of this team. Filter by predicate.*/ + /** Returns the closest enemy of this team. Filter by predicate. */ public static Unit getClosestEnemy(Team team, float x, float y, float range, Predicate predicate){ if(team == Team.none) return null; @@ -186,7 +182,7 @@ public class Units{ return result; } - /**Returns the closest ally of this team. Filter by predicate.*/ + /** Returns the closest ally of this team. Filter by predicate. */ public static Unit getClosest(Team team, float x, float y, float range, Predicate predicate){ result = null; cdist = 0f; @@ -209,21 +205,21 @@ public class Units{ return result; } - /**Iterates over all units in a rectangle.*/ + /** Iterates over all units in a rectangle. */ public static void getNearby(Team team, Rectangle rect, Consumer cons){ EntityGroup group = unitGroups[team.ordinal()]; if(!group.isEmpty()){ - EntityQuery.getNearby(group, rect, entity -> cons.accept((Unit) entity)); + EntityQuery.getNearby(group, rect, entity -> cons.accept((Unit)entity)); } //now check all players EntityQuery.getNearby(playerGroup, rect, player -> { - if(((Unit) player).getTeam() == team) cons.accept((Unit) player); + if(((Unit)player).getTeam() == team) cons.accept((Unit)player); }); } - /**Iterates over all units in a circle around this position.*/ + /** Iterates over all units in a circle around this position. */ public static void getNearby(Team team, float x, float y, float radius, Consumer cons){ rect.setSize(radius * 2).setCenter(x, y); @@ -231,53 +227,53 @@ public class Units{ if(!group.isEmpty()){ EntityQuery.getNearby(group, rect, entity -> { if(entity.dst(x, y) <= radius){ - cons.accept((Unit) entity); + cons.accept((Unit)entity); } }); } //now check all players EntityQuery.getNearby(playerGroup, rect, player -> { - if(((Unit) player).getTeam() == team && player.dst(x, y) <= radius){ - cons.accept((Unit) player); + if(((Unit)player).getTeam() == team && player.dst(x, y) <= radius){ + cons.accept((Unit)player); } }); } - /**Iterates over all units in a rectangle.*/ + /** Iterates over all units in a rectangle. */ public static void getNearby(Rectangle rect, Consumer cons){ for(Team team : Team.all){ EntityGroup group = unitGroups[team.ordinal()]; if(!group.isEmpty()){ - EntityQuery.getNearby(group, rect, entity -> cons.accept((Unit) entity)); + EntityQuery.getNearby(group, rect, entity -> cons.accept((Unit)entity)); } } //now check all enemy players - EntityQuery.getNearby(playerGroup, rect, player -> cons.accept((Unit) player)); + EntityQuery.getNearby(playerGroup, rect, player -> cons.accept((Unit)player)); } - /**Iterates over all units that are enemies of this team.*/ + /** Iterates over all units that are enemies of this team. */ public static void getNearbyEnemies(Team team, Rectangle rect, Consumer cons){ EnumSet targets = state.teams.enemiesOf(team); for(Team other : targets){ EntityGroup group = unitGroups[other.ordinal()]; if(!group.isEmpty()){ - EntityQuery.getNearby(group, rect, entity -> cons.accept((Unit) entity)); + EntityQuery.getNearby(group, rect, entity -> cons.accept((Unit)entity)); } } //now check all enemy players EntityQuery.getNearby(playerGroup, rect, player -> { - if(targets.contains(((Player) player).getTeam())){ - cons.accept((Unit) player); + if(targets.contains(((Player)player).getTeam())){ + cons.accept((Unit)player); } }); } - /**Iterates over all units.*/ + /** Iterates over all units. */ public static void getAllUnits(Consumer cons){ for(Team team : Team.all){ diff --git a/core/src/io/anuke/mindustry/entities/bullet/ArtilleryBulletType.java b/core/src/io/anuke/mindustry/entities/bullet/ArtilleryBulletType.java index 5c74a9f9f7..cbe7cae4fd 100644 --- a/core/src/io/anuke/mindustry/entities/bullet/ArtilleryBulletType.java +++ b/core/src/io/anuke/mindustry/entities/bullet/ArtilleryBulletType.java @@ -1,9 +1,9 @@ package io.anuke.mindustry.entities.bullet; -import io.anuke.mindustry.entities.Effects; -import io.anuke.mindustry.entities.Effects.Effect; import io.anuke.arc.graphics.g2d.Draw; import io.anuke.mindustry.content.Fx; +import io.anuke.mindustry.entities.Effects; +import io.anuke.mindustry.entities.Effects.Effect; //TODO scale velocity depending on fslope() public class ArtilleryBulletType extends BasicBulletType{ diff --git a/core/src/io/anuke/mindustry/entities/bullet/BasicBulletType.java b/core/src/io/anuke/mindustry/entities/bullet/BasicBulletType.java index d20a71efd5..86b96ba7a8 100644 --- a/core/src/io/anuke/mindustry/entities/bullet/BasicBulletType.java +++ b/core/src/io/anuke/mindustry/entities/bullet/BasicBulletType.java @@ -6,7 +6,7 @@ import io.anuke.arc.graphics.g2d.Draw; import io.anuke.arc.graphics.g2d.TextureRegion; import io.anuke.mindustry.graphics.Pal; -/**An extended BulletType for most ammo-based bullets shot from turrets and units.*/ +/** An extended BulletType for most ammo-based bullets shot from turrets and units. */ public class BasicBulletType extends BulletType{ public Color backColor = Pal.bulletYellowBack, frontColor = Pal.bulletYellow; public float bulletWidth = 5f, bulletHeight = 7f; diff --git a/core/src/io/anuke/mindustry/entities/bullet/Bullet.java b/core/src/io/anuke/mindustry/entities/bullet/Bullet.java index cc985fc058..590e3b1635 100644 --- a/core/src/io/anuke/mindustry/entities/bullet/Bullet.java +++ b/core/src/io/anuke/mindustry/entities/bullet/Bullet.java @@ -5,9 +5,7 @@ import io.anuke.annotations.Annotations.Remote; import io.anuke.arc.math.Mathf; import io.anuke.arc.math.geom.Rectangle; import io.anuke.arc.math.geom.Vector2; -import io.anuke.arc.util.Interval; -import io.anuke.arc.util.Time; -import io.anuke.arc.util.Tmp; +import io.anuke.arc.util.*; import io.anuke.arc.util.pooling.Pool.Poolable; import io.anuke.arc.util.pooling.Pools; import io.anuke.mindustry.entities.EntityGroup; @@ -18,9 +16,7 @@ import io.anuke.mindustry.entities.type.Unit; import io.anuke.mindustry.game.Team; import io.anuke.mindustry.world.Tile; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; +import java.io.*; import static io.anuke.mindustry.Vars.*; @@ -36,7 +32,7 @@ public class Bullet extends SolidEntity implements DamageTrait, ScaleTrait, Pool protected Entity owner; protected float time; - /**Internal use only!*/ + /** Internal use only! */ public Bullet(){ } @@ -64,7 +60,7 @@ public class Bullet extends SolidEntity implements DamageTrait, ScaleTrait, Pool bullet.velocity.set(0, type.speed).setAngle(angle).scl(velocityScl); if(type.keepVelocity){ - bullet.velocity.add(owner instanceof VelocityTrait ? ((VelocityTrait) owner).velocity() : Vector2.ZERO); + bullet.velocity.add(owner instanceof VelocityTrait ? ((VelocityTrait)owner).velocity() : Vector2.ZERO); } bullet.team = team; @@ -85,13 +81,13 @@ public class Bullet extends SolidEntity implements DamageTrait, ScaleTrait, Pool return create(type, parent.owner, parent.team, x, y, angle, velocityScl); } - /**Internal use only.*/ + /** Internal use only. */ @Remote(called = Loc.server, unreliable = true) public static void createBullet(BulletType type, float x, float y, float angle){ create(type, null, Team.none, x, y, angle); } - /**ok*/ + /** ok */ @Remote(called = Loc.server, unreliable = true) public static void createBullet(BulletType type, Team team, float x, float y, float angle){ create(type, null, team, x, y, angle); @@ -133,7 +129,7 @@ public class Bullet extends SolidEntity implements DamageTrait, ScaleTrait, Pool public float damageMultiplier(){ if(owner instanceof Unit){ - return ((Unit) owner).getDamageMultipler(); + return ((Unit)owner).getDamageMultipler(); } return 1f; } @@ -194,7 +190,7 @@ public class Bullet extends SolidEntity implements DamageTrait, ScaleTrait, Pool @Override public boolean collides(SolidTrait other){ - return type.collides && (other != owner && !(other instanceof DamageTrait)) && !supressCollision && !(other instanceof Unit && ((Unit) other).isFlying() && !type.collidesAir); + return type.collides && (other != owner && !(other instanceof DamageTrait)) && !supressCollision && !(other instanceof Unit && ((Unit)other).isFlying() && !type.collidesAir); } @Override @@ -203,7 +199,7 @@ public class Bullet extends SolidEntity implements DamageTrait, ScaleTrait, Pool type.hit(this, x, y); if(other instanceof Unit){ - Unit unit = (Unit) other; + Unit unit = (Unit)other; unit.velocity().add(Tmp.v3.set(other.getX(), other.getY()).sub(x, y).setLength(type.knockback / unit.mass())); unit.applyEffect(type.status, type.statusDuration); } @@ -218,7 +214,7 @@ public class Bullet extends SolidEntity implements DamageTrait, ScaleTrait, Pool velocity.scl(Mathf.clamp(1f - type.drag * Time.delta())); - time += Time.delta() * 1f/(lifeScl); + time += Time.delta() * 1f / (lifeScl); time = Mathf.clamp(time, 0, type.lifetime); if(time >= type.lifetime){ @@ -336,12 +332,12 @@ public class Bullet extends SolidEntity implements DamageTrait, ScaleTrait, Pool velocity.limit(f); } - /** Sets the bullet's rotation in degrees.*/ + /** Sets the bullet's rotation in degrees. */ public void rot(float angle){ velocity.setAngle(angle); } - /** @return the bullet's rotation.*/ + /** @return the bullet's rotation. */ public float rot(){ float angle = Mathf.atan2(velocity.x, velocity.y) * Mathf.radiansToDegrees; if(angle < 0) angle += 360; diff --git a/core/src/io/anuke/mindustry/entities/bullet/BulletType.java b/core/src/io/anuke/mindustry/entities/bullet/BulletType.java index 55287cb800..45cbc8aa8a 100644 --- a/core/src/io/anuke/mindustry/entities/bullet/BulletType.java +++ b/core/src/io/anuke/mindustry/entities/bullet/BulletType.java @@ -4,10 +4,8 @@ import io.anuke.arc.math.Angles; import io.anuke.arc.math.Mathf; import io.anuke.mindustry.content.Fx; import io.anuke.mindustry.content.StatusEffects; -import io.anuke.mindustry.entities.Damage; -import io.anuke.mindustry.entities.Effects; +import io.anuke.mindustry.entities.*; import io.anuke.mindustry.entities.Effects.Effect; -import io.anuke.mindustry.entities.Units; import io.anuke.mindustry.entities.effect.Lightning; import io.anuke.mindustry.entities.traits.TargetTrait; import io.anuke.mindustry.game.Content; @@ -26,39 +24,39 @@ public abstract class BulletType extends Content{ public boolean pierce; public Effect hitEffect, despawnEffect; - /**Effect created when shooting.*/ + /** Effect created when shooting. */ public Effect shootEffect = Fx.shootSmall; - /**Extra smoke effect created when shooting.*/ + /** Extra smoke effect created when shooting. */ public Effect smokeEffect = Fx.shootSmallSmoke; - /**Extra inaccuracy when firing.*/ + /** Extra inaccuracy when firing. */ public float inaccuracy = 0f; - /**How many bullets get created per ammo item/liquid.*/ + /** How many bullets get created per ammo item/liquid. */ public float ammoMultiplier = 1f; - /**Multiplied by turret reload speed to get final shoot speed.*/ + /** Multiplied by turret reload speed to get final shoot speed. */ public float reloadMultiplier = 1f; - /**Recoil from shooter entities.*/ + /** Recoil from shooter entities. */ public float recoil; public float splashDamage = 0f; - /**Knockback in velocity.*/ + /** Knockback in velocity. */ public float knockback; - /**Whether this bullet hits tiles.*/ + /** Whether this bullet hits tiles. */ public boolean hitTiles = true; - /**Status effect applied on hit.*/ + /** Status effect applied on hit. */ public StatusEffect status = StatusEffects.none; - /**Intensity of applied status effect in terms of duration.*/ + /** Intensity of applied status effect in terms of duration. */ public float statusDuration = 60 * 1f; - /**Whether to sync this bullet to clients.*/ + /** Whether to sync this bullet to clients. */ public boolean syncable; - /**Whether this bullet type collides with tiles.*/ + /** Whether this bullet type collides with tiles. */ public boolean collidesTiles = true; - /**Whether this bullet type collides with tiles that are of the same team.*/ + /** Whether this bullet type collides with tiles that are of the same team. */ public boolean collidesTeam = false; - /**Whether this bullet type collides with air units.*/ + /** Whether this bullet type collides with air units. */ public boolean collidesAir = true; - /**Whether this bullet types collides with anything at all.*/ + /** Whether this bullet types collides with anything at all. */ public boolean collides = true; - /**Whether velocity is inherited from the shooter.*/ + /** Whether velocity is inherited from the shooter. */ public boolean keepVelocity = true; //additional effects @@ -67,7 +65,7 @@ public abstract class BulletType extends Content{ public float fragVelocityMin = 0.2f, fragVelocityMax = 1f; public BulletType fragBullet = null; - /**Use a negative value to disable splash damage.*/ + /** Use a negative value to disable splash damage. */ public float splashDamageRadius = -1f; public int incendAmount = 0; @@ -90,7 +88,7 @@ public abstract class BulletType extends Content{ despawnEffect = Fx.hitBulletSmall; } - /**Returns maximum distance the bullet this bullet type has can travel.*/ + /** Returns maximum distance the bullet this bullet type has can travel. */ public float range(){ return speed * lifetime * (1f - drag); } @@ -136,7 +134,7 @@ public abstract class BulletType extends Content{ hit(b); } - for (int i = 0; i < lightining; i++) { + for(int i = 0; i < lightining; i++){ Lightning.create(b.getTeam(), Pal.surge, damage, b.x, b.y, Mathf.random(360f), lightningLength); } } diff --git a/core/src/io/anuke/mindustry/entities/bullet/FlakBulletType.java b/core/src/io/anuke/mindustry/entities/bullet/FlakBulletType.java index 908bd3f17b..227191470a 100644 --- a/core/src/io/anuke/mindustry/entities/bullet/FlakBulletType.java +++ b/core/src/io/anuke/mindustry/entities/bullet/FlakBulletType.java @@ -1,9 +1,9 @@ package io.anuke.mindustry.entities.bullet; import io.anuke.arc.math.geom.Rectangle; +import io.anuke.arc.util.Time; import io.anuke.mindustry.content.Fx; import io.anuke.mindustry.entities.Units; -import io.anuke.arc.util.Time; public abstract class FlakBulletType extends BasicBulletType{ protected static Rectangle rect = new Rectangle(); @@ -24,7 +24,7 @@ public abstract class FlakBulletType extends BasicBulletType{ if(b.getData() instanceof Integer) return; if(b.timer.get(2, 6)){ - Units.getNearbyEnemies(b.getTeam(), rect.setSize(explodeRange*2f).setCenter(b.x, b.y), unit -> { + Units.getNearbyEnemies(b.getTeam(), rect.setSize(explodeRange * 2f).setCenter(b.x, b.y), unit -> { if(b.getData() instanceof Float) return; if(unit.dst(b) < explodeRange){ diff --git a/core/src/io/anuke/mindustry/entities/bullet/LiquidBulletType.java b/core/src/io/anuke/mindustry/entities/bullet/LiquidBulletType.java index 88f7175b6c..e3fe41f828 100644 --- a/core/src/io/anuke/mindustry/entities/bullet/LiquidBulletType.java +++ b/core/src/io/anuke/mindustry/entities/bullet/LiquidBulletType.java @@ -1,6 +1,5 @@ package io.anuke.mindustry.entities.bullet; -import io.anuke.mindustry.entities.Effects; import io.anuke.arc.graphics.Color; import io.anuke.arc.graphics.g2d.Draw; import io.anuke.arc.graphics.g2d.Fill; @@ -8,6 +7,7 @@ import io.anuke.arc.math.Mathf; import io.anuke.arc.math.geom.Geometry; import io.anuke.arc.math.geom.Point2; import io.anuke.mindustry.content.Fx; +import io.anuke.mindustry.entities.Effects; import io.anuke.mindustry.entities.effect.Fire; import io.anuke.mindustry.entities.effect.Puddle; import io.anuke.mindustry.type.Liquid; @@ -35,11 +35,11 @@ public class LiquidBulletType extends BulletType{ @Override public float range(){ - return speed * lifetime /2f; + return speed * lifetime / 2f; } @Override - public void update(Bullet b) { + public void update(Bullet b){ super.update(b); if(liquid.canExtinguish()){ diff --git a/core/src/io/anuke/mindustry/entities/bullet/MassDriverBolt.java b/core/src/io/anuke/mindustry/entities/bullet/MassDriverBolt.java index 237aa09a15..01902bd9bc 100644 --- a/core/src/io/anuke/mindustry/entities/bullet/MassDriverBolt.java +++ b/core/src/io/anuke/mindustry/entities/bullet/MassDriverBolt.java @@ -1,11 +1,11 @@ package io.anuke.mindustry.entities.bullet; -import io.anuke.mindustry.entities.Effects; import io.anuke.arc.graphics.Color; import io.anuke.arc.graphics.g2d.Draw; import io.anuke.arc.math.Angles; import io.anuke.arc.math.Mathf; import io.anuke.mindustry.content.Fx; +import io.anuke.mindustry.entities.Effects; import io.anuke.mindustry.graphics.Pal; import io.anuke.mindustry.world.blocks.distribution.MassDriver.DriverBulletData; @@ -45,7 +45,7 @@ public class MassDriverBolt extends BulletType{ float hitDst = 7f; - DriverBulletData data = (DriverBulletData) b.getData(); + DriverBulletData data = (DriverBulletData)b.getData(); //if the target is dead, just keep flying until the bullet explodes if(data.to.isDead()){ @@ -87,7 +87,7 @@ public class MassDriverBolt extends BulletType{ if(!(b.getData() instanceof DriverBulletData)) return; - DriverBulletData data = (DriverBulletData) b.getData(); + DriverBulletData data = (DriverBulletData)b.getData(); data.to.isRecieving = false; for(int i = 0; i < data.items.length; i++){ diff --git a/core/src/io/anuke/mindustry/entities/bullet/MissileBulletType.java b/core/src/io/anuke/mindustry/entities/bullet/MissileBulletType.java index 351078866d..56a6b5ae7f 100644 --- a/core/src/io/anuke/mindustry/entities/bullet/MissileBulletType.java +++ b/core/src/io/anuke/mindustry/entities/bullet/MissileBulletType.java @@ -1,11 +1,11 @@ package io.anuke.mindustry.entities.bullet; import io.anuke.arc.graphics.Color; -import io.anuke.mindustry.content.Fx; -import io.anuke.mindustry.graphics.Pal; -import io.anuke.mindustry.entities.Effects; -import io.anuke.arc.util.Time; import io.anuke.arc.math.Mathf; +import io.anuke.arc.util.Time; +import io.anuke.mindustry.content.Fx; +import io.anuke.mindustry.entities.Effects; +import io.anuke.mindustry.graphics.Pal; public class MissileBulletType extends BasicBulletType{ protected Color trailColor = Pal.missileYellowBack; diff --git a/core/src/io/anuke/mindustry/entities/effect/Decal.java b/core/src/io/anuke/mindustry/entities/effect/Decal.java index 1cb773a3cc..72d251d9be 100644 --- a/core/src/io/anuke/mindustry/entities/effect/Decal.java +++ b/core/src/io/anuke/mindustry/entities/effect/Decal.java @@ -1,12 +1,12 @@ package io.anuke.mindustry.entities.effect; import io.anuke.arc.graphics.Color; -import io.anuke.mindustry.entities.traits.BelowLiquidTrait; -import io.anuke.mindustry.entities.EntityGroup; -import io.anuke.mindustry.entities.impl.TimedEntity; -import io.anuke.mindustry.entities.traits.DrawTrait; import io.anuke.arc.graphics.g2d.Draw; import io.anuke.arc.math.Mathf; +import io.anuke.mindustry.entities.EntityGroup; +import io.anuke.mindustry.entities.impl.TimedEntity; +import io.anuke.mindustry.entities.traits.BelowLiquidTrait; +import io.anuke.mindustry.entities.traits.DrawTrait; import static io.anuke.mindustry.Vars.groundEffectGroup; diff --git a/core/src/io/anuke/mindustry/entities/effect/Fire.java b/core/src/io/anuke/mindustry/entities/effect/Fire.java index 406192c411..18c5c48ebe 100644 --- a/core/src/io/anuke/mindustry/entities/effect/Fire.java +++ b/core/src/io/anuke/mindustry/entities/effect/Fire.java @@ -3,9 +3,6 @@ package io.anuke.mindustry.entities.effect; import io.anuke.annotations.Annotations.Loc; import io.anuke.annotations.Annotations.Remote; import io.anuke.arc.collection.IntMap; -import io.anuke.mindustry.entities.Effects; -import io.anuke.mindustry.entities.EntityGroup; -import io.anuke.mindustry.entities.impl.TimedEntity; import io.anuke.arc.math.Mathf; import io.anuke.arc.math.geom.Geometry; import io.anuke.arc.math.geom.Point2; @@ -13,22 +10,17 @@ import io.anuke.arc.util.Structs; import io.anuke.arc.util.Time; import io.anuke.arc.util.pooling.Pool.Poolable; import io.anuke.arc.util.pooling.Pools; -import io.anuke.mindustry.content.Bullets; -import io.anuke.mindustry.content.StatusEffects; -import io.anuke.mindustry.content.Fx; -import io.anuke.mindustry.entities.Damage; -import io.anuke.mindustry.entities.type.TileEntity; +import io.anuke.mindustry.content.*; +import io.anuke.mindustry.entities.*; +import io.anuke.mindustry.entities.impl.TimedEntity; import io.anuke.mindustry.entities.traits.SaveTrait; import io.anuke.mindustry.entities.traits.SyncTrait; +import io.anuke.mindustry.entities.type.TileEntity; import io.anuke.mindustry.gen.Call; import io.anuke.mindustry.net.Net; -import io.anuke.mindustry.world.Block; -import io.anuke.mindustry.world.Pos; -import io.anuke.mindustry.world.Tile; +import io.anuke.mindustry.world.*; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; +import java.io.*; import static io.anuke.mindustry.Vars.*; @@ -42,10 +34,11 @@ public class Fire extends TimedEntity implements SaveTrait, SyncTrait, Poolable{ private float baseFlammability = -1, puddleFlammability; private float lifetime; - /**Deserialization use only!*/ - public Fire(){} + /** Deserialization use only! */ + public Fire(){ + } - /**Start a fire on the tile. If there already is a file there, refreshes its lifetime.*/ + /** Start a fire on the tile. If there already is a file there, refreshes its lifetime. */ public static void create(Tile tile){ if(Net.client() || tile == null) return; //not clientside. @@ -153,8 +146,8 @@ public class Fire extends TimedEntity implements SaveTrait, SyncTrait, Poolable{ entity.damage(0.4f); } Damage.damageUnits(null, tile.worldx(), tile.worldy(), tilesize, 3f, - unit -> !unit.isFlying() && !unit.isImmune(StatusEffects.burning), - unit -> unit.applyEffect(StatusEffects.burning, 60 * 5)); + unit -> !unit.isFlying() && !unit.isImmune(StatusEffects.burning), + unit -> unit.applyEffect(StatusEffects.burning, 60 * 5)); } } diff --git a/core/src/io/anuke/mindustry/entities/effect/GroundEffectEntity.java b/core/src/io/anuke/mindustry/entities/effect/GroundEffectEntity.java index bc98f1619a..54094c4a87 100644 --- a/core/src/io/anuke/mindustry/entities/effect/GroundEffectEntity.java +++ b/core/src/io/anuke/mindustry/entities/effect/GroundEffectEntity.java @@ -1,12 +1,12 @@ package io.anuke.mindustry.entities.effect; +import io.anuke.arc.math.Mathf; +import io.anuke.arc.util.Time; +import io.anuke.mindustry.Vars; import io.anuke.mindustry.entities.Effects; import io.anuke.mindustry.entities.Effects.Effect; import io.anuke.mindustry.entities.Effects.EffectRenderer; import io.anuke.mindustry.entities.impl.EffectEntity; -import io.anuke.arc.math.Mathf; -import io.anuke.arc.util.Time; -import io.anuke.mindustry.Vars; import io.anuke.mindustry.world.Tile; /** @@ -17,7 +17,7 @@ public class GroundEffectEntity extends EffectEntity{ @Override public void update(){ - GroundEffect effect = (GroundEffect) this.effect; + GroundEffect effect = (GroundEffect)this.effect; if(effect.isStatic){ time += Time.delta(); @@ -41,7 +41,7 @@ public class GroundEffectEntity extends EffectEntity{ @Override public void draw(){ - GroundEffect effect = (GroundEffect) this.effect; + GroundEffect effect = (GroundEffect)this.effect; if(once && effect.isStatic) Effects.renderEffect(id, effect, color, lifetime(), rotation, x, y, data); diff --git a/core/src/io/anuke/mindustry/entities/effect/ItemTransfer.java b/core/src/io/anuke/mindustry/entities/effect/ItemTransfer.java index 5083897a33..2cb7f567e1 100644 --- a/core/src/io/anuke/mindustry/entities/effect/ItemTransfer.java +++ b/core/src/io/anuke/mindustry/entities/effect/ItemTransfer.java @@ -2,18 +2,16 @@ package io.anuke.mindustry.entities.effect; import io.anuke.annotations.Annotations.Loc; import io.anuke.annotations.Annotations.Remote; -import io.anuke.mindustry.entities.EntityGroup; -import io.anuke.mindustry.entities.impl.TimedEntity; -import io.anuke.mindustry.entities.traits.DrawTrait; -import io.anuke.arc.graphics.g2d.Draw; -import io.anuke.arc.graphics.g2d.Fill; -import io.anuke.arc.graphics.g2d.Lines; +import io.anuke.arc.graphics.g2d.*; import io.anuke.arc.math.Interpolation; import io.anuke.arc.math.Mathf; import io.anuke.arc.math.geom.Position; import io.anuke.arc.math.geom.Vector2; import io.anuke.arc.util.Time; import io.anuke.arc.util.pooling.Pools; +import io.anuke.mindustry.entities.EntityGroup; +import io.anuke.mindustry.entities.impl.TimedEntity; +import io.anuke.mindustry.entities.traits.DrawTrait; import io.anuke.mindustry.entities.type.Unit; import io.anuke.mindustry.graphics.Pal; import io.anuke.mindustry.type.Item; diff --git a/core/src/io/anuke/mindustry/entities/effect/Lightning.java b/core/src/io/anuke/mindustry/entities/effect/Lightning.java index 7a89b29f9d..3358d64cd7 100644 --- a/core/src/io/anuke/mindustry/entities/effect/Lightning.java +++ b/core/src/io/anuke/mindustry/entities/effect/Lightning.java @@ -4,27 +4,18 @@ import io.anuke.annotations.Annotations.Loc; import io.anuke.annotations.Annotations.Remote; import io.anuke.arc.collection.Array; import io.anuke.arc.collection.IntSet; -import io.anuke.arc.graphics.g2d.Fill; -import io.anuke.arc.graphics.g2d.Lines; -import io.anuke.mindustry.entities.EntityGroup; -import io.anuke.mindustry.entities.impl.TimedEntity; -import io.anuke.mindustry.entities.traits.DrawTrait; -import io.anuke.mindustry.entities.traits.TimeTrait; import io.anuke.arc.graphics.Color; -import io.anuke.arc.graphics.g2d.Draw; -import io.anuke.arc.math.Angles; -import io.anuke.arc.math.Mathf; -import io.anuke.arc.math.RandomXS128; -import io.anuke.arc.math.geom.Geometry; -import io.anuke.arc.math.geom.Position; -import io.anuke.arc.math.geom.Rectangle; -import io.anuke.arc.math.geom.Vector2; +import io.anuke.arc.graphics.g2d.*; +import io.anuke.arc.math.*; +import io.anuke.arc.math.geom.*; import io.anuke.arc.util.pooling.Pools; import io.anuke.mindustry.content.Bullets; -import io.anuke.mindustry.entities.type.Unit; +import io.anuke.mindustry.entities.EntityGroup; import io.anuke.mindustry.entities.Units; import io.anuke.mindustry.entities.bullet.Bullet; -import io.anuke.mindustry.entities.traits.SyncTrait; +import io.anuke.mindustry.entities.impl.TimedEntity; +import io.anuke.mindustry.entities.traits.*; +import io.anuke.mindustry.entities.type.Unit; import io.anuke.mindustry.game.Team; import io.anuke.mindustry.gen.Call; import io.anuke.mindustry.graphics.Pal; @@ -48,16 +39,16 @@ public class Lightning extends TimedEntity implements DrawTrait, SyncTrait, Time private Array lines = new Array<>(); private Color color = Pal.lancerLaser; - /**For pooling use only. Do not call directly!*/ + /** For pooling use only. Do not call directly! */ public Lightning(){ } - /**Create a lighting branch at a location. Use Team.none to damage everyone.*/ + /** Create a lighting branch at a location. Use Team.none to damage everyone. */ public static void create(Team team, Color color, float damage, float x, float y, float targetAngle, int length){ Call.createLighting(lastSeed++, team, color, damage, x, y, targetAngle, length); } - /**Do not invoke!*/ + /** Do not invoke! */ @Remote(called = Loc.server) public static void createLighting(int seed, Team team, Color color, float damage, float x, float y, float rotation, int length){ @@ -72,7 +63,7 @@ public class Lightning extends TimedEntity implements DrawTrait, SyncTrait, Time random.setSeed(seed); hit.clear(); - for (int i = 0; i < length/2; i++) { + for(int i = 0; i < length / 2; i++){ Bullet.create(Bullets.damageLightning, l, team, x, y, 0f, 1f, 1f, dmg); l.lines.add(new Vector2(x + Mathf.range(3f), y + Mathf.range(3f))); @@ -94,8 +85,8 @@ public class Lightning extends TimedEntity implements DrawTrait, SyncTrait, Time y = furthest.y; }else{ rotation += random.range(20f); - x += Angles.trnsx(rotation, hitRange/2f); - y += Angles.trnsy(rotation, hitRange/2f); + x += Angles.trnsx(rotation, hitRange / 2f); + y += Angles.trnsy(rotation, hitRange / 2f); } } } @@ -106,10 +97,12 @@ public class Lightning extends TimedEntity implements DrawTrait, SyncTrait, Time } @Override - public void write(DataOutput data){} + public void write(DataOutput data){ + } @Override - public void read(DataInput data){} + public void read(DataInput data){ + } @Override public float lifetime(){ @@ -144,7 +137,7 @@ public class Lightning extends TimedEntity implements DrawTrait, SyncTrait, Time int i = 0; for(Position p : lines){ - Fill.square(p.getX(), p.getY(), (5f - (float)i++/lines.size*2f) * fout(), 45); + Fill.square(p.getX(), p.getY(), (5f - (float)i++ / lines.size * 2f) * fout(), 45); } Draw.reset(); } diff --git a/core/src/io/anuke/mindustry/entities/effect/Puddle.java b/core/src/io/anuke/mindustry/entities/effect/Puddle.java index d99b7e8f56..f07800844c 100644 --- a/core/src/io/anuke/mindustry/entities/effect/Puddle.java +++ b/core/src/io/anuke/mindustry/entities/effect/Puddle.java @@ -3,36 +3,25 @@ package io.anuke.mindustry.entities.effect; import io.anuke.annotations.Annotations.Loc; import io.anuke.annotations.Annotations.Remote; import io.anuke.arc.collection.IntMap; -import io.anuke.mindustry.entities.Effects; -import io.anuke.mindustry.entities.EntityGroup; -import io.anuke.mindustry.entities.impl.SolidEntity; -import io.anuke.mindustry.entities.traits.DrawTrait; import io.anuke.arc.graphics.Color; import io.anuke.arc.graphics.g2d.Draw; import io.anuke.arc.graphics.g2d.Fill; import io.anuke.arc.math.Angles; import io.anuke.arc.math.Mathf; -import io.anuke.arc.math.geom.Geometry; -import io.anuke.arc.math.geom.Point2; -import io.anuke.arc.math.geom.Rectangle; +import io.anuke.arc.math.geom.*; import io.anuke.arc.util.Time; import io.anuke.arc.util.pooling.Pool.Poolable; import io.anuke.arc.util.pooling.Pools; -import io.anuke.mindustry.content.Liquids; -import io.anuke.mindustry.content.Blocks; -import io.anuke.mindustry.content.Bullets; -import io.anuke.mindustry.content.Fx; -import io.anuke.mindustry.entities.Units; -import io.anuke.mindustry.entities.traits.SaveTrait; -import io.anuke.mindustry.entities.traits.SyncTrait; +import io.anuke.mindustry.content.*; +import io.anuke.mindustry.entities.*; +import io.anuke.mindustry.entities.impl.SolidEntity; +import io.anuke.mindustry.entities.traits.*; import io.anuke.mindustry.gen.Call; import io.anuke.mindustry.net.Net; import io.anuke.mindustry.type.Liquid; import io.anuke.mindustry.world.Tile; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; +import java.io.*; import static io.anuke.mindustry.Vars.*; @@ -55,21 +44,21 @@ public class Puddle extends SolidEntity implements SaveTrait, Poolable, DrawTrai private float accepting; private byte generation; - /**Deserialization use only!*/ + /** Deserialization use only! */ public Puddle(){ } - /**Deposists a puddle between tile and source.*/ + /** Deposists a puddle between tile and source. */ public static void deposit(Tile tile, Tile source, Liquid liquid, float amount){ deposit(tile, source, liquid, amount, 0); } - /**Deposists a puddle at a tile.*/ + /** Deposists a puddle at a tile. */ public static void deposit(Tile tile, Liquid liquid, float amount){ deposit(tile, tile, liquid, amount, 0); } - /**Returns the puddle on the specified tile. May return null.*/ + /** Returns the puddle on the specified tile. May return null. */ public static Puddle getPuddle(Tile tile){ return map.get(tile.pos()); } @@ -79,13 +68,13 @@ public class Puddle extends SolidEntity implements SaveTrait, Poolable, DrawTrai if(tile.floor().isLiquid && !canStayOn(liquid, tile.floor().liquidDrop)){ reactPuddle(tile.floor().liquidDrop, liquid, amount, tile, - (tile.worldx() + source.worldx()) / 2f, (tile.worldy() + source.worldy()) / 2f); + (tile.worldx() + source.worldx()) / 2f, (tile.worldy() + source.worldy()) / 2f); Puddle p = map.get(tile.pos()); if(generation == 0 && p != null && p.lastRipple <= Time.time() - 40f){ Effects.effect(Fx.ripple, tile.floor().liquidDrop.color, - (tile.worldx() + source.worldx()) / 2f, (tile.worldy() + source.worldy()) / 2f); + (tile.worldx() + source.worldx()) / 2f, (tile.worldy() + source.worldy()) / 2f); p.lastRipple = Time.time(); } return; @@ -99,14 +88,14 @@ public class Puddle extends SolidEntity implements SaveTrait, Poolable, DrawTrai puddle.tile = tile; puddle.liquid = liquid; puddle.amount = amount; - puddle.generation = (byte) generation; + puddle.generation = (byte)generation; puddle.set((tile.worldx() + source.worldx()) / 2f, (tile.worldy() + source.worldy()) / 2f); puddle.add(); map.put(tile.pos(), puddle); }else if(p.liquid == liquid){ p.accepting = Math.max(amount, p.accepting); - if(generation == 0 && p.lastRipple <= Time.time() - 40f && p.amount >= maxLiquid / 2f){ + if(generation == 0 && p.lastRipple <= Time.time() - 40f && p.amount >= maxLiquid / 2f){ Effects.effect(Fx.ripple, p.liquid.color, (tile.worldx() + source.worldx()) / 2f, (tile.worldy() + source.worldy()) / 2f); p.lastRipple = Time.time(); } @@ -123,10 +112,10 @@ public class Puddle extends SolidEntity implements SaveTrait, Poolable, DrawTrai return liquid == Liquids.oil && other == Liquids.water; } - /**Reacts two liquids together at a location.*/ + /** Reacts two liquids together at a location. */ private static float reactPuddle(Liquid dest, Liquid liquid, float amount, Tile tile, float x, float y){ if((dest.flammability > 0.3f && liquid.temperature > 0.7f) || - (liquid.flammability > 0.3f && dest.temperature > 0.7f)){ //flammable liquid + hot liquid + (liquid.flammability > 0.3f && dest.temperature > 0.7f)){ //flammable liquid + hot liquid Fire.create(tile); if(Mathf.chance(0.006 * amount)){ Call.createBullet(Bullets.fireball, x, y, Mathf.random(360f)); @@ -234,7 +223,7 @@ public class Puddle extends SolidEntity implements SaveTrait, Poolable, DrawTrai Fill.circle(x + Mathf.sin(Time.time() + seeds * 532, sscl, smag), y + Mathf.sin(Time.time() + seeds * 53, sscl, smag), f * 8f); Angles.randLenVectors(id, 3, f * 6f, (ex, ey) -> { Fill.circle(x + ex + Mathf.sin(Time.time() + seeds * 532, sscl, smag), - y + ey + Mathf.sin(Time.time() + seeds * 53, sscl, smag), f * 5f); + y + ey + Mathf.sin(Time.time() + seeds * 53, sscl, smag), f * 5f); seeds++; }); Draw.color(); @@ -295,7 +284,7 @@ public class Puddle extends SolidEntity implements SaveTrait, Poolable, DrawTrai data.writeFloat(x); data.writeFloat(y); data.writeByte(liquid.id); - data.writeShort((short) (amount * 4)); + data.writeShort((short)(amount * 4)); data.writeInt(tile.pos()); } diff --git a/core/src/io/anuke/mindustry/entities/effect/RubbleDecal.java b/core/src/io/anuke/mindustry/entities/effect/RubbleDecal.java index bc94ecbec9..eb5e4b01ab 100644 --- a/core/src/io/anuke/mindustry/entities/effect/RubbleDecal.java +++ b/core/src/io/anuke/mindustry/entities/effect/RubbleDecal.java @@ -11,7 +11,7 @@ public class RubbleDecal extends Decal{ private static final TextureRegion[][] regions = new TextureRegion[16][0]; private TextureRegion region; - /**Creates a rubble effect at a position. Provide a block size to use.*/ + /** Creates a rubble effect at a position. Provide a block size to use. */ public static void create(float x, float y, int size){ if(headless) return; diff --git a/core/src/io/anuke/mindustry/entities/effect/ScorchDecal.java b/core/src/io/anuke/mindustry/entities/effect/ScorchDecal.java index eba584b76b..5de0a894a2 100644 --- a/core/src/io/anuke/mindustry/entities/effect/ScorchDecal.java +++ b/core/src/io/anuke/mindustry/entities/effect/ScorchDecal.java @@ -40,10 +40,10 @@ public class ScorchDecal extends Decal{ float space = 1.5f + Mathf.randomSeed(id + i + 1, 0, 20) / 10f; Draw.rect(region, x + Angles.trnsx(rotation, space), - y + Angles.trnsy(rotation, space) + region.getHeight()/2f*Draw.scl, + y + Angles.trnsy(rotation, space) + region.getHeight() / 2f * Draw.scl, region.getWidth() * Draw.scl, region.getHeight() * Draw.scl, - region.getWidth()/2f*Draw.scl, 0, rotation - 90); + region.getWidth() / 2f * Draw.scl, 0, rotation - 90); } } } diff --git a/core/src/io/anuke/mindustry/entities/impl/DestructibleEntity.java b/core/src/io/anuke/mindustry/entities/impl/DestructibleEntity.java index fdb22094c6..dce6f3dae5 100644 --- a/core/src/io/anuke/mindustry/entities/impl/DestructibleEntity.java +++ b/core/src/io/anuke/mindustry/entities/impl/DestructibleEntity.java @@ -1,9 +1,7 @@ package io.anuke.mindustry.entities.impl; -import io.anuke.mindustry.entities.traits.DamageTrait; -import io.anuke.mindustry.entities.traits.HealthTrait; -import io.anuke.mindustry.entities.traits.SolidTrait; +import io.anuke.mindustry.entities.traits.*; public abstract class DestructibleEntity extends SolidEntity implements HealthTrait{ public transient boolean dead; @@ -18,7 +16,7 @@ public abstract class DestructibleEntity extends SolidEntity implements HealthTr public void collision(SolidTrait other, float x, float y){ if(other instanceof DamageTrait){ onHit(other); - damage(((DamageTrait) other).damage()); + damage(((DamageTrait)other).damage()); } } diff --git a/core/src/io/anuke/mindustry/entities/traits/BuilderTrait.java b/core/src/io/anuke/mindustry/entities/traits/BuilderTrait.java index 3cb66988bd..ec745b67c3 100644 --- a/core/src/io/anuke/mindustry/entities/traits/BuilderTrait.java +++ b/core/src/io/anuke/mindustry/entities/traits/BuilderTrait.java @@ -5,9 +5,7 @@ import io.anuke.arc.Events; import io.anuke.arc.collection.Array; import io.anuke.arc.collection.Queue; import io.anuke.arc.graphics.Color; -import io.anuke.arc.graphics.g2d.Draw; -import io.anuke.arc.graphics.g2d.Fill; -import io.anuke.arc.graphics.g2d.Lines; +import io.anuke.arc.graphics.g2d.*; import io.anuke.arc.math.Angles; import io.anuke.arc.math.Mathf; import io.anuke.arc.math.geom.Vector2; @@ -16,29 +14,23 @@ import io.anuke.mindustry.Vars; import io.anuke.mindustry.content.Blocks; import io.anuke.mindustry.content.Fx; import io.anuke.mindustry.entities.Effects; -import io.anuke.mindustry.entities.type.Player; -import io.anuke.mindustry.entities.type.TileEntity; -import io.anuke.mindustry.entities.type.Unit; +import io.anuke.mindustry.entities.type.*; import io.anuke.mindustry.game.EventType.BuildSelectEvent; import io.anuke.mindustry.gen.Call; import io.anuke.mindustry.graphics.Pal; import io.anuke.mindustry.graphics.Shapes; import io.anuke.mindustry.net.Net; import io.anuke.mindustry.type.Item; -import io.anuke.mindustry.world.Block; -import io.anuke.mindustry.world.Build; -import io.anuke.mindustry.world.Pos; -import io.anuke.mindustry.world.Tile; +import io.anuke.mindustry.world.*; import io.anuke.mindustry.world.blocks.BuildBlock; import io.anuke.mindustry.world.blocks.BuildBlock.BuildEntity; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; +import java.io.*; import java.util.Arrays; import static io.anuke.mindustry.Vars.*; -import static io.anuke.mindustry.entities.traits.BuilderTrait.BuildDataStatic.*; +import static io.anuke.mindustry.entities.traits.BuilderTrait.BuildDataStatic.removal; +import static io.anuke.mindustry.entities.traits.BuilderTrait.BuildDataStatic.tmptr; /** * Interface for units that build, break or mine things. @@ -54,25 +46,25 @@ public interface BuilderTrait extends Entity, TeamTrait{ static Vector2[] tmptr = new Vector2[]{new Vector2(), new Vector2(), new Vector2(), new Vector2()}; } - /**Returns the queue for storing build requests.*/ + /** Returns the queue for storing build requests. */ Queue getPlaceQueue(); - /**Returns the tile this builder is currently mining.*/ + /** Returns the tile this builder is currently mining. */ Tile getMineTile(); - /**Sets the tile this builder is currently mining.*/ + /** Sets the tile this builder is currently mining. */ void setMineTile(Tile tile); - /**Returns the minining speed of this miner. 1 = standard, 0.5 = half speed, 2 = double speed, etc.*/ + /** Returns the minining speed of this miner. 1 = standard, 0.5 = half speed, 2 = double speed, etc. */ float getMinePower(); - /**Build power, can be any float. 1 = builds recipes in normal time, 0 = doesn't build at all.*/ + /** Build power, can be any float. 1 = builds recipes in normal time, 0 = doesn't build at all. */ float getBuildPower(Tile tile); - /**Returns whether or not this builder can mine a specific item type.*/ + /** Returns whether or not this builder can mine a specific item type. */ boolean canMine(Item item); - /**Whether this type of builder can begin creating new blocks.*/ + /** Whether this type of builder can begin creating new blocks. */ default boolean canCreateBlocks(){ return true; } @@ -106,13 +98,13 @@ public interface BuilderTrait extends Entity, TeamTrait{ float progress = input.readFloat(); BuildRequest request; - if(type == 1){ //remove - request = new BuildRequest(Pos.x(position), Pos.y(position)); - }else{ //place - byte block = input.readByte(); - byte rotation = input.readByte(); - request = new BuildRequest(Pos.x(position), Pos.y(position), rotation, content.block(block)); - } + if(type == 1){ //remove + request = new BuildRequest(Pos.x(position), Pos.y(position)); + }else{ //place + byte block = input.readByte(); + byte rotation = input.readByte(); + request = new BuildRequest(Pos.x(position), Pos.y(position), rotation, content.block(block)); + } request.progress = progress; @@ -124,17 +116,17 @@ public interface BuilderTrait extends Entity, TeamTrait{ } } - /**Return whether this builder's place queue contains items.*/ + /** Return whether this builder's place queue contains items. */ default boolean isBuilding(){ return getPlaceQueue().size != 0; } - /**Clears the placement queue.*/ + /** Clears the placement queue. */ default void clearBuilding(){ getPlaceQueue().clear(); } - /**Add another build requests to the tail of the queue, if it doesn't exist there yet.*/ + /** Add another build requests to the tail of the queue, if it doesn't exist there yet. */ default void addBuildRequest(BuildRequest place){ for(BuildRequest request : getPlaceQueue()){ if(request.x == place.x && request.y == place.y){ @@ -172,8 +164,8 @@ public interface BuilderTrait extends Entity, TeamTrait{ for(BuildRequest request : removal){ if(!((request.breaking && world.tile(request.x, request.y).block() == Blocks.air) || - (!request.breaking && (world.tile(request.x, request.y).getRotation() == request.rotation || !request.block.rotate) - && world.tile(request.x, request.y).block() == request.block))){ + (!request.breaking && (world.tile(request.x, request.y).getRotation() == request.rotation || !request.block.rotate) + && world.tile(request.x, request.y).block() == request.block))){ getPlaceQueue().addLast(request); } } @@ -249,14 +241,14 @@ public interface BuilderTrait extends Entity, TeamTrait{ } } - /**Do not call directly.*/ + /** Do not call directly. */ default void updateMining(){ Unit unit = (Unit)this; Tile tile = getMineTile(); TileEntity core = unit.getClosestCore(); if(core == null || tile.block() != Blocks.air || dst(tile.worldx(), tile.worldy()) > mineDistance - || tile.drop() == null || !unit.acceptsItem(tile.drop()) || !canMine(tile.drop())){ + || tile.drop() == null || !unit.acceptsItem(tile.drop()) || !canMine(tile.drop())){ setMineTile(null); }else{ Item item = tile.drop(); @@ -266,25 +258,25 @@ public interface BuilderTrait extends Entity, TeamTrait{ if(unit.dst(core) < mineTransferRange && core.tile.block().acceptStack(item, 1, core.tile, unit) == 1){ Call.transferItemTo(item, 1, - tile.worldx() + Mathf.range(tilesize / 2f), - tile.worldy() + Mathf.range(tilesize / 2f), core.tile); + tile.worldx() + Mathf.range(tilesize / 2f), + tile.worldy() + Mathf.range(tilesize / 2f), core.tile); }else if(unit.acceptsItem(item)){ Call.transferItemToUnit(item, - tile.worldx() + Mathf.range(tilesize / 2f), - tile.worldy() + Mathf.range(tilesize / 2f), - unit); + tile.worldx() + Mathf.range(tilesize / 2f), + tile.worldy() + Mathf.range(tilesize / 2f), + unit); } } if(Mathf.chance(0.06 * Time.delta())){ Effects.effect(Fx.pulverizeSmall, - tile.worldx() + Mathf.range(tilesize / 2f), - tile.worldy() + Mathf.range(tilesize / 2f), 0f, item.color); + tile.worldx() + Mathf.range(tilesize / 2f), + tile.worldy() + Mathf.range(tilesize / 2f), 0f, item.color); } } } - /**Draw placement effects for an entity. This includes mining*/ + /** Draw placement effects for an entity. This includes mining */ default void drawBuilding(){ Unit unit = (Unit)this; BuildRequest request; @@ -317,10 +309,10 @@ public interface BuilderTrait extends Entity, TeamTrait{ tmptr[3].set(tile.drawx() + sz, tile.drawy() + sz); Arrays.sort(tmptr, (a, b) -> -Float.compare(Angles.angleDist(Angles.angle(unit.x, unit.y, a.x, a.y), ang), - Angles.angleDist(Angles.angle(unit.x, unit.y, b.x, b.y), ang))); + Angles.angleDist(Angles.angle(unit.x, unit.y, b.x, b.y), ang))); float x1 = tmptr[0].x, y1 = tmptr[0].y, - x3 = tmptr[1].x, y3 = tmptr[1].y; + x3 = tmptr[1].x, y3 = tmptr[1].y; Draw.alpha(1f); @@ -332,7 +324,7 @@ public interface BuilderTrait extends Entity, TeamTrait{ Draw.color(); } - /**Internal use only.*/ + /** Internal use only. */ default void drawMining(){ Unit unit = (Unit)this; Tile tile = getMineTile(); @@ -353,7 +345,7 @@ public interface BuilderTrait extends Entity, TeamTrait{ Shapes.laser("minelaser", "minelaser-end", px, py, ex, ey, 0.75f); - if(unit instanceof Player && ((Player) unit).isLocal){ + if(unit instanceof Player && ((Player)unit).isLocal){ Lines.stroke(1f, Pal.accent); Lines.poly(tile.worldx(), tile.worldy(), 4, tilesize / 2f * Mathf.sqrt2, Time.time()); } @@ -361,7 +353,7 @@ public interface BuilderTrait extends Entity, TeamTrait{ Draw.color(); } - /**Class for storing build requests. Can be either a place or remove request.*/ + /** Class for storing build requests. Can be either a place or remove request. */ class BuildRequest{ public final int x, y, rotation; public final Block block; @@ -370,7 +362,7 @@ public interface BuilderTrait extends Entity, TeamTrait{ public float progress; public boolean initialized; - /**This creates a build request.*/ + /** This creates a build request. */ public BuildRequest(int x, int y, int rotation, Block block){ this.x = x; this.y = y; @@ -379,7 +371,7 @@ public interface BuilderTrait extends Entity, TeamTrait{ this.breaking = false; } - /**This creates a remove request.*/ + /** This creates a remove request. */ public BuildRequest(int x, int y){ this.x = x; this.y = y; diff --git a/core/src/io/anuke/mindustry/entities/traits/Saveable.java b/core/src/io/anuke/mindustry/entities/traits/Saveable.java index 6f3950bcb0..b3b3bc5914 100644 --- a/core/src/io/anuke/mindustry/entities/traits/Saveable.java +++ b/core/src/io/anuke/mindustry/entities/traits/Saveable.java @@ -1,8 +1,6 @@ package io.anuke.mindustry.entities.traits; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; +import java.io.*; public interface Saveable{ void writeSave(DataOutput stream) throws IOException; diff --git a/core/src/io/anuke/mindustry/entities/traits/SolidTrait.java b/core/src/io/anuke/mindustry/entities/traits/SolidTrait.java index 83f5a70524..9321c6fcc1 100644 --- a/core/src/io/anuke/mindustry/entities/traits/SolidTrait.java +++ b/core/src/io/anuke/mindustry/entities/traits/SolidTrait.java @@ -1,11 +1,9 @@ package io.anuke.mindustry.entities.traits; -import io.anuke.mindustry.entities.EntityQuery; -import io.anuke.arc.math.geom.Position; +import io.anuke.arc.math.geom.*; import io.anuke.arc.math.geom.QuadTree.QuadTreeObject; -import io.anuke.arc.math.geom.Rectangle; -import io.anuke.arc.math.geom.Vector2; +import io.anuke.mindustry.entities.EntityQuery; public interface SolidTrait extends QuadTreeObject, MoveTrait, VelocityTrait, Entity, Position{ @@ -35,7 +33,8 @@ public interface SolidTrait extends QuadTreeObject, MoveTrait, VelocityTrait, En return true; } - default void collision(SolidTrait other, float x, float y){} + default void collision(SolidTrait other, float x, float y){ + } default void move(float x, float y){ EntityQuery.collisions().move(this, x, y); diff --git a/core/src/io/anuke/mindustry/entities/traits/SyncTrait.java b/core/src/io/anuke/mindustry/entities/traits/SyncTrait.java index 81e5419014..4d8a473984 100644 --- a/core/src/io/anuke/mindustry/entities/traits/SyncTrait.java +++ b/core/src/io/anuke/mindustry/entities/traits/SyncTrait.java @@ -1,17 +1,15 @@ package io.anuke.mindustry.entities.traits; -import io.anuke.mindustry.core.NetClient; -import io.anuke.mindustry.net.Interpolator; import io.anuke.arc.Core; import io.anuke.arc.util.Tmp; +import io.anuke.mindustry.core.NetClient; +import io.anuke.mindustry.net.Interpolator; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; +import java.io.*; public interface SyncTrait extends Entity, TypeTrait{ - /**Sets the position of this entity and updated the interpolator.*/ + /** Sets the position of this entity and updated the interpolator. */ default void setNet(float x, float y){ set(x, y); @@ -24,7 +22,7 @@ public interface SyncTrait extends Entity, TypeTrait{ } } - /**Interpolate entity position only. Override if you need to interpolate rotations or other values.*/ + /** Interpolate entity position only. Override if you need to interpolate rotations or other values. */ default void interpolate(){ if(getInterpolator() == null){ throw new RuntimeException("This entity must have an interpolator to interpolate()!"); @@ -47,17 +45,17 @@ public interface SyncTrait extends Entity, TypeTrait{ setY(getInterpolator().pos.y); } - /**Return the interpolator used for smoothing the position. Optional.*/ + /** Return the interpolator used for smoothing the position. Optional. */ default Interpolator getInterpolator(){ return null; } - /**Whether syncing is enabled for this entity; true by default.*/ + /** Whether syncing is enabled for this entity; true by default. */ default boolean isSyncing(){ return true; } - /**Whether this entity is clipped and not synced when out of viewport.*/ + /** Whether this entity is clipped and not synced when out of viewport. */ default boolean isClipped(){ return true; } diff --git a/core/src/io/anuke/mindustry/entities/traits/TargetTrait.java b/core/src/io/anuke/mindustry/entities/traits/TargetTrait.java index dcc7a876b9..819e9dbcdc 100644 --- a/core/src/io/anuke/mindustry/entities/traits/TargetTrait.java +++ b/core/src/io/anuke/mindustry/entities/traits/TargetTrait.java @@ -14,14 +14,14 @@ public interface TargetTrait extends Position, VelocityTrait{ default float getTargetVelocityX(){ if(this instanceof SolidTrait){ - return ((SolidTrait) this).getDeltaX(); + return ((SolidTrait)this).getDeltaX(); } return velocity().x; } default float getTargetVelocityY(){ if(this instanceof SolidTrait){ - return ((SolidTrait) this).getDeltaY(); + return ((SolidTrait)this).getDeltaY(); } return velocity().y; } diff --git a/core/src/io/anuke/mindustry/entities/traits/VelocityTrait.java b/core/src/io/anuke/mindustry/entities/traits/VelocityTrait.java index c836154f9c..e5bddaed43 100644 --- a/core/src/io/anuke/mindustry/entities/traits/VelocityTrait.java +++ b/core/src/io/anuke/mindustry/entities/traits/VelocityTrait.java @@ -28,7 +28,7 @@ public interface VelocityTrait extends MoveTrait{ velocity().scl(1f - drag() * Time.delta()); if(this instanceof SolidTrait){ - ((SolidTrait) this).move(velocity().x * Time.delta(), velocity().y * Time.delta()); + ((SolidTrait)this).move(velocity().x * Time.delta(), velocity().y * Time.delta()); }else{ moveBy(velocity().x * Time.delta(), velocity().y * Time.delta()); } diff --git a/core/src/io/anuke/mindustry/entities/type/BaseUnit.java b/core/src/io/anuke/mindustry/entities/type/BaseUnit.java index d4d2ad4063..a64128d392 100644 --- a/core/src/io/anuke/mindustry/entities/type/BaseUnit.java +++ b/core/src/io/anuke/mindustry/entities/type/BaseUnit.java @@ -29,7 +29,7 @@ import java.io.*; import static io.anuke.mindustry.Vars.*; -/**Base class for AI units.*/ +/** Base class for AI units. */ public abstract class BaseUnit extends Unit implements ShooterTrait{ protected static int timerIndex = 0; @@ -45,7 +45,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{ protected int spawner = noSpawner; - /**internal constructor used for deserialization, DO NOT USE*/ + /** internal constructor used for deserialization, DO NOT USE */ public BaseUnit(){ } @@ -78,7 +78,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{ return type.drag; } - /**Initialize the type and team of this unit. Only call once!*/ + /** Initialize the type and team of this unit. Only call once! */ public void init(UnitType type, Team team){ if(this.type != null) throw new RuntimeException("This unit is already initialized!"); @@ -99,7 +99,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{ } public boolean targetHasFlag(BlockFlag flag){ - return target instanceof TileEntity && ((TileEntity) target).tile.block().flags.contains(flag); + return target instanceof TileEntity && ((TileEntity)target).tile.block().flags.contains(flag); } public void setState(UnitState state){ @@ -112,14 +112,14 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{ } } - /**Only runs when the unit has a target.*/ + /** Only runs when the unit has a target. */ public void behavior(){ } public void updateTargeting(){ if(target == null || (target instanceof Unit && (target.isDead() || target.getTeam() == team)) - || (target instanceof TileEntity && ((TileEntity) target).tile.entity == null)){ + || (target instanceof TileEntity && ((TileEntity)target).tile.entity == null)){ target = null; } } @@ -166,9 +166,9 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{ float angT = i == 0 ? 0 : Mathf.randomSeedRange(i + 2, 60f); float lenT = i == 0 ? 0 : Mathf.randomSeedRange(i + 3, 1f) - 1f; Draw.rect(item.item.icon(Item.Icon.large), - x + Angles.trnsx(rotation + 180f + angT, backTrns + lenT), - y + Angles.trnsy(rotation + 180f + angT, backTrns + lenT), - itemSize, itemSize, rotation); + x + Angles.trnsx(rotation + 180f + angT, backTrns + lenT), + y + Angles.trnsy(rotation + 180f + angT, backTrns + lenT), + itemSize, itemSize, rotation); } } } diff --git a/core/src/io/anuke/mindustry/entities/type/FlyingUnit.java b/core/src/io/anuke/mindustry/entities/type/FlyingUnit.java index 6f011652d9..854cd51c3d 100644 --- a/core/src/io/anuke/mindustry/entities/type/FlyingUnit.java +++ b/core/src/io/anuke/mindustry/entities/type/FlyingUnit.java @@ -127,11 +127,11 @@ public abstract class FlyingUnit extends BaseUnit{ public void drawEngine(){ Draw.color(Pal.engine); Fill.circle(x + Angles.trnsx(rotation + 180, type.engineOffset), y + Angles.trnsy(rotation + 180, type.engineOffset), - type.engineSize + Mathf.absin(Time.time(), 2f, type.engineSize/4f)); + type.engineSize + Mathf.absin(Time.time(), 2f, type.engineSize / 4f)); Draw.color(Color.WHITE); - Fill.circle(x + Angles.trnsx(rotation + 180, type.engineOffset-1f), y + Angles.trnsy(rotation + 180, type.engineOffset-1f), - (type.engineSize + Mathf.absin(Time.time(), 2f, type.engineSize/4f)) / 2f); + Fill.circle(x + Angles.trnsx(rotation + 180, type.engineOffset - 1f), y + Angles.trnsy(rotation + 180, type.engineOffset - 1f), + (type.engineSize + Mathf.absin(Time.time(), 2f, type.engineSize / 4f)) / 2f); Draw.color(); } @@ -141,7 +141,7 @@ public abstract class FlyingUnit extends BaseUnit{ if(Units.invalidateTarget(target, this)){ for(boolean left : Mathf.booleans){ int wi = Mathf.num(left); - weaponAngles[wi] = Mathf.slerpDelta(weaponAngles[wi],rotation, 0.1f); + weaponAngles[wi] = Mathf.slerpDelta(weaponAngles[wi], rotation, 0.1f); } } } @@ -154,8 +154,8 @@ public abstract class FlyingUnit extends BaseUnit{ protected void wobble(){ if(Net.client()) return; - x += Mathf.sin(Time.time() + id * 999, 25f, 0.05f)*Time.delta(); - y += Mathf.cos(Time.time() + id * 999, 25f, 0.05f)*Time.delta(); + x += Mathf.sin(Time.time() + id * 999, 25f, 0.05f) * Time.delta(); + y += Mathf.cos(Time.time() + id * 999, 25f, 0.05f) * Time.delta(); if(velocity.len() <= 0.05f){ //rotation += Mathf.sin(Time.time() + id * 99, 10f, 2f * type.speed)*Time.delta(); diff --git a/core/src/io/anuke/mindustry/entities/type/GroundUnit.java b/core/src/io/anuke/mindustry/entities/type/GroundUnit.java index 6b0f0528c1..062231d760 100644 --- a/core/src/io/anuke/mindustry/entities/type/GroundUnit.java +++ b/core/src/io/anuke/mindustry/entities/type/GroundUnit.java @@ -111,7 +111,7 @@ public abstract class GroundUnit extends BaseUnit{ public void draw(){ Draw.mixcol(Color.WHITE, hitTime / hitDuration); - float ft = Mathf.sin(walkTime * type.speed*5f, 6f, 2f + type.hitsize/15f); + float ft = Mathf.sin(walkTime * type.speed * 5f, 6f, 2f + type.hitsize / 15f); Floor floor = getFloorOn(); @@ -121,9 +121,9 @@ public abstract class GroundUnit extends BaseUnit{ for(int i : Mathf.signs){ Draw.rect(type.legRegion, - x + Angles.trnsx(baseRotation, ft * i), - y + Angles.trnsy(baseRotation, ft * i), - type.legRegion.getWidth() * i * Draw.scl, type.legRegion.getHeight() * Draw.scl - Mathf.clamp(ft * i, 0, 2), baseRotation - 90); + x + Angles.trnsx(baseRotation, ft * i), + y + Angles.trnsy(baseRotation, ft * i), + type.legRegion.getWidth() * i * Draw.scl, type.legRegion.getHeight() * Draw.scl - Mathf.clamp(ft * i, 0, 2), baseRotation - 90); } if(floor.isLiquid){ @@ -138,10 +138,10 @@ public abstract class GroundUnit extends BaseUnit{ for(int i : Mathf.signs){ float tra = rotation - 90, trY = -type.weapon.getRecoil(this, i > 0) + type.weaponOffsetY; - float w = - i * type.weapon.region.getWidth() * Draw.scl; + float w = -i * type.weapon.region.getWidth() * Draw.scl; Draw.rect(type.weapon.region, - x + Angles.trnsx(tra, getWeapon().width * i, trY), - y + Angles.trnsy(tra, getWeapon().width * i, trY), w, type.weapon.region.getHeight() * Draw.scl, rotation - 90); + x + Angles.trnsx(tra, getWeapon().width * i, trY), + y + Angles.trnsy(tra, getWeapon().width * i, trY), w, type.weapon.region.getHeight() * Draw.scl, rotation - 90); } drawItems(); @@ -211,7 +211,7 @@ public abstract class GroundUnit extends BaseUnit{ if(tile == targetTile) return; - velocity.add(vec.trns(angleTo(targetTile), type.speed*Time.delta())); + velocity.add(vec.trns(angleTo(targetTile), type.speed * Time.delta())); if(Units.invalidateTarget(target, this)){ rotation = Mathf.slerpDelta(rotation, baseRotation, type.rotatespeed); } @@ -235,7 +235,7 @@ public abstract class GroundUnit extends BaseUnit{ if(tile == targetTile || core == null || dst(core) < 90f) return; - velocity.add(vec.trns(angleTo(targetTile), type.speed*Time.delta())); + velocity.add(vec.trns(angleTo(targetTile), type.speed * Time.delta())); rotation = Mathf.slerpDelta(rotation, baseRotation, type.rotatespeed); } } diff --git a/core/src/io/anuke/mindustry/entities/type/Player.java b/core/src/io/anuke/mindustry/entities/type/Player.java index cafebce954..aca2af1f3e 100644 --- a/core/src/io/anuke/mindustry/entities/type/Player.java +++ b/core/src/io/anuke/mindustry/entities/type/Player.java @@ -365,11 +365,11 @@ public class Player extends Unit implements BuilderTrait, ShooterTrait{ float size = mech.engineSize * (mech.flying ? 1f : boostHeat); Draw.color(mech.engineColor); Fill.circle(x + Angles.trnsx(rotation + 180, mech.engineOffset), y + Angles.trnsy(rotation + 180, mech.engineOffset), - size + Mathf.absin(Time.time(), 2f, size/4f)); + size + Mathf.absin(Time.time(), 2f, size / 4f)); Draw.color(Color.WHITE); - Fill.circle(x + Angles.trnsx(rotation + 180, mech.engineOffset-1f), y + Angles.trnsy(rotation + 180, mech.engineOffset-1f), - (size + Mathf.absin(Time.time(), 2f, size/4f)) / 2f); + Fill.circle(x + Angles.trnsx(rotation + 180, mech.engineOffset - 1f), y + Angles.trnsy(rotation + 180, mech.engineOffset - 1f), + (size + Mathf.absin(Time.time(), 2f, size / 4f)) / 2f); Draw.color(); } @@ -443,15 +443,16 @@ public class Player extends Unit implements BuilderTrait, ShooterTrait{ TextureRegion region = draw.region; Draw.rect(region, - request.x * tilesize + request.block.offset(), request.y * tilesize + request.block.offset(), - region.getWidth() * 1f * Draw.scl * draw.scalex, - region.getHeight() * 1f * Draw.scl * draw.scaley, request.block.rotate ? draw.rotation * 90 : 0); + request.x * tilesize + request.block.offset(), request.y * tilesize + request.block.offset(), + region.getWidth() * 1f * Draw.scl * draw.scalex, + region.getHeight() * 1f * Draw.scl * draw.scaley, request.block.rotate ? draw.rotation * 90 : 0); Draw.color(Pal.accent); for(int i = 0; i < 4; i++){ Point2 p = Geometry.d8edge[i]; - float offset = -Math.max(request.block.size-1, 0)/2f * tilesize; - if(i % 2 == 0) Draw.rect("block-select", request.x * tilesize + request.block.offset() + offset * p.x, request.y * tilesize + request.block.offset() + offset * p.y, i * 90); + float offset = -Math.max(request.block.size - 1, 0) / 2f * tilesize; + if(i % 2 == 0) + Draw.rect("block-select", request.x * tilesize + request.block.offset() + offset * p.x, request.y * tilesize + request.block.offset() + offset * p.y, i * 90); } Draw.color(); @@ -615,7 +616,7 @@ public class Player extends Unit implements BuilderTrait, ShooterTrait{ } protected void updateFlying(){ - if(Units.invalidateTarget(target, this) && !(target instanceof TileEntity && ((TileEntity) target).damaged() && target.getTeam() == team && + if(Units.invalidateTarget(target, this) && !(target instanceof TileEntity && ((TileEntity)target).damaged() && target.getTeam() == team && mech.canHeal && dst(target) < getWeapon().bullet.range())){ target = null; } @@ -635,7 +636,7 @@ public class Player extends Unit implements BuilderTrait, ShooterTrait{ if(dst(moveTarget) < 2f){ if(tapping){ - Tile tile = ((TileEntity) moveTarget).tile; + Tile tile = ((TileEntity)moveTarget).tile; tile.block().tapped(tile, this); } @@ -695,7 +696,7 @@ public class Player extends Unit implements BuilderTrait, ShooterTrait{ if(target != null && dst(target) > getWeapon().bullet.range()){ target = null; }else if(target != null){ - target = ((Tile) target).entity; + target = ((Tile)target).entity; } } @@ -703,7 +704,7 @@ public class Player extends Unit implements BuilderTrait, ShooterTrait{ setMineTile(null); } } - }else if(target.isValid() || (target instanceof TileEntity && ((TileEntity) target).damaged() && target.getTeam() == team && + }else if(target.isValid() || (target instanceof TileEntity && ((TileEntity)target).damaged() && target.getTeam() == team && mech.canHeal && dst(target) < getWeapon().bullet.range())){ //rotate toward and shoot the target if(mech.turnCursor){ @@ -840,7 +841,7 @@ public class Player extends Unit implements BuilderTrait, ShooterTrait{ buffer.writeByte(mech.id); buffer.writeInt(mining == null ? noSpawner : mining.pos()); buffer.writeInt(spawner == null ? noSpawner : spawner.getTile().pos()); - buffer.writeShort((short) (baseRotation * 2)); + buffer.writeShort((short)(baseRotation * 2)); writeBuilding(buffer); } diff --git a/core/src/io/anuke/mindustry/entities/type/TileEntity.java b/core/src/io/anuke/mindustry/entities/type/TileEntity.java index a6eacb1fbe..2fb3bb1d81 100644 --- a/core/src/io/anuke/mindustry/entities/type/TileEntity.java +++ b/core/src/io/anuke/mindustry/entities/type/TileEntity.java @@ -20,18 +20,11 @@ import io.anuke.mindustry.entities.traits.TargetTrait; import io.anuke.mindustry.game.EventType.BlockDestroyEvent; import io.anuke.mindustry.game.Team; import io.anuke.mindustry.gen.Call; -import io.anuke.mindustry.world.Block; -import io.anuke.mindustry.world.Edges; -import io.anuke.mindustry.world.Tile; +import io.anuke.mindustry.world.*; import io.anuke.mindustry.world.blocks.defense.Wall; -import io.anuke.mindustry.world.modules.ConsumeModule; -import io.anuke.mindustry.world.modules.ItemModule; -import io.anuke.mindustry.world.modules.LiquidModule; -import io.anuke.mindustry.world.modules.PowerModule; +import io.anuke.mindustry.world.modules.*; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; +import java.io.*; import static io.anuke.mindustry.Vars.tileGroup; import static io.anuke.mindustry.Vars.world; @@ -39,7 +32,7 @@ import static io.anuke.mindustry.Vars.world; public class TileEntity extends BaseEntity implements TargetTrait, HealthTrait{ public static final float timeToSleep = 60f * 4; //4 seconds to fall asleep private static final ObjectSet tmpTiles = new ObjectSet<>(); - /**This value is only used for debugging.*/ + /** This value is only used for debugging. */ public static int sleepingEntities = 0; public Tile tile; @@ -53,7 +46,7 @@ public class TileEntity extends BaseEntity implements TargetTrait, HealthTrait{ public LiquidModule liquids; public ConsumeModule cons; - /**List of (cached) tiles with entities in proximity, used for outputting to*/ + /** List of (cached) tiles with entities in proximity, used for outputting to */ private Array proximity = new Array<>(8); private boolean dead = false; private boolean sleeping; @@ -76,7 +69,7 @@ public class TileEntity extends BaseEntity implements TargetTrait, HealthTrait{ tile.entity.onDeath(); } - /**Sets this tile entity data to this tile, and adds it if necessary.*/ + /** Sets this tile entity data to this tile, and adds it if necessary. */ public TileEntity init(Tile tile, boolean shouldAdd){ this.tile = tile; x = tile.drawx(); @@ -93,12 +86,12 @@ public class TileEntity extends BaseEntity implements TargetTrait, HealthTrait{ return this; } - /**Scaled delta.*/ + /** Scaled delta. */ public float delta(){ return Time.delta() * timeScale; } - /**Call when nothing is happening to the entity. This increments the internal sleep timer.*/ + /** Call when nothing is happening to the entity. This increments the internal sleep timer. */ public void sleep(){ sleepTime += Time.delta(); if(!sleeping && sleepTime >= timeToSleep){ @@ -108,7 +101,7 @@ public class TileEntity extends BaseEntity implements TargetTrait, HealthTrait{ } } - /**Call when this entity is updating. This wakes it up.*/ + /** Call when this entity is updating. This wakes it up. */ public void noSleep(){ sleepTime = 0f; if(sleeping){ @@ -126,13 +119,17 @@ public class TileEntity extends BaseEntity implements TargetTrait, HealthTrait{ return dead || tile.entity != this; } - public void write(DataOutput stream) throws IOException{} + public void write(DataOutput stream) throws IOException{ + } - public void writeConfig(DataOutput stream) throws IOException{} + public void writeConfig(DataOutput stream) throws IOException{ + } - public void read(DataInput stream) throws IOException{} + public void read(DataInput stream) throws IOException{ + } - public void readConfig(DataInput stream) throws IOException{} + public void readConfig(DataInput stream) throws IOException{ + } public boolean collide(Bullet other){ return true; @@ -269,7 +266,7 @@ public class TileEntity extends BaseEntity implements TargetTrait, HealthTrait{ public void update(){ //TODO better smoke effect, this one is awful if(health != 0 && health < block.health && !(block instanceof Wall) && - Mathf.chance(0.009f * Time.delta() * (1f - health / block.health))){ + Mathf.chance(0.009f * Time.delta() * (1f - health / block.health))){ Effects.effect(Fx.smoke, x + Mathf.range(4), y + Mathf.range(4)); } diff --git a/core/src/io/anuke/mindustry/entities/type/Unit.java b/core/src/io/anuke/mindustry/entities/type/Unit.java index 2cb0f2af98..910f8299ab 100644 --- a/core/src/io/anuke/mindustry/entities/type/Unit.java +++ b/core/src/io/anuke/mindustry/entities/type/Unit.java @@ -24,26 +24,21 @@ import io.anuke.mindustry.game.Teams.TeamData; import io.anuke.mindustry.graphics.Pal; import io.anuke.mindustry.net.Interpolator; import io.anuke.mindustry.net.Net; -import io.anuke.mindustry.type.Item; -import io.anuke.mindustry.type.ItemStack; -import io.anuke.mindustry.type.StatusEffect; -import io.anuke.mindustry.type.Weapon; +import io.anuke.mindustry.type.*; import io.anuke.mindustry.world.Pos; import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.blocks.Floor; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; +import java.io.*; import static io.anuke.mindustry.Vars.*; public abstract class Unit extends DestructibleEntity implements SaveTrait, TargetTrait, SyncTrait, DrawTrait, TeamTrait{ - /**Total duration of hit flash effect*/ + /** Total duration of hit flash effect */ public static final float hitDuration = 9f; - /**Percision divisor of velocity, used when writing. For example a value of '2' would mean the percision is 1/2 = 0.5-size chunks.*/ + /** Percision divisor of velocity, used when writing. For example a value of '2' would mean the percision is 1/2 = 0.5-size chunks. */ public static final float velocityPercision = 8f; - /**Maximum absolute value of a velocity vector component.*/ + /** Maximum absolute value of a velocity vector component. */ public static final float maxAbsVelocity = 127f / velocityPercision; public static final int noSpawner = Pos.get(-1, 1); @@ -106,9 +101,9 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ if(isDead()) return false; if(other instanceof DamageTrait){ - return other instanceof TeamTrait && state.teams.areEnemies((((TeamTrait) other).getTeam()), team); + return other instanceof TeamTrait && state.teams.areEnemies((((TeamTrait)other).getTeam()), team); }else{ - return other instanceof Unit && ((Unit) other).isFlying() == isFlying(); + return other instanceof Unit && ((Unit)other).isFlying() == isFlying(); } } @@ -198,10 +193,10 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ stream.writeBoolean(isDead()); stream.writeFloat(net ? interpolator.target.x : x); stream.writeFloat(net ? interpolator.target.y : y); - stream.writeByte((byte) (Mathf.clamp(velocity.x, -maxAbsVelocity, maxAbsVelocity) * velocityPercision)); - stream.writeByte((byte) (Mathf.clamp(velocity.y, -maxAbsVelocity, maxAbsVelocity) * velocityPercision)); - stream.writeShort((short) (rotation * 2)); - stream.writeShort((short) health); + stream.writeByte((byte)(Mathf.clamp(velocity.x, -maxAbsVelocity, maxAbsVelocity) * velocityPercision)); + stream.writeByte((byte)(Mathf.clamp(velocity.y, -maxAbsVelocity, maxAbsVelocity) * velocityPercision)); + stream.writeShort((short)(rotation * 2)); + stream.writeShort((short)health); stream.writeByte(item.item.id); stream.writeShort((short)item.amount); status.writeSave(stream); @@ -258,10 +253,10 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ moveVector.setZero(); for(int cx = -rad; cx <= rad; cx++){ for(int cy = -rad; cy <= rad; cy++){ - Tile tile = world.tileWorld(x + cx*tilesize, y + cy*tilesize); + Tile tile = world.tileWorld(x + cx * tilesize, y + cy * tilesize); if(tile == null) continue; int weight = flying ? tile.airWeight : tile.weight; - float scl = (rad - Mathf.dst(tile.worldx(), tile.worldy(), x, y)/(8f * 1.2f * Mathf.sqrt2)) * 0.1f; + float scl = (rad - Mathf.dst(tile.worldx(), tile.worldy(), x, y) / (8f * 1.2f * Mathf.sqrt2)) * 0.1f; moveVector.add(Mathf.sign(x - tile.worldx()) * scaling * weight * scl, Mathf.sign(y - tile.worldy()) * scaling * weight * scl); } @@ -301,12 +296,13 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ public Floor getFloorOn(){ Tile tile = world.tileWorld(x, y); - return tile == null ? (Floor) Blocks.air : tile.floor(); + return tile == null ? (Floor)Blocks.air : tile.floor(); } - public void onRespawn(Tile tile){} + public void onRespawn(Tile tile){ + } - /**Updates velocity and status effects.*/ + /** Updates velocity and status effects. */ public void updateVelocityStatus(){ Floor floor = getFloorOn(); @@ -314,7 +310,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ status.update(this); - velocity.limit(maxVelocity()).scl(1f + (status.getSpeedMultiplier()-1f) * Time.delta()); + velocity.limit(maxVelocity()).scl(1f + (status.getSpeedMultiplier() - 1f) * Time.delta()); if(x < -finalWorldBounds || y < -finalWorldBounds || x >= world.width() * tilesize + finalWorldBounds || y >= world.height() * tilesize + finalWorldBounds){ kill(); @@ -420,7 +416,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ } public void drawStats(){ - Draw.color(Color.BLACK, team.color, healthf() + Mathf.absin(Time.time(), healthf()*5f, 1f - healthf())); + Draw.color(Color.BLACK, team.color, healthf() + Mathf.absin(Time.time(), healthf() * 5f, 1f - healthf())); Draw.rect(getPowerCellRegion(), x, y, rotation - 90); Draw.color(); } diff --git a/core/src/io/anuke/mindustry/entities/type/base/Drone.java b/core/src/io/anuke/mindustry/entities/type/base/Drone.java index 20e662fd76..5b09640e57 100644 --- a/core/src/io/anuke/mindustry/entities/type/base/Drone.java +++ b/core/src/io/anuke/mindustry/entities/type/base/Drone.java @@ -2,31 +2,24 @@ package io.anuke.mindustry.entities.type.base; import io.anuke.arc.Events; import io.anuke.arc.collection.Queue; -import io.anuke.mindustry.entities.EntityGroup; import io.anuke.arc.math.Mathf; import io.anuke.arc.math.geom.Geometry; import io.anuke.arc.util.Structs; import io.anuke.mindustry.content.Blocks; -import io.anuke.mindustry.entities.type.Player; -import io.anuke.mindustry.entities.type.TileEntity; +import io.anuke.mindustry.entities.EntityGroup; import io.anuke.mindustry.entities.Units; import io.anuke.mindustry.entities.traits.BuilderTrait; -import io.anuke.mindustry.entities.type.BaseUnit; -import io.anuke.mindustry.entities.type.FlyingUnit; +import io.anuke.mindustry.entities.type.*; import io.anuke.mindustry.entities.units.UnitState; import io.anuke.mindustry.game.EventType.BuildSelectEvent; import io.anuke.mindustry.gen.Call; -import io.anuke.mindustry.type.Item; -import io.anuke.mindustry.type.ItemStack; -import io.anuke.mindustry.type.ItemType; +import io.anuke.mindustry.type.*; import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.blocks.BuildBlock; import io.anuke.mindustry.world.blocks.BuildBlock.BuildEntity; import io.anuke.mindustry.world.meta.BlockFlag; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; +import java.io.*; import static io.anuke.mindustry.Vars.unitGroups; import static io.anuke.mindustry.Vars.world; @@ -48,7 +41,7 @@ public class Drone extends FlyingUnit implements BuilderTrait{ } public void update(){ - BuildEntity entity = (BuildEntity) target; + BuildEntity entity = (BuildEntity)target; TileEntity core = getClosestCore(); if(entity == null){ @@ -105,7 +98,7 @@ public class Drone extends FlyingUnit implements BuilderTrait{ if(target == null) return; if(target.dst(Drone.this) > type.range){ - circle(type.range*0.9f); + circle(type.range * 0.9f); }else{ getWeapon().update(Drone.this, target.getX(), target.getY()); } @@ -155,10 +148,10 @@ public class Drone extends FlyingUnit implements BuilderTrait{ moveTo(type.range / 1.5f); if(dst(target) < type.range && mineTile != target){ - setMineTile((Tile) target); + setMineTile((Tile)target); } - if(((Tile) target).block() != Blocks.air){ + if(((Tile)target).block() != Blocks.air){ setState(drop); } } @@ -190,7 +183,7 @@ public class Drone extends FlyingUnit implements BuilderTrait{ if(target == null) return; - TileEntity tile = (TileEntity) target; + TileEntity tile = (TileEntity)target; if(dst(target) < type.range){ if(tile.tile.block().acceptStack(item.item, item.amount, tile.tile, Drone.this) == item.amount){ @@ -312,7 +305,7 @@ public class Drone extends FlyingUnit implements BuilderTrait{ @Override public void behavior(){ if(health <= health * type.retreatPercent && - Geometry.findClosest(x, y, world.indexer.getAllied(team, BlockFlag.repair)) != null){ + Geometry.findClosest(x, y, world.indexer.getAllied(team, BlockFlag.repair)) != null){ setState(retreat); } } diff --git a/core/src/io/anuke/mindustry/entities/type/base/Revenant.java b/core/src/io/anuke/mindustry/entities/type/base/Revenant.java index 9f3c5f2c6e..03233dbb5d 100644 --- a/core/src/io/anuke/mindustry/entities/type/base/Revenant.java +++ b/core/src/io/anuke/mindustry/entities/type/base/Revenant.java @@ -14,7 +14,7 @@ public class Revenant extends FlyingUnit{ float tra = rotation - 90, trY = -getWeapon().getRecoil(this, i > 0) + type.weaponOffsetY; float w = i > 0 ? -12 : 12; float wx = x + Angles.trnsx(tra, getWeapon().width * i, trY), wy = y + Angles.trnsy(tra, getWeapon().width * i, trY); - int wi = (i + 1)/2; + int wi = (i + 1) / 2; Draw.rect(getWeapon().region, wx, wy, w, 12, weaponAngles[wi] - 90); } } diff --git a/core/src/io/anuke/mindustry/entities/units/Statuses.java b/core/src/io/anuke/mindustry/entities/units/Statuses.java index ffc4fe8278..b8d0116ce3 100644 --- a/core/src/io/anuke/mindustry/entities/units/Statuses.java +++ b/core/src/io/anuke/mindustry/entities/units/Statuses.java @@ -12,12 +12,11 @@ import io.anuke.mindustry.entities.type.Unit; import io.anuke.mindustry.type.ContentType; import io.anuke.mindustry.type.StatusEffect; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; +import java.io.*; import static io.anuke.mindustry.Vars.content; -/** Class for controlling status effects on an entity.*/ + +/** Class for controlling status effects on an entity. */ public class Statuses implements Saveable{ private static final StatusEntry globalResult = new StatusEntry(); private static final Array removals = new Array<>(); diff --git a/core/src/io/anuke/mindustry/entities/units/UnitDrops.java b/core/src/io/anuke/mindustry/entities/units/UnitDrops.java index 84c47a4457..fb18a9b9fb 100644 --- a/core/src/io/anuke/mindustry/entities/units/UnitDrops.java +++ b/core/src/io/anuke/mindustry/entities/units/UnitDrops.java @@ -1,12 +1,12 @@ package io.anuke.mindustry.entities.units; +import io.anuke.arc.math.Mathf; import io.anuke.mindustry.Vars; import io.anuke.mindustry.content.Items; import io.anuke.mindustry.entities.type.BaseUnit; import io.anuke.mindustry.entities.type.TileEntity; import io.anuke.mindustry.gen.Call; import io.anuke.mindustry.type.Item; -import io.anuke.arc.math.Mathf; public class UnitDrops{ private static Item[] dropTable; @@ -37,7 +37,8 @@ public class UnitDrops{ if(Mathf.chance(0.03)){ int amount = Mathf.random(20, 40); amount = core.tile.block().acceptStack(item, amount, core.tile, null); - if (amount > 0) Call.transferItemTo(item, amount, unit.x + Mathf.range(2f), unit.y + Mathf.range(2f), core.tile); + if(amount > 0) + Call.transferItemTo(item, amount, unit.x + Mathf.range(2f), unit.y + Mathf.range(2f), core.tile); } } } diff --git a/core/src/io/anuke/mindustry/game/Content.java b/core/src/io/anuke/mindustry/game/Content.java index 34ec10b4dd..4da406e960 100644 --- a/core/src/io/anuke/mindustry/game/Content.java +++ b/core/src/io/anuke/mindustry/game/Content.java @@ -4,7 +4,7 @@ import io.anuke.mindustry.Vars; import io.anuke.mindustry.type.ContentType; -/**Base class for a content type that is loaded in {@link io.anuke.mindustry.core.ContentLoader}.*/ +/** Base class for a content type that is loaded in {@link io.anuke.mindustry.core.ContentLoader}. */ public abstract class Content{ public final byte id; @@ -19,7 +19,7 @@ public abstract class Content{ */ public abstract ContentType getContentType(); - /**Called after all content is created. Do not use to load regions or texture data!*/ + /** Called after all content is created. Do not use to load regions or texture data! */ public void init(){ } diff --git a/core/src/io/anuke/mindustry/game/ContentList.java b/core/src/io/anuke/mindustry/game/ContentList.java index 8fc59c8bf2..82406a9880 100644 --- a/core/src/io/anuke/mindustry/game/ContentList.java +++ b/core/src/io/anuke/mindustry/game/ContentList.java @@ -1,7 +1,7 @@ package io.anuke.mindustry.game; -/**Interface for a list of content to be loaded in {@link io.anuke.mindustry.core.ContentLoader}.*/ +/** Interface for a list of content to be loaded in {@link io.anuke.mindustry.core.ContentLoader}. */ public interface ContentList{ - /**This method should create all the content.*/ + /** This method should create all the content. */ void load(); } diff --git a/core/src/io/anuke/mindustry/game/DefaultWaves.java b/core/src/io/anuke/mindustry/game/DefaultWaves.java index 2a54a06d20..a2bee78936 100644 --- a/core/src/io/anuke/mindustry/game/DefaultWaves.java +++ b/core/src/io/anuke/mindustry/game/DefaultWaves.java @@ -1,9 +1,7 @@ package io.anuke.mindustry.game; import io.anuke.arc.collection.Array; -import io.anuke.mindustry.content.Items; -import io.anuke.mindustry.content.StatusEffects; -import io.anuke.mindustry.content.UnitTypes; +import io.anuke.mindustry.content.*; import io.anuke.mindustry.type.ItemStack; public class DefaultWaves{ @@ -12,158 +10,158 @@ public class DefaultWaves{ public static Array get(){ if(spawns == null && UnitTypes.dagger != null){ spawns = Array.with( - new SpawnGroup(UnitTypes.dagger){{ - end = 8; - unitScaling = 1.5f; - }}, + new SpawnGroup(UnitTypes.dagger){{ + end = 8; + unitScaling = 1.5f; + }}, - new SpawnGroup(UnitTypes.wraith){{ - begin = 12; - end = 14; - unitScaling = 1f; - }}, + new SpawnGroup(UnitTypes.wraith){{ + begin = 12; + end = 14; + unitScaling = 1f; + }}, - new SpawnGroup(UnitTypes.dagger){{ - begin = 11; - unitScaling = 1.7f; - spacing = 2; - max = 4; - }}, + new SpawnGroup(UnitTypes.dagger){{ + begin = 11; + unitScaling = 1.7f; + spacing = 2; + max = 4; + }}, - new SpawnGroup(UnitTypes.titan){{ - begin = 9; - spacing = 3; - unitScaling = 2; + new SpawnGroup(UnitTypes.titan){{ + begin = 9; + spacing = 3; + unitScaling = 2; - end = 30; - }}, + end = 30; + }}, - new SpawnGroup(UnitTypes.dagger){{ - begin = 8; - unitScaling = 1; - unitAmount = 1; - spacing = 2; - }}, + new SpawnGroup(UnitTypes.dagger){{ + begin = 8; + unitScaling = 1; + unitAmount = 1; + spacing = 2; + }}, - new SpawnGroup(UnitTypes.titan){{ - begin = 28; - spacing = 3; - unitScaling = 1; - end = 40; - }}, + new SpawnGroup(UnitTypes.titan){{ + begin = 28; + spacing = 3; + unitScaling = 1; + end = 40; + }}, - new SpawnGroup(UnitTypes.titan){{ - begin = 45; - spacing = 3; - unitScaling = 2; - effect = StatusEffects.overdrive; - }}, + new SpawnGroup(UnitTypes.titan){{ + begin = 45; + spacing = 3; + unitScaling = 2; + effect = StatusEffects.overdrive; + }}, - new SpawnGroup(UnitTypes.titan){{ - begin = 120; - spacing = 2; - unitScaling = 3; - unitAmount = 5; - effect = StatusEffects.overdrive; - }}, + new SpawnGroup(UnitTypes.titan){{ + begin = 120; + spacing = 2; + unitScaling = 3; + unitAmount = 5; + effect = StatusEffects.overdrive; + }}, - new SpawnGroup(UnitTypes.wraith){{ - begin = 16; - unitScaling = 1; - spacing = 2; + new SpawnGroup(UnitTypes.wraith){{ + begin = 16; + unitScaling = 1; + spacing = 2; - max = 12; - }}, + max = 12; + }}, - new SpawnGroup(UnitTypes.dagger){{ - begin = 82; - spacing = 3; - unitAmount = 4; - unitScaling = 3; - effect = StatusEffects.overdrive; - }}, + new SpawnGroup(UnitTypes.dagger){{ + begin = 82; + spacing = 3; + unitAmount = 4; + unitScaling = 3; + effect = StatusEffects.overdrive; + }}, - new SpawnGroup(UnitTypes.dagger){{ - begin = 41; - spacing = 5; - unitAmount = 1; - unitScaling = 3; - effect = StatusEffects.shielded; - }}, + new SpawnGroup(UnitTypes.dagger){{ + begin = 41; + spacing = 5; + unitAmount = 1; + unitScaling = 3; + effect = StatusEffects.shielded; + }}, - new SpawnGroup(UnitTypes.fortress){{ - begin = 40; - spacing = 5; - unitAmount = 2; - unitScaling = 2; - max = 20; - }}, + new SpawnGroup(UnitTypes.fortress){{ + begin = 40; + spacing = 5; + unitAmount = 2; + unitScaling = 2; + max = 20; + }}, - new SpawnGroup(UnitTypes.dagger){{ - begin = 35; - spacing = 3; - unitAmount = 4; - effect = StatusEffects.overdrive; - items = new ItemStack(Items.blastCompound, 60); - end = 60; - }}, + new SpawnGroup(UnitTypes.dagger){{ + begin = 35; + spacing = 3; + unitAmount = 4; + effect = StatusEffects.overdrive; + items = new ItemStack(Items.blastCompound, 60); + end = 60; + }}, - new SpawnGroup(UnitTypes.dagger){{ - begin = 42; - spacing = 3; - unitAmount = 4; - effect = StatusEffects.overdrive; - items = new ItemStack(Items.pyratite, 100); - end = 130; - }}, + new SpawnGroup(UnitTypes.dagger){{ + begin = 42; + spacing = 3; + unitAmount = 4; + effect = StatusEffects.overdrive; + items = new ItemStack(Items.pyratite, 100); + end = 130; + }}, - new SpawnGroup(UnitTypes.ghoul){{ - begin = 40; - unitAmount = 2; - spacing = 2; - unitScaling = 3; - max = 8; - }}, + new SpawnGroup(UnitTypes.ghoul){{ + begin = 40; + unitAmount = 2; + spacing = 2; + unitScaling = 3; + max = 8; + }}, - new SpawnGroup(UnitTypes.wraith){{ - begin = 50; - unitAmount = 4; - unitScaling = 3; - spacing = 5; - effect = StatusEffects.overdrive; - max = 8; - }}, + new SpawnGroup(UnitTypes.wraith){{ + begin = 50; + unitAmount = 4; + unitScaling = 3; + spacing = 5; + effect = StatusEffects.overdrive; + max = 8; + }}, - new SpawnGroup(UnitTypes.revenant){{ - begin = 50; - unitAmount = 2; - unitScaling = 3; - spacing = 5; - max = 8; - }}, + new SpawnGroup(UnitTypes.revenant){{ + begin = 50; + unitAmount = 2; + unitScaling = 3; + spacing = 5; + max = 8; + }}, - new SpawnGroup(UnitTypes.ghoul){{ - begin = 53; - unitAmount = 2; - unitScaling = 3; - spacing = 4; - max = 8; - }}, + new SpawnGroup(UnitTypes.ghoul){{ + begin = 53; + unitAmount = 2; + unitScaling = 3; + spacing = 4; + max = 8; + }}, - new SpawnGroup(UnitTypes.eruptor){{ - begin = 31; - unitAmount = 4; - unitScaling = 1; - spacing = 3; - }}, + new SpawnGroup(UnitTypes.eruptor){{ + begin = 31; + unitAmount = 4; + unitScaling = 1; + spacing = 3; + }}, - new SpawnGroup(UnitTypes.ghoul){{ - begin = 90; - unitAmount = 2; - unitScaling = 3; - spacing = 4; - max = 8; - }} + new SpawnGroup(UnitTypes.ghoul){{ + begin = 90; + unitAmount = 2; + unitScaling = 3; + spacing = 4; + max = 8; + }} ); } return spawns == null ? new Array<>() : spawns; diff --git a/core/src/io/anuke/mindustry/game/Difficulty.java b/core/src/io/anuke/mindustry/game/Difficulty.java index ae19a30f49..8dc4a79269 100644 --- a/core/src/io/anuke/mindustry/game/Difficulty.java +++ b/core/src/io/anuke/mindustry/game/Difficulty.java @@ -2,15 +2,17 @@ package io.anuke.mindustry.game; import io.anuke.arc.Core; -/**Presets for time between waves. - * TODO specify correct time*/ +/** + * Presets for time between waves. + * TODO specify correct time + */ public enum Difficulty{ easy(1.4f), normal(1f), hard(0.5f), insane(0.25f); - /**Multiplier of the time between waves.*/ + /** Multiplier of the time between waves. */ public final float waveTime; private String value; diff --git a/core/src/io/anuke/mindustry/game/EventType.java b/core/src/io/anuke/mindustry/game/EventType.java index 48a9e19920..f55079b0c0 100644 --- a/core/src/io/anuke/mindustry/game/EventType.java +++ b/core/src/io/anuke/mindustry/game/EventType.java @@ -2,14 +2,14 @@ package io.anuke.mindustry.game; import io.anuke.arc.Events.Event; import io.anuke.mindustry.core.GameState.State; -import io.anuke.mindustry.entities.type.Unit; import io.anuke.mindustry.entities.traits.BuilderTrait; +import io.anuke.mindustry.entities.type.Unit; import io.anuke.mindustry.type.Zone; import io.anuke.mindustry.world.Tile; public class EventType{ - /**Called when a zone's requirements are met.*/ + /** Called when a zone's requirements are met. */ public static class ZoneRequireCompleteEvent implements Event{ public final Zone zone, required; @@ -19,7 +19,7 @@ public class EventType{ } } - /**Called when a zone's requirements are met.*/ + /** Called when a zone's requirements are met. */ public static class ZoneConfigureCompleteEvent implements Event{ public final Zone zone; @@ -28,7 +28,7 @@ public class EventType{ } } - /**Called when the game is first loaded.*/ + /** Called when the game is first loaded. */ public static class GameLoadEvent implements Event{ } @@ -53,12 +53,12 @@ public class EventType{ } } - /**Called when a game begins and the world is loaded.*/ + /** Called when a game begins and the world is loaded. */ public static class WorldLoadEvent implements Event{ } - /**Called from the logic thread. Do not access graphics here!*/ + /** Called from the logic thread. Do not access graphics here! */ public static class TileChangeEvent implements Event{ public final Tile tile; @@ -84,8 +84,10 @@ public class EventType{ } } - /**Called when block building begins by placing down the BuildBlock. - * The tile's block will nearly always be a BuildBlock.*/ + /** + * Called when block building begins by placing down the BuildBlock. + * The tile's block will nearly always be a BuildBlock. + */ public static class BlockBuildBeginEvent implements Event{ public final Tile tile; public final Team team; @@ -110,8 +112,10 @@ public class EventType{ } } - /**Called when a player or drone begins building something. - * This does not necessarily happen when a new BuildBlock is created.*/ + /** + * Called when a player or drone begins building something. + * This does not necessarily happen when a new BuildBlock is created. + */ public static class BuildSelectEvent implements Event{ public final Tile tile; public final Team team; diff --git a/core/src/io/anuke/mindustry/game/GlobalData.java b/core/src/io/anuke/mindustry/game/GlobalData.java index 6726f6fd7f..11dabeb994 100644 --- a/core/src/io/anuke/mindustry/game/GlobalData.java +++ b/core/src/io/anuke/mindustry/game/GlobalData.java @@ -2,20 +2,16 @@ package io.anuke.mindustry.game; import io.anuke.arc.Core; import io.anuke.arc.Events; -import io.anuke.arc.collection.ObjectIntMap; -import io.anuke.arc.collection.ObjectMap; -import io.anuke.arc.collection.ObjectSet; +import io.anuke.arc.collection.*; import io.anuke.mindustry.Vars; import io.anuke.mindustry.content.Items; import io.anuke.mindustry.game.EventType.UnlockEvent; -import io.anuke.mindustry.type.ContentType; -import io.anuke.mindustry.type.Item; -import io.anuke.mindustry.type.ItemStack; +import io.anuke.mindustry.type.*; import static io.anuke.mindustry.Vars.content; import static io.anuke.mindustry.Vars.state; -/**Stores player unlocks. Clientside only.*/ +/** Stores player unlocks. Clientside only. */ public class GlobalData{ private ObjectMap> unlocked = new ObjectMap<>(); private ObjectIntMap items = new ObjectIntMap<>(); @@ -74,7 +70,7 @@ public class GlobalData{ return items; } - /** Returns whether or not this piece of content is unlocked yet.*/ + /** Returns whether or not this piece of content is unlocked yet. */ public boolean isUnlocked(UnlockableContent content){ return content.alwaysUnlocked() || unlocked.getOr(content.getContentType(), ObjectSet::new).contains(content.name); } @@ -95,7 +91,7 @@ public class GlobalData{ } } - /** Clears all unlocked content. Automatically saves.*/ + /** Clears all unlocked content. Automatically saves. */ public void reset(){ save(); } @@ -116,7 +112,7 @@ public class GlobalData{ //set up default values if(!Core.settings.has("item-" + Items.copper.name)){ - addItem(Items.copper, 50); + addItem(Items.copper, 50); } } diff --git a/core/src/io/anuke/mindustry/game/MappableContent.java b/core/src/io/anuke/mindustry/game/MappableContent.java index 9b1e7bbc36..3253975085 100644 --- a/core/src/io/anuke/mindustry/game/MappableContent.java +++ b/core/src/io/anuke/mindustry/game/MappableContent.java @@ -1,6 +1,6 @@ package io.anuke.mindustry.game; -public abstract class MappableContent extends Content { +public abstract class MappableContent extends Content{ public final String name; public MappableContent(String name){ diff --git a/core/src/io/anuke/mindustry/game/RulePreset.java b/core/src/io/anuke/mindustry/game/RulePreset.java index c86a7a0570..6e6e03914d 100644 --- a/core/src/io/anuke/mindustry/game/RulePreset.java +++ b/core/src/io/anuke/mindustry/game/RulePreset.java @@ -3,7 +3,7 @@ package io.anuke.mindustry.game; import io.anuke.arc.Core; import io.anuke.arc.function.Supplier; -/**Defines preset rule sets..*/ +/** Defines preset rule sets.. */ public enum RulePreset{ survival(() -> new Rules(){{ waveTimer = true; diff --git a/core/src/io/anuke/mindustry/game/Rules.java b/core/src/io/anuke/mindustry/game/Rules.java index 4e6d35cb58..25483bc69d 100644 --- a/core/src/io/anuke/mindustry/game/Rules.java +++ b/core/src/io/anuke/mindustry/game/Rules.java @@ -3,42 +3,44 @@ package io.anuke.mindustry.game; import io.anuke.annotations.Annotations.Serialize; import io.anuke.arc.collection.Array; -/**Defines current rules on how the game should function. - * Does not store game state, just configuration.*/ +/** + * Defines current rules on how the game should function. + * Does not store game state, just configuration. + */ @Serialize public class Rules{ - /**Whether the player has infinite resources.*/ + /** Whether the player has infinite resources. */ public boolean infiniteResources; - /**Whether the waves come automatically on a timer. If not, waves come when the play button is pressed.*/ + /** Whether the waves come automatically on a timer. If not, waves come when the play button is pressed. */ public boolean waveTimer = true; - /**Whether waves are spawnable at all.*/ + /** Whether waves are spawnable at all. */ public boolean waves; - /**Whether the enemy AI has infinite resources in most of their buildings and turrets.*/ + /** Whether the enemy AI has infinite resources in most of their buildings and turrets. */ public boolean enemyCheat; - /**Whether the game objective is PvP. Note that this enables automatic hosting.*/ + /** Whether the game objective is PvP. Note that this enables automatic hosting. */ public boolean pvp; - /**Whether enemy units drop random items on death.*/ + /** Whether enemy units drop random items on death. */ public boolean unitDrops; - /**How fast unit pads build units.*/ + /** How fast unit pads build units. */ public float unitBuildSpeedMultiplier = 1f; - /**How much health units start with.*/ + /** How much health units start with. */ public float unitHealthMultiplier = 1f; - /**How much damage player mechs deal.*/ + /** How much damage player mechs deal. */ public float playerDamageMultiplier = 1f; - /**How much damage any other units deal.*/ + /** How much damage any other units deal. */ public float unitDamageMultiplier = 1f; - /**Multiplier for buildings for the player.*/ + /** Multiplier for buildings for the player. */ public float buildCostMultiplier = 1f; - /**Multiplier for building speed.*/ + /** Multiplier for building speed. */ public float buildSpeedMultiplier = 1f; - /**No-build zone around enemy core radius.*/ + /** No-build zone around enemy core radius. */ public float enemyCoreBuildRadius = 400f; - /**Player respawn time in ticks.*/ + /** Player respawn time in ticks. */ public float respawnTime = 60 * 4; - /**Time between waves in ticks.*/ + /** Time between waves in ticks. */ public float waveSpacing = 60 * 60 * 2; - /**Zone ID, -1 for invalid zone.*/ + /** Zone ID, -1 for invalid zone. */ public byte zone = -1; - /**Spawn layout. Since only zones modify this, it should be assigned on save load.*/ + /** Spawn layout. Since only zones modify this, it should be assigned on save load. */ public transient Array spawns = DefaultWaves.get(); } diff --git a/core/src/io/anuke/mindustry/game/Saves.java b/core/src/io/anuke/mindustry/game/Saves.java index 0142f194f7..3078637c01 100644 --- a/core/src/io/anuke/mindustry/game/Saves.java +++ b/core/src/io/anuke/mindustry/game/Saves.java @@ -2,9 +2,7 @@ package io.anuke.mindustry.game; import io.anuke.arc.Core; import io.anuke.arc.Events; -import io.anuke.arc.collection.Array; -import io.anuke.arc.collection.IntArray; -import io.anuke.arc.collection.IntMap; +import io.anuke.arc.collection.*; import io.anuke.arc.files.FileHandle; import io.anuke.arc.util.Strings; import io.anuke.arc.util.Time; @@ -48,7 +46,7 @@ public class Saves{ saves.clear(); IntArray slots = Core.settings.getObject("save-slots", IntArray.class, IntArray::new); - for(int i = 0; i < slots.size; i ++){ + for(int i = 0; i < slots.size; i++){ int index = slots.get(i); if(SaveIO.isSaveValid(index)){ SaveSlot slot = new SaveSlot(index); @@ -68,7 +66,7 @@ public class Saves{ SaveSlot current = this.current; if(current != null && !state.is(State.menu) - && !(state.isPaused() && Core.scene.hasDialog())){ + && !(state.isPaused() && Core.scene.hasDialog())){ if(lastTimestamp != 0){ totalPlaytime += Time.timeSinceMillis(lastTimestamp); } diff --git a/core/src/io/anuke/mindustry/game/SpawnGroup.java b/core/src/io/anuke/mindustry/game/SpawnGroup.java index 99a89885ff..d6cc11f243 100644 --- a/core/src/io/anuke/mindustry/game/SpawnGroup.java +++ b/core/src/io/anuke/mindustry/game/SpawnGroup.java @@ -4,10 +4,7 @@ import io.anuke.arc.util.serialization.Json; import io.anuke.arc.util.serialization.Json.Serializable; import io.anuke.arc.util.serialization.JsonValue; import io.anuke.mindustry.entities.type.BaseUnit; -import io.anuke.mindustry.type.ContentType; -import io.anuke.mindustry.type.ItemStack; -import io.anuke.mindustry.type.StatusEffect; -import io.anuke.mindustry.type.UnitType; +import io.anuke.mindustry.type.*; import static io.anuke.mindustry.Vars.content; @@ -19,23 +16,23 @@ import static io.anuke.mindustry.Vars.content; public class SpawnGroup implements Serializable{ public static final int never = Integer.MAX_VALUE; - /**The unit type spawned*/ + /** The unit type spawned */ public UnitType type; - /**When this spawn should end*/ + /** When this spawn should end */ public int end = never; - /**When this spawn should start*/ + /** When this spawn should start */ public int begin; - /**The spacing, in waves, of spawns. For example, 2 = spawns every other wave*/ + /** The spacing, in waves, of spawns. For example, 2 = spawns every other wave */ public int spacing = 1; - /**Maximum amount of units that spawn*/ + /** Maximum amount of units that spawn */ public int max = 100; - /**How many waves need to pass before the amount of units spawned increases by 1*/ + /** How many waves need to pass before the amount of units spawned increases by 1 */ public float unitScaling = never; - /**Amount of enemies spawned initially, with no scaling*/ + /** Amount of enemies spawned initially, with no scaling */ public int unitAmount = 1; - /**Status effect applied to the spawned unit. Null to disable.*/ + /** Status effect applied to the spawned unit. Null to disable. */ public StatusEffect effect; - /**Items this unit spawns with. Null to disable.*/ + /** Items this unit spawns with. Null to disable. */ public ItemStack items; public SpawnGroup(UnitType type){ @@ -46,14 +43,14 @@ public class SpawnGroup implements Serializable{ //serialization use only } - /**Returns the amount of units spawned on a specific wave.*/ + /** Returns the amount of units spawned on a specific wave. */ public int getUnitsSpawned(int wave){ if(wave < begin || wave > end || (wave - begin) % spacing != 0){ return 0; } float scaling = this.unitScaling; - return Math.min(unitAmount - 1 + Math.max((int) (((wave - begin + 1) / spacing) / scaling), 1), max); + return Math.min(unitAmount - 1 + Math.max((int)(((wave - begin + 1) / spacing) / scaling), 1), max); } /** diff --git a/core/src/io/anuke/mindustry/game/Stats.java b/core/src/io/anuke/mindustry/game/Stats.java index 05917231c5..7e00d05d44 100644 --- a/core/src/io/anuke/mindustry/game/Stats.java +++ b/core/src/io/anuke/mindustry/game/Stats.java @@ -4,25 +4,23 @@ import io.anuke.annotations.Annotations.Serialize; import io.anuke.arc.collection.Array; import io.anuke.arc.collection.ObjectIntMap; import io.anuke.arc.math.Mathf; -import io.anuke.mindustry.type.Item; -import io.anuke.mindustry.type.ItemType; -import io.anuke.mindustry.type.Zone; +import io.anuke.mindustry.type.*; @Serialize public class Stats{ - /**Items delivered to global resoure counter. Zones only.*/ + /** Items delivered to global resoure counter. Zones only. */ public ObjectIntMap itemsDelivered = new ObjectIntMap<>(); - /**Enemy (red team) units destroyed.*/ + /** Enemy (red team) units destroyed. */ public int enemyUnitsDestroyed; - /**Total waves lasted.*/ + /** Total waves lasted. */ public int wavesLasted; - /**Total (ms) time lasted in this save/zone.*/ + /** Total (ms) time lasted in this save/zone. */ public long timeLasted; - /**Friendly buildings fully built.*/ + /** Friendly buildings fully built. */ public int buildingsBuilt; - /**Friendly buildings fully deconstructed.*/ + /** Friendly buildings fully deconstructed. */ public int buildingsDeconstructed; - /**Friendly buildings destroyed.*/ + /** Friendly buildings destroyed. */ public int buildingsDestroyed; public RankResult calculateRank(Zone zone, boolean launched){ @@ -30,7 +28,7 @@ public class Stats{ //each new launch period adds onto the rank 'points' if(wavesLasted >= zone.conditionWave){ - score += (float)((wavesLasted - zone.conditionWave) / zone.launchPeriod + 1) * 1.2f; + score += (float)((wavesLasted - zone.conditionWave) / zone.launchPeriod + 1) * 1.2f; } int capacity = zone.loadout.core().itemCapacity; @@ -42,13 +40,13 @@ public class Stats{ frac += Mathf.clamp((float)itemsDelivered.get(item, 0) / capacity) / (float)obtainable.size; } - score += frac*1.6f; + score += frac * 1.6f; if(!launched){ score *= 0.5f; } - int rankIndex = Mathf.clamp((int)(score), 0, Rank.values().length-1); + int rankIndex = Mathf.clamp((int)(score), 0, Rank.values().length - 1); Rank rank = Rank.values()[rankIndex]; String sign = Math.abs((rankIndex + 0.5f) - score) < 0.2f || rank.name().contains("S") ? "" : (rankIndex + 0.5f) < score ? "-" : "+"; @@ -57,7 +55,7 @@ public class Stats{ public static class RankResult{ public final Rank rank; - /**+ or -*/ + /** + or - */ public final String modifier; public RankResult(Rank rank, String modifier){ diff --git a/core/src/io/anuke/mindustry/game/Teams.java b/core/src/io/anuke/mindustry/game/Teams.java index 28ffdfc2a2..1dc52906f1 100644 --- a/core/src/io/anuke/mindustry/game/Teams.java +++ b/core/src/io/anuke/mindustry/game/Teams.java @@ -1,18 +1,15 @@ package io.anuke.mindustry.game; -import io.anuke.arc.collection.Array; -import io.anuke.arc.collection.EnumSet; -import io.anuke.arc.collection.ObjectSet; +import io.anuke.arc.collection.*; import io.anuke.mindustry.Vars; import io.anuke.mindustry.world.Tile; -/**Class for various team-based utilities.*/ +/** Class for various team-based utilities. */ public class Teams{ private TeamData[] map = new TeamData[Team.all.length]; /** * Register a team. - * * @param team The team type enum. * @param enemies The array of enemies of this team. Any team not in this array is considered neutral. */ @@ -20,7 +17,7 @@ public class Teams{ map[team.ordinal()] = new TeamData(team, EnumSet.of(enemies)); } - /**Returns team data by type.*/ + /** Returns team data by type. */ public TeamData get(Team team){ if(map[team.ordinal()] == null){ add(team, Array.with(Team.all).select(t -> t != team).toArray(Team.class)); @@ -28,18 +25,18 @@ public class Teams{ return map[team.ordinal()]; } - /**Returns whether a team is active, e.g. whether it has any cores remaining.*/ + /** Returns whether a team is active, e.g. whether it has any cores remaining. */ public boolean isActive(Team team){ //the enemy wave team is always active return (Vars.state.rules.waves && team == Vars.waveTeam) || get(team).cores.size > 0; } - /**Returns a set of all teams that are enemies of this team.*/ + /** Returns a set of all teams that are enemies of this team. */ public EnumSet enemiesOf(Team team){ return get(team).enemies; } - /**Returns whether {@param other} is an enemy of {@param #team}.*/ + /** Returns whether {@param other} is an enemy of {@param #team}. */ public boolean areEnemies(Team team, Team other){ return enemiesOf(team).contains(other); } diff --git a/core/src/io/anuke/mindustry/game/UnlockableContent.java b/core/src/io/anuke/mindustry/game/UnlockableContent.java index 7a843ecdfc..24edd13949 100644 --- a/core/src/io/anuke/mindustry/game/UnlockableContent.java +++ b/core/src/io/anuke/mindustry/game/UnlockableContent.java @@ -5,11 +5,11 @@ import io.anuke.arc.graphics.g2d.TextureRegion; import io.anuke.arc.scene.ui.layout.Table; import io.anuke.mindustry.Vars; -/**Base interface for an unlockable content type.*/ +/** Base interface for an unlockable content type. */ public abstract class UnlockableContent extends MappableContent{ - /**Localized, formal name. Never null. Set to block name if not found in bundle.*/ + /** Localized, formal name. Never null. Set to block name if not found in bundle. */ public String localizedName; - /**Localized description. May be null.*/ + /** Localized description. May be null. */ public String description; public UnlockableContent(String name){ @@ -19,24 +19,24 @@ public abstract class UnlockableContent extends MappableContent{ this.description = Core.bundle.getOrNull(getContentType() + "." + name + ".description"); } - /**Returns the localized name of this content.*/ + /** Returns the localized name of this content. */ public abstract String localizedName(); public abstract TextureRegion getContentIcon(); - /**This should show all necessary info about this content in the specified table.*/ + /** This should show all necessary info about this content in the specified table. */ public abstract void displayInfo(Table table); - /**Called when this content is unlocked. Use this to unlock other related content.*/ + /** Called when this content is unlocked. Use this to unlock other related content. */ public void onUnlock(){ } - /**Whether this content is always hidden in the content info dialog.*/ + /** Whether this content is always hidden in the content info dialog. */ public boolean isHidden(){ return false; } - /**Override to make content always unlocked.*/ + /** Override to make content always unlocked. */ public boolean alwaysUnlocked(){ return false; } diff --git a/core/src/io/anuke/mindustry/game/Version.java b/core/src/io/anuke/mindustry/game/Version.java index 276dd04354..5349306321 100644 --- a/core/src/io/anuke/mindustry/game/Version.java +++ b/core/src/io/anuke/mindustry/game/Version.java @@ -9,15 +9,15 @@ import io.anuke.arc.util.io.PropertiesUtils; import java.io.IOException; public class Version{ - /**Build type. 'official' for official releases; 'custom' or 'bleeding edge' are also used.*/ + /** Build type. 'official' for official releases; 'custom' or 'bleeding edge' are also used. */ public static String type; - /**Build modifier, e.g. 'alpha' or 'release'*/ + /** Build modifier, e.g. 'alpha' or 'release' */ public static String modifier; - /**Number specifying the major version, e.g. '4'*/ + /** Number specifying the major version, e.g. '4' */ public static int number; - /**Build number, e.g. '43'. set to '-1' for custom builds.*/ + /** Build number, e.g. '43'. set to '-1' for custom builds. */ public static int build = 0; - /**Revision number. Used for hotfixes. Does not affect server compatibility.*/ + /** Revision number. Used for hotfixes. Does not affect server compatibility. */ public static int revision = 0; public static void init(){ diff --git a/core/src/io/anuke/mindustry/graphics/BlockRenderer.java b/core/src/io/anuke/mindustry/graphics/BlockRenderer.java index 0ea6dd31ca..524d1df00a 100644 --- a/core/src/io/anuke/mindustry/graphics/BlockRenderer.java +++ b/core/src/io/anuke/mindustry/graphics/BlockRenderer.java @@ -77,7 +77,7 @@ public class BlockRenderer{ for(int y = 0; y < world.height(); y++){ Tile tile = world.rawTile(x, y); if(tile.getRotation() > 0 && tile.block().solid && tile.block().fillsTile && !tile.block().synthetic()){ - Draw.color(0f, 0f, 0f, Math.min((tile.getRotation() + 0.5f)/4f, 1f)); + Draw.color(0f, 0f, 0f, Math.min((tile.getRotation() + 0.5f) / 4f, 1f)); Fill.rect(tile.x + 0.5f, tile.y + 0.5f, 1, 1); } } @@ -92,9 +92,9 @@ public class BlockRenderer{ shadowEvents.add(event.tile); int avgx = (int)(camera.position.x / tilesize); - int avgy = (int)(camera.position. y / tilesize); - int rangex = (int) (camera.width / tilesize / 2) + 2; - int rangey = (int) (camera.height / tilesize / 2) + 2; + int avgy = (int)(camera.position.y / tilesize); + int rangex = (int)(camera.width / tilesize / 2) + 2; + int rangey = (int)(camera.height / tilesize / 2) + 2; if(Math.abs(avgx - event.tile.x) <= rangex && Math.abs(avgy - event.tile.y) <= rangey){ lastCamY = lastCamX = -99; //invalidate camera position so blocks get updated @@ -104,11 +104,11 @@ public class BlockRenderer{ public void drawFog(){ float ww = world.width() * tilesize, wh = world.height() * tilesize; - float x = camera.position.x + tilesize/2f, y = camera.position.y + tilesize/2f; - float u = (x - camera.width/2f) / ww, - v = (y - camera.height/2f) / wh, - u2 = (x + camera.width/2f) / ww, - v2 = (y + camera.height/2f) / wh; + float x = camera.position.x + tilesize / 2f, y = camera.position.y + tilesize / 2f; + float u = (x - camera.width / 2f) / ww, + v = (y - camera.height / 2f) / wh, + u2 = (x + camera.width / 2f) / ww, + v2 = (y + camera.height / 2f) / wh; Tmp.tr1.set(fog.getTexture()); Tmp.tr1.set(u, v2, u2, v); @@ -144,11 +144,11 @@ public class BlockRenderer{ } float ww = world.width() * tilesize, wh = world.height() * tilesize; - float x = camera.position.x + tilesize/2f, y = camera.position.y + tilesize/2f; - float u = (x - camera.width/2f) / ww, - v = (y - camera.height/2f) / wh, - u2 = (x + camera.width/2f) / ww, - v2 = (y + camera.height/2f) / wh; + float x = camera.position.x + tilesize / 2f, y = camera.position.y + tilesize / 2f; + float u = (x - camera.width / 2f) / ww, + v = (y - camera.height / 2f) / wh, + u2 = (x + camera.width / 2f) / ww, + v2 = (y + camera.height / 2f) / wh; Tmp.tr1.set(shadows.getTexture()); Tmp.tr1.set(u, v2, u2, v); @@ -158,15 +158,15 @@ public class BlockRenderer{ Draw.shader(); } - /**Process all blocks to draw.*/ + /** Process all blocks to draw. */ public void processBlocks(){ iterateidx = 0; int avgx = (int)(camera.position.x / tilesize); int avgy = (int)(camera.position.y / tilesize); - int rangex = (int) (camera.width / tilesize / 2) + 3; - int rangey = (int) (camera.height / tilesize / 2) + 3; + int rangex = (int)(camera.width / tilesize / 2) + 3; + int rangey = (int)(camera.height / tilesize / 2) + 3; if(avgx == lastCamX && avgy == lastCamY && lastRangeX == rangex && lastRangeY == rangey){ return; diff --git a/core/src/io/anuke/mindustry/graphics/FloorRenderer.java b/core/src/io/anuke/mindustry/graphics/FloorRenderer.java index be3e823a37..b3276147dc 100644 --- a/core/src/io/anuke/mindustry/graphics/FloorRenderer.java +++ b/core/src/io/anuke/mindustry/graphics/FloorRenderer.java @@ -2,20 +2,13 @@ package io.anuke.mindustry.graphics; import io.anuke.arc.Core; import io.anuke.arc.Events; -import io.anuke.arc.collection.IntArray; -import io.anuke.arc.collection.IntSet; +import io.anuke.arc.collection.*; import io.anuke.arc.collection.IntSet.IntSetIterator; -import io.anuke.arc.collection.ObjectSet; import io.anuke.arc.graphics.Camera; import io.anuke.arc.graphics.GL20; -import io.anuke.arc.graphics.g2d.CacheBatch; -import io.anuke.arc.graphics.g2d.Draw; -import io.anuke.arc.graphics.g2d.SpriteBatch; -import io.anuke.arc.graphics.g2d.SpriteCache; +import io.anuke.arc.graphics.g2d.*; import io.anuke.arc.math.Mathf; -import io.anuke.arc.util.Log; -import io.anuke.arc.util.Structs; -import io.anuke.arc.util.Time; +import io.anuke.arc.util.*; import io.anuke.mindustry.game.EventType.WorldLoadEvent; import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.blocks.Floor; @@ -45,8 +38,8 @@ public class FloorRenderer{ Camera camera = Core.camera; - int crangex = (int) (camera.width / (chunksize * tilesize)) + 1; - int crangey = (int) (camera.height / (chunksize * tilesize)) + 1; + int crangex = (int)(camera.width / (chunksize * tilesize)) + 1; + int crangey = (int)(camera.height / (chunksize * tilesize)) + 1; int camx = (int)(camera.position.x / (chunksize * tilesize)); int camy = (int)(camera.position.y / (chunksize * tilesize)); @@ -129,8 +122,8 @@ public class FloorRenderer{ Camera camera = Core.camera; - int crangex = (int) (camera.width / (chunksize * tilesize)) + 1; - int crangey = (int) (camera.height / (chunksize * tilesize)) + 1; + int crangex = (int)(camera.width / (chunksize * tilesize)) + 1; + int crangey = (int)(camera.height / (chunksize * tilesize)) + 1; layer.begin(); @@ -183,7 +176,7 @@ public class FloorRenderer{ for(int tilex = cx * chunksize; tilex < (cx + 1) * chunksize; tilex++){ for(int tiley = cy * chunksize; tiley < (cy + 1) * chunksize; tiley++){ - Tile tile = world.tile(tilex , tiley); + Tile tile = world.tile(tilex, tiley); Floor floor; if(tile == null){ @@ -194,7 +187,7 @@ public class FloorRenderer{ if(tile.block().cacheLayer == layer && layer == CacheLayer.walls){ tile.block().draw(tile); - }else if(floor.cacheLayer == layer && (world.isAccessible(tile.x,tile.y) || tile.block().cacheLayer != CacheLayer.walls || !tile.block().fillsTile)){ + }else if(floor.cacheLayer == layer && (world.isAccessible(tile.x, tile.y) || tile.block().cacheLayer != CacheLayer.walls || !tile.block().fillsTile)){ floor.draw(tile); }else if(floor.cacheLayer.ordinal() < layer.ordinal() && layer != CacheLayer.walls){ floor.drawNonLayer(tile); @@ -208,8 +201,8 @@ public class FloorRenderer{ public void clearTiles(){ if(cbatch != null) cbatch.dispose(); - int chunksx = Mathf.ceil((float) (world.width()) / chunksize), - chunksy = Mathf.ceil((float) (world.height()) / chunksize) ; + int chunksx = Mathf.ceil((float)(world.width()) / chunksize), + chunksy = Mathf.ceil((float)(world.height()) / chunksize); cache = new Chunk[chunksx][chunksy]; SpriteCache sprites = new SpriteCache(world.width() * world.height() * 6, (world.width() / chunksize) * (world.height() / chunksize) * 2, false); cbatch = new CacheBatch(sprites); diff --git a/core/src/io/anuke/mindustry/graphics/IndexedRenderer.java b/core/src/io/anuke/mindustry/graphics/IndexedRenderer.java index ca2e9787b4..b4165dbe63 100644 --- a/core/src/io/anuke/mindustry/graphics/IndexedRenderer.java +++ b/core/src/io/anuke/mindustry/graphics/IndexedRenderer.java @@ -16,35 +16,35 @@ public class IndexedRenderer implements Disposable{ private final static int vsize = 5; private Shader program = new Shader( - Strings.join("\n", - "attribute vec4 " + Shader.POSITION_ATTRIBUTE + ";", - "attribute vec4 " + Shader.COLOR_ATTRIBUTE + ";", - "attribute vec2 " + Shader.TEXCOORD_ATTRIBUTE + "0;", - "uniform mat4 u_projTrans;", - "varying vec4 v_color;", - "varying vec2 v_texCoords;", - "", - "void main(){", - " v_color = " + Shader.COLOR_ATTRIBUTE + ";", - " v_color.a = v_color.a * (255.0/254.0);", - " v_texCoords = " + Shader.TEXCOORD_ATTRIBUTE + "0;", - " gl_Position = u_projTrans * " + Shader.POSITION_ATTRIBUTE + ";", - "}"), - Strings.join("\n", - "#ifdef GL_ES", - "#define LOWP lowp", - "precision mediump float;", - "#else", - "#define LOWP ", - "#endif", - "", - "varying LOWP vec4 v_color;", - "varying vec2 v_texCoords;", - "uniform sampler2D u_texture;", - "", - "void main(){", - " gl_FragColor = v_color * texture2D(u_texture, v_texCoords);", - "}" + Strings.join("\n", + "attribute vec4 " + Shader.POSITION_ATTRIBUTE + ";", + "attribute vec4 " + Shader.COLOR_ATTRIBUTE + ";", + "attribute vec2 " + Shader.TEXCOORD_ATTRIBUTE + "0;", + "uniform mat4 u_projTrans;", + "varying vec4 v_color;", + "varying vec2 v_texCoords;", + "", + "void main(){", + " v_color = " + Shader.COLOR_ATTRIBUTE + ";", + " v_color.a = v_color.a * (255.0/254.0);", + " v_texCoords = " + Shader.TEXCOORD_ATTRIBUTE + "0;", + " gl_Position = u_projTrans * " + Shader.POSITION_ATTRIBUTE + ";", + "}"), + Strings.join("\n", + "#ifdef GL_ES", + "#define LOWP lowp", + "precision mediump float;", + "#else", + "#define LOWP ", + "#endif", + "", + "varying LOWP vec4 v_color;", + "varying vec2 v_texCoords;", + "uniform sampler2D u_texture;", + "", + "void main(){", + " gl_FragColor = v_color * texture2D(u_texture, v_texCoords);", + "}" )); private Mesh mesh; private float[] tmpVerts = new float[vsize * 6]; @@ -226,9 +226,9 @@ public class IndexedRenderer implements Disposable{ if(mesh != null) mesh.dispose(); mesh = new Mesh(true, 6 * sprites, 0, - new VertexAttribute(Usage.Position, 2, "a_position"), - new VertexAttribute(Usage.ColorPacked, 4, "a_color"), - new VertexAttribute(Usage.TextureCoordinates, 2, "a_texCoord0")); + new VertexAttribute(Usage.Position, 2, "a_position"), + new VertexAttribute(Usage.ColorPacked, 4, "a_color"), + new VertexAttribute(Usage.TextureCoordinates, 2, "a_texCoord0")); vertices = new float[6 * sprites * vsize]; mesh.setVertices(vertices); } diff --git a/core/src/io/anuke/mindustry/graphics/Layer.java b/core/src/io/anuke/mindustry/graphics/Layer.java index 8a3571d51a..f84f6aa3c2 100644 --- a/core/src/io/anuke/mindustry/graphics/Layer.java +++ b/core/src/io/anuke/mindustry/graphics/Layer.java @@ -1,16 +1,16 @@ package io.anuke.mindustry.graphics; public enum Layer{ - /**Base block layer.*/ + /** Base block layer. */ block, - /**for placement*/ + /** for placement */ placement, - /**First overlay. Stuff like conveyor items.*/ + /** First overlay. Stuff like conveyor items. */ overlay, - /**"High" blocks, like turrets.*/ + /** "High" blocks, like turrets. */ turret, - /**Power lasers.*/ + /** Power lasers. */ power, - /**Extra lasers, like healing turrets.*/ + /** Extra lasers, like healing turrets. */ laser } diff --git a/core/src/io/anuke/mindustry/graphics/MinimapRenderer.java b/core/src/io/anuke/mindustry/graphics/MinimapRenderer.java index 716b2479ca..38a8691b44 100644 --- a/core/src/io/anuke/mindustry/graphics/MinimapRenderer.java +++ b/core/src/io/anuke/mindustry/graphics/MinimapRenderer.java @@ -3,13 +3,9 @@ package io.anuke.mindustry.graphics; import io.anuke.arc.Core; import io.anuke.arc.Events; import io.anuke.arc.collection.Array; -import io.anuke.arc.graphics.Pixmap; +import io.anuke.arc.graphics.*; import io.anuke.arc.graphics.Pixmap.Format; -import io.anuke.arc.graphics.Pixmaps; -import io.anuke.arc.graphics.Texture; -import io.anuke.arc.graphics.g2d.Draw; -import io.anuke.arc.graphics.g2d.Fill; -import io.anuke.arc.graphics.g2d.TextureRegion; +import io.anuke.arc.graphics.g2d.*; import io.anuke.arc.math.Mathf; import io.anuke.arc.math.geom.Rectangle; import io.anuke.arc.util.Disposable; @@ -83,7 +79,7 @@ public class MinimapRenderer implements Disposable{ for(Unit unit : units){ float rx = (unit.x - rect.x) / rect.width * w, ry = (unit.y - rect.y) / rect.width * h; Draw.color(unit.getTeam().color); - Fill.rect(x + rx, y + ry, baseSize/2f, baseSize/2f); + Fill.rect(x + rx, y + ry, baseSize / 2f, baseSize / 2f); } Draw.color(); diff --git a/core/src/io/anuke/mindustry/graphics/OverlayRenderer.java b/core/src/io/anuke/mindustry/graphics/OverlayRenderer.java index 4f5f8cbb28..a08d9d1788 100644 --- a/core/src/io/anuke/mindustry/graphics/OverlayRenderer.java +++ b/core/src/io/anuke/mindustry/graphics/OverlayRenderer.java @@ -76,7 +76,7 @@ public class OverlayRenderer{ buildFadeTime = Mathf.lerpDelta(buildFadeTime, input.isPlacing() ? 1f : 0f, 0.06f); Draw.reset(); - Lines.stroke(buildFadeTime*2f); + Lines.stroke(buildFadeTime * 2f); if(buildFadeTime > 0.005f){ for(Team enemy : state.teams.enemiesOf(player.getTeam())){ diff --git a/core/src/io/anuke/mindustry/graphics/Shaders.java b/core/src/io/anuke/mindustry/graphics/Shaders.java index 7839716f71..9a60823e2b 100644 --- a/core/src/io/anuke/mindustry/graphics/Shaders.java +++ b/core/src/io/anuke/mindustry/graphics/Shaders.java @@ -120,10 +120,10 @@ public class Shaders{ setUniformf("u_dp", Unit.dp.scl(1f)); setUniformf("u_time", Time.time() / Unit.dp.scl(1f)); setUniformf("u_offset", - Core.camera.position.x - Core.camera.width / 2 , - Core.camera.position.y - Core.camera.height / 2 ); - setUniformf("u_texsize", Core.camera.width , - Core.camera.height ); + Core.camera.position.x - Core.camera.width / 2, + Core.camera.position.y - Core.camera.height / 2); + setUniformf("u_texsize", Core.camera.width, + Core.camera.height); } } @@ -140,7 +140,7 @@ public class Shaders{ setUniformf("time", Time.time()); } } - + public static class LoadShader extends Shader{ public LoadShader(String frag, String vert){ super(Core.files.internal("shaders/" + vert + ".vertex"), Core.files.internal("shaders/" + frag + ".fragment")); diff --git a/core/src/io/anuke/mindustry/graphics/Shapes.java b/core/src/io/anuke/mindustry/graphics/Shapes.java index 899ed2ae8d..4918d5dd1b 100644 --- a/core/src/io/anuke/mindustry/graphics/Shapes.java +++ b/core/src/io/anuke/mindustry/graphics/Shapes.java @@ -1,10 +1,7 @@ package io.anuke.mindustry.graphics; import io.anuke.arc.Core; -import io.anuke.arc.graphics.g2d.CapStyle; -import io.anuke.arc.graphics.g2d.Draw; -import io.anuke.arc.graphics.g2d.Lines; -import io.anuke.arc.graphics.g2d.TextureRegion; +import io.anuke.arc.graphics.g2d.*; import io.anuke.arc.math.Mathf; import io.anuke.arc.util.Tmp; @@ -34,6 +31,6 @@ public class Shapes{ public static void tri(float x, float y, float width, float length, float rotation){ float oy = 17f / 63f * length; - Draw.rect(Core.atlas.find("shape-3"), x, y - oy + length/2f, width, length, width / 2f, oy, rotation - 90); + Draw.rect(Core.atlas.find("shape-3"), x, y - oy + length / 2f, width, length, width / 2f, oy, rotation - 90); } } diff --git a/core/src/io/anuke/mindustry/input/Binding.java b/core/src/io/anuke/mindustry/input/Binding.java index 7e6a73eff6..d135f1f528 100644 --- a/core/src/io/anuke/mindustry/input/Binding.java +++ b/core/src/io/anuke/mindustry/input/Binding.java @@ -2,9 +2,7 @@ package io.anuke.mindustry.input; import io.anuke.arc.Application.ApplicationType; import io.anuke.arc.Core; -import io.anuke.arc.KeyBinds.Axis; -import io.anuke.arc.KeyBinds.KeyBind; -import io.anuke.arc.KeyBinds.KeybindValue; +import io.anuke.arc.KeyBinds.*; import io.anuke.arc.input.InputDevice.DeviceType; import io.anuke.arc.input.KeyCode; @@ -37,9 +35,22 @@ public enum Binding implements KeyBind{ private final KeybindValue defaultValue; private final String category; - Binding(KeybindValue defaultValue, String category){ this.defaultValue = defaultValue; this.category = category; } - Binding(KeybindValue defaultValue){ this(defaultValue, null); } + Binding(KeybindValue defaultValue, String category){ + this.defaultValue = defaultValue; + this.category = category; + } - @Override public KeybindValue defaultValue(DeviceType type){ return defaultValue; } - @Override public String category(){ return category; } + Binding(KeybindValue defaultValue){ + this(defaultValue, null); + } + + @Override + public KeybindValue defaultValue(DeviceType type){ + return defaultValue; + } + + @Override + public String category(){ + return category; + } } diff --git a/core/src/io/anuke/mindustry/input/DesktopInput.java b/core/src/io/anuke/mindustry/input/DesktopInput.java index becf62dc85..bc3ef2533c 100644 --- a/core/src/io/anuke/mindustry/input/DesktopInput.java +++ b/core/src/io/anuke/mindustry/input/DesktopInput.java @@ -21,34 +21,35 @@ import static io.anuke.mindustry.Vars.*; import static io.anuke.mindustry.input.PlaceMode.*; public class DesktopInput extends InputHandler{ - /**Current cursor type.*/ + /** Current cursor type. */ private Cursor cursorType = SystemCursor.arrow; - /**Position where the player started dragging a line.*/ + /** Position where the player started dragging a line. */ private int selectX, selectY; - /**Whether selecting mode is active.*/ + /** Whether selecting mode is active. */ private PlaceMode mode; - /**Animation scale for line.*/ + /** Animation scale for line. */ private float selectScale; private int prevX, prevY, prevRotation; - /**Draws a placement icon for a specific block.*/ + /** Draws a placement icon for a specific block. */ void drawPlace(int x, int y, Block block, int rotation, int prevX, int prevY, int prevRotation){ if(validPlace(x, y, block, rotation)){ block.getPlaceDraw(placeDraw, rotation, prevX, prevY, prevRotation); Draw.color(); Draw.rect(placeDraw.region, x * tilesize + block.offset(), y * tilesize + block.offset(), - placeDraw.region.getWidth() * selectScale * Draw.scl * placeDraw.scalex, - placeDraw.region.getHeight() * selectScale * Draw.scl * placeDraw.scaley, - block.rotate ? placeDraw.rotation * 90 : 0); + placeDraw.region.getWidth() * selectScale * Draw.scl * placeDraw.scalex, + placeDraw.region.getHeight() * selectScale * Draw.scl * placeDraw.scaley, + block.rotate ? placeDraw.rotation * 90 : 0); Draw.color(Pal.accent); for(int i = 0; i < 4; i++){ Point2 p = Geometry.d8edge[i]; - float offset = -Math.max(block.size-1, 0)/2f * tilesize; - if(i % 2 == 0)Draw.rect("block-select", x * tilesize + block.offset() + offset * p.x, y * tilesize + block.offset() + offset * p.y, i * 90); + float offset = -Math.max(block.size - 1, 0) / 2f * tilesize; + if(i % 2 == 0) + Draw.rect("block-select", x * tilesize + block.offset() + offset * p.x, y * tilesize + block.offset() + offset * p.y, i * 90); } Draw.color(); }else{ @@ -98,7 +99,7 @@ public class DesktopInput extends InputHandler{ tile = tile.target(); Draw.color(Pal.removeBack); - Lines.square(tile.drawx(), tile.drawy()-1, tile.block().size * tilesize / 2f - 1); + Lines.square(tile.drawx(), tile.drawy() - 1, tile.block().size * tilesize / 2f - 1); Draw.color(Pal.remove); Lines.square(tile.drawx(), tile.drawy(), tile.block().size * tilesize / 2f - 1); } @@ -161,7 +162,7 @@ public class DesktopInput extends InputHandler{ selectScale = 0f; } - rotation = Mathf.mod(rotation + (int) Core.input.axisTap(Binding.rotate), 4); + rotation = Mathf.mod(rotation + (int)Core.input.axisTap(Binding.rotate), 4); Tile cursor = tileAt(Core.input.mouseX(), Core.input.mouseY()); @@ -206,8 +207,8 @@ public class DesktopInput extends InputHandler{ mode = placing; }else if(selected != null){ //only begin shooting if there's no cursor event - if (!tileTapped(selected) && !tryTapPlayer(Core.input.mouseWorld().x, Core.input.mouseWorld().y) && player.getPlaceQueue().size == 0 && !droppingItem && - !tryBeginMine(selected) && player.getMineTile() == null && !ui.chatfrag.chatOpen()) { + if(!tileTapped(selected) && !tryTapPlayer(Core.input.mouseWorld().x, Core.input.mouseWorld().y) && player.getPlaceQueue().size == 0 && !droppingItem && + !tryBeginMine(selected) && player.getMineTile() == null && !ui.chatfrag.chatOpen()){ player.isShooting = true; } }else if(!ui.chatfrag.chatOpen()){ //if it's out of bounds, shooting is just fine diff --git a/core/src/io/anuke/mindustry/input/InputHandler.java b/core/src/io/anuke/mindustry/input/InputHandler.java index 164088fb6f..e16c44f5c8 100644 --- a/core/src/io/anuke/mindustry/input/InputHandler.java +++ b/core/src/io/anuke/mindustry/input/InputHandler.java @@ -29,19 +29,17 @@ import io.anuke.mindustry.net.ValidateException; import io.anuke.mindustry.type.Item; import io.anuke.mindustry.type.ItemStack; import io.anuke.mindustry.ui.fragments.OverlayFragment; -import io.anuke.mindustry.world.Block; -import io.anuke.mindustry.world.Build; -import io.anuke.mindustry.world.Tile; +import io.anuke.mindustry.world.*; import static io.anuke.mindustry.Vars.*; public abstract class InputHandler implements InputProcessor{ - /**Used for dropping items.*/ + /** Used for dropping items. */ final static float playerSelectRange = mobile ? 17f : 11f; - /**Maximum line length.*/ + /** Maximum line length. */ final static int maxLength = 100; final static Vector2 stackTrns = new Vector2(); - /**Distance on the back from where items originate.*/ + /** Distance on the back from where items originate. */ final static float backTrns = 3f; public final OverlayFragment frag = new OverlayFragment(this); @@ -91,17 +89,17 @@ public abstract class InputHandler implements InputProcessor{ tile.block().getStackOffset(item, tile, stackTrns); ItemTransfer.create(item, - player.x + Angles.trnsx(player.rotation + 180f, backTrns), player.y + Angles.trnsy(player.rotation + 180f, backTrns), - new Vector2(tile.drawx() + stackTrns.x, tile.drawy() + stackTrns.y), () -> { - if(tile.block() != block || tile.entity == null || tile.entity.items == null) return; + player.x + Angles.trnsx(player.rotation + 180f, backTrns), player.y + Angles.trnsy(player.rotation + 180f, backTrns), + new Vector2(tile.drawx() + stackTrns.x, tile.drawy() + stackTrns.y), () -> { + if(tile.block() != block || tile.entity == null || tile.entity.items == null) return; - tile.block().handleStack(item, removed, tile, player); - remaining[1] -= removed; + tile.block().handleStack(item, removed, tile, player); + remaining[1] -= removed; - if(end && remaining[1] > 0){ - tile.block().handleStack(item, remaining[1], tile, player); - } - }); + if(end && remaining[1] > 0){ + tile.block().handleStack(item, remaining[1], tile, player); + } + }); remaining[0] -= removed; @@ -154,7 +152,7 @@ public abstract class InputHandler implements InputProcessor{ return false; } - /**Handles tile tap events that are not platform specific.*/ + /** Handles tile tap events that are not platform specific. */ boolean tileTapped(Tile tile){ tile = tile.target(); @@ -164,8 +162,8 @@ public abstract class InputHandler implements InputProcessor{ if(tile.block().configurable && tile.interactable(player.getTeam())){ consumed = true; if(((!frag.config.isShown() && tile.block().shouldShowConfigure(tile, player)) //if the config fragment is hidden, show - //alternatively, the current selected block can 'agree' to switch config tiles - || (frag.config.isShown() && frag.config.getSelectedTile().block().onConfigureTileTapped(frag.config.getSelectedTile(), tile)))){ + //alternatively, the current selected block can 'agree' to switch config tiles + || (frag.config.isShown() && frag.config.getSelectedTile().block().onConfigureTileTapped(frag.config.getSelectedTile(), tile)))){ frag.config.showConfig(tile); } //otherwise... @@ -210,7 +208,7 @@ public abstract class InputHandler implements InputProcessor{ return consumed; } - /**Tries to select the player to drop off items, returns true if successful.*/ + /** Tries to select the player to drop off items, returns true if successful. */ boolean tryTapPlayer(float x, float y){ if(canTapPlayer(x, y)){ droppingItem = true; @@ -223,7 +221,7 @@ public abstract class InputHandler implements InputProcessor{ return Mathf.dst(x, y, player.x, player.y) <= playerSelectRange && player.item().amount > 0; } - /**Tries to begin mining a tile, returns true if successful.*/ + /** Tries to begin mining a tile, returns true if successful. */ boolean tryBeginMine(Tile tile){ if(canMine(tile)){ //if a block is clicked twice, reset it @@ -235,13 +233,13 @@ public abstract class InputHandler implements InputProcessor{ boolean canMine(Tile tile){ return !Core.scene.hasMouse() - && tile.drop() != null && tile.drop().hardness <= player.mech.drillPower - && !(tile.floor().playerUnmineable && tile.ore() == Blocks.air) - && player.acceptsItem(tile.drop()) - && tile.block() == Blocks.air && player.dst(tile.worldx(), tile.worldy()) <= Player.mineDistance; + && tile.drop() != null && tile.drop().hardness <= player.mech.drillPower + && !(tile.floor().playerUnmineable && tile.ore() == Blocks.air) + && player.acceptsItem(tile.drop()) + && tile.block() == Blocks.air && player.dst(tile.worldx(), tile.worldy()) <= Player.mineDistance; } - /**Returns the tile at the specified MOUSE coordinates.*/ + /** Returns the tile at the specified MOUSE coordinates. */ Tile tileAt(float x, float y){ return world.tile(tileX(x), tileY(y)); } @@ -374,7 +372,7 @@ public abstract class InputHandler implements InputProcessor{ for(int i = 0; i < points.size; i++){ Point2 point = points.get(i); - if(block != null && Tmp.r2.setSize(block.size * tilesize).setCenter(point.x*tilesize + block.offset(), point.y*tilesize + block.offset()).overlaps(Tmp.r3)){ + if(block != null && Tmp.r2.setSize(block.size * tilesize).setCenter(point.x * tilesize + block.offset(), point.y * tilesize + block.offset()).overlaps(Tmp.r3)){ continue; } @@ -385,7 +383,7 @@ public abstract class InputHandler implements InputProcessor{ line.last = next == null; cons.accept(line); - Tmp.r3.setSize(block.size * tilesize).setCenter(point.x*tilesize + block.offset(), point.y*tilesize + block.offset()); + Tmp.r3.setSize(block.size * tilesize).setCenter(point.x * tilesize + block.offset(), point.y * tilesize + block.offset()); } } diff --git a/core/src/io/anuke/mindustry/input/MobileInput.java b/core/src/io/anuke/mindustry/input/MobileInput.java index e79c614a6f..ab33b78716 100644 --- a/core/src/io/anuke/mindustry/input/MobileInput.java +++ b/core/src/io/anuke/mindustry/input/MobileInput.java @@ -4,24 +4,17 @@ import io.anuke.arc.Core; import io.anuke.arc.collection.Array; import io.anuke.arc.function.BooleanProvider; import io.anuke.arc.graphics.Color; -import io.anuke.arc.graphics.g2d.Draw; -import io.anuke.arc.graphics.g2d.Lines; -import io.anuke.arc.graphics.g2d.TextureRegion; +import io.anuke.arc.graphics.g2d.*; import io.anuke.arc.input.GestureDetector; import io.anuke.arc.input.GestureDetector.GestureListener; import io.anuke.arc.input.KeyCode; import io.anuke.arc.math.Interpolation; import io.anuke.arc.math.Mathf; -import io.anuke.arc.math.geom.Geometry; -import io.anuke.arc.math.geom.Point2; -import io.anuke.arc.math.geom.Rectangle; -import io.anuke.arc.math.geom.Vector2; +import io.anuke.arc.math.geom.*; import io.anuke.arc.scene.actions.Actions; import io.anuke.arc.scene.event.Touchable; import io.anuke.arc.scene.ui.layout.Table; -import io.anuke.arc.util.Align; -import io.anuke.arc.util.Time; -import io.anuke.arc.util.Tmp; +import io.anuke.arc.util.*; import io.anuke.mindustry.content.Blocks; import io.anuke.mindustry.content.Fx; import io.anuke.mindustry.core.GameState.State; @@ -60,7 +53,7 @@ public class MobileInput extends InputHandler implements GestureListener{ /** Animation data for crosshair. */ private float crosshairScale; private TargetTrait lastTarget; - /** Used for shifting build requests.*/ + /** Used for shifting build requests. */ private float shiftDeltaX, shiftDeltaY; /** List of currently selected tiles to place. */ @@ -173,7 +166,7 @@ public class MobileInput extends InputHandler implements GestureListener{ Core.scene.table("guideDim", t -> { t.margin(10f); t.touchable(Touchable.disabled); - t.top().table("button", s -> s.add("$"+type).growX().wrap().labelAlign(Align.center, Align.center)).growX(); + t.top().table("button", s -> s.add("$" + type).growX().wrap().labelAlign(Align.center, Align.center)).growX(); t.update(() -> { if((done.get() || state.is(State.menu)) && t.getUserObject() == null){ t.actions(Actions.delay(1f), Actions.fadeOut(1f, Interpolation.fade), Actions.remove()); @@ -187,11 +180,11 @@ public class MobileInput extends InputHandler implements GestureListener{ } boolean isLinePlacing(){ - return mode == placing && lineMode && Mathf.dst(lineStartX * tilesize, lineStartY * tilesize, Core.input.mouseWorld().x, Core.input.mouseWorld().y) >= 3*tilesize; + return mode == placing && lineMode && Mathf.dst(lineStartX * tilesize, lineStartY * tilesize, Core.input.mouseWorld().x, Core.input.mouseWorld().y) >= 3 * tilesize; } boolean isAreaBreaking(){ - return mode == breaking && lineMode && Mathf.dst(lineStartX * tilesize, lineStartY * tilesize, Core.input.mouseWorld().x, Core.input.mouseWorld().y) >= 2*tilesize; + return mode == breaking && lineMode && Mathf.dst(lineStartX * tilesize, lineStartY * tilesize, Core.input.mouseWorld().x, Core.input.mouseWorld().y) >= 2 * tilesize; } //endregion @@ -222,10 +215,11 @@ public class MobileInput extends InputHandler implements GestureListener{ Draw.mixcol(Pal.accent, 1f); for(int i = 0; i < 4; i++){ Point2 p = Geometry.d8edge[i]; - float poffset = -Math.max(request.block.size-1, 0)/2f * tilesize; + float poffset = -Math.max(request.block.size - 1, 0) / 2f * tilesize; TextureRegion find = Core.atlas.find("block-select"); - if(i%2 == 0) Draw.rect("block-select", request.tile().x * tilesize + request.block.offset() + poffset * p.x, request.tile().y * tilesize + request.block.offset() + poffset * p.y, - find.getWidth() * Draw.scl * request.scale, find.getHeight() * Draw.scl * request.scale, i * 90); + if(i % 2 == 0) + Draw.rect("block-select", request.tile().x * tilesize + request.block.offset() + poffset * p.x, request.tile().y * tilesize + request.block.offset() + poffset * p.y, + find.getWidth() * Draw.scl * request.scale, find.getHeight() * Draw.scl * request.scale, i * 90); } Draw.color(); }else{ @@ -235,13 +229,13 @@ public class MobileInput extends InputHandler implements GestureListener{ Draw.mixcol(); //draw removing request Draw.tint(Pal.removeBack); - Lines.square(tile.drawx(), tile.drawy()-1, rad); + Lines.square(tile.drawx(), tile.drawy() - 1, rad); Draw.tint(Pal.remove); Lines.square(tile.drawx(), tile.drawy(), rad); } } - /**Draws a placement icon for a specific block.*/ + /** Draws a placement icon for a specific block. */ void drawPlace(int x, int y, Block block, int rotation, int prevX, int prevY, int prevRotation){ if(validPlace(x, y, block, rotation)){ block.getPlaceDraw(placeDraw, rotation, prevX, prevY, prevRotation); @@ -255,8 +249,9 @@ public class MobileInput extends InputHandler implements GestureListener{ Draw.color(Pal.accent); for(int i = 0; i < 4; i++){ Point2 p = Geometry.d8edge[i]; - float offset = -Math.max(block.size-1, 0)/2f * tilesize; - if(i % 2 == 0)Draw.rect("block-select", x * tilesize + block.offset() + offset * p.x, y * tilesize + block.offset() + offset * p.y, i * 90); + float offset = -Math.max(block.size - 1, 0) / 2f * tilesize; + if(i % 2 == 0) + Draw.rect("block-select", x * tilesize + block.offset() + offset * p.x, y * tilesize + block.offset() + offset * p.y, i * 90); } Draw.color(); }else{ @@ -353,7 +348,7 @@ public class MobileInput extends InputHandler implements GestureListener{ if(tile == null) continue; if((!request.remove && validPlace(tile.x, tile.y, request.block, request.rotation)) - || (request.remove && validBreak(tile.x, tile.y))){ + || (request.remove && validBreak(tile.x, tile.y))){ request.scale = Mathf.lerpDelta(request.scale, 1f, 0.2f); request.redness = Mathf.lerpDelta(request.redness, 0f, 0.2f); }else{ @@ -418,7 +413,7 @@ public class MobileInput extends InputHandler implements GestureListener{ other = other.target(); Draw.color(Pal.removeBack); - Lines.square(other.drawx(), other.drawy()-1, other.block().size * tilesize / 2f - 1); + Lines.square(other.drawx(), other.drawy() - 1, other.block().size * tilesize / 2f - 1); Draw.color(Pal.remove); Lines.square(other.drawx(), other.drawy(), other.block().size * tilesize / 2f - 1); } @@ -658,7 +653,7 @@ public class MobileInput extends InputHandler implements GestureListener{ panY = (screenY - Core.graphics.getHeight()) + edgePan; } - vector.set(panX, panY).scl((Core.camera.width ) / Core.graphics.getWidth()); + vector.set(panX, panY).scl((Core.camera.width) / Core.graphics.getWidth()); vector.limit(maxPanSpeed); //pan view diff --git a/core/src/io/anuke/mindustry/input/PlaceUtils.java b/core/src/io/anuke/mindustry/input/PlaceUtils.java index 1a36c24608..52e06e518b 100644 --- a/core/src/io/anuke/mindustry/input/PlaceUtils.java +++ b/core/src/io/anuke/mindustry/input/PlaceUtils.java @@ -15,26 +15,26 @@ public class PlaceUtils{ private static Bresenham2 bres = new Bresenham2(); private static Array points = new Array<>(); - /**Normalize a diagonal line into points. */ + /** Normalize a diagonal line into points. */ public static Array normalizeDiagonal(int startX, int startY, int endX, int endY){ Pools.freeAll(points); points.clear(); return bres.lineNoDiagonal(startX, startY, endX, endY, Pools.get(Point2.class, Point2::new), points); } - /**Normalize two points into one straight line, no diagonals.*/ + /** Normalize two points into one straight line, no diagonals. */ public static Array normalizeLine(int startX, int startY, int endX, int endY){ Pools.freeAll(points); points.clear(); if(Math.abs(startX - endX) > Math.abs(startY - endY)){ //go width for(int i = 0; i <= Math.abs(startX - endX); i++){ - points.add(Pools.obtain(Point2.class, Point2::new).set(startX + i*Mathf.sign(endX - startX), startY)); + points.add(Pools.obtain(Point2.class, Point2::new).set(startX + i * Mathf.sign(endX - startX), startY)); } }else{ //go height for(int i = 0; i <= Math.abs(startY - endY); i++){ - points.add(Pools.obtain(Point2.class, Point2::new).set(startX, startY + i*Mathf.sign(endY - startY))); + points.add(Pools.obtain(Point2.class, Point2::new).set(startX, startY + i * Mathf.sign(endY - startY))); } } return points; @@ -43,7 +43,6 @@ public class PlaceUtils{ /** * Normalizes a placement area and returns the result, ready to be used for drawing a rectangle. * Returned x2 and y2 will always be greater than x and y. - * * @param block block that will be drawn * @param startx starting X coordinate * @param starty starting Y coordinate @@ -80,7 +79,6 @@ public class PlaceUtils{ /** * Normalizes a placement area and returns the result. * Returned x2 and y2 will always be greater than x and y. - * * @param tilex starting X coordinate * @param tiley starting Y coordinate * @param endx ending X coordinate diff --git a/core/src/io/anuke/mindustry/io/BundleLoader.java b/core/src/io/anuke/mindustry/io/BundleLoader.java index ba11207bf1..14cb5e3e67 100644 --- a/core/src/io/anuke/mindustry/io/BundleLoader.java +++ b/core/src/io/anuke/mindustry/io/BundleLoader.java @@ -2,10 +2,8 @@ package io.anuke.mindustry.io; import io.anuke.arc.Core; import io.anuke.arc.files.FileHandle; -import io.anuke.arc.util.I18NBundle; +import io.anuke.arc.util.*; import io.anuke.mindustry.Vars; -import io.anuke.arc.util.Time; -import io.anuke.arc.util.Log; import io.anuke.mindustry.input.Binding; import java.util.Locale; diff --git a/core/src/io/anuke/mindustry/io/Changelogs.java b/core/src/io/anuke/mindustry/io/Changelogs.java index 6dfcf6ce3c..33d888be47 100644 --- a/core/src/io/anuke/mindustry/io/Changelogs.java +++ b/core/src/io/anuke/mindustry/io/Changelogs.java @@ -44,11 +44,11 @@ public class Changelogs{ @Override public String toString(){ return "VersionInfo{" + - "name='" + name + '\'' + - ", description='" + description + '\'' + - ", id=" + id + - ", build=" + build + - '}'; + "name='" + name + '\'' + + ", description='" + description + '\'' + + ", id=" + id + + ", build=" + build + + '}'; } } } diff --git a/core/src/io/anuke/mindustry/io/Contributors.java b/core/src/io/anuke/mindustry/io/Contributors.java index 9924e8e44c..13e3a3dad1 100644 --- a/core/src/io/anuke/mindustry/io/Contributors.java +++ b/core/src/io/anuke/mindustry/io/Contributors.java @@ -36,8 +36,8 @@ public class Contributors{ @Override public String toString(){ return "Contributor{" + - "login='" + login + '\'' + - '}'; + "login='" + login + '\'' + + '}'; } } } diff --git a/core/src/io/anuke/mindustry/io/MapIO.java b/core/src/io/anuke/mindustry/io/MapIO.java index 4f5029c63e..d8cb81bf56 100644 --- a/core/src/io/anuke/mindustry/io/MapIO.java +++ b/core/src/io/anuke/mindustry/io/MapIO.java @@ -8,22 +8,14 @@ import io.anuke.arc.graphics.Color; import io.anuke.arc.graphics.Pixmap; import io.anuke.arc.graphics.Pixmap.Format; import io.anuke.arc.math.Mathf; -import io.anuke.arc.util.Pack; -import io.anuke.arc.util.Strings; -import io.anuke.arc.util.Structs; -import io.anuke.arc.util.Time; +import io.anuke.arc.util.*; import io.anuke.mindustry.content.Blocks; -import io.anuke.mindustry.game.MappableContent; -import io.anuke.mindustry.game.Team; -import io.anuke.mindustry.game.Version; +import io.anuke.mindustry.game.*; import io.anuke.mindustry.maps.Map; import io.anuke.mindustry.type.ContentType; import io.anuke.mindustry.type.Item; -import io.anuke.mindustry.world.Block; -import io.anuke.mindustry.world.CachedTile; -import io.anuke.mindustry.world.LegacyColorMapper; +import io.anuke.mindustry.world.*; import io.anuke.mindustry.world.LegacyColorMapper.LegacyBlock; -import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.blocks.BlockPart; import io.anuke.mindustry.world.blocks.Floor; @@ -35,7 +27,7 @@ import java.util.zip.InflaterInputStream; import static io.anuke.mindustry.Vars.bufferSize; import static io.anuke.mindustry.Vars.content; -/** Reads and writes map files.*/ +/** Reads and writes map files. */ public class MapIO{ public static final int version = 1; @@ -47,13 +39,13 @@ public class MapIO{ //stainedRocks, stainedRocksRed, stainedRocksYellow, stainedStoneYellow, stainedBoulder, missingBlocks = ObjectMap.of( - "stained-stone", Blocks.shale, - "stained-stone-red", Blocks.shale, - "stained-stone-yellow", Blocks.shale, - "stained-rocks", Blocks.shaleRocks, - "stained-boulder", Blocks.shaleBoulder, - "stained-rocks-red", Blocks.shaleRocks, - "stained-rocks-yellow", Blocks.shaleRocks + "stained-stone", Blocks.shale, + "stained-stone-red", Blocks.shale, + "stained-stone-yellow", Blocks.shale, + "stained-rocks", Blocks.shaleRocks, + "stained-boulder", Blocks.shaleBoulder, + "stained-rocks-red", Blocks.shaleRocks, + "stained-rocks-yellow", Blocks.shaleRocks ); } @@ -84,7 +76,8 @@ public class MapIO{ @Override public void setOreByte(byte b){ - if(b != 0) floors.drawPixel(x, floors.getHeight() - 1 - y, colorFor(floor(), Blocks.air, content.block(b), getTeam())); + if(b != 0) + floors.drawPixel(x, floors.getHeight() - 1 - y, colorFor(floor(), Blocks.air, content.block(b), getTeam())); } @Override @@ -223,12 +216,12 @@ public class MapIO{ } } - /**Reads tiles from a map, version-agnostic.*/ + /** Reads tiles from a map, version-agnostic. */ public static void readTiles(Map map, Tile[][] tiles) throws IOException{ readTiles(map, (x, y) -> tiles[x][y]); } - /**Reads tiles from a map, version-agnostic.*/ + /** Reads tiles from a map, version-agnostic. */ public static void readTiles(Map map, TileProvider tiles) throws IOException{ if(map.version == 0){ readLegacyMmapTiles(map.file, tiles); @@ -239,12 +232,12 @@ public class MapIO{ } } - /**Reads tiles from a map in the new build-65 format.*/ + /** Reads tiles from a map in the new build-65 format. */ private static void readTiles(FileHandle file, int width, int height, Tile[][] tiles) throws IOException{ readTiles(file, width, height, (x, y) -> tiles[x][y]); } - /**Reads tiles from a map in the new build-65 format.*/ + /** Reads tiles from a map in the new build-65 format. */ private static void readTiles(FileHandle file, int width, int height, TileProvider tiles) throws IOException{ try(BufferedInputStream input = file.read(bufferSize)){ @@ -334,7 +327,7 @@ public class MapIO{ //region legacy IO - /**Reads a pixmap in the 3.5 pixmap format.*/ + /** Reads a pixmap in the 3.5 pixmap format. */ public static void readLegacyPixmap(Pixmap pixmap, Tile[][] tiles){ for(int x = 0; x < pixmap.getWidth(); x++){ for(int y = 0; y < pixmap.getHeight(); y++){ @@ -358,7 +351,7 @@ public class MapIO{ Tile write = tiles[worldx][worldy]; write.setBlock(Blocks.part); write.setTeam(Team.blue); - write.setLinkByte(Pack.byteByte((byte) (dx - 1 + 8), (byte) (dy - 1 + 8))); + write.setLinkByte(Pack.byteByte((byte)(dx - 1 + 8), (byte)(dy - 1 + 8))); } } } @@ -371,12 +364,12 @@ public class MapIO{ } } - /**Reads a pixmap in the old 4.0 .mmap format.*/ + /** Reads a pixmap in the old 4.0 .mmap format. */ private static void readLegacyMmapTiles(FileHandle file, Tile[][] tiles) throws IOException{ readLegacyMmapTiles(file, (x, y) -> tiles[x][y]); } - /**Reads a mmap in the old 4.0 .mmap format.*/ + /** Reads a mmap in the old 4.0 .mmap format. */ private static void readLegacyMmapTiles(FileHandle file, TileProvider tiles) throws IOException{ try(DataInputStream stream = new DataInputStream(file.read(bufferSize))){ stream.readInt(); //version diff --git a/core/src/io/anuke/mindustry/io/SaveFileVersion.java b/core/src/io/anuke/mindustry/io/SaveFileVersion.java index 69f1c3339a..6d56b963cf 100644 --- a/core/src/io/anuke/mindustry/io/SaveFileVersion.java +++ b/core/src/io/anuke/mindustry/io/SaveFileVersion.java @@ -5,21 +5,14 @@ import io.anuke.arc.util.Pack; import io.anuke.mindustry.content.Blocks; import io.anuke.mindustry.entities.Entities; import io.anuke.mindustry.entities.EntityGroup; -import io.anuke.mindustry.entities.traits.Entity; -import io.anuke.mindustry.entities.traits.SaveTrait; -import io.anuke.mindustry.entities.traits.TypeTrait; -import io.anuke.mindustry.game.Content; -import io.anuke.mindustry.game.MappableContent; -import io.anuke.mindustry.game.Rules; -import io.anuke.mindustry.game.Team; +import io.anuke.mindustry.entities.traits.*; +import io.anuke.mindustry.game.*; import io.anuke.mindustry.gen.Serialization; import io.anuke.mindustry.type.ContentType; import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Tile; -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; +import java.io.*; import static io.anuke.mindustry.Vars.content; import static io.anuke.mindustry.Vars.world; @@ -77,7 +70,7 @@ public abstract class SaveFileVersion{ stream.writeByte(tile.link); }else if(tile.entity != null){ stream.writeByte(Pack.byteByte(tile.getTeamID(), tile.getRotation())); //team + rotation - stream.writeShort((short) tile.entity.health); //health + stream.writeShort((short)tile.entity.health); //health if(tile.entity.items != null) tile.entity.items.write(stream); if(tile.entity.power != null) tile.entity.power.write(stream); @@ -193,8 +186,8 @@ public abstract class SaveFileVersion{ if(!group.isEmpty() && group.all().get(0) instanceof SaveTrait){ stream.writeInt(group.size()); for(Entity entity : group.all()){ - stream.writeByte(((SaveTrait) entity).getTypeID()); - ((SaveTrait) entity).writeSave(stream); + stream.writeByte(((SaveTrait)entity).getTypeID()); + ((SaveTrait)entity).writeSave(stream); } } } @@ -207,7 +200,7 @@ public abstract class SaveFileVersion{ int amount = stream.readInt(); for(int j = 0; j < amount; j++){ byte typeid = stream.readByte(); - SaveTrait trait = (SaveTrait) TypeTrait.getTypeByID(typeid).get(); + SaveTrait trait = (SaveTrait)TypeTrait.getTypeByID(typeid).get(); trait.readSave(stream); } } @@ -219,12 +212,12 @@ public abstract class SaveFileVersion{ MappableContent[][] map = new MappableContent[ContentType.values().length][0]; - for (int i = 0; i < mapped; i++) { + for(int i = 0; i < mapped; i++){ ContentType type = ContentType.values()[stream.readByte()]; short total = stream.readShort(); map[type.ordinal()] = new MappableContent[total]; - for (int j = 0; j < total; j++) { + for(int j = 0; j < total; j++){ String name = stream.readUTF(); map[type.ordinal()][j] = content.getByName(type, name); } @@ -249,7 +242,7 @@ public abstract class SaveFileVersion{ stream.writeByte(arr.first().getContentType().ordinal()); stream.writeShort(arr.size); for(Content c : arr){ - stream.writeUTF(((MappableContent) c).name); + stream.writeUTF(((MappableContent)c).name); } } } diff --git a/core/src/io/anuke/mindustry/io/SaveIO.java b/core/src/io/anuke/mindustry/io/SaveIO.java index f7c5b50320..d39433142a 100644 --- a/core/src/io/anuke/mindustry/io/SaveIO.java +++ b/core/src/io/anuke/mindustry/io/SaveIO.java @@ -1,8 +1,6 @@ package io.anuke.mindustry.io; -import io.anuke.arc.collection.Array; -import io.anuke.arc.collection.IntArray; -import io.anuke.arc.collection.IntMap; +import io.anuke.arc.collection.*; import io.anuke.arc.files.FileHandle; import io.anuke.mindustry.Vars; import io.anuke.mindustry.io.versions.Save16; @@ -18,7 +16,7 @@ public class SaveIO{ public static final IntArray breakingVersions = IntArray.with(47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 63); public static final IntMap versions = new IntMap<>(); public static final Array versionArray = Array.with( - new Save16() + new Save16() ); static{ @@ -98,7 +96,7 @@ public class SaveIO{ write(new DeflaterOutputStream(file.write(false, bufferSize)){ byte[] tmp = {0}; - public void write(int var1) throws IOException { + public void write(int var1) throws IOException{ tmp[0] = (byte)(var1 & 255); this.write(tmp, 0, 1); } diff --git a/core/src/io/anuke/mindustry/io/TypeIO.java b/core/src/io/anuke/mindustry/io/TypeIO.java index c88bce34eb..367207d9b9 100644 --- a/core/src/io/anuke/mindustry/io/TypeIO.java +++ b/core/src/io/anuke/mindustry/io/TypeIO.java @@ -10,28 +10,19 @@ import io.anuke.mindustry.entities.bullet.Bullet; import io.anuke.mindustry.entities.bullet.BulletType; import io.anuke.mindustry.entities.traits.BuilderTrait.BuildRequest; import io.anuke.mindustry.entities.traits.ShooterTrait; -import io.anuke.mindustry.entities.type.BaseUnit; -import io.anuke.mindustry.entities.type.Player; -import io.anuke.mindustry.entities.type.Unit; +import io.anuke.mindustry.entities.type.*; import io.anuke.mindustry.game.Team; import io.anuke.mindustry.net.Packets.AdminAction; import io.anuke.mindustry.net.Packets.KickReason; -import io.anuke.mindustry.type.ContentType; -import io.anuke.mindustry.type.Item; -import io.anuke.mindustry.type.Liquid; -import io.anuke.mindustry.type.Mech; -import io.anuke.mindustry.world.Block; -import io.anuke.mindustry.world.Pos; -import io.anuke.mindustry.world.Tile; +import io.anuke.mindustry.type.*; +import io.anuke.mindustry.world.*; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; +import java.io.*; import java.nio.ByteBuffer; import static io.anuke.mindustry.Vars.*; -/** Class for specifying read/write methods for code generation.*/ +/** Class for specifying read/write methods for code generation. */ @SuppressWarnings("unused") public class TypeIO{ @@ -56,7 +47,7 @@ public class TypeIO{ buffer.put((byte)-1); return; } - buffer.put((byte) unit.getGroup().getID()); + buffer.put((byte)unit.getGroup().getID()); buffer.putInt(unit.getID()); } @@ -65,12 +56,12 @@ public class TypeIO{ byte gid = buffer.get(); if(gid == -1) return null; int id = buffer.getInt(); - return (Unit) Entities.getGroup(gid).getByID(id); + return (Unit)Entities.getGroup(gid).getByID(id); } @WriteClass(ShooterTrait.class) public static void writeShooter(ByteBuffer buffer, ShooterTrait trait){ - buffer.put((byte) trait.getGroup().getID()); + buffer.put((byte)trait.getGroup().getID()); buffer.putInt(trait.getID()); } @@ -78,7 +69,7 @@ public class TypeIO{ public static ShooterTrait readShooter(ByteBuffer buffer){ byte gid = buffer.get(); int id = buffer.getInt(); - return (ShooterTrait) Entities.getGroup(gid).getByID(id); + return (ShooterTrait)Entities.getGroup(gid).getByID(id); } @WriteClass(Bullet.class) @@ -94,7 +85,7 @@ public class TypeIO{ @WriteClass(BaseUnit.class) public static void writeBaseUnit(ByteBuffer buffer, BaseUnit unit){ - buffer.put((byte) unitGroups[unit.getTeam().ordinal()].getID()); + buffer.put((byte)unitGroups[unit.getTeam().ordinal()].getID()); buffer.putInt(unit.getID()); } @@ -102,7 +93,7 @@ public class TypeIO{ public static BaseUnit writeBaseUnit(ByteBuffer buffer){ byte gid = buffer.get(); int id = buffer.getInt(); - return (BaseUnit) Entities.getGroup(gid).getByID(id); + return (BaseUnit)Entities.getGroup(gid).getByID(id); } @WriteClass(Tile.class) @@ -129,11 +120,11 @@ public class TypeIO{ public static void writeRequests(ByteBuffer buffer, BuildRequest[] requests){ buffer.putShort((short)requests.length); for(BuildRequest request : requests){ - buffer.put(request.breaking ? (byte) 1 : 0); + buffer.put(request.breaking ? (byte)1 : 0); buffer.putInt(Pos.get(request.x, request.y)); if(!request.breaking){ buffer.put(request.block.id); - buffer.put((byte) request.rotation); + buffer.put((byte)request.rotation); } } } @@ -163,7 +154,7 @@ public class TypeIO{ @WriteClass(KickReason.class) public static void writeKick(ByteBuffer buffer, KickReason reason){ - buffer.put((byte) reason.ordinal()); + buffer.put((byte)reason.ordinal()); } @ReadClass(KickReason.class) @@ -173,7 +164,7 @@ public class TypeIO{ @WriteClass(Team.class) public static void writeTeam(ByteBuffer buffer, Team reason){ - buffer.put((byte) reason.ordinal()); + buffer.put((byte)reason.ordinal()); } @ReadClass(Team.class) @@ -183,7 +174,7 @@ public class TypeIO{ @WriteClass(AdminAction.class) public static void writeAction(ByteBuffer buffer, AdminAction reason){ - buffer.put((byte) reason.ordinal()); + buffer.put((byte)reason.ordinal()); } @ReadClass(AdminAction.class) @@ -193,7 +184,7 @@ public class TypeIO{ @WriteClass(Effect.class) public static void writeEffect(ByteBuffer buffer, Effect effect){ - buffer.putShort((short) effect.id); + buffer.putShort((short)effect.id); } @ReadClass(Effect.class) @@ -256,10 +247,10 @@ public class TypeIO{ public static void writeString(ByteBuffer buffer, String string){ if(string != null){ byte[] bytes = string.getBytes(charset); - buffer.putShort((short) bytes.length); + buffer.putShort((short)bytes.length); buffer.put(bytes); }else{ - buffer.putShort((short) -1); + buffer.putShort((short)-1); } } @@ -277,7 +268,7 @@ public class TypeIO{ @WriteClass(byte[].class) public static void writeBytes(ByteBuffer buffer, byte[] bytes){ - buffer.putShort((short) bytes.length); + buffer.putShort((short)bytes.length); buffer.put(bytes); } @@ -292,10 +283,10 @@ public class TypeIO{ public static void writeStringData(DataOutput buffer, String string) throws IOException{ if(string != null){ byte[] bytes = string.getBytes(charset); - buffer.writeShort((short) bytes.length); + buffer.writeShort((short)bytes.length); buffer.write(bytes); }else{ - buffer.writeShort((short) -1); + buffer.writeShort((short)-1); } } diff --git a/core/src/io/anuke/mindustry/io/versions/Save16.java b/core/src/io/anuke/mindustry/io/versions/Save16.java index 3b5d8f2116..07549b53be 100644 --- a/core/src/io/anuke/mindustry/io/versions/Save16.java +++ b/core/src/io/anuke/mindustry/io/versions/Save16.java @@ -7,9 +7,7 @@ import io.anuke.mindustry.gen.Serialization; import io.anuke.mindustry.io.SaveFileVersion; import io.anuke.mindustry.maps.Map; -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; +import java.io.*; import static io.anuke.mindustry.Vars.*; diff --git a/core/src/io/anuke/mindustry/maps/Map.java b/core/src/io/anuke/mindustry/maps/Map.java index 2495df33db..83f4d5f02d 100644 --- a/core/src/io/anuke/mindustry/maps/Map.java +++ b/core/src/io/anuke/mindustry/maps/Map.java @@ -14,19 +14,19 @@ import io.anuke.mindustry.io.MapIO; import static io.anuke.mindustry.Vars.world; public class Map implements Comparable{ - /** Whether this is a custom map.*/ + /** Whether this is a custom map. */ public final boolean custom; - /** Metadata. Author description, display name, etc.*/ + /** Metadata. Author description, display name, etc. */ public final ObjectMap tags; - /** Base file of this map. File can be named anything at all.*/ + /** Base file of this map. File can be named anything at all. */ public final FileHandle file; - /** Format version.*/ + /** Format version. */ public final int version; - /** Map width/height, shorts.*/ + /** Map width/height, shorts. */ public int width, height; - /** Preview texture.*/ + /** Preview texture. */ public Texture texture; - /** Build that this map was created in. -1 = unknown or custom build.*/ + /** Build that this map was created in. -1 = unknown or custom build. */ public int build; public Map(FileHandle file, int width, int height, ObjectMap tags, boolean custom, int version, int build){ @@ -103,9 +103,9 @@ public class Map implements Comparable{ @Override public String toString(){ return "Map{" + - "file='" + file + '\'' + - ", custom=" + custom + - ", tags=" + tags + - '}'; + "file='" + file + '\'' + + ", custom=" + custom + + ", tags=" + tags + + '}'; } } diff --git a/core/src/io/anuke/mindustry/maps/Maps.java b/core/src/io/anuke/mindustry/maps/Maps.java index da11552ffc..72ecba7c64 100644 --- a/core/src/io/anuke/mindustry/maps/Maps.java +++ b/core/src/io/anuke/mindustry/maps/Maps.java @@ -18,11 +18,11 @@ import java.io.StringWriter; import static io.anuke.mindustry.Vars.*; public class Maps implements Disposable{ - /** List of all built-in maps. Filenames only.*/ + /** List of all built-in maps. Filenames only. */ private static final String[] defaultMapNames = {"fortress"}; /** All maps stored in an ordered array. */ private Array maps = new Array<>(); - /** Serializer for meta.*/ + /** Serializer for meta. */ private Json json = new Json(); public Maps(){ @@ -81,8 +81,10 @@ public class Maps implements Disposable{ load(); } - /** Save a custom map to the directory. This updates all values and stored data necessary. - * The tags are copied to prevent mutation later.*/ + /** + * Save a custom map to the directory. This updates all values and stored data necessary. + * The tags are copied to prevent mutation later. + */ public void saveMap(ObjectMap baseTags, Tile[][] data){ try{ @@ -162,12 +164,12 @@ public class Maps implements Disposable{ return str == null ? null : str.equals("[]") ? new Array<>() : Array.with(json.fromJson(SpawnGroup[].class, str)); } - /** Find a new filename to put a map to.*/ + /** Find a new filename to put a map to. */ private FileHandle findFile(){ //find a map name that isn't used. int i = maps.size; while(customMapDirectory.child("map_" + i + "." + mapExtension).exists()){ - i ++; + i++; } return customMapDirectory.child("map_" + i + "." + mapExtension); } diff --git a/core/src/io/anuke/mindustry/maps/generators/BasicGenerator.java b/core/src/io/anuke/mindustry/maps/generators/BasicGenerator.java index 26a9d62ace..687cbd9117 100644 --- a/core/src/io/anuke/mindustry/maps/generators/BasicGenerator.java +++ b/core/src/io/anuke/mindustry/maps/generators/BasicGenerator.java @@ -34,7 +34,7 @@ public class BasicGenerator extends RandomGenerator{ for(int i = ores.size - 1; i >= 0; i--){ Item entry = ores.get(i); if(Math.abs(0.5f - sim.octaveNoise2D(2, 0.7, 1f / (50 + i * 2), offsetX, offsetY)) > 0.23f && - Math.abs(0.5f - sim2.octaveNoise2D(1, 1, 1f / (40 + i * 4), offsetX, offsetY)) > 0.32f){ + Math.abs(0.5f - sim2.octaveNoise2D(1, 1, 1f / (40 + i * 4), offsetX, offsetY)) > 0.32f){ //floor = OreBlock.get(floor, entry); break; diff --git a/core/src/io/anuke/mindustry/maps/generators/Generator.java b/core/src/io/anuke/mindustry/maps/generators/Generator.java index a9d31fe87c..f6bc16806d 100644 --- a/core/src/io/anuke/mindustry/maps/generators/Generator.java +++ b/core/src/io/anuke/mindustry/maps/generators/Generator.java @@ -11,7 +11,8 @@ public abstract class Generator{ this.height = height; } - public Generator(){} + public Generator(){ + } public void init(Loadout loadout){ diff --git a/core/src/io/anuke/mindustry/maps/generators/MapGenerator.java b/core/src/io/anuke/mindustry/maps/generators/MapGenerator.java index 3eeb372729..96f9f9e0ce 100644 --- a/core/src/io/anuke/mindustry/maps/generators/MapGenerator.java +++ b/core/src/io/anuke/mindustry/maps/generators/MapGenerator.java @@ -27,14 +27,16 @@ public class MapGenerator extends Generator{ private String mapName; private Array decorations = Array.with(new Decoration(Blocks.stone, Blocks.rock, 0.003f)); private Loadout loadout; - /**How much the landscape is randomly distorted.*/ + /** How much the landscape is randomly distorted. */ public float distortion = 3; - /**The amount of final enemy spawns used. -1 to use everything in the map. - * This amount of enemy spawns is selected randomly from the map.*/ + /** + * The amount of final enemy spawns used. -1 to use everything in the map. + * This amount of enemy spawns is selected randomly from the map. + */ public int enemySpawns = -1; - /**Whether floor is distorted along with blocks.*/ + /** Whether floor is distorted along with blocks. */ public boolean distortFloor = false; - /**Items randomly added to containers and vaults.*/ + /** Items randomly added to containers and vaults. */ public ItemStack[] storageDrops = ItemStack.with(Items.copper, 300, Items.lead, 300, Items.silicon, 200, Items.graphite, 200, Items.blastCompound, 200); public MapGenerator(String mapName){ diff --git a/core/src/io/anuke/mindustry/maps/generators/RandomGenerator.java b/core/src/io/anuke/mindustry/maps/generators/RandomGenerator.java index 9692f0dc54..c7d07b9218 100644 --- a/core/src/io/anuke/mindustry/maps/generators/RandomGenerator.java +++ b/core/src/io/anuke/mindustry/maps/generators/RandomGenerator.java @@ -24,11 +24,13 @@ public abstract class RandomGenerator extends Generator{ } } - tiles[width/2][height/2].setBlock(Blocks.coreShard, Team.blue); - tiles[width/2][height/2 - 6].setBlock(Blocks.launchPad, Team.blue); + tiles[width / 2][height / 2].setBlock(Blocks.coreShard, Team.blue); + tiles[width / 2][height / 2 - 6].setBlock(Blocks.launchPad, Team.blue); } - /**Sets {@link #floor} and {@link #block} to the correct values as output. - * Before this method is called, both are set to {@link Blocks#air} as defaults.*/ + /** + * Sets {@link #floor} and {@link #block} to the correct values as output. + * Before this method is called, both are set to {@link Blocks#air} as defaults. + */ public abstract void generate(int x, int y); } diff --git a/core/src/io/anuke/mindustry/net/Administration.java b/core/src/io/anuke/mindustry/net/Administration.java index 681de95177..81f729fd67 100644 --- a/core/src/io/anuke/mindustry/net/Administration.java +++ b/core/src/io/anuke/mindustry/net/Administration.java @@ -2,21 +2,19 @@ package io.anuke.mindustry.net; import io.anuke.annotations.Annotations.Serialize; import io.anuke.arc.Core; -import io.anuke.arc.collection.Array; -import io.anuke.arc.collection.ObjectMap; -import io.anuke.arc.collection.ObjectSet; +import io.anuke.arc.collection.*; import static io.anuke.mindustry.Vars.headless; public class Administration{ - /**All player info. Maps UUIDs to info. This persists throughout restarts.*/ + /** All player info. Maps UUIDs to info. This persists throughout restarts. */ private ObjectMap playerInfo = new ObjectMap<>(); private Array bannedIPs = new Array<>(); public Administration(){ Core.settings.defaults( - "strict", true + "strict", true ); load(); @@ -40,7 +38,7 @@ public class Administration{ Core.settings.save(); } - /**Call when a player joins to update their information here.*/ + /** Call when a player joins to update their information here. */ public void updatePlayerJoined(String id, String ip, String name){ PlayerInfo info = getCreateInfo(id); info.lastName = name; @@ -74,7 +72,7 @@ public class Administration{ return true; } - /**Bans a player by UUID; returns whether this player was already banned.*/ + /** Bans a player by UUID; returns whether this player was already banned. */ public boolean banPlayerID(String id){ if(playerInfo.containsKey(id) && playerInfo.get(id).banned) return false; @@ -201,13 +199,13 @@ public class Administration{ return info.admin && usid.equals(info.adminUsid); } - /**Finds player info by IP, UUID and name.*/ + /** Finds player info by IP, UUID and name. */ public ObjectSet findByName(String name){ ObjectSet result = new ObjectSet<>(); for(PlayerInfo info : playerInfo.values()){ if(info.lastName.toLowerCase().equals(name.toLowerCase()) || (info.names.contains(name, false)) - || info.ips.contains(name, false) || info.id.equals(name)){ + || info.ips.contains(name, false) || info.id.equals(name)){ result.add(info); } } diff --git a/core/src/io/anuke/mindustry/net/Net.java b/core/src/io/anuke/mindustry/net/Net.java index 8c2b04cb6a..92448d9c90 100644 --- a/core/src/io/anuke/mindustry/net/Net.java +++ b/core/src/io/anuke/mindustry/net/Net.java @@ -1,12 +1,8 @@ package io.anuke.mindustry.net; import io.anuke.arc.Core; -import io.anuke.arc.Net.HttpRequest; -import io.anuke.arc.Net.HttpResponse; -import io.anuke.arc.Net.HttpResponseListener; -import io.anuke.arc.collection.Array; -import io.anuke.arc.collection.IntMap; -import io.anuke.arc.collection.ObjectMap; +import io.anuke.arc.Net.*; +import io.anuke.arc.collection.*; import io.anuke.arc.function.BiConsumer; import io.anuke.arc.function.Consumer; import io.anuke.arc.net.HttpRequestBuilder; @@ -15,9 +11,7 @@ import io.anuke.arc.util.Time; import io.anuke.arc.util.pooling.Pools; import io.anuke.mindustry.core.Platform; import io.anuke.mindustry.gen.Call; -import io.anuke.mindustry.net.Packets.KickReason; -import io.anuke.mindustry.net.Packets.StreamBegin; -import io.anuke.mindustry.net.Packets.StreamChunk; +import io.anuke.mindustry.net.Packets.*; import io.anuke.mindustry.net.Streamable.StreamBuilder; import java.io.IOException; @@ -47,7 +41,7 @@ public class Net{ return serverProvider != null; } - /**Display a network error. Call on the graphics thread.*/ + /** Display a network error. Call on the graphics thread. */ public static void showError(Throwable e){ if(!headless){ @@ -170,7 +164,7 @@ public class Net{ * Returns a list of all connections IDs. */ public static Array getConnections(){ - return (Array) serverProvider.getConnections(); + return (Array)serverProvider.getConnections(); } /** @@ -237,7 +231,7 @@ public class Net{ * Registers a server listener for when an object is recieved. */ public static void handleServer(Class type, BiConsumer listener){ - serverListeners.put(type, (BiConsumer) listener); + serverListeners.put(type, (BiConsumer)listener); } /** @@ -246,10 +240,10 @@ public class Net{ public static void handleClientReceived(Object object){ if(object instanceof StreamBegin){ - StreamBegin b = (StreamBegin) object; + StreamBegin b = (StreamBegin)object; streams.put(b.id, new StreamBuilder(b)); }else if(object instanceof StreamChunk){ - StreamChunk c = (StreamChunk) object; + StreamChunk c = (StreamChunk)object; StreamBuilder builder = streams.get(c.id); if(builder == null){ throw new RuntimeException("Recieved stream chunk without a StreamBegin beforehand!"); @@ -261,11 +255,11 @@ public class Net{ } }else if(clientListeners.get(object.getClass()) != null){ - if(clientLoaded || ((object instanceof Packet) && ((Packet) object).isImportant())){ + if(clientLoaded || ((object instanceof Packet) && ((Packet)object).isImportant())){ if(clientListeners.get(object.getClass()) != null) clientListeners.get(object.getClass()).accept(object); Pools.free(object); - }else if(!((object instanceof Packet) && ((Packet) object).isUnimportant())){ + }else if(!((object instanceof Packet) && ((Packet)object).isUnimportant())){ packetQueue.add(object); }else{ Pools.free(object); @@ -369,24 +363,24 @@ public class Net{ tcp, udp } - /**Client implementation.*/ + /** Client implementation. */ public interface ClientProvider{ - /**Connect to a server.*/ + /** Connect to a server. */ void connect(String ip, int port, Runnable success) throws IOException; - /**Send an object to the server.*/ + /** Send an object to the server. */ void send(Object object, SendMode mode); - /**Update the ping. Should be done every second or so.*/ + /** Update the ping. Should be done every second or so. */ void updatePing(); - /**Get ping in milliseconds. Will only be valid after a call to updatePing.*/ + /** Get ping in milliseconds. Will only be valid after a call to updatePing. */ int getPing(); - /**Disconnect from the server.*/ + /** Disconnect from the server. */ void disconnect(); - /**Decompress an input snapshot byte array.*/ + /** Decompress an input snapshot byte array. */ byte[] decompressSnapshot(byte[] input, int size); /** @@ -396,43 +390,43 @@ public class Net{ */ void discover(Consumer callback, Runnable done); - /**Ping a host. If an error occured, failed() should be called with the exception.*/ + /** Ping a host. If an error occured, failed() should be called with the exception. */ void pingHost(String address, int port, Consumer valid, Consumer failed); - /**Close all connections.*/ + /** Close all connections. */ void dispose(); } - /**Server implementation.*/ + /** Server implementation. */ public interface ServerProvider{ - /**Host a server at specified port.*/ + /** Host a server at specified port. */ void host(int port) throws IOException; - /**Sends a large stream of data to a specific client.*/ + /** Sends a large stream of data to a specific client. */ void sendStream(int id, Streamable stream); - /**Send an object to everyone connected.*/ + /** Send an object to everyone connected. */ void send(Object object, SendMode mode); - /**Send an object to a specific client ID.*/ + /** Send an object to a specific client ID. */ void sendTo(int id, Object object, SendMode mode); - /**Send an object to everyone except a client ID.*/ + /** Send an object to everyone except a client ID. */ void sendExcept(int id, Object object, SendMode mode); - /**Close the server connection.*/ + /** Close the server connection. */ void close(); - /**Compress an input snapshot byte array.*/ + /** Compress an input snapshot byte array. */ byte[] compressSnapshot(byte[] input); - /**Return all connected users.*/ + /** Return all connected users. */ Array getConnections(); - /**Returns a connection by ID.*/ + /** Returns a connection by ID. */ NetConnection getByID(int id); - /**Close all connections.*/ + /** Close all connections. */ void dispose(); } } diff --git a/core/src/io/anuke/mindustry/net/NetConnection.java b/core/src/io/anuke/mindustry/net/NetConnection.java index d016c34442..2bb53fb9f7 100644 --- a/core/src/io/anuke/mindustry/net/NetConnection.java +++ b/core/src/io/anuke/mindustry/net/NetConnection.java @@ -9,9 +9,9 @@ public abstract class NetConnection{ public boolean modclient; public boolean mobile; - /**ID of last recieved client snapshot.*/ + /** ID of last recieved client snapshot. */ public int lastRecievedClientSnapshot = -1; - /**Timestamp of last recieved snapshot.*/ + /** Timestamp of last recieved snapshot. */ public long lastRecievedClientTime; public boolean hasConnected = false; diff --git a/core/src/io/anuke/mindustry/net/NetworkIO.java b/core/src/io/anuke/mindustry/net/NetworkIO.java index d1730ea593..19ca66cf53 100644 --- a/core/src/io/anuke/mindustry/net/NetworkIO.java +++ b/core/src/io/anuke/mindustry/net/NetworkIO.java @@ -6,10 +6,8 @@ import io.anuke.arc.collection.ObjectMap.Entry; import io.anuke.arc.util.Time; import io.anuke.mindustry.entities.Entities; import io.anuke.mindustry.entities.type.Player; -import io.anuke.mindustry.game.Team; -import io.anuke.mindustry.game.Teams; +import io.anuke.mindustry.game.*; import io.anuke.mindustry.game.Teams.TeamData; -import io.anuke.mindustry.game.Version; import io.anuke.mindustry.gen.Serialization; import io.anuke.mindustry.io.SaveIO; import io.anuke.mindustry.maps.Map; @@ -146,10 +144,10 @@ public class NetworkIO{ ByteBuffer buffer = ByteBuffer.allocate(128); - buffer.put((byte) host.getBytes(charset).length); + buffer.put((byte)host.getBytes(charset).length); buffer.put(host.getBytes(charset)); - buffer.put((byte) map.getBytes(charset).length); + buffer.put((byte)map.getBytes(charset).length); buffer.put(map.getBytes(charset)); buffer.putInt(playerGroup.size()); diff --git a/core/src/io/anuke/mindustry/net/Packets.java b/core/src/io/anuke/mindustry/net/Packets.java index 381df947c5..75d218cc11 100644 --- a/core/src/io/anuke/mindustry/net/Packets.java +++ b/core/src/io/anuke/mindustry/net/Packets.java @@ -76,7 +76,7 @@ public class Packets{ TypeIO.writeString(buffer, versionType); TypeIO.writeString(buffer, name); TypeIO.writeString(buffer, usid); - buffer.put(mobile ? (byte) 1 : 0); + buffer.put(mobile ? (byte)1 : 0); buffer.putInt(color); buffer.put(Base64Coder.decode(uuid)); } @@ -115,7 +115,7 @@ public class Packets{ public void write(ByteBuffer buffer){ buffer.put(type); buffer.put(priority); - buffer.putShort((short) writeLength); + buffer.putShort((short)writeLength); writeBuffer.position(0); for(int i = 0; i < writeLength; i++){ @@ -139,7 +139,7 @@ public class Packets{ } } - /**Marks the beginning of a stream.*/ + /** Marks the beginning of a stream. */ public static class StreamBegin implements Packet{ private static int lastid; @@ -169,7 +169,7 @@ public class Packets{ @Override public void write(ByteBuffer buffer){ buffer.putInt(id); - buffer.putShort((short) data.length); + buffer.putShort((short)data.length); buffer.put(data); } diff --git a/core/src/io/anuke/mindustry/net/Registrator.java b/core/src/io/anuke/mindustry/net/Registrator.java index 6430a686a9..cfbcffd163 100644 --- a/core/src/io/anuke/mindustry/net/Registrator.java +++ b/core/src/io/anuke/mindustry/net/Registrator.java @@ -6,11 +6,11 @@ import io.anuke.mindustry.net.Packets.*; public class Registrator{ private static ClassEntry[] classes = { - new ClassEntry(StreamBegin.class, StreamBegin::new), - new ClassEntry(StreamChunk.class, StreamChunk::new), - new ClassEntry(WorldStream.class, WorldStream::new), - new ClassEntry(ConnectPacket.class, ConnectPacket::new), - new ClassEntry(InvokePacket.class, InvokePacket::new) + new ClassEntry(StreamBegin.class, StreamBegin::new), + new ClassEntry(StreamChunk.class, StreamChunk::new), + new ClassEntry(WorldStream.class, WorldStream::new), + new ClassEntry(ConnectPacket.class, ConnectPacket::new), + new ClassEntry(InvokePacket.class, InvokePacket::new) }; private static ObjectIntMap ids = new ObjectIntMap<>(); @@ -26,7 +26,7 @@ public class Registrator{ } public static byte getID(Class type){ - return (byte) ids.get(type, -1); + return (byte)ids.get(type, -1); } public static ClassEntry[] getClasses(){ diff --git a/core/src/io/anuke/mindustry/net/Streamable.java b/core/src/io/anuke/mindustry/net/Streamable.java index 7ad7910149..9f2c3c0fbc 100644 --- a/core/src/io/anuke/mindustry/net/Streamable.java +++ b/core/src/io/anuke/mindustry/net/Streamable.java @@ -2,9 +2,7 @@ package io.anuke.mindustry.net; import io.anuke.mindustry.net.Packets.StreamBegin; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; +import java.io.*; public class Streamable implements Packet{ public transient ByteArrayInputStream stream; @@ -36,7 +34,7 @@ public class Streamable implements Packet{ } public Streamable build(){ - Streamable s = (Streamable) Registrator.getByID(type).constructor.get(); + Streamable s = (Streamable)Registrator.getByID(type).constructor.get(); s.stream = new ByteArrayInputStream(stream.toByteArray()); return s; } diff --git a/core/src/io/anuke/mindustry/type/Category.java b/core/src/io/anuke/mindustry/type/Category.java index 6e5f7a621a..a90bad9c64 100644 --- a/core/src/io/anuke/mindustry/type/Category.java +++ b/core/src/io/anuke/mindustry/type/Category.java @@ -1,24 +1,24 @@ package io.anuke.mindustry.type; public enum Category{ - /**Offensive turrets.*/ + /** Offensive turrets. */ turret, - /**Blocks that produce raw resources, such as drills.*/ + /** Blocks that produce raw resources, such as drills. */ production, - /**Blocks that move items around.*/ + /** Blocks that move items around. */ distribution, - /**Blocks that move liquids around.*/ + /** Blocks that move liquids around. */ liquid, - /**Blocks that generate or transport power.*/ + /** Blocks that generate or transport power. */ power, - /**Walls and other defensive structures.*/ + /** Walls and other defensive structures. */ defense, - /**Blocks that craft things.*/ + /** Blocks that craft things. */ crafting, - /**Blocks that create units.*/ + /** Blocks that create units. */ units, - /**Things that upgrade the player such as mech pads.*/ + /** Things that upgrade the player such as mech pads. */ upgrade, - /**Things for storage or passive effects.*/ + /** Things for storage or passive effects. */ effect } diff --git a/core/src/io/anuke/mindustry/type/ContentType.java b/core/src/io/anuke/mindustry/type/ContentType.java index c20ff0f310..125ccc8221 100644 --- a/core/src/io/anuke/mindustry/type/ContentType.java +++ b/core/src/io/anuke/mindustry/type/ContentType.java @@ -1,7 +1,7 @@ package io.anuke.mindustry.type; -/**Do not rearrange, ever!*/ -public enum ContentType { +/** Do not rearrange, ever! */ +public enum ContentType{ item, block, mech, diff --git a/core/src/io/anuke/mindustry/type/Item.java b/core/src/io/anuke/mindustry/type/Item.java index d763b1ba66..0cea6c4007 100644 --- a/core/src/io/anuke/mindustry/type/Item.java +++ b/core/src/io/anuke/mindustry/type/Item.java @@ -16,22 +16,22 @@ public class Item extends UnlockableContent implements Comparable{ public final Color color; private TextureRegion[] regions; - /**type of the item; used for tabs and core acceptance. default value is {@link ItemType#resource}.*/ + /** type of the item; used for tabs and core acceptance. default value is {@link ItemType#resource}. */ public ItemType type = ItemType.resource; - /**how explosive this item is.*/ + /** how explosive this item is. */ public float explosiveness = 0f; - /**flammability above 0.3 makes this eleigible for item burners.*/ + /** flammability above 0.3 makes this eleigible for item burners. */ public float flammability = 0f; - /**how radioactive this item is. 0=none, 1=chernobyl ground zero*/ + /** how radioactive this item is. 0=none, 1=chernobyl ground zero */ public float radioactivity; - /**drill hardness of the item*/ + /** drill hardness of the item */ public int hardness = 0; /** * base material cost of this item, used for calculating place times * 1 cost = 1 tick added to build time */ public float cost = 3f; - /**If true, item is always unlocked.*/ + /** If true, item is always unlocked. */ public boolean alwaysUnlocked = false; public Item(String name, Color color){ @@ -53,7 +53,7 @@ public class Item extends UnlockableContent implements Comparable{ } @Override - public boolean alwaysUnlocked() { + public boolean alwaysUnlocked(){ return alwaysUnlocked; } @@ -88,10 +88,10 @@ public class Item extends UnlockableContent implements Comparable{ } public enum Icon{ - small(8*2), - medium(8*3), - large(8*4), - xlarge(8*5); + small(8 * 2), + medium(8 * 3), + large(8 * 4), + xlarge(8 * 5); public final int size; @@ -100,7 +100,7 @@ public class Item extends UnlockableContent implements Comparable{ } } - /**Allocates a new array containing all items the generate ores.*/ + /** Allocates a new array containing all items the generate ores. */ public static Array getAllOres(){ return content.blocks().select(b -> b instanceof OreBlock).map(b -> ((Floor)b).itemDrop); } diff --git a/core/src/io/anuke/mindustry/type/ItemStack.java b/core/src/io/anuke/mindustry/type/ItemStack.java index 47cfc87868..b99cf26069 100644 --- a/core/src/io/anuke/mindustry/type/ItemStack.java +++ b/core/src/io/anuke/mindustry/type/ItemStack.java @@ -16,16 +16,16 @@ public class ItemStack implements Comparable{ } public static ItemStack[] with(Object... items){ - ItemStack[] stacks = new ItemStack[items.length/2]; - for(int i = 0; i < items.length; i+= 2){ - stacks[i/2] = new ItemStack((Item)items[i], (Integer)items[i + 1]); + ItemStack[] stacks = new ItemStack[items.length / 2]; + for(int i = 0; i < items.length; i += 2){ + stacks[i / 2] = new ItemStack((Item)items[i], (Integer)items[i + 1]); } return stacks; } public static Array list(Object... items){ - Array stacks = new Array<>(items.length/2); - for(int i = 0; i < items.length; i+= 2){ + Array stacks = new Array<>(items.length / 2); + for(int i = 0; i < items.length; i += 2){ stacks.add(new ItemStack((Item)items[i], (Integer)items[i + 1])); } return stacks; diff --git a/core/src/io/anuke/mindustry/type/ItemType.java b/core/src/io/anuke/mindustry/type/ItemType.java index 320e0d0fce..40459f070e 100644 --- a/core/src/io/anuke/mindustry/type/ItemType.java +++ b/core/src/io/anuke/mindustry/type/ItemType.java @@ -1,8 +1,8 @@ package io.anuke.mindustry.type; public enum ItemType{ - /**Not used for anything besides crafting inside blocks.*/ + /** Not used for anything besides crafting inside blocks. */ resource, - /**Can be used for constructing blocks. Only materials are accepted into the core.*/ + /** Can be used for constructing blocks. Only materials are accepted into the core. */ material } diff --git a/core/src/io/anuke/mindustry/type/Liquid.java b/core/src/io/anuke/mindustry/type/Liquid.java index 2f04dfa787..bb3a0f363a 100644 --- a/core/src/io/anuke/mindustry/type/Liquid.java +++ b/core/src/io/anuke/mindustry/type/Liquid.java @@ -11,21 +11,21 @@ import io.anuke.mindustry.ui.ContentDisplay; public class Liquid extends UnlockableContent{ public final Color color; - /**0-1, 0 is completely inflammable, anything above that may catch fire when exposed to heat, 0.5+ is very flammable.*/ + /** 0-1, 0 is completely inflammable, anything above that may catch fire when exposed to heat, 0.5+ is very flammable. */ public float flammability; - /**temperature: 0.5 is 'room' temperature, 0 is very cold, 1 is molten hot*/ + /** temperature: 0.5 is 'room' temperature, 0 is very cold, 1 is molten hot */ public float temperature = 0.5f; - /**how much heat this liquid can store. 0.4=water (decent), anything lower is probably less dense and bad at cooling.*/ + /** how much heat this liquid can store. 0.4=water (decent), anything lower is probably less dense and bad at cooling. */ public float heatCapacity = 0.5f; - /**how thick this liquid is. 0.5=water (relatively viscous), 1 would be something like tar (very slow)*/ + /** how thick this liquid is. 0.5=water (relatively viscous), 1 would be something like tar (very slow) */ public float viscosity = 0.5f; - /**how prone to exploding this liquid is, when heated. 0 = nothing, 1 = nuke*/ + /** how prone to exploding this liquid is, when heated. 0 = nothing, 1 = nuke */ public float explosiveness; - /**the burning color of this liquid*/ + /** the burning color of this liquid */ public Color flameColor = Color.valueOf("ffb763"); - /**The associated status effect.*/ + /** The associated status effect. */ public StatusEffect effect = StatusEffects.none; - /**Displayed icon. TODO fix it by removing autogen, draw icons manually*/ + /** Displayed icon. TODO fix it by removing autogen, draw icons manually */ public TextureRegion iconRegion; public Liquid(String name, Color color){ diff --git a/core/src/io/anuke/mindustry/type/Loadout.java b/core/src/io/anuke/mindustry/type/Loadout.java index 26303254b2..66f7186f41 100644 --- a/core/src/io/anuke/mindustry/type/Loadout.java +++ b/core/src/io/anuke/mindustry/type/Loadout.java @@ -4,9 +4,7 @@ import io.anuke.arc.collection.Array; import io.anuke.arc.collection.IntMap; import io.anuke.mindustry.content.Blocks; import io.anuke.mindustry.game.Content; -import io.anuke.mindustry.world.Block; -import io.anuke.mindustry.world.Pos; -import io.anuke.mindustry.world.Tile; +import io.anuke.mindustry.world.*; import io.anuke.mindustry.world.blocks.storage.CoreBlock; import static io.anuke.mindustry.Vars.defaultTeam; @@ -34,7 +32,7 @@ public class Loadout extends Content{ int coreX = -1, coreY = -1; outer: - for(int y = 0; y < layout.length; y ++){ + for(int y = 0; y < layout.length; y++){ for(int x = 0; x < layout[0].length(); x++){ char c = layout[y].charAt(x); if(entries.get(c) != null && entries.get(c).block instanceof CoreBlock){ @@ -48,7 +46,7 @@ public class Loadout extends Content{ if(coreX == -1) throw new IllegalArgumentException("Schematic does not have a core."); - for(int y = 0; y < layout.length; y ++){ + for(int y = 0; y < layout.length; y++){ for(int x = 0; x < layout[0].length(); x++){ char c = layout[y].charAt(x); if(entries.containsKey(c)){ diff --git a/core/src/io/anuke/mindustry/type/Mech.java b/core/src/io/anuke/mindustry/type/Mech.java index aa56ac67fc..1d9a7cb520 100644 --- a/core/src/io/anuke/mindustry/type/Mech.java +++ b/core/src/io/anuke/mindustry/type/Mech.java @@ -44,9 +44,11 @@ public class Mech extends UnlockableContent{ return Core.bundle.get("mech." + name + ".name"); } - public void updateAlt(Player player){} + public void updateAlt(Player player){ + } - public void draw(Player player){} + public void draw(Player player){ + } public float getExtraArmor(Player player){ return 0f; @@ -56,13 +58,16 @@ public class Mech extends UnlockableContent{ return 0f; } - public float getRotationAlpha(Player player){return 1f;} + public float getRotationAlpha(Player player){ + return 1f; + } public boolean canShoot(Player player){ return true; } - public void onLand(Player player){} + public void onLand(Player player){ + } @Override public void displayInfo(Table table){ diff --git a/core/src/io/anuke/mindustry/type/StatusEffect.java b/core/src/io/anuke/mindustry/type/StatusEffect.java index 3852f0a38e..785bcab946 100644 --- a/core/src/io/anuke/mindustry/type/StatusEffect.java +++ b/core/src/io/anuke/mindustry/type/StatusEffect.java @@ -2,15 +2,15 @@ package io.anuke.mindustry.type; import io.anuke.arc.collection.Array; import io.anuke.arc.collection.ObjectMap; -import io.anuke.mindustry.entities.Effects; -import io.anuke.mindustry.entities.Effects.Effect; import io.anuke.arc.function.Supplier; import io.anuke.arc.graphics.Color; import io.anuke.arc.math.Mathf; import io.anuke.arc.util.Time; import io.anuke.mindustry.content.Fx; -import io.anuke.mindustry.entities.units.Statuses.StatusEntry; +import io.anuke.mindustry.entities.Effects; +import io.anuke.mindustry.entities.Effects.Effect; import io.anuke.mindustry.entities.type.Unit; +import io.anuke.mindustry.entities.units.Statuses.StatusEntry; import io.anuke.mindustry.game.Content; public class StatusEffect extends Content{ @@ -19,29 +19,31 @@ public class StatusEffect extends Content{ public float speedMultiplier = 1f; //speed public Color color = Color.WHITE.cpy(); //tint color - /**Transition handler map.*/ + /** Transition handler map. */ private ObjectMap transitions = new ObjectMap<>(); - /**Transition initializer array. Since provided effects are only available after init(), this handles putting things - * in the transitions map.*/ + /** + * Transition initializer array. Since provided effects are only available after init(), this handles putting things + * in the transitions map. + */ private Array transInit = new Array<>(); - /**Damage per frame.*/ + /** Damage per frame. */ protected float damage; - /**Effect that happens randomly on top of the affected unit.*/ + /** Effect that happens randomly on top of the affected unit. */ protected Effect effect = Fx.none; @SuppressWarnings("unchecked") @Override public void init(){ for(Object[] pair : transInit){ - Supplier sup = (Supplier) pair[0]; - TransitionHandler handler = (TransitionHandler) pair[1]; + Supplier sup = (Supplier)pair[0]; + TransitionHandler handler = (TransitionHandler)pair[1]; transitions.put(sup.get(), handler); } transInit.clear(); } - /**Runs every tick on the affected unit while time is greater than 0.*/ + /** Runs every tick on the affected unit while time is greater than 0. */ public void update(Unit unit, float time){ if(damage > 0){ unit.damagePeriodic(damage); @@ -78,7 +80,6 @@ public class StatusEffect extends Content{ /** * Called when transitioning between two status effects. - * * @param to The state to transition to * @param time The current status effect time * @param newTime The time that the new status effect will last diff --git a/core/src/io/anuke/mindustry/type/Weapon.java b/core/src/io/anuke/mindustry/type/Weapon.java index f57b6f0ec4..fceb8d22fc 100644 --- a/core/src/io/anuke/mindustry/type/Weapon.java +++ b/core/src/io/anuke/mindustry/type/Weapon.java @@ -22,38 +22,38 @@ import io.anuke.mindustry.net.Net; public class Weapon{ public final String name; - /**minimum cursor distance from player, fixes 'cross-eyed' shooting.*/ + /** minimum cursor distance from player, fixes 'cross-eyed' shooting. */ protected static float minPlayerDist = 20f; protected static int sequenceNum = 0; - /**bullet shot*/ + /** bullet shot */ public BulletType bullet; - /**shell ejection effect*/ + /** shell ejection effect */ public Effect ejectEffect = Fx.none; - /**weapon reload in frames*/ + /** weapon reload in frames */ public float reload; - /**amount of shots per fire*/ + /** amount of shots per fire */ public int shots = 1; - /**spacing in degrees between multiple shots, if applicable*/ + /** spacing in degrees between multiple shots, if applicable */ public float spacing = 12f; - /**inaccuracy of degrees of each shot*/ + /** inaccuracy of degrees of each shot */ public float inaccuracy = 0f; - /**intensity and duration of each shot's screen shake*/ + /** intensity and duration of each shot's screen shake */ public float shake = 0f; - /**visual weapon knockback.*/ + /** visual weapon knockback. */ public float recoil = 1.5f; - /**shoot barrel y offset*/ + /** shoot barrel y offset */ public float length = 3f; - /**shoot barrel x offset.*/ + /** shoot barrel x offset. */ public float width = 4f; - /**fraction of velocity that is random*/ + /** fraction of velocity that is random */ public float velocityRnd = 0f; - /**whether to shoot the weapons in different arms one after another, rather than all at once*/ + /** whether to shoot the weapons in different arms one after another, rather than all at once */ public boolean roundrobin = false; - /**randomization of shot length*/ + /** randomization of shot length */ public float lengthRand = 0f; - /**delay in ticks between shots*/ + /** delay in ticks between shots */ public float shotDelay = 0; - /**whether shooter rotation is ignored when shooting.*/ + /** whether shooter rotation is ignored when shooting. */ public boolean ignoreRotation = false; public TextureRegion region; @@ -95,7 +95,7 @@ public class Weapon{ if(weapon.shotDelay > 0.01f){ Angles.shotgun(weapon.shots, weapon.spacing, rotation, f -> { Time.run(sequenceNum * weapon.shotDelay, () -> weapon.bullet(shooter, x, y, f + Mathf.range(weapon.inaccuracy))); - sequenceNum ++; + sequenceNum++; }); }else{ Angles.shotgun(weapon.shots, weapon.spacing, rotation, f -> weapon.bullet(shooter, x, y, f + Mathf.range(weapon.inaccuracy))); @@ -156,7 +156,7 @@ public class Weapon{ shootDirect(p, x, y, angle, left); }else{ if(p instanceof Player){ //players need special weapon handling logic - Call.onPlayerShootWeapon((Player) p, x, y, angle, left); + Call.onPlayerShootWeapon((Player)p, x, y, angle, left); }else{ Call.onGenericShootWeapon(p, x, y, angle, left); } @@ -168,6 +168,6 @@ public class Weapon{ Tmp.v1.trns(angle, 3f); Bullet.create(bullet, - owner, owner.getTeam(), x + Tmp.v1.x, y + Tmp.v1.y, angle, (1f - velocityRnd) + Mathf.random(velocityRnd)); + owner, owner.getTeam(), x + Tmp.v1.x, y + Tmp.v1.y, angle, (1f - velocityRnd) + Mathf.random(velocityRnd)); } } diff --git a/core/src/io/anuke/mindustry/type/Zone.java b/core/src/io/anuke/mindustry/type/Zone.java index 2809039ac7..72f1c4008b 100644 --- a/core/src/io/anuke/mindustry/type/Zone.java +++ b/core/src/io/anuke/mindustry/type/Zone.java @@ -115,7 +115,7 @@ public class Zone extends UnlockableContent{ data.modified(); } - /**Whether this zone has met its condition; if true, the player can leave.*/ + /** Whether this zone has met its condition; if true, the player can leave. */ public boolean metCondition(){ return state.wave >= conditionWave; } @@ -147,14 +147,17 @@ public class Zone extends UnlockableContent{ //neither of these are implemented, as zones are not displayed in a normal fashion... yet @Override - public void displayInfo(Table table){} + public void displayInfo(Table table){ + } @Override - public TextureRegion getContentIcon(){ return null; } + public TextureRegion getContentIcon(){ + return null; + } @Override public String localizedName(){ - return Core.bundle.get("zone."+name+".name"); + return Core.bundle.get("zone." + name + ".name"); } @Override @@ -172,9 +175,9 @@ public class Zone extends UnlockableContent{ } public static ZoneRequirement[] with(Object... objects){ - ZoneRequirement[] out = new ZoneRequirement[objects.length/2]; - for(int i = 0; i < objects.length; i+= 2){ - out[i/2] = new ZoneRequirement((Zone)objects[i], (Integer)objects[i + 1]); + ZoneRequirement[] out = new ZoneRequirement[objects.length / 2]; + for(int i = 0; i < objects.length; i += 2){ + out[i / 2] = new ZoneRequirement((Zone)objects[i], (Integer)objects[i + 1]); } return out; } diff --git a/core/src/io/anuke/mindustry/ui/Bar.java b/core/src/io/anuke/mindustry/ui/Bar.java index cbd2b7b0f9..4e9a87659d 100644 --- a/core/src/io/anuke/mindustry/ui/Bar.java +++ b/core/src/io/anuke/mindustry/ui/Bar.java @@ -4,10 +4,7 @@ import io.anuke.arc.Core; import io.anuke.arc.function.FloatProvider; import io.anuke.arc.function.Supplier; import io.anuke.arc.graphics.Color; -import io.anuke.arc.graphics.g2d.BitmapFont; -import io.anuke.arc.graphics.g2d.Draw; -import io.anuke.arc.graphics.g2d.GlyphLayout; -import io.anuke.arc.graphics.g2d.ScissorStack; +import io.anuke.arc.graphics.g2d.*; import io.anuke.arc.math.Mathf; import io.anuke.arc.math.geom.Rectangle; import io.anuke.arc.scene.Element; @@ -79,7 +76,7 @@ public class Bar extends Element{ lay.setText(font, name); font.setColor(Color.WHITE); - font.draw(name, x + width/2f - lay.width/2f, y + height/2f + lay.height/2f + 1); + font.draw(name, x + width / 2f - lay.width / 2f, y + height / 2f + lay.height / 2f + 1); Pools.free(lay); } diff --git a/core/src/io/anuke/mindustry/ui/BorderImage.java b/core/src/io/anuke/mindustry/ui/BorderImage.java index 0db23da2ba..0e14960df0 100644 --- a/core/src/io/anuke/mindustry/ui/BorderImage.java +++ b/core/src/io/anuke/mindustry/ui/BorderImage.java @@ -1,12 +1,10 @@ package io.anuke.mindustry.ui; import io.anuke.arc.graphics.Texture; -import io.anuke.arc.graphics.g2d.TextureRegion; -import io.anuke.mindustry.graphics.Pal; -import io.anuke.arc.graphics.g2d.Draw; -import io.anuke.arc.graphics.g2d.Lines; +import io.anuke.arc.graphics.g2d.*; import io.anuke.arc.scene.ui.Image; import io.anuke.arc.scene.ui.layout.Unit; +import io.anuke.mindustry.graphics.Pal; public class BorderImage extends Image{ private float thickness = 3f; diff --git a/core/src/io/anuke/mindustry/ui/ContentDisplay.java b/core/src/io/anuke/mindustry/ui/ContentDisplay.java index 26656fa488..f00506202d 100644 --- a/core/src/io/anuke/mindustry/ui/ContentDisplay.java +++ b/core/src/io/anuke/mindustry/ui/ContentDisplay.java @@ -6,17 +6,11 @@ import io.anuke.arc.collection.OrderedMap; import io.anuke.arc.graphics.Color; import io.anuke.arc.scene.ui.layout.Table; import io.anuke.arc.util.Strings; -import io.anuke.mindustry.type.UnitType; import io.anuke.mindustry.graphics.Pal; -import io.anuke.mindustry.type.Item; -import io.anuke.mindustry.type.Liquid; -import io.anuke.mindustry.type.Mech; +import io.anuke.mindustry.type.*; import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Block.Icon; -import io.anuke.mindustry.world.meta.BlockStat; -import io.anuke.mindustry.world.meta.BlockStats; -import io.anuke.mindustry.world.meta.StatCategory; -import io.anuke.mindustry.world.meta.StatValue; +import io.anuke.mindustry.world.meta.*; public class ContentDisplay{ @@ -93,11 +87,11 @@ public class ContentDisplay{ table.left().defaults().fillX(); - table.add(Core.bundle.format("item.explosiveness", (int) (item.explosiveness * 100))); + table.add(Core.bundle.format("item.explosiveness", (int)(item.explosiveness * 100))); table.row(); - table.add(Core.bundle.format("item.flammability", (int) (item.flammability * 100))); + table.add(Core.bundle.format("item.flammability", (int)(item.flammability * 100))); table.row(); - table.add(Core.bundle.format("item.radioactivity", (int) (item.radioactivity * 100))); + table.add(Core.bundle.format("item.radioactivity", (int)(item.radioactivity * 100))); table.row(); } @@ -124,15 +118,15 @@ public class ContentDisplay{ table.left().defaults().fillX(); - table.add(Core.bundle.format("item.explosiveness", (int) (liquid.explosiveness * 100))); + table.add(Core.bundle.format("item.explosiveness", (int)(liquid.explosiveness * 100))); table.row(); - table.add(Core.bundle.format("item.flammability", (int) (liquid.flammability * 100))); + table.add(Core.bundle.format("item.flammability", (int)(liquid.flammability * 100))); table.row(); - table.add(Core.bundle.format("liquid.heatcapacity", (int) (liquid.heatCapacity * 100))); + table.add(Core.bundle.format("liquid.heatcapacity", (int)(liquid.heatCapacity * 100))); table.row(); - table.add(Core.bundle.format("liquid.temperature", (int) (liquid.temperature * 100))); + table.add(Core.bundle.format("liquid.temperature", (int)(liquid.temperature * 100))); table.row(); - table.add(Core.bundle.format("liquid.viscosity", (int) (liquid.viscosity * 100))); + table.add(Core.bundle.format("liquid.viscosity", (int)(liquid.viscosity * 100))); table.row(); } diff --git a/core/src/io/anuke/mindustry/ui/GridImage.java b/core/src/io/anuke/mindustry/ui/GridImage.java index fd164cc191..81916cba40 100644 --- a/core/src/io/anuke/mindustry/ui/GridImage.java +++ b/core/src/io/anuke/mindustry/ui/GridImage.java @@ -19,15 +19,15 @@ public class GridImage extends Element{ int minspace = 10; - int jumpx = (int) (Math.max(minspace, xspace) / xspace); - int jumpy = (int) (Math.max(minspace, yspace) / yspace); + int jumpx = (int)(Math.max(minspace, xspace) / xspace); + int jumpy = (int)(Math.max(minspace, yspace) / yspace); for(int x = 0; x <= imageWidth; x += jumpx){ - Fill.crect((int) (getX() + xspace * x - s), getY() - s, 2, getHeight() + (x == imageWidth ? 1 : 0)); + Fill.crect((int)(getX() + xspace * x - s), getY() - s, 2, getHeight() + (x == imageWidth ? 1 : 0)); } for(int y = 0; y <= imageHeight; y += jumpy){ - Fill.crect(getX() - s, (int) (getY() + y * yspace - s), getWidth(), 2); + Fill.crect(getX() - s, (int)(getY() + y * yspace - s), getWidth(), 2); } } diff --git a/core/src/io/anuke/mindustry/ui/ItemDisplay.java b/core/src/io/anuke/mindustry/ui/ItemDisplay.java index b8f755986b..1e7dd9fbbf 100644 --- a/core/src/io/anuke/mindustry/ui/ItemDisplay.java +++ b/core/src/io/anuke/mindustry/ui/ItemDisplay.java @@ -1,10 +1,10 @@ package io.anuke.mindustry.ui; +import io.anuke.arc.scene.ui.layout.Table; import io.anuke.mindustry.type.Item; import io.anuke.mindustry.type.ItemStack; -import io.anuke.arc.scene.ui.layout.Table; -/**An item image with text.*/ +/** An item image with text. */ public class ItemDisplay extends Table{ public ItemDisplay(Item item){ @@ -12,7 +12,7 @@ public class ItemDisplay extends Table{ } public ItemDisplay(Item item, int amount){ - add(new ItemImage(new ItemStack(item, amount))).size(8*4); + add(new ItemImage(new ItemStack(item, amount))).size(8 * 4); add(item.localizedName()).padLeft(4); } } diff --git a/core/src/io/anuke/mindustry/ui/ItemImage.java b/core/src/io/anuke/mindustry/ui/ItemImage.java index 6ac6e91ad3..6ef197b8d9 100644 --- a/core/src/io/anuke/mindustry/ui/ItemImage.java +++ b/core/src/io/anuke/mindustry/ui/ItemImage.java @@ -1,12 +1,12 @@ package io.anuke.mindustry.ui; -import io.anuke.arc.graphics.g2d.TextureRegion; -import io.anuke.mindustry.type.Item.Icon; -import io.anuke.mindustry.type.ItemStack; import io.anuke.arc.function.Supplier; +import io.anuke.arc.graphics.g2d.TextureRegion; import io.anuke.arc.scene.ui.Image; import io.anuke.arc.scene.ui.layout.Stack; import io.anuke.arc.scene.ui.layout.Table; +import io.anuke.mindustry.type.Item.Icon; +import io.anuke.mindustry.type.ItemStack; public class ItemImage extends Stack{ diff --git a/core/src/io/anuke/mindustry/ui/ItemsDisplay.java b/core/src/io/anuke/mindustry/ui/ItemsDisplay.java index c5816cd512..a4ca3d6d07 100644 --- a/core/src/io/anuke/mindustry/ui/ItemsDisplay.java +++ b/core/src/io/anuke/mindustry/ui/ItemsDisplay.java @@ -33,7 +33,7 @@ public class ItemsDisplay extends Table{ for(Item item : content.items()){ if(item.type == ItemType.material && data.isUnlocked(item)){ t.label(() -> format.format(items.get(item, 0))).left(); - t.addImage(item.icon(Icon.medium)).size(8*3).padLeft(4).padRight(4); + t.addImage(item.icon(Icon.medium)).size(8 * 3).padLeft(4).padRight(4); t.add(item.localizedName()).color(Color.LIGHT_GRAY).left(); t.row(); } diff --git a/core/src/io/anuke/mindustry/ui/Links.java b/core/src/io/anuke/mindustry/ui/Links.java index 5f47c61a5a..0348970890 100644 --- a/core/src/io/anuke/mindustry/ui/Links.java +++ b/core/src/io/anuke/mindustry/ui/Links.java @@ -8,13 +8,13 @@ public class Links{ private static void createLinks(){ links = new LinkEntry[]{ - new LinkEntry("discord", "https://discord.gg/mindustry", Color.valueOf("7289da")), - new LinkEntry("trello", "https://trello.com/b/aE2tcUwF", Color.valueOf("026aa7")), - new LinkEntry("wiki", "http://mindustry.wikia.com/wiki/Mindustry_Wiki", Color.valueOf("0f142f")), - new LinkEntry("itch.io", "https://anuke.itch.io/mindustry", Color.valueOf("fa5c5c")), - new LinkEntry("google-play", "https://play.google.com/store/apps/details?id=io.anuke.mindustry", Color.valueOf("689f38")), - new LinkEntry("github", "https://github.com/Anuken/Mindustry/", Color.valueOf("24292e")), - new LinkEntry("dev-builds", "https://jenkins.hellomouse.net/job/mindustry/", Color.valueOf("fafbfc")) + new LinkEntry("discord", "https://discord.gg/mindustry", Color.valueOf("7289da")), + new LinkEntry("trello", "https://trello.com/b/aE2tcUwF", Color.valueOf("026aa7")), + new LinkEntry("wiki", "http://mindustry.wikia.com/wiki/Mindustry_Wiki", Color.valueOf("0f142f")), + new LinkEntry("itch.io", "https://anuke.itch.io/mindustry", Color.valueOf("fa5c5c")), + new LinkEntry("google-play", "https://play.google.com/store/apps/details?id=io.anuke.mindustry", Color.valueOf("689f38")), + new LinkEntry("github", "https://github.com/Anuken/Mindustry/", Color.valueOf("24292e")), + new LinkEntry("dev-builds", "https://jenkins.hellomouse.net/job/mindustry/", Color.valueOf("fafbfc")) }; } diff --git a/core/src/io/anuke/mindustry/ui/LiquidDisplay.java b/core/src/io/anuke/mindustry/ui/LiquidDisplay.java index 3b18801085..efa010f207 100644 --- a/core/src/io/anuke/mindustry/ui/LiquidDisplay.java +++ b/core/src/io/anuke/mindustry/ui/LiquidDisplay.java @@ -8,7 +8,7 @@ import io.anuke.arc.util.Strings; import io.anuke.mindustry.type.Liquid; import io.anuke.mindustry.world.meta.StatUnit; -/**An ItemDisplay, but for liquids.*/ +/** An ItemDisplay, but for liquids. */ public class LiquidDisplay extends Table{ public LiquidDisplay(Liquid liquid, float amount, boolean perSecond){ @@ -20,7 +20,7 @@ public class LiquidDisplay extends Table{ t.add(Strings.autoFixed(amount, 1)); add(t); } - }}).size(8*4).padRight(3); + }}).size(8 * 4).padRight(3); if(perSecond){ add(StatUnit.perSecond.localized()).padLeft(2).padRight(5).color(Color.LIGHT_GRAY); diff --git a/core/src/io/anuke/mindustry/ui/MenuButton.java b/core/src/io/anuke/mindustry/ui/MenuButton.java index 9d5f34430e..80f577f4cf 100644 --- a/core/src/io/anuke/mindustry/ui/MenuButton.java +++ b/core/src/io/anuke/mindustry/ui/MenuButton.java @@ -1,8 +1,8 @@ package io.anuke.mindustry.ui; import io.anuke.arc.graphics.Color; -import io.anuke.arc.util.Align; import io.anuke.arc.scene.ui.TextButton; +import io.anuke.arc.util.Align; public class MenuButton extends TextButton{ diff --git a/core/src/io/anuke/mindustry/ui/Minimap.java b/core/src/io/anuke/mindustry/ui/Minimap.java index 9fb1417cd9..e39e128e3e 100644 --- a/core/src/io/anuke/mindustry/ui/Minimap.java +++ b/core/src/io/anuke/mindustry/ui/Minimap.java @@ -4,10 +4,7 @@ import io.anuke.arc.Core; import io.anuke.arc.graphics.g2d.Draw; import io.anuke.arc.input.KeyCode; import io.anuke.arc.scene.Element; -import io.anuke.arc.scene.event.ClickListener; -import io.anuke.arc.scene.event.InputEvent; -import io.anuke.arc.scene.event.InputListener; -import io.anuke.arc.scene.event.Touchable; +import io.anuke.arc.scene.event.*; import io.anuke.arc.scene.ui.layout.Container; import io.anuke.arc.scene.ui.layout.Unit; @@ -36,7 +33,7 @@ public class Minimap extends Container{ public void draw(){ if(renderer.minimap.getRegion() == null) return; - Draw.rect(renderer.minimap.getRegion(), x + width/2f, y + height/2f, width, height); + Draw.rect(renderer.minimap.getRegion(), x + width / 2f, y + height / 2f, width, height); if(renderer.minimap.getTexture() != null){ renderer.minimap.drawEntities(x, y, width, height); diff --git a/core/src/io/anuke/mindustry/ui/MobileButton.java b/core/src/io/anuke/mindustry/ui/MobileButton.java index 4d64eafe5c..102357e80c 100644 --- a/core/src/io/anuke/mindustry/ui/MobileButton.java +++ b/core/src/io/anuke/mindustry/ui/MobileButton.java @@ -1,7 +1,7 @@ package io.anuke.mindustry.ui; -import io.anuke.arc.util.Align; import io.anuke.arc.scene.ui.ImageButton; +import io.anuke.arc.util.Align; public class MobileButton extends ImageButton{ diff --git a/core/src/io/anuke/mindustry/ui/ReqImage.java b/core/src/io/anuke/mindustry/ui/ReqImage.java index 315ce91211..1b3da1c6a7 100644 --- a/core/src/io/anuke/mindustry/ui/ReqImage.java +++ b/core/src/io/anuke/mindustry/ui/ReqImage.java @@ -1,9 +1,7 @@ package io.anuke.mindustry.ui; import io.anuke.arc.function.BooleanProvider; -import io.anuke.arc.graphics.g2d.Draw; -import io.anuke.arc.graphics.g2d.Lines; -import io.anuke.arc.graphics.g2d.TextureRegion; +import io.anuke.arc.graphics.g2d.*; import io.anuke.arc.scene.Element; import io.anuke.arc.scene.ui.Image; import io.anuke.arc.scene.ui.layout.Stack; diff --git a/core/src/io/anuke/mindustry/ui/TreeLayout.java b/core/src/io/anuke/mindustry/ui/TreeLayout.java index 9f411d0d72..1a7395f928 100644 --- a/core/src/io/anuke/mindustry/ui/TreeLayout.java +++ b/core/src/io/anuke/mindustry/ui/TreeLayout.java @@ -1,5 +1,3 @@ - - package io.anuke.mindustry.ui; import io.anuke.arc.collection.FloatArray; @@ -108,7 +106,7 @@ public class TreeLayout{ } private TreeNode getAncestor(TreeNode node){ - return node.ancestor != null ? node.ancestor : node; + return node.ancestor != null ? node.ancestor : node; } private float getDistance(TreeNode v, TreeNode w){ @@ -211,7 +209,7 @@ public class TreeLayout{ float shift = 0; float change = 0; - for(int i = v.children.length - 1; i >= 0; i --){ + for(int i = v.children.length - 1; i >= 0; i--){ TreeNode w = v.children[i]; change = change + w.change; w.prelim += shift; @@ -236,7 +234,7 @@ public class TreeLayout{ previousChild = w; } executeShifts(v); - float midpoint = (v.children[0].prelim + v.children[v.children.length-1].prelim) / 2f; + float midpoint = (v.children[0].prelim + v.children[v.children.length - 1].prelim) / 2f; if(leftSibling != null){ v.prelim = leftSibling.prelim + getDistance(v, leftSibling); v.mode = v.prelim - midpoint; diff --git a/core/src/io/anuke/mindustry/ui/dialogs/AboutDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/AboutDialog.java index df97fac608..a4297444fa 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/AboutDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/AboutDialog.java @@ -1,21 +1,19 @@ package io.anuke.mindustry.ui.dialogs; import io.anuke.arc.Core; -import io.anuke.arc.graphics.Color; import io.anuke.arc.collection.Array; import io.anuke.arc.collection.ObjectSet; +import io.anuke.arc.graphics.Color; +import io.anuke.arc.scene.ui.ScrollPane; +import io.anuke.arc.scene.ui.layout.Cell; +import io.anuke.arc.scene.ui.layout.Table; +import io.anuke.arc.scene.utils.UIUtils; +import io.anuke.arc.util.*; import io.anuke.mindustry.graphics.Pal; import io.anuke.mindustry.io.Contributors; import io.anuke.mindustry.io.Contributors.Contributor; import io.anuke.mindustry.ui.Links; import io.anuke.mindustry.ui.Links.LinkEntry; -import io.anuke.arc.util.Time; -import io.anuke.arc.scene.ui.ScrollPane; -import io.anuke.arc.scene.ui.layout.Cell; -import io.anuke.arc.scene.ui.layout.Table; -import io.anuke.arc.scene.utils.UIUtils; -import io.anuke.arc.util.OS; -import io.anuke.arc.util.Strings; import static io.anuke.mindustry.Vars.ios; import static io.anuke.mindustry.Vars.ui; diff --git a/core/src/io/anuke/mindustry/ui/dialogs/AdminsDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/AdminsDialog.java index 70a1e5abb3..42fed50472 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/AdminsDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/AdminsDialog.java @@ -1,8 +1,8 @@ package io.anuke.mindustry.ui.dialogs; -import io.anuke.mindustry.net.Administration.PlayerInfo; import io.anuke.arc.scene.ui.ScrollPane; import io.anuke.arc.scene.ui.layout.Table; +import io.anuke.mindustry.net.Administration.PlayerInfo; import static io.anuke.mindustry.Vars.*; diff --git a/core/src/io/anuke/mindustry/ui/dialogs/BansDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/BansDialog.java index 741ce3c983..be60408759 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/BansDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/BansDialog.java @@ -1,10 +1,11 @@ package io.anuke.mindustry.ui.dialogs; -import io.anuke.mindustry.net.Administration.PlayerInfo; import io.anuke.arc.scene.ui.ScrollPane; import io.anuke.arc.scene.ui.layout.Table; +import io.anuke.mindustry.net.Administration.PlayerInfo; -import static io.anuke.mindustry.Vars.*; +import static io.anuke.mindustry.Vars.netServer; +import static io.anuke.mindustry.Vars.ui; public class BansDialog extends FloatingDialog{ diff --git a/core/src/io/anuke/mindustry/ui/dialogs/ContentInfoDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/ContentInfoDialog.java index 23f46045e8..f76bba6bbc 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/ContentInfoDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/ContentInfoDialog.java @@ -1,8 +1,8 @@ package io.anuke.mindustry.ui.dialogs; -import io.anuke.mindustry.game.UnlockableContent; import io.anuke.arc.scene.ui.ScrollPane; import io.anuke.arc.scene.ui.layout.Table; +import io.anuke.mindustry.game.UnlockableContent; public class ContentInfoDialog extends FloatingDialog{ diff --git a/core/src/io/anuke/mindustry/ui/dialogs/ControlsDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/ControlsDialog.java index 2a6db67316..aad28dc08e 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/ControlsDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/ControlsDialog.java @@ -16,7 +16,7 @@ public class ControlsDialog extends KeybindDialog{ title.setAlignment(Align.center); titleTable.row(); titleTable.add(new Image("white")) - .growX().height(3f).pad(4f).get().setColor(Pal.accent); + .growX().height(3f).pad(4f).get().setColor(Pal.accent); } @Override diff --git a/core/src/io/anuke/mindustry/ui/dialogs/CustomGameDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/CustomGameDialog.java index e76fa9d942..aa0c22c37e 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/CustomGameDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/CustomGameDialog.java @@ -4,10 +4,7 @@ import io.anuke.arc.Core; import io.anuke.arc.graphics.g2d.TextureRegion; import io.anuke.arc.math.Mathf; import io.anuke.arc.scene.event.Touchable; -import io.anuke.arc.scene.ui.ButtonGroup; -import io.anuke.arc.scene.ui.ImageButton; -import io.anuke.arc.scene.ui.ScrollPane; -import io.anuke.arc.scene.ui.TextButton; +import io.anuke.arc.scene.ui.*; import io.anuke.arc.scene.ui.layout.Table; import io.anuke.arc.util.Align; import io.anuke.arc.util.Scaling; @@ -60,7 +57,8 @@ public class CustomGameDialog extends FloatingDialog{ if(i++ % 2 == 1) modes.row(); } selmode.add(modes); - selmode.addButton("$mode.custom", "toggle", () -> {}) + selmode.addButton("$mode.custom", "toggle", () -> { + }) .update(b -> b.setChecked(lastPreset == null)).size(108f).group(group).get().tapped(() -> { lastPreset = null; dialog.show(); @@ -84,7 +82,8 @@ public class CustomGameDialog extends FloatingDialog{ state.wavetime = difficulty.waveTime; }).width(s); - sdif.addButton("", () -> {}) + sdif.addButton("", () -> { + }) .update(t -> { t.setText(difficulty.toString()); t.touchable(Touchable.disabled); diff --git a/core/src/io/anuke/mindustry/ui/dialogs/CustomRulesDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/CustomRulesDialog.java index 87c0c5d0c7..1db96e6471 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/CustomRulesDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/CustomRulesDialog.java @@ -47,9 +47,9 @@ public class CustomRulesDialog extends FloatingDialog{ number("$rules.unithealthmultiplier", f -> rules.unitHealthMultiplier = f, () -> rules.unitHealthMultiplier); number("$rules.playerdamagemultiplier", f -> rules.playerDamageMultiplier = f, () -> rules.playerDamageMultiplier); number("$rules.unitdamagemultiplier", f -> rules.unitDamageMultiplier = f, () -> rules.unitDamageMultiplier); - number("$rules.enemycorebuildradius", f -> rules.enemyCoreBuildRadius = f*tilesize, () -> Math.min(rules.enemyCoreBuildRadius/tilesize, 200)); - number("$rules.respawntime", f -> rules.respawnTime = f*60f, () -> rules.respawnTime/60f); - number("$rules.wavespacing", f -> rules.waveSpacing = f*60f, () -> rules.waveSpacing/60f); + number("$rules.enemycorebuildradius", f -> rules.enemyCoreBuildRadius = f * tilesize, () -> Math.min(rules.enemyCoreBuildRadius / tilesize, 200)); + number("$rules.respawntime", f -> rules.respawnTime = f * 60f, () -> rules.respawnTime / 60f); + number("$rules.wavespacing", f -> rules.waveSpacing = f * 60f, () -> rules.waveSpacing / 60f); } void number(String text, FloatConsumer cons, FloatProvider prov){ diff --git a/core/src/io/anuke/mindustry/ui/dialogs/DatabaseDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/DatabaseDialog.java index 41adede89b..1c094e841e 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/DatabaseDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/DatabaseDialog.java @@ -2,9 +2,7 @@ package io.anuke.mindustry.ui.dialogs; import io.anuke.arc.collection.Array; import io.anuke.arc.scene.event.HandCursorListener; -import io.anuke.arc.scene.ui.Image; -import io.anuke.arc.scene.ui.ScrollPane; -import io.anuke.arc.scene.ui.Tooltip; +import io.anuke.arc.scene.ui.*; import io.anuke.arc.scene.ui.layout.Table; import io.anuke.arc.scene.utils.UIUtils; import io.anuke.mindustry.Vars; @@ -34,7 +32,7 @@ public class DatabaseDialog extends FloatingDialog{ Array[] allContent = Vars.content.getContentMap(); - for(int j = 0; j < allContent.length; j ++){ + for(int j = 0; j < allContent.length; j++){ ContentType type = ContentType.values()[j]; Array array = allContent[j].select(c -> c instanceof UnlockableContent && !((UnlockableContent)c).isHidden()); @@ -53,7 +51,7 @@ public class DatabaseDialog extends FloatingDialog{ int count = 0; for(int i = 0; i < array.size; i++){ - UnlockableContent unlock = (UnlockableContent) array.get(i); + UnlockableContent unlock = (UnlockableContent)array.get(i); Image image = unlocked(unlock) ? new Image(unlock.getContentIcon()) : new Image("icon-tree-locked"); image.addListener(new HandCursorListener()); diff --git a/core/src/io/anuke/mindustry/ui/dialogs/DeployDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/DeployDialog.java index ac275e3d80..af0c8b34a2 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/DeployDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/DeployDialog.java @@ -137,7 +137,7 @@ public class DeployDialog extends FloatingDialog{ TextButton button = new TextButton("", "node"); button.setSize(node.width, node.height); button.update(() -> { - button.setPosition(node.x + panX + width/2f, node.y + panY + height/2f, Align.center); + button.setPosition(node.x + panX + width / 2f, node.y + panY + height / 2f, Align.center); }); button.clearChildren(); buildButton(node.zone, button); @@ -152,7 +152,7 @@ public class DeployDialog extends FloatingDialog{ @Override public void draw(){ - float offsetX = panX + width/2f + x, offsetY = panY + height/2f + y; + float offsetX = panX + width / 2f + x, offsetY = panY + height / 2f + y; for(ZoneNode node : nodes){ for(ZoneNode child : node.children){ diff --git a/core/src/io/anuke/mindustry/ui/dialogs/DiscordDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/DiscordDialog.java index b21e875749..7ea5b5b683 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/DiscordDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/DiscordDialog.java @@ -2,8 +2,8 @@ package io.anuke.mindustry.ui.dialogs; import io.anuke.arc.Core; import io.anuke.arc.graphics.Color; -import io.anuke.mindustry.graphics.Pal; import io.anuke.arc.scene.ui.Dialog; +import io.anuke.mindustry.graphics.Pal; import static io.anuke.mindustry.Vars.discordURL; import static io.anuke.mindustry.Vars.ui; diff --git a/core/src/io/anuke/mindustry/ui/dialogs/FileChooser.java b/core/src/io/anuke/mindustry/ui/dialogs/FileChooser.java index a6e42fa975..2bb98b5cd9 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/FileChooser.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/FileChooser.java @@ -11,9 +11,7 @@ import io.anuke.arc.scene.ui.*; import io.anuke.arc.scene.ui.layout.Table; import io.anuke.arc.scene.ui.layout.Unit; import io.anuke.arc.scene.utils.UIUtils; -import io.anuke.arc.util.Align; -import io.anuke.arc.util.OS; -import io.anuke.arc.util.Time; +import io.anuke.arc.util.*; import io.anuke.arc.util.pooling.Pools; import io.anuke.mindustry.Vars; import io.anuke.mindustry.core.Platform; @@ -27,7 +25,7 @@ public class FileChooser extends FloatingDialog{ public static Predicate defaultFilter = file -> true; private Table files; private FileHandle homeDirectory = Core.files.absolute(OS.isMac ? OS.getProperty("user.home") + "/Downloads/" : - Core.files.getExternalStoragePath()); + Core.files.getExternalStoragePath()); private FileHandle directory = homeDirectory; private ScrollPane pane; private TextField navigation, filefield; @@ -241,7 +239,7 @@ public class FileChooser extends FloatingDialog{ button.add(image).padRight(4f).size(14 * 2f); button.getCells().reverse(); files.top().left().add(button).align(Align.topLeft).fillX().expandX() - .height(50).pad(2).padTop(0).padBottom(0).colspan(2); + .height(50).pad(2).padTop(0).padBottom(0).colspan(2); button.getLabel().setAlignment(Align.left); files.row(); } diff --git a/core/src/io/anuke/mindustry/ui/dialogs/FloatingDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/FloatingDialog.java index 7e95935bef..967fda7db8 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/FloatingDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/FloatingDialog.java @@ -1,15 +1,15 @@ package io.anuke.mindustry.ui.dialogs; import io.anuke.arc.Core; +import io.anuke.arc.Events; import io.anuke.arc.input.KeyCode; +import io.anuke.arc.scene.ui.Dialog; +import io.anuke.arc.scene.ui.ScrollPane; import io.anuke.arc.util.Align; import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.game.EventType.ResizeEvent; import io.anuke.mindustry.graphics.Pal; import io.anuke.mindustry.net.Net; -import io.anuke.arc.Events; -import io.anuke.arc.scene.ui.Dialog; -import io.anuke.arc.scene.ui.ScrollPane; import static io.anuke.mindustry.Vars.state; @@ -23,7 +23,7 @@ public class FloatingDialog extends Dialog{ this.title.setAlignment(Align.center); titleTable.row(); titleTable.addImage("white", Pal.accent) - .growX().height(3f).pad(4f); + .growX().height(3f).pad(4f); hidden(() -> { if(shouldPause && !state.is(State.menu)){ @@ -43,14 +43,14 @@ public class FloatingDialog extends Dialog{ boolean[] done = {false}; shown(() -> Core.app.post(() -> - forEach(child -> { - if(done[0]) return; + forEach(child -> { + if(done[0]) return; - if(child instanceof ScrollPane){ - Core.scene.setScrollFocus(child); - done[0] = true; - } - }))); + if(child instanceof ScrollPane){ + Core.scene.setScrollFocus(child); + done[0] = true; + } + }))); } protected void onResize(Runnable run){ @@ -66,7 +66,7 @@ public class FloatingDialog extends Dialog{ buttons.addImageTextButton("$back", "icon-arrow-left", 30f, this::hide).size(210f, 64f); keyDown(key -> { - if(key == KeyCode.ESCAPE || key == KeyCode.BACK) { + if(key == KeyCode.ESCAPE || key == KeyCode.BACK){ Core.app.post(this::hide); } }); diff --git a/core/src/io/anuke/mindustry/ui/dialogs/GameOverDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/GameOverDialog.java index 67147e1b4d..ca7cdcf5d7 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/GameOverDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/GameOverDialog.java @@ -31,7 +31,7 @@ public class GameOverDialog extends FloatingDialog{ buttons.margin(10); if(state.rules.pvp){ - cont.add(Core.bundle.format("gameover.pvp",winner.localized())).pad(6); + cont.add(Core.bundle.format("gameover.pvp", winner.localized())).pad(6); buttons.addButton("$menu", () -> { hide(); state.set(State.menu); @@ -63,7 +63,7 @@ public class GameOverDialog extends FloatingDialog{ if(state.stats.itemsDelivered.get(item, 0) > 0){ t.table(items -> { items.add(" [LIGHT_GRAY]" + state.stats.itemsDelivered.get(item, 0)); - items.addImage(item.icon(Icon.medium)).size(8 *3).pad(4); + items.addImage(item.icon(Icon.medium)).size(8 * 3).pad(4); }).left(); t.row(); } diff --git a/core/src/io/anuke/mindustry/ui/dialogs/JoinDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/JoinDialog.java index 5207e95c47..b9a0630102 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/JoinDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/JoinDialog.java @@ -154,10 +154,10 @@ public class JoinDialog extends FloatingDialog{ versionString = Core.bundle.get("server.outdated"); }else if(host.version < Version.build && Version.build != -1){ versionString = Core.bundle.get("server.outdated") + "\n" + - Core.bundle.format("server.version", host.version, ""); + Core.bundle.format("server.version", host.version, ""); }else if(host.version > Version.build && Version.build != -1){ versionString = Core.bundle.get("server.outdated.client") + "\n" + - Core.bundle.format("server.version", host.version, ""); + Core.bundle.format("server.version", host.version, ""); }else{ versionString = Core.bundle.format("server.version", host.version, host.versionType); } @@ -170,7 +170,7 @@ public class JoinDialog extends FloatingDialog{ t.add("[lightgray]" + Core.bundle.format("server.hostname", host.name)).width(targetWidth() - 10f).left().get().setEllipsis(true); t.row(); t.add("[lightgray]" + (host.players != 1 ? Core.bundle.format("players", host.players) : - Core.bundle.format("players.single", host.players))).left(); + Core.bundle.format("players.single", host.players))).left(); t.row(); t.add("[lightgray]" + Core.bundle.format("save.map", host.mapname) + " / " + Core.bundle.format("save.wave", host.wave)).width(targetWidth() - 10f).left().get().setEllipsis(true); }).expand().left().bottom().padLeft(12f).padBottom(8); @@ -229,7 +229,7 @@ public class JoinDialog extends FloatingDialog{ pad = 6; } - Cell cell = ((Table) pane.getParent()).getCell(button); + Cell cell = ((Table)pane.getParent()).getCell(button); if(!Mathf.isEqual(cell.getMinWidth(), pw)){ cell.width(pw); @@ -256,7 +256,7 @@ public class JoinDialog extends FloatingDialog{ local.add().growX(); local.addImageButton("icon-loading", 16 * 2f, this::refreshLocal).pad(-12f).padLeft(0).size(70f); }else{ - local.background((Drawable) null); + local.background((Drawable)null); } } @@ -264,8 +264,8 @@ public class JoinDialog extends FloatingDialog{ if(totalHosts == 0){ local.clear(); } - local.background((Drawable) null); - totalHosts ++; + local.background((Drawable)null); + totalHosts++; float w = targetWidth(); local.row(); @@ -324,7 +324,7 @@ public class JoinDialog extends FloatingDialog{ void setIP(String ip){ //parse ip:port, if unsuccessful, use default values - if(ip.lastIndexOf(':') != -1 && ip.lastIndexOf(':') != ip.length()-1){ + if(ip.lastIndexOf(':') != -1 && ip.lastIndexOf(':') != ip.length() - 1){ try{ int idx = ip.lastIndexOf(':'); this.ip = ip.substring(0, idx); @@ -343,6 +343,7 @@ public class JoinDialog extends FloatingDialog{ return ip + (port != Vars.port ? ":" + port : ""); } - public Server(){} + public Server(){ + } } } diff --git a/core/src/io/anuke/mindustry/ui/dialogs/LanguageDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/LanguageDialog.java index 53317eca9e..006b9c25d9 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/LanguageDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/LanguageDialog.java @@ -1,9 +1,7 @@ package io.anuke.mindustry.ui.dialogs; import io.anuke.arc.Core; -import io.anuke.arc.scene.ui.ButtonGroup; -import io.anuke.arc.scene.ui.ScrollPane; -import io.anuke.arc.scene.ui.TextButton; +import io.anuke.arc.scene.ui.*; import io.anuke.arc.scene.ui.layout.Table; import io.anuke.arc.util.Log; diff --git a/core/src/io/anuke/mindustry/ui/dialogs/LoadDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/LoadDialog.java index 5b4b7f778c..01e1126217 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/LoadDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/LoadDialog.java @@ -1,19 +1,17 @@ package io.anuke.mindustry.ui.dialogs; import io.anuke.arc.Core; -import io.anuke.arc.files.FileHandle; import io.anuke.arc.collection.Array; -import io.anuke.mindustry.Vars; -import io.anuke.mindustry.core.GameState.State; -import io.anuke.mindustry.core.Platform; -import io.anuke.mindustry.io.SaveIO; -import io.anuke.mindustry.game.Saves.SaveSlot; -import io.anuke.arc.util.Time; +import io.anuke.arc.files.FileHandle; import io.anuke.arc.scene.ui.ScrollPane; import io.anuke.arc.scene.ui.TextButton; import io.anuke.arc.scene.ui.layout.Table; -import io.anuke.arc.util.Log; -import io.anuke.arc.util.Strings; +import io.anuke.arc.util.*; +import io.anuke.mindustry.Vars; +import io.anuke.mindustry.core.GameState.State; +import io.anuke.mindustry.core.Platform; +import io.anuke.mindustry.game.Saves.SaveSlot; +import io.anuke.mindustry.io.SaveIO; import io.anuke.mindustry.io.SaveIO.SaveException; import java.io.IOException; diff --git a/core/src/io/anuke/mindustry/ui/dialogs/MapsDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/MapsDialog.java index a98770f023..87a6f4c805 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/MapsDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/MapsDialog.java @@ -3,14 +3,10 @@ package io.anuke.mindustry.ui.dialogs; import io.anuke.arc.Core; import io.anuke.arc.graphics.Color; import io.anuke.arc.scene.event.Touchable; -import io.anuke.arc.scene.ui.Image; -import io.anuke.arc.scene.ui.ScrollPane; -import io.anuke.arc.scene.ui.TextButton; +import io.anuke.arc.scene.ui.*; import io.anuke.arc.scene.ui.layout.Table; import io.anuke.arc.scene.utils.UIUtils; -import io.anuke.arc.util.Log; -import io.anuke.arc.util.Scaling; -import io.anuke.arc.util.Strings; +import io.anuke.arc.util.*; import io.anuke.mindustry.Vars; import io.anuke.mindustry.core.Platform; import io.anuke.mindustry.io.MapIO; diff --git a/core/src/io/anuke/mindustry/ui/dialogs/MinimapDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/MinimapDialog.java index 088852b948..36f57dc608 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/MinimapDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/MinimapDialog.java @@ -31,7 +31,7 @@ public class MinimapDialog extends FloatingDialog{ t.addRect((x, y, width, height) -> { if(renderer.minimap.getRegion() == null) return; Draw.color(Color.WHITE); - Draw.rect(renderer.minimap.getRegion(), x + width/2f, y + height/2f, width, height); + Draw.rect(renderer.minimap.getRegion(), x + width / 2f, y + height / 2f, width, height); if(renderer.minimap.getTexture() != null){ renderer.minimap.drawEntities(x, y, width, height); diff --git a/core/src/io/anuke/mindustry/ui/dialogs/PausedDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/PausedDialog.java index 77e071c8a6..452c4e2627 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/PausedDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/PausedDialog.java @@ -18,7 +18,7 @@ public class PausedDialog extends FloatingDialog{ shown(this::rebuild); keyDown(key -> { - if(key == KeyCode.ESCAPE || key == KeyCode.BACK) { + if(key == KeyCode.ESCAPE || key == KeyCode.BACK){ hide(); } }); @@ -37,7 +37,7 @@ public class PausedDialog extends FloatingDialog{ float dw = 210f; cont.defaults().width(dw).height(50).pad(5f); - cont.addButton("$back", this::hide).colspan(2).width(dw*2 + 20f); + cont.addButton("$back", this::hide).colspan(2).width(dw * 2 + 20f); cont.row(); if(world.isZone()){ @@ -55,7 +55,7 @@ public class PausedDialog extends FloatingDialog{ cont.row(); - cont.addButton("$hostserver", ui.host::show).disabled(b -> Net.active()).colspan(2).width(dw*2 + 20f); + cont.addButton("$hostserver", ui.host::show).disabled(b -> Net.active()).colspan(2).width(dw * 2 + 20f); cont.row(); @@ -97,7 +97,7 @@ public class PausedDialog extends FloatingDialog{ public void runExitSave(){ if(control.saves.getCurrent() == null || - !control.saves.getCurrent().isAutosave()){ + !control.saves.getCurrent().isAutosave()){ state.set(State.menu); return; } @@ -107,7 +107,7 @@ public class PausedDialog extends FloatingDialog{ control.saves.getCurrent().save(); }catch(Throwable e){ e.printStackTrace(); - ui.showError("[accent]" + Core.bundle.get("savefail")); + ui.showError("[accent]" + Core.bundle.get("savefail")); } state.set(State.menu); }); diff --git a/core/src/io/anuke/mindustry/ui/dialogs/SaveDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/SaveDialog.java index 9baf019de2..004a1fafe5 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/SaveDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/SaveDialog.java @@ -22,13 +22,13 @@ public class SaveDialog extends LoadDialog{ public void addSetup(){ slots.row(); - slots.addImageTextButton("$save.new", "icon-add",14 * 3, () -> - ui.showTextInput("$save", "$save.newslot", "", text -> { - ui.loadAnd("$saving", () -> { - control.saves.addSave(text); - Core.app.post(() -> Core.app.post(this::setup)); - }); - }) + slots.addImageTextButton("$save.new", "icon-add", 14 * 3, () -> + ui.showTextInput("$save", "$save.newslot", "", text -> { + ui.loadAnd("$saving", () -> { + control.saves.addSave(text); + Core.app.post(() -> Core.app.post(this::setup)); + }); + }) ).fillX().margin(10f).minWidth(300f).height(70f).pad(4f).padRight(-4); } diff --git a/core/src/io/anuke/mindustry/ui/dialogs/SettingsMenuDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/SettingsMenuDialog.java index a8c35f5eaf..88052c3e50 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/SettingsMenuDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/SettingsMenuDialog.java @@ -50,7 +50,7 @@ public class SettingsMenuDialog extends SettingsDialog{ title.setAlignment(Align.center); titleTable.row(); titleTable.add(new Image("white")) - .growX().height(3f).pad(4f).get().setColor(Pal.accent); + .growX().height(3f).pad(4f).get().setColor(Pal.accent); cont.clearChildren(); cont.remove(); diff --git a/core/src/io/anuke/mindustry/ui/dialogs/TechTreeDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/TechTreeDialog.java index a8ace4a842..13a9b935ed 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/TechTreeDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/TechTreeDialog.java @@ -46,7 +46,7 @@ public class TechTreeDialog extends FloatingDialog{ hidden(ui.deploy::setup); addCloseButton(); - buttons.addImageTextButton("$database", "icon-database", 14*2, () -> { + buttons.addImageTextButton("$database", "icon-database", 14 * 2, () -> { hide(); ui.database.show(); }).size(210f, 64f); @@ -94,7 +94,7 @@ public class TechTreeDialog extends FloatingDialog{ table.setName("toast"); table.update(() -> { table.toFront(); - table.setPosition(Core.graphics.getWidth()/2f, Core.graphics.getHeight() - 21, Align.top); + table.setPosition(Core.graphics.getWidth() / 2f, Core.graphics.getHeight() - 21, Align.top); }); Core.scene.add(table); } @@ -172,10 +172,10 @@ public class TechTreeDialog extends FloatingDialog{ button.setSize(nodeSize); button.update(() -> { float offset = (Core.graphics.getHeight() % 2) / 2f; - button.setPosition(node.x + panX + width/2f, node.y + panY + height/2f + offset, Align.center); + button.setPosition(node.x + panX + width / 2f, node.y + panY + height / 2f + offset, Align.center); button.getStyle().up = Core.scene.skin.getDrawable(!locked(node.node) ? "content-background" : "content-background-locked"); ((TextureRegionDrawable)button.getStyle().imageUp) - .setRegion(node.visible ? node.node.block.icon(Icon.medium) : Core.atlas.find("icon-tree-locked")); + .setRegion(node.visible ? node.node.block.icon(Icon.medium) : Core.atlas.find("icon-tree-locked")); button.getImage().setColor(!locked(node.node) ? Color.WHITE : Color.GRAY); }); addChild(button); @@ -222,7 +222,7 @@ public class TechTreeDialog extends FloatingDialog{ infoTable.margin(0).left().defaults().left(); - infoTable.addImageButton("icon-info", "node", 14*2, () -> ui.content.show(node.block)).growY().width(50f); + infoTable.addImageButton("icon-info", "node", 14 * 2, () -> ui.content.show(node.block)).growY().width(50f); infoTable.add().grow(); @@ -251,7 +251,7 @@ public class TechTreeDialog extends FloatingDialog{ if(mobile && locked(node)){ infoTable.row(); - infoTable.addImageTextButton("$research", "icon-check", "node", 16*2, () -> unlock(node)) + infoTable.addImageTextButton("$research", "icon-check", "node", 16 * 2, () -> unlock(node)) .disabled(b -> !data.hasItems(node.requirements)).growX().height(44f).colspan(3); } @@ -261,7 +261,7 @@ public class TechTreeDialog extends FloatingDialog{ @Override public void draw(){ - float offsetX = panX + width/2f + x, offsetY = panY + height/2f + y; + float offsetX = panX + width / 2f + x, offsetY = panY + height / 2f + y; for(TechTreeNode node : nodes){ if(!node.visible) continue; diff --git a/core/src/io/anuke/mindustry/ui/dialogs/ZoneInfoDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/ZoneInfoDialog.java index 52b18a6b89..fc716b74a7 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/ZoneInfoDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/ZoneInfoDialog.java @@ -6,10 +6,7 @@ import io.anuke.arc.scene.ui.Button; import io.anuke.arc.scene.ui.TextButton; import io.anuke.arc.scene.ui.layout.Table; import io.anuke.mindustry.graphics.Pal; -import io.anuke.mindustry.type.Item; -import io.anuke.mindustry.type.ItemStack; -import io.anuke.mindustry.type.ItemType; -import io.anuke.mindustry.type.Zone; +import io.anuke.mindustry.type.*; import io.anuke.mindustry.type.Zone.ZoneRequirement; import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Block.Icon; @@ -52,7 +49,7 @@ public class ZoneInfoDialog extends FloatingDialog{ if(i++ % 2 == 0){ iteminfo.row(); } - iteminfo.addImage(stack.item.icon(Item.Icon.medium)).size(8*3).padRight(1); + iteminfo.addImage(stack.item.icon(Item.Icon.medium)).size(8 * 3).padRight(1); iteminfo.add(stack.amount + "").color(Color.LIGHT_GRAY).padRight(5); } }; @@ -168,7 +165,7 @@ public class ZoneInfoDialog extends FloatingDialog{ }).size(300f, 35f).pad(1).get(); button.clearChildren(); button.left(); - button.addImage(item.icon(Item.Icon.medium)).size(8*3).pad(4); + button.addImage(item.icon(Item.Icon.medium)).size(8 * 3).pad(4); button.add(item.localizedName); dialog.cont.row(); } diff --git a/core/src/io/anuke/mindustry/ui/fragments/BackgroundFragment.java b/core/src/io/anuke/mindustry/ui/fragments/BackgroundFragment.java index de0b8851cb..1914fbf8fa 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/BackgroundFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/BackgroundFragment.java @@ -1,9 +1,7 @@ package io.anuke.mindustry.ui.fragments; import io.anuke.arc.Core; -import io.anuke.arc.graphics.g2d.Draw; -import io.anuke.arc.graphics.g2d.Fill; -import io.anuke.arc.graphics.g2d.TextureRegion; +import io.anuke.arc.graphics.g2d.*; import io.anuke.arc.scene.Group; import io.anuke.arc.scene.ui.layout.Unit; import io.anuke.mindustry.core.GameState.State; @@ -23,13 +21,13 @@ public class BackgroundFragment extends Fragment{ Draw.shader(); boolean portrait = Core.graphics.getWidth() < Core.graphics.getHeight(); - float logoscl = (int) Unit.dp.scl(1); + float logoscl = (int)Unit.dp.scl(1); TextureRegion logo = Core.atlas.find("logotext"); float logow = logo.getWidth() * logoscl; float logoh = logo.getHeight() * logoscl; Draw.color(); - Draw.rect(logo, (int) (w / 2), (int) (h - 10 - logoh - Unit.dp.scl(portrait ? 30f : 0)) + logoh/2, logow, logoh); + Draw.rect(logo, (int)(w / 2), (int)(h - 10 - logoh - Unit.dp.scl(portrait ? 30f : 0)) + logoh / 2, logow, logoh); }).visible(() -> state.is(State.menu)).grow(); } } diff --git a/core/src/io/anuke/mindustry/ui/fragments/BlockConfigFragment.java b/core/src/io/anuke/mindustry/ui/fragments/BlockConfigFragment.java index a3b577ccde..e51801c200 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/BlockConfigFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/BlockConfigFragment.java @@ -50,7 +50,7 @@ public class BlockConfigFragment extends Fragment{ table.pack(); table.setTransform(true); table.actions(Actions.scaleTo(0f, 1f), Actions.visible(true), - Actions.scaleTo(1f, 1f, 0.07f, Interpolation.pow3Out)); + Actions.scaleTo(1f, 1f, 0.07f, Interpolation.pow3Out)); table.update(() -> { if(state.is(State.menu)){ diff --git a/core/src/io/anuke/mindustry/ui/fragments/BlockInventoryFragment.java b/core/src/io/anuke/mindustry/ui/fragments/BlockInventoryFragment.java index 8fc9e43885..77e0670121 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/BlockInventoryFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/BlockInventoryFragment.java @@ -11,14 +11,9 @@ import io.anuke.arc.math.Mathf; import io.anuke.arc.math.geom.Vector2; import io.anuke.arc.scene.Group; import io.anuke.arc.scene.actions.Actions; -import io.anuke.arc.scene.event.HandCursorListener; -import io.anuke.arc.scene.event.InputEvent; -import io.anuke.arc.scene.event.InputListener; -import io.anuke.arc.scene.event.Touchable; +import io.anuke.arc.scene.event.*; import io.anuke.arc.scene.ui.layout.Table; -import io.anuke.arc.util.Align; -import io.anuke.arc.util.Strings; -import io.anuke.arc.util.Time; +import io.anuke.arc.util.*; import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.entities.type.Player; import io.anuke.mindustry.gen.Call; @@ -180,18 +175,18 @@ public class BlockInventoryFragment extends Fragment{ if(actions){ table.actions(Actions.scaleTo(0f, 1f), Actions.visible(true), - Actions.scaleTo(1f, 1f, 0.07f, Interpolation.pow3Out)); + Actions.scaleTo(1f, 1f, 0.07f, Interpolation.pow3Out)); } } private String round(float f){ - f = (int) f; + f = (int)f; if(f >= 1000000){ return Strings.fixed(f / 1000000f, 1) + "[gray]mil[]"; }else if(f >= 1000){ return Strings.fixed(f / 1000, 1) + "k"; }else{ - return (int) f + ""; + return (int)f + ""; } } diff --git a/core/src/io/anuke/mindustry/ui/fragments/ChatFragment.java b/core/src/io/anuke/mindustry/ui/fragments/ChatFragment.java index 6327ffa657..9d5258f3c5 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/ChatFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/ChatFragment.java @@ -81,7 +81,7 @@ public class ChatFragment extends Table{ historyPos--; updateChat(); } - scrollPos = (int) Mathf.clamp(scrollPos + input.axis(Binding.chat_scroll), 0, Math.max(0, messages.size - messagesShown)); + scrollPos = (int)Mathf.clamp(scrollPos + input.axis(Binding.chat_scroll), 0, Math.max(0, messages.size - messagesShown)); } }); diff --git a/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java b/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java index c32962ef47..29b5ed1215 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java @@ -11,17 +11,10 @@ import io.anuke.arc.scene.Element; import io.anuke.arc.scene.Group; import io.anuke.arc.scene.actions.Actions; import io.anuke.arc.scene.event.Touchable; -import io.anuke.arc.scene.ui.Image; -import io.anuke.arc.scene.ui.ImageButton; -import io.anuke.arc.scene.ui.TextButton; -import io.anuke.arc.scene.ui.layout.Stack; -import io.anuke.arc.scene.ui.layout.Table; -import io.anuke.arc.scene.ui.layout.Unit; +import io.anuke.arc.scene.ui.*; +import io.anuke.arc.scene.ui.layout.*; import io.anuke.arc.scene.utils.Elements; -import io.anuke.arc.util.Align; -import io.anuke.arc.util.Scaling; -import io.anuke.arc.util.Time; -import io.anuke.arc.util.Tmp; +import io.anuke.arc.util.*; import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.game.EventType.StateChangeEvent; import io.anuke.mindustry.game.UnlockableContent; @@ -30,13 +23,13 @@ import io.anuke.mindustry.graphics.Pal; import io.anuke.mindustry.input.Binding; import io.anuke.mindustry.net.Net; import io.anuke.mindustry.net.Packets.AdminAction; -import io.anuke.mindustry.ui.Bar; -import io.anuke.mindustry.ui.IntFormat; -import io.anuke.mindustry.ui.Minimap; +import io.anuke.mindustry.ui.*; import io.anuke.mindustry.ui.dialogs.FloatingDialog; import static io.anuke.mindustry.Vars.*; +import java.lang.StringBuilder; + public class HudFragment extends Fragment{ public final PlacementFragment blockfrag = new PlacementFragment(); @@ -124,7 +117,7 @@ public class HudFragment extends Fragment{ }); } - cont.add().size(dsize*4 + 3, dsize).left(); + cont.add().size(dsize * 4 + 3, dsize).left(); } cont.row(); @@ -152,14 +145,14 @@ public class HudFragment extends Fragment{ stuff.add(stack).width(dsize * 4 + 3f); stuff.row(); stuff.table("button", t -> t.margin(10f).add(new Bar("boss.health", Pal.health, () -> state.boss() == null ? 0f : state.boss().healthf()).blink(Color.WHITE)) - .grow()).fillX().visible(() -> state.rules.waves && state.boss() != null).height(60f).get(); + .grow()).fillX().visible(() -> state.rules.waves && state.boss() != null).height(60f).get(); stuff.row(); }).visible(() -> shown); //fps display cont.table(info -> { info.top().left().margin(4).visible(() -> Core.settings.getBool("fps")); - info.update(() -> info.setTranslation(state.rules.waves ? 0f : -Unit.dp.scl(dsize*4 + 3), 0)); + info.update(() -> info.setTranslation(state.rules.waves ? 0f : -Unit.dp.scl(dsize * 4 + 3), 0)); IntFormat fps = new IntFormat("fps"); IntFormat ping = new IntFormat("ping"); @@ -187,7 +180,7 @@ public class HudFragment extends Fragment{ t.touchable(Touchable.disabled); t.visible(() -> !state.is(State.menu)); t.table("flat", c -> c.add("") - .update(l ->{ + .update(l -> { l.setColor(Tmp.c1.set(Color.WHITE).lerp(Color.SCARLET, Mathf.absin(Time.time(), 10f, 1f))); l.setText(Core.bundle.format("outofbounds", (int)((boundsCountdown - player.destructTime) / 60f))); }).get().setAlignment(Align.center, Align.center)).margin(6).update(u -> { @@ -237,7 +230,7 @@ public class HudFragment extends Fragment{ return coreAttackOpacity > 0; }); t.table("button", top -> top.add("$coreattack").pad(2) - .update(label -> label.getColor().set(Color.ORANGE).lerp(Color.SCARLET, Mathf.absin(Time.time(), 2f, 1f)))).touchable(Touchable.disabled); + .update(label -> label.getColor().set(Color.ORANGE).lerp(Color.SCARLET, Mathf.absin(Time.time(), 2f, 1f)))).touchable(Touchable.disabled); }); //launch button @@ -270,10 +263,10 @@ public class HudFragment extends Fragment{ button.getStyle().disabledFontColor = Color.WHITE; button.margin(16f); button.visible(() -> - world.isZone() && - world.getZone().metCondition() && - !Net.client() && - state.wave % world.getZone().launchPeriod == 0 && !world.spawner.isSpawning()); + world.isZone() && + world.getZone().metCondition() && + !Net.client() && + state.wave % world.getZone().launchPeriod == 0 && !world.spawner.isSpawning()); button.update(() -> { if(world.getZone() == null){ @@ -282,10 +275,10 @@ public class HudFragment extends Fragment{ } button.setText(state.enemies() > 0 ? Core.bundle.format("launch.unable", state.enemies()) : Core.bundle.get("launch") + "\n" + - Core.bundle.format("launch.next", state.wave + world.getZone().launchPeriod)); + Core.bundle.format("launch.next", state.wave + world.getZone().launchPeriod)); button.getLabel().setColor(Tmp.c1.set(Color.WHITE).lerp(state.enemies() > 0 ? Color.WHITE : Color.SCARLET, - Mathf.absin(Time.time(), 2f, 1f))); + Mathf.absin(Time.time(), 2f, 1f))); }); button.setDisabled(() -> state.enemies() > 0); @@ -466,7 +459,7 @@ public class HudFragment extends Fragment{ } if(state.rules.waveTimer){ - builder.append(waitingf.get((int)(state.wavetime/60))); + builder.append(waitingf.get((int)(state.wavetime / 60))); }else if(state.enemies() == 0){ builder.append(Core.bundle.get("waiting")); } diff --git a/core/src/io/anuke/mindustry/ui/fragments/LoadingFragment.java b/core/src/io/anuke/mindustry/ui/fragments/LoadingFragment.java index 2b178a2125..18876d0e08 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/LoadingFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/LoadingFragment.java @@ -1,11 +1,11 @@ package io.anuke.mindustry.ui.fragments; -import io.anuke.mindustry.graphics.Pal; import io.anuke.arc.scene.Group; import io.anuke.arc.scene.event.Touchable; import io.anuke.arc.scene.ui.Label; import io.anuke.arc.scene.ui.TextButton; import io.anuke.arc.scene.ui.layout.Table; +import io.anuke.mindustry.graphics.Pal; public class LoadingFragment extends Fragment{ private Table table; @@ -25,7 +25,8 @@ public class LoadingFragment extends Fragment{ t.addImage("white").growX().height(3f).pad(4f).growX().get().setColor(Pal.accent); t.row(); - button = t.addButton("$cancel", () -> {}).pad(20).size(250f, 70f).visible(false).get(); + button = t.addButton("$cancel", () -> { + }).pad(20).size(250f, 70f).visible(false).get(); table = t; }); } diff --git a/core/src/io/anuke/mindustry/ui/fragments/MenuFragment.java b/core/src/io/anuke/mindustry/ui/fragments/MenuFragment.java index 8891591981..f012fe48ac 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/MenuFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/MenuFragment.java @@ -34,18 +34,18 @@ public class MenuFragment extends Fragment{ //discord icon in top right parent.fill(c -> c.top().right().addButton("", "discord", ui.discord::show).size(84, 45) - .visible(() -> state.is(State.menu))); + .visible(() -> state.is(State.menu))); //info icon if(mobile){ parent.fill(c -> c.top().left().addButton("", "info", ui.about::show).size(84, 45) - .visible(() -> state.is(State.menu))); + .visible(() -> state.is(State.menu))); } //version info parent.fill(c -> c.bottom().left().add(Strings.format("Mindustry v{0} {1}-{2} {3}{4}", Version.number, Version.modifier, Version.type, - (Version.build == -1 ? "custom build" : "build " + Version.build), Version.revision == 0 ? "" : "." + Version.revision)) - .visible(() -> state.is(State.menu))); + (Version.build == -1 ? "custom build" : "build " + Version.build), Version.revision == 0 ? "" : "." + Version.revision)) + .visible(() -> state.is(State.menu))); } private void buildMobile(){ @@ -57,13 +57,13 @@ public class MenuFragment extends Fragment{ container.defaults().size(size).pad(5).padTop(4f); MobileButton - play = new MobileButton("icon-play-2", isize, "$play", ui.deploy::show), - maps = new MobileButton("icon-map", isize, "$maps", ui.maps::show), - custom = new MobileButton("icon-play-custom", isize, "$customgame", this::showCustomSelect), - join = new MobileButton("icon-add", isize, "$joingame", ui.join::show), - editor = new MobileButton("icon-editor", isize, "$editor", () -> ui.loadAnd(ui.editor::show)), - tools = new MobileButton("icon-tools", isize, "$settings", ui.settings::show), - donate = new MobileButton("icon-donate", isize, "$donate", () -> Core.net.openURI(donationURL)); + play = new MobileButton("icon-play-2", isize, "$play", ui.deploy::show), + maps = new MobileButton("icon-map", isize, "$maps", ui.maps::show), + custom = new MobileButton("icon-play-custom", isize, "$customgame", this::showCustomSelect), + join = new MobileButton("icon-add", isize, "$joingame", ui.join::show), + editor = new MobileButton("icon-editor", isize, "$editor", () -> ui.loadAnd(ui.editor::show)), + tools = new MobileButton("icon-tools", isize, "$settings", ui.settings::show), + donate = new MobileButton("icon-donate", isize, "$donate", () -> Core.net.openURI(donationURL)); if(Core.graphics.getWidth() > Core.graphics.getHeight()){ container.add(play); diff --git a/core/src/io/anuke/mindustry/ui/fragments/OverlayFragment.java b/core/src/io/anuke/mindustry/ui/fragments/OverlayFragment.java index f69986634d..6493496d76 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/OverlayFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/OverlayFragment.java @@ -1,9 +1,9 @@ package io.anuke.mindustry.ui.fragments; -import io.anuke.mindustry.input.InputHandler; import io.anuke.arc.scene.Group; +import io.anuke.mindustry.input.InputHandler; -/**Fragment for displaying overlays such as block inventories. One is created for each input handler.*/ +/** Fragment for displaying overlays such as block inventories. One is created for each input handler. */ public class OverlayFragment extends Fragment{ public final BlockInventoryFragment inv; public final BlockConfigFragment config; diff --git a/core/src/io/anuke/mindustry/ui/fragments/PlacementFragment.java b/core/src/io/anuke/mindustry/ui/fragments/PlacementFragment.java index 0accd359db..11d1533cff 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/PlacementFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/PlacementFragment.java @@ -9,9 +9,7 @@ import io.anuke.arc.math.geom.Vector2; import io.anuke.arc.scene.Group; import io.anuke.arc.scene.event.Touchable; import io.anuke.arc.scene.style.TextureRegionDrawable; -import io.anuke.arc.scene.ui.ButtonGroup; -import io.anuke.arc.scene.ui.Image; -import io.anuke.arc.scene.ui.ImageButton; +import io.anuke.arc.scene.ui.*; import io.anuke.arc.scene.ui.layout.Table; import io.anuke.mindustry.content.Blocks; import io.anuke.mindustry.core.GameState.State; @@ -21,9 +19,7 @@ import io.anuke.mindustry.game.EventType.WorldLoadEvent; import io.anuke.mindustry.graphics.Pal; import io.anuke.mindustry.input.Binding; import io.anuke.mindustry.input.InputHandler; -import io.anuke.mindustry.type.Category; -import io.anuke.mindustry.type.Item; -import io.anuke.mindustry.type.ItemStack; +import io.anuke.mindustry.type.*; import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Block.Icon; import io.anuke.mindustry.world.Tile; @@ -45,15 +41,15 @@ public class PlacementFragment extends Fragment{ //TODO make this configurable final KeyCode[] inputGrid = { - KeyCode.NUM_1, KeyCode.NUM_2, KeyCode.NUM_3, KeyCode.NUM_4, - KeyCode.Q, KeyCode.W, KeyCode.E, KeyCode.R, - KeyCode.A, KeyCode.S, KeyCode.D, KeyCode.F, - KeyCode.Z, KeyCode.X, KeyCode.C, KeyCode.V + KeyCode.NUM_1, KeyCode.NUM_2, KeyCode.NUM_3, KeyCode.NUM_4, + KeyCode.Q, KeyCode.W, KeyCode.E, KeyCode.R, + KeyCode.A, KeyCode.S, KeyCode.D, KeyCode.F, + KeyCode.Z, KeyCode.X, KeyCode.C, KeyCode.V }, inputCatGrid = { - KeyCode.NUM_1, KeyCode.NUM_2, - KeyCode.Q, KeyCode.W, - KeyCode.A, KeyCode.S, - KeyCode.Z, KeyCode.X, KeyCode.C, KeyCode.V + KeyCode.NUM_1, KeyCode.NUM_2, + KeyCode.Q, KeyCode.W, + KeyCode.A, KeyCode.S, + KeyCode.Z, KeyCode.X, KeyCode.C, KeyCode.V }; public PlacementFragment(){ @@ -292,7 +288,7 @@ public class PlacementFragment extends Fragment{ returnCatArray.sort((c1, c2) -> Boolean.compare(categoryEmpty[c1.ordinal()], categoryEmpty[c2.ordinal()])); return returnCatArray; } - + Array getByCategory(Category cat){ returnArray.clear(); for(Block block : content.blocks()){ diff --git a/core/src/io/anuke/mindustry/ui/fragments/PlayerListFragment.java b/core/src/io/anuke/mindustry/ui/fragments/PlayerListFragment.java index 4a4ca776c3..544fbd5ce7 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/PlayerListFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/PlayerListFragment.java @@ -107,9 +107,9 @@ public class PlayerListFragment extends Fragment{ t.defaults().size(bs); t.addImageButton("icon-ban", "clear-partial", 14 * 2, - () -> ui.showConfirm("$confirm", "$confirmban", () -> Call.onAdminRequest(user, AdminAction.ban))); + () -> ui.showConfirm("$confirm", "$confirmban", () -> Call.onAdminRequest(user, AdminAction.ban))); t.addImageButton("icon-cancel", "clear-partial", 16 * 2, - () -> ui.showConfirm("$confirm", "$confirmkick", () -> Call.onAdminRequest(user, AdminAction.kick))); + () -> ui.showConfirm("$confirm", "$confirmkick", () -> Call.onAdminRequest(user, AdminAction.kick))); t.row(); diff --git a/core/src/io/anuke/mindustry/world/Block.java b/core/src/io/anuke/mindustry/world/Block.java index d1b01788c3..c92d9a10cf 100644 --- a/core/src/io/anuke/mindustry/world/Block.java +++ b/core/src/io/anuke/mindustry/world/Block.java @@ -19,20 +19,14 @@ import io.anuke.mindustry.entities.Damage; import io.anuke.mindustry.entities.bullet.Bullet; import io.anuke.mindustry.entities.effect.Puddle; import io.anuke.mindustry.entities.effect.RubbleDecal; -import io.anuke.mindustry.entities.type.Player; -import io.anuke.mindustry.entities.type.TileEntity; -import io.anuke.mindustry.entities.type.Unit; +import io.anuke.mindustry.entities.type.*; import io.anuke.mindustry.game.UnlockableContent; -import io.anuke.mindustry.graphics.CacheLayer; -import io.anuke.mindustry.graphics.Layer; -import io.anuke.mindustry.graphics.Pal; +import io.anuke.mindustry.graphics.*; import io.anuke.mindustry.input.InputHandler.PlaceDraw; import io.anuke.mindustry.type.*; import io.anuke.mindustry.ui.Bar; import io.anuke.mindustry.ui.ContentDisplay; -import io.anuke.mindustry.world.consumers.Consume; -import io.anuke.mindustry.world.consumers.ConsumeLiquid; -import io.anuke.mindustry.world.consumers.ConsumeType; +import io.anuke.mindustry.world.consumers.*; import io.anuke.mindustry.world.meta.*; import java.util.Arrays; @@ -68,7 +62,7 @@ public class Block extends BlockStorage{ public int timers = 0; /** Cache layer. Only used for 'cached' rendering. */ public CacheLayer cacheLayer = CacheLayer.normal; - /**Special flag; if false, floor will be drawn under this block even if it is cached.*/ + /** Special flag; if false, floor will be drawn under this block even if it is cached. */ public boolean fillsTile = true; /** Layer to draw extra stuff on. */ public Layer layer = null; @@ -86,25 +80,27 @@ public class Block extends BlockStorage{ public boolean configurable; /** Whether this block consumes touchDown events when tapped. */ public boolean consumesTap; - /** The color of this block when displayed on the minimap or map preview. - * Do not set manually! This is overriden when loading for most blocks.*/ + /** + * The color of this block when displayed on the minimap or map preview. + * Do not set manually! This is overriden when loading for most blocks. + */ public Color color = new Color(0, 0, 0, 1); - /**Whether units target this block.*/ + /** Whether units target this block. */ public boolean targetable = true; - /**Whether the overdrive core has any effect on this block.*/ + /** Whether the overdrive core has any effect on this block. */ public boolean canOverdrive = true; - /**Whether the icon region has an outline added.*/ + /** Whether the icon region has an outline added. */ public boolean outlineIcon = false; - /**Whether this block has a shadow under it.*/ + /** Whether this block has a shadow under it. */ public boolean hasShadow = true; - /**Cost of constructing this block.*/ + /** Cost of constructing this block. */ public ItemStack[] buildRequirements = new ItemStack[]{}; - /**Category in place menu.*/ + /** Category in place menu. */ public Category buildCategory = Category.distribution; - /**Cost of building this block; do not modify directly!*/ + /** Cost of building this block; do not modify directly! */ public float buildCost; - /**Whether this block is visible and can currently be built.*/ + /** Whether this block is visible and can currently be built. */ public BooleanProvider buildVisibility = () -> false; public boolean alwaysUnlocked = false; @@ -167,7 +163,7 @@ public class Block extends BlockStorage{ for(Tile other : tile.entity.proximity()){ if(other != null && other.entity != null && other.entity.power != null && !(consumesPower && other.block().consumesPower && !outputsPower && !other.block().outputsPower) - && !tile.entity.power.links.contains(other.pos())){ + && !tile.entity.power.links.contains(other.pos())){ out.add(other); } } @@ -221,10 +217,10 @@ public class Block extends BlockStorage{ layout.setText(font, text); font.setColor(color); - float dx = x*tilesize + offset(), dy = y*tilesize + offset() + size*tilesize/2f + 2; + float dx = x * tilesize + offset(), dy = y * tilesize + offset() + size * tilesize / 2f + 2; font.draw(text, dx, dy + layout.height + 1, Align.center); Lines.stroke(1f, color); - Lines.line(dx - layout.width/2f - 2f, dy, dx + layout.width/2f + 2f, dy); + Lines.line(dx - layout.width / 2f - 2f, dy, dx + layout.width / 2f + 2f, dy); font.setUseIntegerPositions(ints); font.setColor(Color.WHITE); @@ -239,7 +235,7 @@ public class Block extends BlockStorage{ public void drawTeam(Tile tile){ Draw.color(tile.getTeam().color); - Draw.rect("block-border", tile.drawx() - size * tilesize/2f + 4, tile.drawy() - size * tilesize/2f + 4); + Draw.rect("block-border", tile.drawx() - size * tilesize / 2f + 4, tile.drawy() - size * tilesize / 2f + 4); Draw.color(); } @@ -258,7 +254,7 @@ public class Block extends BlockStorage{ public void unitOn(Tile tile, Unit unit){ } - /** Called when a unit that spawned at this tile is removed.*/ + /** Called when a unit that spawned at this tile is removed. */ public void unitRemoved(Tile tile, Unit unit){ } @@ -268,7 +264,7 @@ public class Block extends BlockStorage{ return true; } - /**Call when some content is produced. This unlocks the content if it is applicable.*/ + /** Call when some content is produced. This unlocks the content if it is applicable. */ public void useContent(Tile tile, UnlockableContent content){ if(!headless && tile.getTeam() == player.getTeam()){ logic.handleContent(content); @@ -334,13 +330,13 @@ public class Block extends BlockStorage{ } } - /**Adds a region by name to be loaded, with the final name "{name}-suffix". Returns an ID to looks this region up by in {@link #reg(int)}.*/ + /** Adds a region by name to be loaded, with the final name "{name}-suffix". Returns an ID to looks this region up by in {@link #reg(int)}. */ protected int reg(String suffix){ cacheRegionStrings.add(name + suffix); return cacheRegionStrings.size - 1; } - /**Returns an internally cached region by ID.*/ + /** Returns an internally cached region by ID. */ protected TextureRegion reg(int id){ return cacheRegions[id]; } @@ -421,7 +417,7 @@ public class Block extends BlockStorage{ float capacity = consumes.getPower().powerCapacity; bars.add("power", entity -> new Bar(() -> buffered ? Core.bundle.format("bar.poweramount", Float.isNaN(entity.power.satisfaction * capacity) ? "" : (int)(entity.power.satisfaction * capacity)) : - Core.bundle.get("bar.power"), () -> Pal.powerBar, () -> entity.power.satisfaction)); + Core.bundle.get("bar.power"), () -> Pal.powerBar, () -> entity.power.satisfaction)); } if(hasItems && configurable){ @@ -577,18 +573,18 @@ public class Block extends BlockStorage{ draw.rotation = rotation; } - /**Never use outside of the editor!*/ + /** Never use outside of the editor! */ public TextureRegion editorIcon(){ if(editorIcon == null) editorIcon = Core.atlas.find(name + "-icon-editor"); return editorIcon; } - /**Never use outside of the editor!*/ + /** Never use outside of the editor! */ public TextureRegion[] editorVariantRegions(){ if(editorVariantRegions == null){ variantRegions(); editorVariantRegions = new TextureRegion[variantRegions.length]; - for(int i = 0; i < variantRegions.length; i ++){ + for(int i = 0; i < variantRegions.length; i++){ AtlasRegion region = (AtlasRegion)variantRegions[i]; editorVariantRegions[i] = Core.atlas.find("editor-" + region.name); } @@ -654,7 +650,7 @@ public class Block extends BlockStorage{ requirements(cat, () -> true, stacks); } - /**Sets up requirements. Use only this method to set up requirements.*/ + /** Sets up requirements. Use only this method to set up requirements. */ protected void requirements(Category cat, BooleanProvider visible, ItemStack[] stacks){ this.buildCategory = cat; this.buildRequirements = stacks; @@ -667,7 +663,7 @@ public class Block extends BlockStorage{ small(8 * 3), medium(8 * 4), large(8 * 6), - /**uses whatever the size of the block is*/ + /** uses whatever the size of the block is */ full(0); public final int size; diff --git a/core/src/io/anuke/mindustry/world/BlockStorage.java b/core/src/io/anuke/mindustry/world/BlockStorage.java index f4fa6095e4..b6c6f2e0c1 100644 --- a/core/src/io/anuke/mindustry/world/BlockStorage.java +++ b/core/src/io/anuke/mindustry/world/BlockStorage.java @@ -46,7 +46,7 @@ public abstract class BlockStorage extends UnlockableContent{ return 0f; } - /**Returns the amount of items this block can accept.*/ + /** Returns the amount of items this block can accept. */ public int acceptStack(Item item, int amount, Tile tile, Unit source){ if(acceptItem(item, tile, tile) && hasItems && (source == null || source.getTeam() == tile.getTeam())){ return Math.min(getMaximumAccepted(tile, item) - tile.entity.items.get(item), amount); @@ -59,7 +59,7 @@ public abstract class BlockStorage extends UnlockableContent{ return itemCapacity; } - /**Remove a stack from this inventory, and return the amount removed.*/ + /** Remove a stack from this inventory, and return the amount removed. */ public int removeStack(Tile tile, Item item, int amount){ if(tile.entity == null || tile.entity.items == null) return 0; amount = Math.min(amount, tile.entity.items.get(item)); @@ -68,7 +68,7 @@ public abstract class BlockStorage extends UnlockableContent{ return amount; } - /**Handle a stack input.*/ + /** Handle a stack input. */ public void handleStack(Item item, int amount, Tile tile, Unit source){ tile.entity.noSleep(); tile.entity.items.add(item, amount); @@ -78,7 +78,7 @@ public abstract class BlockStorage extends UnlockableContent{ return hasItems; } - /**Returns offset for stack placement.*/ + /** Returns offset for stack placement. */ public void getStackOffset(Item item, Tile tile, Vector2 trns){ } @@ -155,14 +155,14 @@ public abstract class BlockStorage extends UnlockableContent{ }else if(ofract > 0.1f && fract > 0.1f){ Liquid other = next.entity.liquids.current(); if((other.flammability > 0.3f && liquid.temperature > 0.7f) || - (liquid.flammability > 0.3f && other.temperature > 0.7f)){ + (liquid.flammability > 0.3f && other.temperature > 0.7f)){ tile.entity.damage(1 * Time.delta()); next.entity.damage(1 * Time.delta()); if(Mathf.chance(0.1 * Time.delta())){ Effects.effect(Fx.fire, (tile.worldx() + next.worldx()) / 2f, (tile.worldy() + next.worldy()) / 2f); } }else if((liquid.temperature > 0.7f && other.temperature < 0.55f) || - (other.temperature > 0.7f && liquid.temperature < 0.55f)){ + (other.temperature > 0.7f && liquid.temperature < 0.55f)){ tile.entity.liquids.remove(liquid, Math.min(tile.entity.liquids.get(liquid), 0.7f * Time.delta())); if(Mathf.chance(0.2f * Time.delta())){ Effects.effect(Fx.steam, (tile.worldx() + next.worldx()) / 2f, (tile.worldy() + next.worldy()) / 2f); @@ -199,14 +199,13 @@ public abstract class BlockStorage extends UnlockableContent{ handleItem(item, tile, tile); } - /**Try dumping any item near the tile.*/ + /** Try dumping any item near the tile. */ public boolean tryDump(Tile tile){ return tryDump(tile, null); } /** * Try dumping a specific item near the tile. - * * @param todump Item to dump. Can be null to dump anything. */ public boolean tryDump(Tile tile, Item todump){ @@ -252,15 +251,15 @@ public abstract class BlockStorage extends UnlockableContent{ } protected void incrementDump(Tile tile, int prox){ - tile.setDump((byte) ((tile.getDump() + 1) % prox)); + tile.setDump((byte)((tile.getDump() + 1) % prox)); } - /** Used for dumping items.*/ + /** Used for dumping items. */ public boolean canDump(Tile tile, Tile to, Item item){ return true; } - /** Try offloading an item to a nearby container in its facing direction. Returns true if success.*/ + /** Try offloading an item to a nearby container in its facing direction. Returns true if success. */ public boolean offloadDir(Tile tile, Item item){ Tile other = tile.getNearby(tile.getRotation()); if(other != null && other.target().getTeamID() == tile.getTeamID() && other.block().acceptItem(item, other, tile)){ @@ -270,7 +269,7 @@ public abstract class BlockStorage extends UnlockableContent{ return false; } - /** Returns whether this block's inventory has space and is ready for production.*/ + /** Returns whether this block's inventory has space and is ready for production. */ public boolean canProduce(Tile tile){ return true; } diff --git a/core/src/io/anuke/mindustry/world/Build.java b/core/src/io/anuke/mindustry/world/Build.java index 322c736c15..cc9b761488 100644 --- a/core/src/io/anuke/mindustry/world/Build.java +++ b/core/src/io/anuke/mindustry/world/Build.java @@ -5,9 +5,7 @@ import io.anuke.annotations.Annotations.Remote; import io.anuke.arc.Core; import io.anuke.arc.Events; import io.anuke.arc.math.Mathf; -import io.anuke.arc.math.geom.Geometry; -import io.anuke.arc.math.geom.Point2; -import io.anuke.arc.math.geom.Rectangle; +import io.anuke.arc.math.geom.*; import io.anuke.mindustry.content.Blocks; import io.anuke.mindustry.entities.Units; import io.anuke.mindustry.game.EventType.BlockBuildBeginEvent; @@ -20,7 +18,7 @@ import static io.anuke.mindustry.Vars.*; public class Build{ private static final Rectangle rect = new Rectangle(); - /**Returns block type that was broken, or null if unsuccesful.*/ + /** Returns block type that was broken, or null if unsuccesful. */ @Remote(called = Loc.server) public static void beginBreak(Team team, int x, int y){ if(!validBreak(team, x, y)){ @@ -59,7 +57,7 @@ public class Build{ if(!(worldx == tile.x && worldy == tile.y)){ Tile toplace = world.tile(worldx, worldy); if(toplace != null){ - toplace.setLinked((byte) (dx + offsetx), (byte) (dy + offsety)); + toplace.setLinked((byte)(dx + offsetx), (byte)(dy + offsety)); toplace.setTeam(team); } } @@ -71,7 +69,7 @@ public class Build{ Core.app.post(() -> Events.fire(new BlockBuildBeginEvent(ftile, team, true))); } - /**Places a BuildBlock at this location.*/ + /** Places a BuildBlock at this location. */ @Remote(called = Loc.server) public static void beginPlace(Team team, int x, int y, Block result, int rotation){ if(!validPlace(team, x, y, result, rotation)){ @@ -102,7 +100,7 @@ public class Build{ if(!(worldx == x && worldy == y)){ Tile toplace = world.tile(worldx, worldy); if(toplace != null){ - toplace.setLinked((byte) (dx + offsetx), (byte) (dy + offsety)); + toplace.setLinked((byte)(dx + offsetx), (byte)(dy + offsety)); toplace.setTeam(team); } } @@ -113,21 +111,21 @@ public class Build{ Core.app.post(() -> Events.fire(new BlockBuildBeginEvent(tile, team, false))); } - /**Returns whether a tile can be placed at this location by this team.*/ + /** Returns whether a tile can be placed at this location by this team. */ public static boolean validPlace(Team team, int x, int y, Block type, int rotation){ if(!type.isVisible() || type.isHidden()){ return false; } if((type.solid || type.solidifes) && - Units.anyEntities(rect.setSize(tilesize * type.size).setCenter(x * tilesize + type.offset(), y * tilesize + type.offset()))){ + Units.anyEntities(rect.setSize(tilesize * type.size).setCenter(x * tilesize + type.offset(), y * tilesize + type.offset()))){ return false; } //check for enemy cores for(Team enemy : state.teams.enemiesOf(team)){ for(Tile core : state.teams.get(enemy).cores){ - if(Mathf.dst(x*tilesize + type.offset(), y*tilesize + type.offset(), core.drawx(), core.drawy()) < state.rules.enemyCoreBuildRadius + type.size*tilesize/2f){ + if(Mathf.dst(x * tilesize + type.offset(), y * tilesize + type.offset(), core.drawx(), core.drawy()) < state.rules.enemyCoreBuildRadius + type.size * tilesize / 2f){ return false; } } @@ -156,8 +154,8 @@ public class Build{ for(int dy = 0; dy < type.size; dy++){ Tile other = world.tile(x + dx + offsetx, y + dy + offsety); if(other == null || (other.block() != Blocks.air && !other.block().alwaysReplace) || - !other.floor().placeableOn || - (other.floor().isDeep() && !type.floating)){ + !other.floor().placeableOn || + (other.floor().isDeep() && !type.floating)){ return false; } } @@ -165,12 +163,12 @@ public class Build{ return true; }else{ return tile.interactable(team) - && contactsGround(tile.x, tile.y, type) - && (!tile.floor().isDeep() || type.floating) - && tile.floor().placeableOn - && ((type.canReplace(tile.block()) - && !(type == tile.block() && rotation == tile.getRotation() && type.rotate)) || tile.block().alwaysReplace || tile.block() == Blocks.air) - && tile.block().isMultiblock() == type.isMultiblock() && type.canPlaceOn(tile); + && contactsGround(tile.x, tile.y, type) + && (!tile.floor().isDeep() || type.floating) + && tile.floor().placeableOn + && ((type.canReplace(tile.block()) + && !(type == tile.block() && rotation == tile.getRotation() && type.rotate)) || tile.block().alwaysReplace || tile.block() == Blocks.air) + && tile.block().isMultiblock() == type.isMultiblock() && type.canPlaceOn(tile); } } @@ -196,7 +194,7 @@ public class Build{ return false; } - /**Returns whether the tile at this position is breakable by this team*/ + /** Returns whether the tile at this position is breakable by this team */ public static boolean validBreak(Team team, int x, int y){ Tile tile = world.tile(x, y); if(tile != null) tile = tile.target(); diff --git a/core/src/io/anuke/mindustry/world/CachedTile.java b/core/src/io/anuke/mindustry/world/CachedTile.java index 6672bb6d2f..75dded63db 100644 --- a/core/src/io/anuke/mindustry/world/CachedTile.java +++ b/core/src/io/anuke/mindustry/world/CachedTile.java @@ -3,13 +3,12 @@ package io.anuke.mindustry.world; import io.anuke.arc.collection.IntMap; import io.anuke.mindustry.entities.type.TileEntity; import io.anuke.mindustry.game.Team; -import io.anuke.mindustry.world.modules.ConsumeModule; -import io.anuke.mindustry.world.modules.ItemModule; -import io.anuke.mindustry.world.modules.LiquidModule; -import io.anuke.mindustry.world.modules.PowerModule; +import io.anuke.mindustry.world.modules.*; -/**A tile which does not trigger change events and whose entity types are cached. - * Prevents garbage when loading previews.*/ +/** + * A tile which does not trigger change events and whose entity types are cached. + * Prevents garbage when loading previews. + */ public class CachedTile extends Tile{ private static IntMap entities = new IntMap<>(); diff --git a/core/src/io/anuke/mindustry/world/Edges.java b/core/src/io/anuke/mindustry/world/Edges.java index e3501f42ed..dc9586aca0 100644 --- a/core/src/io/anuke/mindustry/world/Edges.java +++ b/core/src/io/anuke/mindustry/world/Edges.java @@ -1,9 +1,7 @@ package io.anuke.mindustry.world; import io.anuke.arc.math.Mathf; -import io.anuke.arc.math.geom.Geometry; -import io.anuke.arc.math.geom.Point2; -import io.anuke.arc.math.geom.Vector2; +import io.anuke.arc.math.geom.*; import java.util.Arrays; @@ -22,8 +20,8 @@ public class Edges{ } for(int i = 0; i < maxSize; i++){ - int bot = -(int) (i / 2f) - 1; - int top = (int) (i / 2f + 0.5f) + 1; + int bot = -(int)(i / 2f) - 1; + int top = (int)(i / 2f + 0.5f) + 1; edges[i] = new Point2[(i + 1) * 4]; int idx = 0; @@ -45,8 +43,8 @@ public class Edges{ for(int j = 0; j < edges[i].length; j++){ Point2 point = edges[i][j]; - edgeInside[i][j] = new Point2(Mathf.clamp(point.x, -(int) ((i) / 2f), (int) (i / 2f + 0.5f)), - Mathf.clamp(point.y, -(int) ((i) / 2f), (int) (i / 2f + 0.5f))); + edgeInside[i][j] = new Point2(Mathf.clamp(point.x, -(int)((i) / 2f), (int)(i / 2f + 0.5f)), + Mathf.clamp(point.y, -(int)((i) / 2f), (int)(i / 2f + 0.5f))); } } } @@ -55,13 +53,13 @@ public class Edges{ if(!tile.block().isMultiblock()) return tile; int size = tile.block().size; return world.tile(tile.x + Mathf.clamp(other.x - tile.x, -(size - 1) / 2, (size / 2)), - tile.y + Mathf.clamp(other.y - tile.y, -(size - 1) / 2, (size / 2))); + tile.y + Mathf.clamp(other.y - tile.y, -(size - 1) / 2, (size / 2))); } public static Vector2[] getPixelPolygon(float radius){ if(radius < 1 || radius > maxRadius) throw new RuntimeException("Polygon size must be between 1 and " + maxRadius); - return polygons[(int) (radius * 2) - 1]; + return polygons[(int)(radius * 2) - 1]; } public static Point2[] getEdges(int size){ diff --git a/core/src/io/anuke/mindustry/world/ItemBuffer.java b/core/src/io/anuke/mindustry/world/ItemBuffer.java index d9f3b584ec..fbb16ad3e0 100644 --- a/core/src/io/anuke/mindustry/world/ItemBuffer.java +++ b/core/src/io/anuke/mindustry/world/ItemBuffer.java @@ -1,8 +1,6 @@ package io.anuke.mindustry.world; -import io.anuke.arc.util.NumberUtils; -import io.anuke.arc.util.Pack; -import io.anuke.arc.util.Time; +import io.anuke.arc.util.*; import io.anuke.mindustry.type.Item; import static io.anuke.mindustry.Vars.content; @@ -24,11 +22,11 @@ public class ItemBuffer{ public void accept(Item item, short data){ //if(!accepts()) return; - buffer[index++] = Pack.longInt(NumberUtils.floatToIntBits(Time.time()), Pack.shortInt((short) item.id, data)); + buffer[index++] = Pack.longInt(NumberUtils.floatToIntBits(Time.time()), Pack.shortInt((short)item.id, data)); } public void accept(Item item){ - accept(item, (short) -1); + accept(item, (short)-1); } public Item poll(){ diff --git a/core/src/io/anuke/mindustry/world/LegacyColorMapper.java b/core/src/io/anuke/mindustry/world/LegacyColorMapper.java index 2879f7d894..1c9e3f2ec1 100644 --- a/core/src/io/anuke/mindustry/world/LegacyColorMapper.java +++ b/core/src/io/anuke/mindustry/world/LegacyColorMapper.java @@ -45,7 +45,7 @@ public class LegacyColorMapper implements ContentList{ private void map(String color, Block block, Block wall, Block ore){ blockMap.put(Color.rgba8888(Color.valueOf(color)), new LegacyBlock(block, wall, ore)); } - + private void map(String color, Block block, Block wall){ blockMap.put(Color.rgba8888(Color.valueOf(color)), new LegacyBlock(block, wall)); } @@ -60,13 +60,13 @@ public class LegacyColorMapper implements ContentList{ public final Block ore; public LegacyBlock(Block floor, Block wall){ - this.floor = (Floor) floor; + this.floor = (Floor)floor; this.wall = wall; this.ore = null; } public LegacyBlock(Block floor, Block wall, Block ore){ - this.floor = (Floor) floor; + this.floor = (Floor)floor; this.wall = wall; this.ore = ore; } diff --git a/core/src/io/anuke/mindustry/world/Pos.java b/core/src/io/anuke/mindustry/world/Pos.java index 9a2860ee2a..97a4d560b8 100644 --- a/core/src/io/anuke/mindustry/world/Pos.java +++ b/core/src/io/anuke/mindustry/world/Pos.java @@ -1,21 +1,21 @@ package io.anuke.mindustry.world; -/**Methods for a packed position 'struct', contained in an int.*/ +/** Methods for a packed position 'struct', contained in an int. */ public class Pos{ public static final int invalid = get(-1, -1); - /**Returns packed position from an x/y position. The values must be within short limits.*/ + /** Returns packed position from an x/y position. The values must be within short limits. */ public static int get(int x, int y){ return (((short)x) << 16) | (((short)y) & 0xFFFF); } - /**Returns the x component of a position.*/ + /** Returns the x component of a position. */ public static short x(int pos){ - return (short) (pos >>> 16); + return (short)(pos >>> 16); } - /**Returns the y component of a position.*/ + /** Returns the y component of a position. */ public static short y(int pos){ - return (short) (pos & 0xFFFF); + return (short)(pos & 0xFFFF); } } diff --git a/core/src/io/anuke/mindustry/world/Tile.java b/core/src/io/anuke/mindustry/world/Tile.java index c83e26fc4b..7c9cdd4434 100644 --- a/core/src/io/anuke/mindustry/world/Tile.java +++ b/core/src/io/anuke/mindustry/world/Tile.java @@ -12,10 +12,7 @@ import io.anuke.mindustry.game.Team; import io.anuke.mindustry.type.Item; import io.anuke.mindustry.world.blocks.BlockPart; import io.anuke.mindustry.world.blocks.Floor; -import io.anuke.mindustry.world.modules.ConsumeModule; -import io.anuke.mindustry.world.modules.ItemModule; -import io.anuke.mindustry.world.modules.LiquidModule; -import io.anuke.mindustry.world.modules.PowerModule; +import io.anuke.mindustry.world.modules.*; import static io.anuke.mindustry.Vars.*; @@ -28,7 +25,7 @@ public class Tile implements Position, TargetTrait{ public byte link = 0; /** Tile traversal cost. */ public byte cost = 1; - /** Weight of [ground] units on this tile.*/ + /** Weight of [ground] units on this tile. */ public byte weight, airWeight = 0; /** Tile entity, usually null. */ public TileEntity entity; @@ -39,32 +36,32 @@ public class Tile implements Position, TargetTrait{ private byte rotation; /** Team ordinal. */ private byte team; - /**Ore that is on top of this (floor) block.*/ + /** Ore that is on top of this (floor) block. */ private byte ore = 0; public Tile(int x, int y){ - this.x = (short) x; - this.y = (short) y; + this.x = (short)x; + this.y = (short)y; wall = floor = (Floor)Blocks.air; } public Tile(int x, int y, byte floor, byte wall){ this(x, y); - this.floor = (Floor) content.block(floor); + this.floor = (Floor)content.block(floor); this.wall = content.block(wall); changed(); } public Tile(int x, int y, byte floor, byte wall, byte rotation, byte team){ this(x, y); - this.floor = (Floor) content.block(floor); + this.floor = (Floor)content.block(floor); this.wall = content.block(wall); this.rotation = rotation; changed(); this.team = team; } - /**Returns this tile's position as a {@link Pos}.*/ + /** Returns this tile's position as a {@link Pos}. */ public int pos(){ return Pos.get(x, y); } @@ -112,7 +109,7 @@ public class Tile implements Position, TargetTrait{ @SuppressWarnings("unchecked") public T entity(){ - return (T) entity; + return (T)entity; } public float worldx(){ @@ -150,7 +147,7 @@ public class Tile implements Position, TargetTrait{ } public void setTeam(Team team){ - this.team = (byte) team.ordinal(); + this.team = (byte)team.ordinal(); } public byte getTeamID(){ @@ -162,7 +159,7 @@ public class Tile implements Position, TargetTrait{ if(rotation < 0) rotation = (-rotation + 2); this.wall = type; this.link = 0; - setRotation((byte) (rotation % 4)); + setRotation((byte)(rotation % 4)); changed(); } diff --git a/core/src/io/anuke/mindustry/world/blocks/BlockPart.java b/core/src/io/anuke/mindustry/world/blocks/BlockPart.java index 307d567d88..bc82001109 100644 --- a/core/src/io/anuke/mindustry/world/blocks/BlockPart.java +++ b/core/src/io/anuke/mindustry/world/blocks/BlockPart.java @@ -41,8 +41,8 @@ public class BlockPart extends Block{ @Override public boolean isSolidFor(Tile tile){ return tile.getLinked() == null - || (tile.getLinked().block() instanceof BlockPart || tile.getLinked().solid() - || tile.getLinked().block().isSolidFor(tile.getLinked())); + || (tile.getLinked().block() instanceof BlockPart || tile.getLinked().solid() + || tile.getLinked().block().isSolidFor(tile.getLinked())); } @Override @@ -59,7 +59,7 @@ public class BlockPart extends Block{ public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount){ Block block = linked(tile); return block.hasLiquids - && block.acceptLiquid(tile.getLinked(), source, liquid, amount); + && block.acceptLiquid(tile.getLinked(), source, liquid, amount); } @Override diff --git a/core/src/io/anuke/mindustry/world/blocks/BuildBlock.java b/core/src/io/anuke/mindustry/world/blocks/BuildBlock.java index 033c1c815a..076bb4d301 100644 --- a/core/src/io/anuke/mindustry/world/blocks/BuildBlock.java +++ b/core/src/io/anuke/mindustry/world/blocks/BuildBlock.java @@ -13,23 +13,17 @@ import io.anuke.mindustry.content.Fx; import io.anuke.mindustry.entities.Effects; import io.anuke.mindustry.entities.effect.RubbleDecal; import io.anuke.mindustry.entities.traits.BuilderTrait.BuildRequest; -import io.anuke.mindustry.entities.type.Player; -import io.anuke.mindustry.entities.type.TileEntity; -import io.anuke.mindustry.entities.type.Unit; +import io.anuke.mindustry.entities.type.*; import io.anuke.mindustry.game.EventType.BlockBuildEndEvent; import io.anuke.mindustry.game.Team; import io.anuke.mindustry.gen.Call; -import io.anuke.mindustry.graphics.Layer; -import io.anuke.mindustry.graphics.Pal; -import io.anuke.mindustry.graphics.Shaders; +import io.anuke.mindustry.graphics.*; import io.anuke.mindustry.type.ItemStack; import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.modules.ItemModule; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; +import java.io.*; import static io.anuke.mindustry.Vars.*; @@ -203,7 +197,7 @@ public class BuildBlock extends Block{ if(builder instanceof Player){ builderID = builder.getID(); } - + if(progress >= 1f || state.rules.infiniteResources){ Call.onConstructFinish(tile, block, builderID, tile.getRotation(), builder.getTeam()); } @@ -246,7 +240,7 @@ public class BuildBlock extends Block{ for(int i = 0; i < block.buildRequirements.length; i++){ int sclamount = Math.round(state.rules.buildCostMultiplier * block.buildRequirements[i].amount); - int required = (int) (accumulator[i]); //calculate items that are required now + int required = (int)(accumulator[i]); //calculate items that are required now if(inventory.get(block.buildRequirements[i].item) == 0 && sclamount != 0){ maxProgress = 0f; @@ -254,7 +248,7 @@ public class BuildBlock extends Block{ //calculate how many items it can actually use int maxUse = Math.min(required, inventory.get(block.buildRequirements[i].item)); //get this as a fraction - float fraction = maxUse / (float) required; + float fraction = maxUse / (float)required; //move max progress down if this fraction is less than 1 maxProgress = Math.min(maxProgress, maxProgress * fraction); diff --git a/core/src/io/anuke/mindustry/world/blocks/Floor.java b/core/src/io/anuke/mindustry/world/blocks/Floor.java index e2b6328563..fffc752b7c 100644 --- a/core/src/io/anuke/mindustry/world/blocks/Floor.java +++ b/core/src/io/anuke/mindustry/world/blocks/Floor.java @@ -8,13 +8,9 @@ import io.anuke.arc.graphics.g2d.TextureRegion; import io.anuke.arc.math.Mathf; import io.anuke.arc.math.geom.Geometry; import io.anuke.arc.math.geom.Point2; -import io.anuke.mindustry.content.Blocks; -import io.anuke.mindustry.content.Fx; -import io.anuke.mindustry.content.StatusEffects; +import io.anuke.mindustry.content.*; import io.anuke.mindustry.entities.Effects.Effect; -import io.anuke.mindustry.type.Item; -import io.anuke.mindustry.type.Liquid; -import io.anuke.mindustry.type.StatusEffect; +import io.anuke.mindustry.type.*; import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Tile; @@ -49,13 +45,13 @@ public class Floor extends Block{ public boolean isLiquid; /** if true, this block cannot be mined by players. useful for annoying things like sand. */ public boolean playerUnmineable = false; - /**Style of the edge stencil. Loaded by looking up "edge-stencil-{name}".*/ + /** Style of the edge stencil. Loaded by looking up "edge-stencil-{name}". */ public String edgeStyle = "smooth"; - /**Group of blocks that this block does not draw edges on.*/ + /** Group of blocks that this block does not draw edges on. */ public Block blendGroup = this; - /**Effect displayed when randomly updated.*/ + /** Effect displayed when randomly updated. */ public Effect updateEffect = Fx.none; - /**Array of affinities to certain things.*/ + /** Array of affinities to certain things. */ public Attributes attributes = new Attributes(); protected TextureRegion[][] edges; @@ -147,7 +143,7 @@ public class Floor extends Block{ Point2 point = Geometry.d8[i]; Tile other = tile.getNearby(point); if(other != null && other.floor() == block){ - TextureRegion region = edge((Floor)block, type(i), 2-(point.x + 1), 2-(point.y + 1)); + TextureRegion region = edge((Floor)block, type(i), 2 - (point.x + 1), 2 - (point.y + 1)); Draw.rect(region, tile.worldx(), tile.worldy()); } } @@ -188,7 +184,7 @@ public class Floor extends Block{ } TextureRegion edge(Floor block, int type, int x, int y){ - return block.edges()[x + type*3][2-y]; + return block.edges()[x + type * 3][2 - y]; } } \ No newline at end of file diff --git a/core/src/io/anuke/mindustry/world/blocks/ItemSelection.java b/core/src/io/anuke/mindustry/world/blocks/ItemSelection.java index 85a64d57d9..2515f58ec8 100644 --- a/core/src/io/anuke/mindustry/world/blocks/ItemSelection.java +++ b/core/src/io/anuke/mindustry/world/blocks/ItemSelection.java @@ -1,13 +1,13 @@ package io.anuke.mindustry.world.blocks; import io.anuke.arc.collection.Array; -import io.anuke.mindustry.type.Item; import io.anuke.arc.function.Consumer; import io.anuke.arc.function.Supplier; import io.anuke.arc.scene.style.TextureRegionDrawable; import io.anuke.arc.scene.ui.ButtonGroup; import io.anuke.arc.scene.ui.ImageButton; import io.anuke.arc.scene.ui.layout.Table; +import io.anuke.mindustry.type.Item; import io.anuke.mindustry.type.Item.Icon; import static io.anuke.mindustry.Vars.*; diff --git a/core/src/io/anuke/mindustry/world/blocks/LiquidBlock.java b/core/src/io/anuke/mindustry/world/blocks/LiquidBlock.java index 9cb743e41e..f20db17790 100644 --- a/core/src/io/anuke/mindustry/world/blocks/LiquidBlock.java +++ b/core/src/io/anuke/mindustry/world/blocks/LiquidBlock.java @@ -1,12 +1,12 @@ package io.anuke.mindustry.world.blocks; import io.anuke.arc.Core; +import io.anuke.arc.graphics.g2d.Draw; import io.anuke.arc.graphics.g2d.TextureRegion; import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.meta.BlockGroup; import io.anuke.mindustry.world.modules.LiquidModule; -import io.anuke.arc.graphics.g2d.Draw; public class LiquidBlock extends Block{ protected TextureRegion liquidRegion, bottomRegion, topRegion; diff --git a/core/src/io/anuke/mindustry/world/blocks/Rock.java b/core/src/io/anuke/mindustry/world/blocks/Rock.java index 7f10510e96..a178ce74f0 100644 --- a/core/src/io/anuke/mindustry/world/blocks/Rock.java +++ b/core/src/io/anuke/mindustry/world/blocks/Rock.java @@ -1,11 +1,11 @@ package io.anuke.mindustry.world.blocks; import io.anuke.arc.Core; +import io.anuke.arc.graphics.g2d.Draw; import io.anuke.arc.graphics.g2d.TextureRegion; +import io.anuke.arc.math.Mathf; import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Tile; -import io.anuke.arc.graphics.g2d.Draw; -import io.anuke.arc.math.Mathf; public class Rock extends Block{ protected int variants; diff --git a/core/src/io/anuke/mindustry/world/blocks/StaticWall.java b/core/src/io/anuke/mindustry/world/blocks/StaticWall.java index cc2d73ce0b..fc02624015 100644 --- a/core/src/io/anuke/mindustry/world/blocks/StaticWall.java +++ b/core/src/io/anuke/mindustry/world/blocks/StaticWall.java @@ -28,7 +28,7 @@ public class StaticWall extends Rock{ if(Core.atlas.isFound(large) && eq(rx, ry) && Mathf.randomSeed(Pos.get(rx, ry)) < 0.5){ if(rx == tile.x && ry == tile.y){ - Draw.rect(large, tile.worldx() + tilesize/2f, tile.worldy() + tilesize/2f); + Draw.rect(large, tile.worldx() + tilesize / 2f, tile.worldy() + tilesize / 2f); } }else if(variants > 0){ Draw.rect(variantRegions[Mathf.randomSeed(tile.pos(), 0, Math.max(0, variantRegions.length - 1))], tile.worldx(), tile.worldy()); @@ -54,8 +54,8 @@ public class StaticWall extends Rock{ boolean eq(int rx, int ry){ return world.tile(rx + 1, ry).block() == this - && world.tile(rx, ry + 1).block() == this - && world.tile(rx, ry).block() == this - && world.tile(rx + 1, ry + 1).block() == this; + && world.tile(rx, ry + 1).block() == this + && world.tile(rx, ry).block() == this + && world.tile(rx + 1, ry + 1).block() == this; } } diff --git a/core/src/io/anuke/mindustry/world/blocks/TreeBlock.java b/core/src/io/anuke/mindustry/world/blocks/TreeBlock.java index 1aa7a8a6e9..9f3bb6d8d6 100644 --- a/core/src/io/anuke/mindustry/world/blocks/TreeBlock.java +++ b/core/src/io/anuke/mindustry/world/blocks/TreeBlock.java @@ -17,7 +17,8 @@ public class TreeBlock extends Block{ } @Override - public void draw(Tile tile){} + public void draw(Tile tile){ + } @Override public void drawLayer(Tile tile){ diff --git a/core/src/io/anuke/mindustry/world/blocks/defense/DeflectorWall.java b/core/src/io/anuke/mindustry/world/blocks/defense/DeflectorWall.java index 5d9b9080b9..1d0822d14f 100644 --- a/core/src/io/anuke/mindustry/world/blocks/defense/DeflectorWall.java +++ b/core/src/io/anuke/mindustry/world/blocks/defense/DeflectorWall.java @@ -4,12 +4,10 @@ import io.anuke.arc.graphics.Blending; import io.anuke.arc.graphics.Color; import io.anuke.arc.graphics.g2d.Draw; import io.anuke.arc.math.Mathf; -import io.anuke.arc.math.geom.Geometry; -import io.anuke.arc.math.geom.Rectangle; -import io.anuke.arc.math.geom.Vector2; +import io.anuke.arc.math.geom.*; import io.anuke.arc.util.Time; -import io.anuke.mindustry.entities.type.TileEntity; import io.anuke.mindustry.entities.bullet.Bullet; +import io.anuke.mindustry.entities.type.TileEntity; import io.anuke.mindustry.game.Team; import io.anuke.mindustry.world.Tile; @@ -56,7 +54,7 @@ public class DeflectorWall extends Wall{ bullet.hitbox(rect2); Vector2 position = Geometry.raycastRect(bullet.x, bullet.y, bullet.x + bullet.velocity().x, bullet.y + bullet.velocity().y, - rect.setCenter(entity.x, entity.y).setSize(size * tilesize + rect2.width + rect2.height)); + rect.setCenter(entity.x, entity.y).setSize(size * tilesize + rect2.width + rect2.height)); if(position != null){ bullet.set(position.x, position.y); @@ -73,7 +71,7 @@ public class DeflectorWall extends Wall{ bullet.scaleTime(1f); bullet.supress(); - ((DeflectorEntity) entity).hit = 1f; + ((DeflectorEntity)entity).hit = 1f; } @Override diff --git a/core/src/io/anuke/mindustry/world/blocks/defense/Door.java b/core/src/io/anuke/mindustry/world/blocks/defense/Door.java index d4c6fd75cc..5676592267 100644 --- a/core/src/io/anuke/mindustry/world/blocks/defense/Door.java +++ b/core/src/io/anuke/mindustry/world/blocks/defense/Door.java @@ -3,20 +3,18 @@ package io.anuke.mindustry.world.blocks.defense; import io.anuke.arc.Core; import io.anuke.arc.Graphics.Cursor; import io.anuke.arc.Graphics.Cursor.SystemCursor; -import io.anuke.mindustry.entities.Effects; -import io.anuke.mindustry.entities.Effects.Effect; import io.anuke.arc.graphics.g2d.Draw; import io.anuke.arc.graphics.g2d.TextureRegion; import io.anuke.arc.math.geom.Rectangle; import io.anuke.mindustry.content.Fx; +import io.anuke.mindustry.entities.Effects; +import io.anuke.mindustry.entities.Effects.Effect; +import io.anuke.mindustry.entities.Units; import io.anuke.mindustry.entities.type.Player; import io.anuke.mindustry.entities.type.TileEntity; -import io.anuke.mindustry.entities.Units; import io.anuke.mindustry.world.Tile; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; +import java.io.*; public class Door extends Wall{ protected final Rectangle rect = new Rectangle(); diff --git a/core/src/io/anuke/mindustry/world/blocks/defense/ForceProjector.java b/core/src/io/anuke/mindustry/world/blocks/defense/ForceProjector.java index 92b218c9e3..93bc7d6648 100644 --- a/core/src/io/anuke/mindustry/world/blocks/defense/ForceProjector.java +++ b/core/src/io/anuke/mindustry/world/blocks/defense/ForceProjector.java @@ -23,8 +23,8 @@ import java.io.*; import static io.anuke.mindustry.Vars.*; -public class ForceProjector extends Block { - protected int timerUse = timers ++; +public class ForceProjector extends Block{ + protected int timerUse = timers++; protected float phaseUseTime = 350f; protected float phaseRadiusBoost = 80f; @@ -57,7 +57,7 @@ public class ForceProjector extends Block { } }; - public ForceProjector(String name) { + public ForceProjector(String name){ super(name); update = true; solid = true; @@ -83,7 +83,7 @@ public class ForceProjector extends Block { stats.add(BlockStat.powerUse, basePowerDraw * 60f, StatUnit.powerSecond); stats.add(BlockStat.powerDamage, powerDamage, StatUnit.powerUnits); - stats.add(BlockStat.boostEffect, phaseRadiusBoost/tilesize, StatUnit.blocks); + stats.add(BlockStat.boostEffect, phaseRadiusBoost / tilesize, StatUnit.blocks); } @Override @@ -108,7 +108,7 @@ public class ForceProjector extends Block { boolean phaseValid = consumes.get(ConsumeType.item).valid(tile.entity); - entity.phaseHeat = Mathf.lerpDelta(entity.phaseHeat, Mathf.num(phaseValid), 0.1f); + entity.phaseHeat = Mathf.lerpDelta(entity.phaseHeat, Mathf.num(phaseValid), 0.1f); if(phaseValid && !entity.broken && entity.timer.get(timerUse, phaseUseTime)){ entity.cons.trigger(); @@ -117,7 +117,7 @@ public class ForceProjector extends Block { entity.radscl = Mathf.lerpDelta(entity.radscl, entity.broken ? 0f : 1f, 0.05f); if(Mathf.chance(Time.delta() * entity.buildup / breakage * 0.1f)){ - Effects.effect(Fx.reactorsmoke, tile.drawx() + Mathf.range(tilesize/2f), tile.drawy() + Mathf.range(tilesize/2f)); + Effects.effect(Fx.reactorsmoke, tile.drawx() + Mathf.range(tilesize / 2f), tile.drawy() + Mathf.range(tilesize / 2f)); } //use cases: @@ -140,7 +140,7 @@ public class ForceProjector extends Block { } }else{ entity.warmup = Mathf.lerpDelta(entity.warmup, 1f, 0.1f); - entity.power.satisfaction -= Math.min(entity.power.satisfaction, relativePowerDraw*Time.delta()); + entity.power.satisfaction -= Math.min(entity.power.satisfaction, relativePowerDraw * Time.delta()); } if(entity.buildup > 0){ @@ -148,10 +148,10 @@ public class ForceProjector extends Block { ConsumeLiquidFilter cons = consumes.get(ConsumeType.liquid); if(cons.valid(entity)){ cons.update(entity); - scale *= (cooldownLiquid * (1f+(entity.liquids.current().heatCapacity-0.4f)*0.9f)); + scale *= (cooldownLiquid * (1f + (entity.liquids.current().heatCapacity - 0.4f) * 0.9f)); } - entity.buildup -= Time.delta()*scale; + entity.buildup -= Time.delta() * scale; } if(entity.broken && entity.buildup <= 0 && entity.warmup >= 0.9f){ @@ -165,7 +165,7 @@ public class ForceProjector extends Block { } if(entity.hit > 0f){ - entity.hit -= 1f/5f * Time.delta(); + entity.hit -= 1f / 5f * Time.delta(); } float realRadius = realRadius(entity); @@ -173,18 +173,18 @@ public class ForceProjector extends Block { paramTile = tile; paramEntity = entity; paramBlock = this; - EntityQuery.getNearby(bulletGroup, tile.drawx(), tile.drawy(), realRadius*2f, shieldConsumer); + EntityQuery.getNearby(bulletGroup, tile.drawx(), tile.drawy(), realRadius * 2f, shieldConsumer); } float realRadius(ForceEntity entity){ - return (radius+entity.phaseHeat*phaseRadiusBoost) * entity.radscl; + return (radius + entity.phaseHeat * phaseRadiusBoost) * entity.radscl; } - boolean isInsideHexagon(float x0, float y0, float d, float x, float y) { - float dx = Math.abs(x - x0)/d; - float dy = Math.abs(y - y0)/d; + boolean isInsideHexagon(float x0, float y0, float d, float x, float y){ + float dx = Math.abs(x - x0) / d; + float dy = Math.abs(y - y0) / d; float a = 0.25f * Mathf.sqrt3; - return (dy <= a) && (a*dx + 0.25*dy <= 0.5*a); + return (dy <= a) && (a * dx + 0.25 * dy <= 0.5 * a); } @Override @@ -251,7 +251,7 @@ public class ForceProjector extends Block { @Override public float drawSize(){ - return realRadius(entity)*2f+2f; + return realRadius(entity) * 2f + 2f; } @Override @@ -271,7 +271,8 @@ public class ForceProjector extends Block { } public void drawSimple(){ - if(realRadius(entity) < 0.5f) return;; + if(realRadius(entity) < 0.5f) return; + ; float rad = realRadius(entity); @@ -294,6 +295,7 @@ public class ForceProjector extends Block { public ConsumeForceProjectorPower(float powerCapacity, float ticksToFill){ super(powerCapacity / ticksToFill, powerCapacity, true); } + @Override public boolean valid(TileEntity entity){ return entity.power.satisfaction >= basePowerDraw / powerCapacity && super.valid(entity); diff --git a/core/src/io/anuke/mindustry/world/blocks/defense/MendProjector.java b/core/src/io/anuke/mindustry/world/blocks/defense/MendProjector.java index f99dc77c19..df97089bda 100644 --- a/core/src/io/anuke/mindustry/world/blocks/defense/MendProjector.java +++ b/core/src/io/anuke/mindustry/world/blocks/defense/MendProjector.java @@ -2,16 +2,14 @@ package io.anuke.mindustry.world.blocks.defense; import io.anuke.arc.Core; import io.anuke.arc.collection.IntSet; -import io.anuke.mindustry.entities.Effects; import io.anuke.arc.graphics.Blending; import io.anuke.arc.graphics.Color; -import io.anuke.arc.graphics.g2d.Draw; -import io.anuke.arc.graphics.g2d.Lines; -import io.anuke.arc.graphics.g2d.TextureRegion; +import io.anuke.arc.graphics.g2d.*; import io.anuke.arc.math.Mathf; import io.anuke.arc.util.Time; import io.anuke.arc.util.Tmp; import io.anuke.mindustry.content.Fx; +import io.anuke.mindustry.entities.Effects; import io.anuke.mindustry.entities.type.TileEntity; import io.anuke.mindustry.graphics.Pal; import io.anuke.mindustry.world.Block; @@ -19,9 +17,7 @@ import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.meta.BlockStat; import io.anuke.mindustry.world.meta.StatUnit; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; +import java.io.*; import static io.anuke.mindustry.Vars.tilesize; import static io.anuke.mindustry.Vars.world; @@ -31,7 +27,7 @@ public class MendProjector extends Block{ private static Color phase = Color.valueOf("ffd59e"); private static IntSet healed = new IntSet(); - protected int timerUse = timers ++; + protected int timerUse = timers++; protected TextureRegion topRegion; protected float reload = 250f; @@ -62,7 +58,7 @@ public class MendProjector extends Block{ stats.add(BlockStat.repairTime, (int)(100f / healPercent * reload / 60f), StatUnit.seconds); stats.add(BlockStat.range, range / tilesize, StatUnit.blocks); - stats.add(BlockStat.boostEffect, phaseRangeBoost/tilesize, StatUnit.blocks); + stats.add(BlockStat.boostEffect, phaseRangeBoost / tilesize, StatUnit.blocks); stats.add(BlockStat.boostEffect, (phaseBoost + healPercent) / healPercent, StatUnit.timesSpeed); } @@ -95,7 +91,7 @@ public class MendProjector extends Block{ other = other.target(); if(other.getTeamID() == tile.getTeamID() && !healed.contains(other.pos()) && other.entity != null && other.entity.health < other.entity.maxHealth()){ - other.entity.healBy(other.entity.maxHealth() * (healPercent + entity.phaseHeat*phaseBoost)/100f * entity.power.satisfaction); + other.entity.healBy(other.entity.maxHealth() * (healPercent + entity.phaseHeat * phaseBoost) / 100f * entity.power.satisfaction); Effects.effect(Fx.healBlockFull, Tmp.c1.set(color).lerp(phase, entity.phaseHeat), other.drawx(), other.drawy(), other.block().size); healed.add(other.pos()); } @@ -135,8 +131,8 @@ public class MendProjector extends Block{ Draw.blend(); Draw.alpha(1f); - Lines.stroke((2f * f + 0.2f)* entity.heat); - Lines.circle(tile.drawx(), tile.drawy(), ((1f-f) * 8f) * size/2f); + Lines.stroke((2f * f + 0.2f) * entity.heat); + Lines.circle(tile.drawx(), tile.drawy(), ((1f - f) * 8f) * size / 2f); Draw.reset(); } diff --git a/core/src/io/anuke/mindustry/world/blocks/defense/OverdriveProjector.java b/core/src/io/anuke/mindustry/world/blocks/defense/OverdriveProjector.java index a9a198fd0d..1e284f2717 100644 --- a/core/src/io/anuke/mindustry/world/blocks/defense/OverdriveProjector.java +++ b/core/src/io/anuke/mindustry/world/blocks/defense/OverdriveProjector.java @@ -4,9 +4,7 @@ import io.anuke.arc.Core; import io.anuke.arc.collection.IntSet; import io.anuke.arc.graphics.Blending; import io.anuke.arc.graphics.Color; -import io.anuke.arc.graphics.g2d.Draw; -import io.anuke.arc.graphics.g2d.Lines; -import io.anuke.arc.graphics.g2d.TextureRegion; +import io.anuke.arc.graphics.g2d.*; import io.anuke.arc.math.Mathf; import io.anuke.arc.util.Time; import io.anuke.mindustry.entities.type.TileEntity; @@ -16,9 +14,7 @@ import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.meta.BlockStat; import io.anuke.mindustry.world.meta.StatUnit; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; +import java.io.*; import static io.anuke.mindustry.Vars.tilesize; import static io.anuke.mindustry.Vars.world; @@ -28,7 +24,7 @@ public class OverdriveProjector extends Block{ private static Color phase = Color.valueOf("ffd59e"); private static IntSet healed = new IntSet(); - protected int timerUse = timers ++; + protected int timerUse = timers++; protected TextureRegion topRegion; protected float reload = 60f; @@ -67,7 +63,7 @@ public class OverdriveProjector extends Block{ stats.add(BlockStat.speedIncrease, (int)(100f * speedBoost), StatUnit.percent); stats.add(BlockStat.range, range / tilesize, StatUnit.blocks); - stats.add(BlockStat.boostEffect, phaseRangeBoost/tilesize, StatUnit.blocks); + stats.add(BlockStat.boostEffect, phaseRangeBoost / tilesize, StatUnit.blocks); stats.add(BlockStat.boostEffect, (int)((speedBoost + speedBoostPhase) * 100f), StatUnit.percent); } @@ -85,7 +81,7 @@ public class OverdriveProjector extends Block{ if(entity.charge >= reload){ float realRange = range + entity.phaseHeat * phaseRangeBoost; - float realBoost = (speedBoost + entity.phaseHeat*speedBoostPhase) * entity.power.satisfaction; + float realBoost = (speedBoost + entity.phaseHeat * speedBoostPhase) * entity.power.satisfaction; entity.charge = 0f; @@ -104,7 +100,7 @@ public class OverdriveProjector extends Block{ if(other.getTeamID() == tile.getTeamID() && !healed.contains(other.pos()) && other.entity != null){ other.entity.timeScaleDuration = Math.max(other.entity.timeScaleDuration, reload + 1f); other.entity.timeScale = Math.max(other.entity.timeScale, realBoost); - healed.add(other.pos()); + healed.add(other.pos()); } } } @@ -134,8 +130,8 @@ public class OverdriveProjector extends Block{ Draw.rect(topRegion, tile.drawx(), tile.drawy()); Draw.blend(); Draw.alpha(1f); - Lines.stroke((2f * f + 0.2f)* entity.heat); - Lines.circle(tile.drawx(), tile.drawy(), (1f-f) * 9f); + Lines.stroke((2f * f + 0.2f) * entity.heat); + Lines.circle(tile.drawx(), tile.drawy(), (1f - f) * 9f); Draw.reset(); } diff --git a/core/src/io/anuke/mindustry/world/blocks/defense/ShockMine.java b/core/src/io/anuke/mindustry/world/blocks/defense/ShockMine.java index 94e8a0590c..e834812f5a 100644 --- a/core/src/io/anuke/mindustry/world/blocks/defense/ShockMine.java +++ b/core/src/io/anuke/mindustry/world/blocks/defense/ShockMine.java @@ -3,15 +3,15 @@ package io.anuke.mindustry.world.blocks.defense; import io.anuke.arc.graphics.g2d.Draw; import io.anuke.arc.graphics.g2d.Fill; import io.anuke.arc.math.Mathf; -import io.anuke.mindustry.entities.type.Unit; import io.anuke.mindustry.entities.effect.Lightning; +import io.anuke.mindustry.entities.type.Unit; import io.anuke.mindustry.graphics.Layer; import io.anuke.mindustry.graphics.Pal; import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Tile; public class ShockMine extends Block{ - protected int timerDamage = timers ++; + protected int timerDamage = timers++; protected float cooldown = 80f; protected float tileDamage = 5f; diff --git a/core/src/io/anuke/mindustry/world/blocks/defense/SurgeWall.java b/core/src/io/anuke/mindustry/world/blocks/defense/SurgeWall.java index e9a26e505a..d7cd84b321 100644 --- a/core/src/io/anuke/mindustry/world/blocks/defense/SurgeWall.java +++ b/core/src/io/anuke/mindustry/world/blocks/defense/SurgeWall.java @@ -1,10 +1,10 @@ package io.anuke.mindustry.world.blocks.defense; -import io.anuke.mindustry.entities.type.TileEntity; +import io.anuke.arc.math.Mathf; import io.anuke.mindustry.entities.bullet.Bullet; import io.anuke.mindustry.entities.effect.Lightning; +import io.anuke.mindustry.entities.type.TileEntity; import io.anuke.mindustry.graphics.Pal; -import io.anuke.arc.math.Mathf; public class SurgeWall extends Wall{ protected float lightningChance = 0.05f; diff --git a/core/src/io/anuke/mindustry/world/blocks/defense/turrets/BurstTurret.java b/core/src/io/anuke/mindustry/world/blocks/defense/turrets/BurstTurret.java index dac9df8e98..d746227559 100644 --- a/core/src/io/anuke/mindustry/world/blocks/defense/turrets/BurstTurret.java +++ b/core/src/io/anuke/mindustry/world/blocks/defense/turrets/BurstTurret.java @@ -23,7 +23,7 @@ public class BurstTurret extends ItemTurret{ for(int i = 0; i < shots; i++){ Time.run(burstSpacing * i, () -> { if(!(tile.entity instanceof TurretEntity) || - !hasAmmo(tile)) return; + !hasAmmo(tile)) return; entity.recoil = recoil; diff --git a/core/src/io/anuke/mindustry/world/blocks/defense/turrets/ChargeTurret.java b/core/src/io/anuke/mindustry/world/blocks/defense/turrets/ChargeTurret.java index 47faa0bd91..aa7151df98 100644 --- a/core/src/io/anuke/mindustry/world/blocks/defense/turrets/ChargeTurret.java +++ b/core/src/io/anuke/mindustry/world/blocks/defense/turrets/ChargeTurret.java @@ -1,12 +1,12 @@ package io.anuke.mindustry.world.blocks.defense.turrets; -import io.anuke.mindustry.entities.Effects; -import io.anuke.mindustry.entities.Effects.Effect; import io.anuke.arc.math.Mathf; import io.anuke.arc.util.Time; import io.anuke.mindustry.content.Fx; -import io.anuke.mindustry.entities.type.TileEntity; +import io.anuke.mindustry.entities.Effects; +import io.anuke.mindustry.entities.Effects.Effect; import io.anuke.mindustry.entities.bullet.BulletType; +import io.anuke.mindustry.entities.type.TileEntity; import io.anuke.mindustry.world.Tile; import static io.anuke.mindustry.Vars.tilesize; diff --git a/core/src/io/anuke/mindustry/world/blocks/defense/turrets/CooledTurret.java b/core/src/io/anuke/mindustry/world/blocks/defense/turrets/CooledTurret.java index d9cffb3be8..b425dd689d 100644 --- a/core/src/io/anuke/mindustry/world/blocks/defense/turrets/CooledTurret.java +++ b/core/src/io/anuke/mindustry/world/blocks/defense/turrets/CooledTurret.java @@ -7,16 +7,14 @@ import io.anuke.mindustry.entities.Effects; import io.anuke.mindustry.entities.Effects.Effect; import io.anuke.mindustry.type.Liquid; import io.anuke.mindustry.world.Tile; -import io.anuke.mindustry.world.consumers.ConsumeLiquidBase; -import io.anuke.mindustry.world.consumers.ConsumeLiquidFilter; -import io.anuke.mindustry.world.consumers.ConsumeType; +import io.anuke.mindustry.world.consumers.*; import io.anuke.mindustry.world.meta.BlockStat; import io.anuke.mindustry.world.meta.StatUnit; import static io.anuke.mindustry.Vars.tilesize; public class CooledTurret extends Turret{ - /**How much reload is lowered by for each unit of liquid of heat capacity.*/ + /** How much reload is lowered by for each unit of liquid of heat capacity. */ protected float coolantMultiplier = 5f; protected Effect coolEffect = Fx.fuelburn; diff --git a/core/src/io/anuke/mindustry/world/blocks/defense/turrets/ItemTurret.java b/core/src/io/anuke/mindustry/world/blocks/defense/turrets/ItemTurret.java index b9c2ea1bc6..6caa16390e 100644 --- a/core/src/io/anuke/mindustry/world/blocks/defense/turrets/ItemTurret.java +++ b/core/src/io/anuke/mindustry/world/blocks/defense/turrets/ItemTurret.java @@ -14,9 +14,7 @@ import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.meta.BlockStat; import io.anuke.mindustry.world.meta.values.AmmoListValue; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; +import java.io.*; public class ItemTurret extends CooledTurret{ protected int maxAmmo = 30; @@ -27,7 +25,7 @@ public class ItemTurret extends CooledTurret{ hasItems = true; } - /**Initializes accepted ammo map. Format: [item1, bullet1, item2, bullet2...]*/ + /** Initializes accepted ammo map. Format: [item1, bullet1, item2, bullet2...] */ protected void ammo(Object... objects){ ammo = OrderedMap.of(objects); } @@ -59,7 +57,7 @@ public class ItemTurret extends CooledTurret{ if(type == null) return 0; - return Math.min((int) ((maxAmmo - entity.totalAmmo) / ammo.get(item).ammoMultiplier), amount); + return Math.min((int)((maxAmmo - entity.totalAmmo) / ammo.get(item).ammoMultiplier), amount); } @Override @@ -96,7 +94,7 @@ public class ItemTurret extends CooledTurret{ } //must not be found - entity.ammo.add(new ItemEntry(item, (int) type.ammoMultiplier)); + entity.ammo.add(new ItemEntry(item, (int)type.ammoMultiplier)); } @Override diff --git a/core/src/io/anuke/mindustry/world/blocks/defense/turrets/LaserTurret.java b/core/src/io/anuke/mindustry/world/blocks/defense/turrets/LaserTurret.java index ef83d2d455..38703102e2 100644 --- a/core/src/io/anuke/mindustry/world/blocks/defense/turrets/LaserTurret.java +++ b/core/src/io/anuke/mindustry/world/blocks/defense/turrets/LaserTurret.java @@ -9,9 +9,7 @@ import io.anuke.mindustry.entities.bullet.BulletType; import io.anuke.mindustry.entities.type.TileEntity; import io.anuke.mindustry.type.Liquid; import io.anuke.mindustry.world.Tile; -import io.anuke.mindustry.world.consumers.ConsumeLiquidBase; -import io.anuke.mindustry.world.consumers.ConsumeLiquidFilter; -import io.anuke.mindustry.world.consumers.ConsumeType; +import io.anuke.mindustry.world.consumers.*; import io.anuke.mindustry.world.meta.BlockStat; import static io.anuke.mindustry.Vars.tilesize; @@ -35,7 +33,7 @@ public class LaserTurret extends PowerTurret{ } @Override - public void update(Tile tile) { + public void update(Tile tile){ super.update(tile); LaserTurretEntity entity = tile.entity(); diff --git a/core/src/io/anuke/mindustry/world/blocks/defense/turrets/LiquidTurret.java b/core/src/io/anuke/mindustry/world/blocks/defense/turrets/LiquidTurret.java index 7fcbb36e05..48e3f52c77 100644 --- a/core/src/io/anuke/mindustry/world/blocks/defense/turrets/LiquidTurret.java +++ b/core/src/io/anuke/mindustry/world/blocks/defense/turrets/LiquidTurret.java @@ -22,7 +22,7 @@ public abstract class LiquidTurret extends Turret{ hasLiquids = true; } - /**Initializes accepted ammo map. Format: [liquid1, bullet1, liquid2, bullet2...]*/ + /** Initializes accepted ammo map. Format: [liquid1, bullet1, liquid2, bullet2...] */ protected void ammo(Object... objects){ ammo = OrderedMap.of(objects); } @@ -35,21 +35,21 @@ public abstract class LiquidTurret extends Turret{ } @Override - protected boolean validateTarget(Tile tile) { + protected boolean validateTarget(Tile tile){ TurretEntity entity = tile.entity(); if(entity.liquids.current().canExtinguish() && entity.target instanceof Tile){ - return Fire.has(((Tile) entity.target).x, ((Tile) entity.target).y); + return Fire.has(((Tile)entity.target).x, ((Tile)entity.target).y); } return super.validateTarget(tile); } @Override - protected void findTarget(Tile tile) { + protected void findTarget(Tile tile){ TurretEntity entity = tile.entity(); if(entity.liquids.current().canExtinguish()){ int tr = (int)(range / tilesize); - for (int x = -tr; x <= tr; x++) { - for (int y = -tr; y <= tr; y++) { + for(int x = -tr; x <= tr; x++){ + for(int y = -tr; y <= tr; y++){ if(Fire.has(x + tile.x, y + tile.y)){ entity.target = world.tile(x + tile.x, y + tile.y); return; @@ -105,7 +105,7 @@ public abstract class LiquidTurret extends Turret{ @Override public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount){ return ammo.get(liquid) != null - && (tile.entity.liquids.current() == liquid || (ammo.containsKey(tile.entity.liquids.current()) && tile.entity.liquids.get(tile.entity.liquids.current()) <= ammo.get(tile.entity.liquids.current()).ammoMultiplier + 0.001f)); + && (tile.entity.liquids.current() == liquid || (ammo.containsKey(tile.entity.liquids.current()) && tile.entity.liquids.get(tile.entity.liquids.current()) <= ammo.get(tile.entity.liquids.current()).ammoMultiplier + 0.001f)); } } diff --git a/core/src/io/anuke/mindustry/world/blocks/defense/turrets/Turret.java b/core/src/io/anuke/mindustry/world/blocks/defense/turrets/Turret.java index c257eea735..3755868fb9 100644 --- a/core/src/io/anuke/mindustry/world/blocks/defense/turrets/Turret.java +++ b/core/src/io/anuke/mindustry/world/blocks/defense/turrets/Turret.java @@ -3,33 +3,26 @@ package io.anuke.mindustry.world.blocks.defense.turrets; import io.anuke.arc.Core; import io.anuke.arc.collection.Array; import io.anuke.arc.collection.EnumSet; -import io.anuke.mindustry.entities.Effects; -import io.anuke.mindustry.entities.Effects.Effect; import io.anuke.arc.function.BiConsumer; import io.anuke.arc.graphics.Blending; import io.anuke.arc.graphics.Color; -import io.anuke.arc.graphics.g2d.Draw; -import io.anuke.arc.graphics.g2d.Lines; -import io.anuke.arc.graphics.g2d.TextureRegion; +import io.anuke.arc.graphics.g2d.*; import io.anuke.arc.math.Angles; import io.anuke.arc.math.Mathf; import io.anuke.arc.math.geom.Vector2; import io.anuke.arc.util.Time; import io.anuke.mindustry.content.Fx; -import io.anuke.mindustry.entities.Predict; -import io.anuke.mindustry.entities.type.TileEntity; -import io.anuke.mindustry.entities.Units; +import io.anuke.mindustry.entities.*; +import io.anuke.mindustry.entities.Effects.Effect; import io.anuke.mindustry.entities.bullet.Bullet; import io.anuke.mindustry.entities.bullet.BulletType; import io.anuke.mindustry.entities.traits.TargetTrait; +import io.anuke.mindustry.entities.type.TileEntity; import io.anuke.mindustry.graphics.Layer; import io.anuke.mindustry.graphics.Pal; import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Tile; -import io.anuke.mindustry.world.meta.BlockFlag; -import io.anuke.mindustry.world.meta.BlockGroup; -import io.anuke.mindustry.world.meta.BlockStat; -import io.anuke.mindustry.world.meta.StatUnit; +import io.anuke.mindustry.world.meta.*; import static io.anuke.mindustry.Vars.tilesize; @@ -66,7 +59,7 @@ public abstract class Turret extends Block{ protected TextureRegion baseRegion, heatRegion; protected BiConsumer drawer = (tile, entity) -> - Draw.rect(region, tile.drawx() + tr2.x, tile.drawy() + tr2.y, entity.rotation - 90); + Draw.rect(region, tile.drawx() + tr2.x, tile.drawy() + tr2.y, entity.rotation - 90); protected BiConsumer heatDrawer = (tile, entity) -> { if(entity.heat <= 0.00001f) return; Draw.color(heatColor, entity.heat); @@ -105,7 +98,7 @@ public abstract class Turret extends Block{ super.setStats(); stats.add(BlockStat.shootRange, range, StatUnit.blocks); - stats.add(BlockStat.inaccuracy, (int) inaccuracy, StatUnit.degrees); + stats.add(BlockStat.inaccuracy, (int)inaccuracy, StatUnit.degrees); stats.add(BlockStat.reload, 60f / reload * shots, StatUnit.none); stats.add(BlockStat.shots, shots, StatUnit.none); stats.add(BlockStat.targetsAir, targetAir); @@ -203,7 +196,7 @@ public abstract class Turret extends Block{ TurretEntity entity = tile.entity(); entity.target = Units.getClosestTarget(tile.getTeam(), - tile.drawx(), tile.drawy(), range, e -> !e.isDead() && (!e.isFlying() || targetAir) && (e.isFlying() || targetGround)); + tile.drawx(), tile.drawy(), range, e -> !e.isDead() && (!e.isFlying() || targetAir) && (e.isFlying() || targetGround)); } protected void turnToTarget(Tile tile, float targetRot){ @@ -216,7 +209,7 @@ public abstract class Turret extends Block{ return true; } - /**Consume ammo and return a type.*/ + /** Consume ammo and return a type. */ public BulletType useAmmo(Tile tile){ if(tile.isEnemyCheat()) return peekAmmo(tile); @@ -268,7 +261,7 @@ public abstract class Turret extends Block{ tr.trns(entity.rotation, size * tilesize / 2f, Mathf.range(xRand)); for(int i = 0; i < shots; i++){ - bullet(tile, type, entity.rotation + Mathf.range(inaccuracy + type.inaccuracy) + (i-shots/2) * spread); + bullet(tile, type, entity.rotation + Mathf.range(inaccuracy + type.inaccuracy) + (i - shots / 2) * spread); } effects(tile); @@ -300,7 +293,7 @@ public abstract class Turret extends Block{ TurretEntity entity = tile.entity(); Effects.effect(ammoUseEffect, tile.drawx() - Angles.trnsx(entity.rotation, ammoEjectBack), - tile.drawy() - Angles.trnsy(entity.rotation, ammoEjectBack), entity.rotation); + tile.drawy() - Angles.trnsy(entity.rotation, ammoEjectBack), entity.rotation); } protected boolean isTurret(Tile tile){ diff --git a/core/src/io/anuke/mindustry/world/blocks/distribution/BufferedItemBridge.java b/core/src/io/anuke/mindustry/world/blocks/distribution/BufferedItemBridge.java index 6e833659c5..709c84300e 100644 --- a/core/src/io/anuke/mindustry/world/blocks/distribution/BufferedItemBridge.java +++ b/core/src/io/anuke/mindustry/world/blocks/distribution/BufferedItemBridge.java @@ -1,10 +1,10 @@ package io.anuke.mindustry.world.blocks.distribution; +import io.anuke.arc.math.Mathf; import io.anuke.mindustry.entities.type.TileEntity; import io.anuke.mindustry.type.Item; import io.anuke.mindustry.world.ItemBuffer; import io.anuke.mindustry.world.Tile; -import io.anuke.arc.math.Mathf; public class BufferedItemBridge extends ExtendingItemBridge{ protected int timerAccept = timers++; diff --git a/core/src/io/anuke/mindustry/world/blocks/distribution/Conduit.java b/core/src/io/anuke/mindustry/world/blocks/distribution/Conduit.java index 8097ef6325..44c54540ce 100644 --- a/core/src/io/anuke/mindustry/world/blocks/distribution/Conduit.java +++ b/core/src/io/anuke/mindustry/world/blocks/distribution/Conduit.java @@ -1,18 +1,16 @@ package io.anuke.mindustry.world.blocks.distribution; import io.anuke.arc.Core; +import io.anuke.arc.graphics.g2d.Draw; import io.anuke.arc.graphics.g2d.TextureRegion; +import io.anuke.arc.math.Mathf; import io.anuke.mindustry.entities.type.TileEntity; import io.anuke.mindustry.type.Liquid; import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.blocks.LiquidBlock; import io.anuke.mindustry.world.modules.LiquidModule; -import io.anuke.arc.graphics.g2d.Draw; -import io.anuke.arc.math.Mathf; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; +import java.io.*; public class Conduit extends LiquidBlock{ protected final int timerFlow = timers++; diff --git a/core/src/io/anuke/mindustry/world/blocks/distribution/Conveyor.java b/core/src/io/anuke/mindustry/world/blocks/distribution/Conveyor.java index 45d87e6b2e..fe2f550a6c 100644 --- a/core/src/io/anuke/mindustry/world/blocks/distribution/Conveyor.java +++ b/core/src/io/anuke/mindustry/world/blocks/distribution/Conveyor.java @@ -5,12 +5,8 @@ import io.anuke.arc.collection.LongArray; import io.anuke.arc.graphics.g2d.Draw; import io.anuke.arc.graphics.g2d.TextureRegion; import io.anuke.arc.math.Mathf; -import io.anuke.arc.math.geom.Geometry; -import io.anuke.arc.math.geom.Point2; -import io.anuke.arc.math.geom.Vector2; -import io.anuke.arc.util.Log; -import io.anuke.arc.util.Pack; -import io.anuke.arc.util.Time; +import io.anuke.arc.math.geom.*; +import io.anuke.arc.util.*; import io.anuke.mindustry.entities.type.TileEntity; import io.anuke.mindustry.entities.type.Unit; import io.anuke.mindustry.graphics.Layer; @@ -18,13 +14,9 @@ import io.anuke.mindustry.input.InputHandler.PlaceDraw; import io.anuke.mindustry.type.Item; import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Tile; -import io.anuke.mindustry.world.meta.BlockGroup; -import io.anuke.mindustry.world.meta.BlockStat; -import io.anuke.mindustry.world.meta.StatUnit; +import io.anuke.mindustry.world.meta.*; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; +import java.io.*; import static io.anuke.mindustry.Vars.*; @@ -79,9 +71,9 @@ public class Conveyor extends Block{ ConveyorEntity entity = tile.entity(); byte rotation = tile.getRotation(); - int frame = entity.clogHeat <= 0.5f ? (int) (((Time.time() * speed * 8f * entity.timeScale)) % 4) : 0; + int frame = entity.clogHeat <= 0.5f ? (int)(((Time.time() * speed * 8f * entity.timeScale)) % 4) : 0; Draw.rect(regions[Mathf.clamp(entity.blendbits, 0, regions.length - 1)][Mathf.clamp(frame, 0, regions[0].length - 1)], tile.drawx(), tile.drawy(), - tilesize * entity.blendsclx, tilesize * entity.blendscly, rotation*90); + tilesize * entity.blendsclx, tilesize * entity.blendscly, rotation * 90); } @Override @@ -162,8 +154,8 @@ public class Conveyor extends Block{ tr2.trns(rotation * 90, -tilesize / 2f, pos.x * tilesize / 2f); Draw.rect(pos.item.icon(Item.Icon.medium), - (tile.x * tilesize + tr1.x * pos.y + tr2.x), - (tile.y * tilesize + tr1.y * pos.y + tr2.y), itemSize, itemSize); + (tile.x * tilesize + tr1.x * pos.y + tr2.x), + (tile.y * tilesize + tr1.y * pos.y + tr2.y), itemSize, itemSize); } }catch(IndexOutOfBoundsException e){ @@ -321,7 +313,7 @@ public class Conveyor extends Block{ int direction = source == null ? 0 : Math.abs(source.relativeTo(tile.x, tile.y) - tile.getRotation()); float minitem = tile.entity().minitem; return (((direction == 0) && minitem > itemSpace) || - ((direction % 2 == 1) && minitem > 0.52f)) && (source == null || !(source.block().rotate && (source.getRotation() + 2) % 4 == tile.getRotation())); + ((direction % 2 == 1) && minitem > 0.52f)) && (source == null || !(source.block().rotate && (source.getRotation() + 2) % 4 == tile.getRotation())); } @Override @@ -350,7 +342,7 @@ public class Conveyor extends Block{ //this item must be greater than anything there... entity.convey.add(result); - entity.lastInserted = (byte)(entity.convey.size-1); + entity.lastInserted = (byte)(entity.convey.size - 1); } @Override @@ -407,9 +399,9 @@ public class Conveyor extends Block{ static long packItem(Item item, float x, float y){ short[] shorts = packShorts; - shorts[0] = (short) item.id; - shorts[1] = (short) (x * Short.MAX_VALUE); - shorts[2] = (short) ((y - 1f) * Short.MAX_VALUE); + shorts[0] = (short)item.id; + shorts[1] = (short)(x * Short.MAX_VALUE); + shorts[2] = (short)((y - 1f) * Short.MAX_VALUE); return Pack.longShorts(shorts); } @@ -417,13 +409,13 @@ public class Conveyor extends Block{ short[] values = Pack.shorts(value, writeShort); short itemid = values[0]; - float x = values[1] / (float) Short.MAX_VALUE; - float y = ((float) values[2]) / Short.MAX_VALUE + 1f; + float x = values[1] / (float)Short.MAX_VALUE; + float y = ((float)values[2]) / Short.MAX_VALUE + 1f; byte[] bytes = writeByte; - bytes[0] = (byte) itemid; - bytes[1] = (byte) (x * 127); - bytes[2] = (byte) (y * 255 - 128); + bytes[0] = (byte)itemid; + bytes[1] = (byte)(x * 127); + bytes[2] = (byte)(y * 255 - 128); return Pack.intBytes(bytes); } @@ -433,12 +425,12 @@ public class Conveyor extends Block{ byte itemid = values[0]; float x = values[1] / 127f; - float y = ((int) values[2] + 128) / 255f; + float y = ((int)values[2] + 128) / 255f; short[] shorts = writeShort; - shorts[0] = (short) itemid; - shorts[1] = (short) (x * Short.MAX_VALUE); - shorts[2] = (short) ((y - 1f) * Short.MAX_VALUE); + shorts[0] = (short)itemid; + shorts[1] = (short)(x * Short.MAX_VALUE); + shorts[2] = (short)((y - 1f) * Short.MAX_VALUE); return Pack.longShorts(shorts); } @@ -450,8 +442,8 @@ public class Conveyor extends Block{ else item = content.items().get(values[0]); - x = values[1] / (float) Short.MAX_VALUE; - y = ((float) values[2]) / Short.MAX_VALUE + 1f; + x = values[1] / (float)Short.MAX_VALUE; + y = ((float)values[2]) / Short.MAX_VALUE + 1f; return this; } diff --git a/core/src/io/anuke/mindustry/world/blocks/distribution/ExtendingItemBridge.java b/core/src/io/anuke/mindustry/world/blocks/distribution/ExtendingItemBridge.java index 1df134830f..4f145022c7 100644 --- a/core/src/io/anuke/mindustry/world/blocks/distribution/ExtendingItemBridge.java +++ b/core/src/io/anuke/mindustry/world/blocks/distribution/ExtendingItemBridge.java @@ -1,8 +1,6 @@ package io.anuke.mindustry.world.blocks.distribution; -import io.anuke.arc.graphics.g2d.CapStyle; -import io.anuke.arc.graphics.g2d.Draw; -import io.anuke.arc.graphics.g2d.Lines; +import io.anuke.arc.graphics.g2d.*; import io.anuke.arc.math.Mathf; import io.anuke.arc.math.geom.Geometry; import io.anuke.mindustry.world.Tile; @@ -27,22 +25,22 @@ public class ExtendingItemBridge extends ItemBridge{ int i = tile.absoluteRelativeTo(other.x, other.y); float ex = other.worldx() - tile.worldx() - Geometry.d4[i].x * tilesize / 2f, - ey = other.worldy() - tile.worldy() - Geometry.d4[i].y * tilesize / 2f; + ey = other.worldy() - tile.worldy() - Geometry.d4[i].y * tilesize / 2f; ex *= entity.uptime; ey *= entity.uptime; Lines.stroke(8f); Lines.line(bridgeRegion, - tile.worldx() + Geometry.d4[i].x * tilesize / 2f, - tile.worldy() + Geometry.d4[i].y * tilesize / 2f, - tile.worldx() + ex, - tile.worldy() + ey, CapStyle.none, 0f); + tile.worldx() + Geometry.d4[i].x * tilesize / 2f, + tile.worldy() + Geometry.d4[i].y * tilesize / 2f, + tile.worldx() + ex, + tile.worldy() + ey, CapStyle.none, 0f); Draw.rect(endRegion, tile.drawx(), tile.drawy(), i * 90 + 90); Draw.rect(endRegion, - tile.worldx() + ex + Geometry.d4[i].x * tilesize / 2f, - tile.worldy() + ey + Geometry.d4[i].y * tilesize / 2f, i * 90 + 270); + tile.worldx() + ex + Geometry.d4[i].x * tilesize / 2f, + tile.worldy() + ey + Geometry.d4[i].y * tilesize / 2f, i * 90 + 270); int dist = Math.max(Math.abs(other.x - tile.x), Math.abs(other.y - tile.y)); @@ -51,10 +49,10 @@ public class ExtendingItemBridge extends ItemBridge{ Draw.color(); for(int a = 0; a < arrows; a++){ - Draw.alpha(Mathf.absin(a / (float) arrows - entity.time / 100f, 0.1f, 1f) * entity.uptime); + Draw.alpha(Mathf.absin(a / (float)arrows - entity.time / 100f, 0.1f, 1f) * entity.uptime); Draw.rect(arrowRegion, - tile.worldx() + Geometry.d4[i].x * (tilesize / 2f + a * 6f + 2) * entity.uptime, - tile.worldy() + Geometry.d4[i].y * (tilesize / 2f + a * 6f + 2) * entity.uptime, i * 90f); + tile.worldx() + Geometry.d4[i].x * (tilesize / 2f + a * 6f + 2) * entity.uptime, + tile.worldy() + Geometry.d4[i].y * (tilesize / 2f + a * 6f + 2) * entity.uptime, i * 90f); } Draw.reset(); } diff --git a/core/src/io/anuke/mindustry/world/blocks/distribution/ItemBridge.java b/core/src/io/anuke/mindustry/world/blocks/distribution/ItemBridge.java index 73d224b2d9..2218991af5 100644 --- a/core/src/io/anuke/mindustry/world/blocks/distribution/ItemBridge.java +++ b/core/src/io/anuke/mindustry/world/blocks/distribution/ItemBridge.java @@ -17,15 +17,10 @@ import io.anuke.mindustry.gen.Call; import io.anuke.mindustry.graphics.Layer; import io.anuke.mindustry.graphics.Pal; import io.anuke.mindustry.type.Item; -import io.anuke.mindustry.world.Block; -import io.anuke.mindustry.world.Edges; -import io.anuke.mindustry.world.Pos; -import io.anuke.mindustry.world.Tile; +import io.anuke.mindustry.world.*; import io.anuke.mindustry.world.meta.BlockGroup; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; +import java.io.*; import static io.anuke.mindustry.Vars.tilesize; import static io.anuke.mindustry.Vars.world; @@ -117,8 +112,8 @@ public class ItemBridge extends Block{ int rot = link.absoluteRelativeTo(x, y); float w = (link.x == x ? tilesize : Math.abs(link.x - x) * tilesize - tilesize); float h = (link.y == y ? tilesize : Math.abs(link.y - y) * tilesize - tilesize); - Lines.rect((x + link.x)/2f * tilesize - w/2f, (y + link.y)/2f * tilesize - h/2f, w, h); - Fill.poly(link.x * tilesize + Geometry.d4[rot].x * tilesize, link.y * tilesize + Geometry.d4[rot].y * tilesize, 3, 2.8f, link.absoluteRelativeTo(x, y)*90); + Lines.rect((x + link.x) / 2f * tilesize - w / 2f, (y + link.y) / 2f * tilesize - h / 2f, w, h); + Fill.poly(link.x * tilesize + Geometry.d4[rot].x * tilesize, link.y * tilesize + Geometry.d4[rot].y * tilesize, 3, 2.8f, link.absoluteRelativeTo(x, y) * 90); } Draw.reset(); } @@ -130,7 +125,7 @@ public class ItemBridge extends Block{ Draw.color(Pal.accent); Lines.stroke(1f); Lines.square(tile.drawx(), tile.drawy(), - tile.block().size * tilesize / 2f + 1f); + tile.block().size * tilesize / 2f + 1f); for(int i = 1; i <= range; i++){ for(int j = 0; j < 4; j++){ @@ -140,7 +135,7 @@ public class ItemBridge extends Block{ Draw.color(linked ? Pal.place : Pal.breakInvalid); Lines.square(other.drawx(), other.drawy(), - other.block().size * tilesize / 2f + 1f + (linked ? 0f : Mathf.absin(Time.time(), 4f, 1f))); + other.block().size * tilesize / 2f + 1f + (linked ? 0f : Mathf.absin(Time.time(), 4f, 1f))); } } } @@ -234,10 +229,10 @@ public class ItemBridge extends Block{ Lines.stroke(8f); Lines.line(bridgeRegion, - tile.worldx(), - tile.worldy(), - other.worldx(), - other.worldy(), CapStyle.none, -tilesize / 2f); + tile.worldx(), + tile.worldy(), + other.worldx(), + other.worldy(), CapStyle.none, -tilesize / 2f); int dist = Math.max(Math.abs(other.x - tile.x), Math.abs(other.y - tile.y)); @@ -247,10 +242,10 @@ public class ItemBridge extends Block{ Draw.color(); for(int a = 0; a < arrows; a++){ - Draw.alpha(Mathf.absin(a / (float) arrows - entity.time / 100f, 0.1f, 1f) * entity.uptime); + Draw.alpha(Mathf.absin(a / (float)arrows - entity.time / 100f, 0.1f, 1f) * entity.uptime); Draw.rect(arrowRegion, - tile.worldx() + Geometry.d4[i].x * (tilesize / 2f + a * 4f + time % 4f), - tile.worldy() + Geometry.d4[i].y * (tilesize / 2f + a * 4f + time % 4f), i * 90f); + tile.worldx() + Geometry.d4[i].x * (tilesize / 2f + a * 4f + time % 4f), + tile.worldy() + Geometry.d4[i].y * (tilesize / 2f + a * 4f + time % 4f), i * 90f); } Draw.reset(); } diff --git a/core/src/io/anuke/mindustry/world/blocks/distribution/Junction.java b/core/src/io/anuke/mindustry/world/blocks/distribution/Junction.java index 84a6f32c6b..2e145a59e5 100644 --- a/core/src/io/anuke/mindustry/world/blocks/distribution/Junction.java +++ b/core/src/io/anuke/mindustry/world/blocks/distribution/Junction.java @@ -1,8 +1,6 @@ package io.anuke.mindustry.world.blocks.distribution; -import io.anuke.arc.util.NumberUtils; -import io.anuke.arc.util.Pack; -import io.anuke.arc.util.Time; +import io.anuke.arc.util.*; import io.anuke.mindustry.entities.type.TileEntity; import io.anuke.mindustry.type.Item; import io.anuke.mindustry.world.Block; diff --git a/core/src/io/anuke/mindustry/world/blocks/distribution/LiquidBridge.java b/core/src/io/anuke/mindustry/world/blocks/distribution/LiquidBridge.java index f33becc63a..1999136d89 100644 --- a/core/src/io/anuke/mindustry/world/blocks/distribution/LiquidBridge.java +++ b/core/src/io/anuke/mindustry/world/blocks/distribution/LiquidBridge.java @@ -28,7 +28,7 @@ public class LiquidBridge extends ItemBridge{ entity.time2 += (entity.cycleSpeed - 1f) * Time.delta(); Tile other = world.tile(entity.link); - if(!linkValid(tile, other) ){ + if(!linkValid(tile, other)){ tryDumpLiquid(tile, entity.liquids.current()); }else{ if(entity.cons.valid()){ diff --git a/core/src/io/anuke/mindustry/world/blocks/distribution/LiquidJunction.java b/core/src/io/anuke/mindustry/world/blocks/distribution/LiquidJunction.java index 7dfd439bc6..8e57c24777 100644 --- a/core/src/io/anuke/mindustry/world/blocks/distribution/LiquidJunction.java +++ b/core/src/io/anuke/mindustry/world/blocks/distribution/LiquidJunction.java @@ -1,12 +1,12 @@ package io.anuke.mindustry.world.blocks.distribution; import io.anuke.arc.Core; +import io.anuke.arc.graphics.g2d.Draw; import io.anuke.arc.graphics.g2d.TextureRegion; import io.anuke.mindustry.type.Liquid; import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.blocks.LiquidBlock; import io.anuke.mindustry.world.meta.BlockStat; -import io.anuke.arc.graphics.g2d.Draw; public class LiquidJunction extends LiquidBlock{ diff --git a/core/src/io/anuke/mindustry/world/blocks/distribution/MassDriver.java b/core/src/io/anuke/mindustry/world/blocks/distribution/MassDriver.java index 55464a8972..8cb1ea19d7 100644 --- a/core/src/io/anuke/mindustry/world/blocks/distribution/MassDriver.java +++ b/core/src/io/anuke/mindustry/world/blocks/distribution/MassDriver.java @@ -4,12 +4,8 @@ import io.anuke.annotations.Annotations.Loc; import io.anuke.annotations.Annotations.Remote; import io.anuke.arc.Core; import io.anuke.arc.collection.ObjectSet; -import io.anuke.mindustry.entities.Effects; -import io.anuke.mindustry.entities.Effects.Effect; import io.anuke.arc.graphics.Color; -import io.anuke.arc.graphics.g2d.Draw; -import io.anuke.arc.graphics.g2d.Lines; -import io.anuke.arc.graphics.g2d.TextureRegion; +import io.anuke.arc.graphics.g2d.*; import io.anuke.arc.math.Angles; import io.anuke.arc.math.Mathf; import io.anuke.arc.util.Time; @@ -17,22 +13,21 @@ import io.anuke.arc.util.pooling.Pool.Poolable; import io.anuke.arc.util.pooling.Pools; import io.anuke.mindustry.content.Bullets; import io.anuke.mindustry.content.Fx; +import io.anuke.mindustry.entities.Effects; +import io.anuke.mindustry.entities.Effects.Effect; +import io.anuke.mindustry.entities.bullet.Bullet; import io.anuke.mindustry.entities.type.Player; import io.anuke.mindustry.entities.type.TileEntity; -import io.anuke.mindustry.entities.bullet.Bullet; import io.anuke.mindustry.gen.Call; import io.anuke.mindustry.graphics.Layer; import io.anuke.mindustry.graphics.Pal; import io.anuke.mindustry.type.Item; import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Tile; -import io.anuke.mindustry.world.consumers.ConsumePower; import io.anuke.mindustry.world.meta.BlockStat; import io.anuke.mindustry.world.meta.StatUnit; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; +import java.io.*; import static io.anuke.mindustry.Vars.*; @@ -73,7 +68,7 @@ public class MassDriver extends Block{ //just in case the client has invalid data if(!(tile.entity instanceof MassDriverEntity) || !(target.entity instanceof MassDriverEntity)) return; - MassDriver driver = (MassDriver) tile.block(); + MassDriver driver = (MassDriver)tile.block(); MassDriverEntity entity = tile.entity(); MassDriverEntity other = target.entity(); @@ -87,7 +82,7 @@ public class MassDriver extends Block{ data.to = other; int totalUsed = 0; for(int i = 0; i < content.items().size; i++){ - int maxTransfer = Math.min(entity.items.get(content.item(i)), ((MassDriver) tile.block()).itemCapacity - totalUsed); + int maxTransfer = Math.min(entity.items.get(content.item(i)), ((MassDriver)tile.block()).itemCapacity - totalUsed); data.items[i] = maxTransfer; totalUsed += maxTransfer; } @@ -97,14 +92,14 @@ public class MassDriver extends Block{ other.isRecieving = true; Bullet.create(Bullets.driverBolt, entity, entity.getTeam(), - tile.drawx() + Angles.trnsx(angle, driver.translation), tile.drawy() + Angles.trnsy(angle, driver.translation), - angle, 1f, 1f, data); + tile.drawx() + Angles.trnsx(angle, driver.translation), tile.drawy() + Angles.trnsy(angle, driver.translation), + angle, 1f, 1f, data); Effects.effect(driver.shootEffect, tile.drawx() + Angles.trnsx(angle, driver.translation), - tile.drawy() + Angles.trnsy(angle, driver.translation), angle); + tile.drawy() + Angles.trnsy(angle, driver.translation), angle); Effects.effect(driver.smokeEffect, tile.drawx() + Angles.trnsx(angle, driver.translation), - tile.drawy() + Angles.trnsy(angle, driver.translation), angle); + tile.drawy() + Angles.trnsy(angle, driver.translation), angle); Effects.shake(driver.shake, driver.shake, entity); } @@ -157,9 +152,9 @@ public class MassDriver extends Block{ entity.rotation = Mathf.slerpDelta(entity.rotation, tile.angleTo(waiter), rotateSpeed); }else if(tile.entity.items.total() >= minDistribute && - linkValid(tile) && //only fire when at 100% power capacity - tile.entity.power.satisfaction >= powerPercentageUsed && - link.block().itemCapacity - link.entity.items.total() >= minDistribute && entity.reload <= 0.0001f){ + linkValid(tile) && //only fire when at 100% power capacity + tile.entity.power.satisfaction >= powerPercentageUsed && + link.block().itemCapacity - link.entity.items.total() >= minDistribute && entity.reload <= 0.0001f){ MassDriverEntity other = link.entity(); other.waiting.add(tile); @@ -188,8 +183,8 @@ public class MassDriver extends Block{ MassDriverEntity entity = tile.entity(); Draw.rect(region, - tile.drawx() + Angles.trnsx(entity.rotation + 180f, entity.reload * knockback), - tile.drawy() + Angles.trnsy(entity.rotation + 180f, entity.reload * knockback), entity.rotation - 90); + tile.drawx() + Angles.trnsx(entity.rotation + 180f, entity.reload * knockback), + tile.drawy() + Angles.trnsy(entity.rotation + 180f, entity.reload * knockback), entity.rotation - 90); } @Override @@ -198,7 +193,7 @@ public class MassDriver extends Block{ Draw.color(Pal.accent); Lines.stroke(1f); - Lines.poly(tile.drawx(), tile.drawy(), 20, (tile.block().size/2f+1) * tilesize + sin); + Lines.poly(tile.drawx(), tile.drawy(), 20, (tile.block().size / 2f + 1) * tilesize + sin); MassDriverEntity entity = tile.entity(); @@ -206,7 +201,7 @@ public class MassDriver extends Block{ Tile target = world.tile(entity.link); Draw.color(Pal.place); - Lines.poly(target.drawx(), target.drawy(), 20, (target.block().size/2f+1) * tilesize + sin); + Lines.poly(target.drawx(), target.drawy(), 20, (target.block().size / 2f + 1) * tilesize + sin); Draw.reset(); } @@ -278,12 +273,12 @@ public class MassDriver extends Block{ //add all the items possible for(int i = 0; i < data.items.length; i++){ - int maxAdd = Math.min(data.items[i], itemCapacity*2 - totalItems); + int maxAdd = Math.min(data.items[i], itemCapacity * 2 - totalItems); items.add(content.item(i), maxAdd); data.items[i] -= maxAdd; totalItems += maxAdd; - if(totalItems >= itemCapacity*2){ + if(totalItems >= itemCapacity * 2){ break; } } diff --git a/core/src/io/anuke/mindustry/world/blocks/distribution/OverflowGate.java b/core/src/io/anuke/mindustry/world/blocks/distribution/OverflowGate.java index 3b22972f08..6ba2d1496b 100644 --- a/core/src/io/anuke/mindustry/world/blocks/distribution/OverflowGate.java +++ b/core/src/io/anuke/mindustry/world/blocks/distribution/OverflowGate.java @@ -1,10 +1,10 @@ package io.anuke.mindustry.world.blocks.distribution; +import io.anuke.arc.math.Mathf; +import io.anuke.arc.util.Time; import io.anuke.mindustry.type.Item; import io.anuke.mindustry.world.Edges; import io.anuke.mindustry.world.Tile; -import io.anuke.arc.util.Time; -import io.anuke.arc.math.Mathf; public class OverflowGate extends Router{ @@ -23,7 +23,7 @@ public class OverflowGate extends Router{ } if(entity.lastItem != null){ - entity.time += 1f/speed * Time.delta(); + entity.time += 1f / speed * Time.delta(); Tile target = getTileTarget(tile, entity.lastItem, entity.lastInput, false); if(target != null && (entity.time >= 1f)){ @@ -60,10 +60,10 @@ public class OverflowGate extends Router{ }else{ if(tile.getDump() == 0){ to = a; - if(flip) tile.setDump((byte) 1); + if(flip) tile.setDump((byte)1); }else{ to = b; - if(flip) tile.setDump((byte) 0); + if(flip) tile.setDump((byte)0); } } } diff --git a/core/src/io/anuke/mindustry/world/blocks/distribution/Router.java b/core/src/io/anuke/mindustry/world/blocks/distribution/Router.java index e0761b0201..a272f1011e 100644 --- a/core/src/io/anuke/mindustry/world/blocks/distribution/Router.java +++ b/core/src/io/anuke/mindustry/world/blocks/distribution/Router.java @@ -4,9 +4,7 @@ import io.anuke.arc.collection.Array; import io.anuke.arc.util.Time; import io.anuke.mindustry.entities.type.TileEntity; import io.anuke.mindustry.type.Item; -import io.anuke.mindustry.world.Block; -import io.anuke.mindustry.world.Edges; -import io.anuke.mindustry.world.Tile; +import io.anuke.mindustry.world.*; import io.anuke.mindustry.world.meta.BlockGroup; public class Router extends Block{ @@ -30,7 +28,7 @@ public class Router extends Block{ } if(entity.lastItem != null){ - entity.time += 1f/speed * Time.delta(); + entity.time += 1f / speed * Time.delta(); Tile target = getTileTarget(tile, entity.lastItem, entity.lastInput, false); if(target != null && (entity.time >= 1f || !(target.block() instanceof Router))){ @@ -64,7 +62,7 @@ public class Router extends Block{ for(int i = 0; i < proximity.size; i++){ Tile other = proximity.get((i + counter) % proximity.size); if(tile == from) continue; - if(set) tile.setDump((byte) ((tile.getDump() + 1) % proximity.size)); + if(set) tile.setDump((byte)((tile.getDump() + 1) % proximity.size)); if(other.block().acceptItem(item, other, Edges.getFacingEdge(tile, other))){ return other; } diff --git a/core/src/io/anuke/mindustry/world/blocks/distribution/Sorter.java b/core/src/io/anuke/mindustry/world/blocks/distribution/Sorter.java index 9744aae4de..e62e0da1a8 100644 --- a/core/src/io/anuke/mindustry/world/blocks/distribution/Sorter.java +++ b/core/src/io/anuke/mindustry/world/blocks/distribution/Sorter.java @@ -3,6 +3,9 @@ package io.anuke.mindustry.world.blocks.distribution; import io.anuke.annotations.Annotations.Loc; import io.anuke.annotations.Annotations.Remote; import io.anuke.arc.Core; +import io.anuke.arc.graphics.g2d.Draw; +import io.anuke.arc.math.Mathf; +import io.anuke.arc.scene.ui.layout.Table; import io.anuke.mindustry.entities.type.Player; import io.anuke.mindustry.entities.type.TileEntity; import io.anuke.mindustry.gen.Call; @@ -11,13 +14,8 @@ import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.blocks.ItemSelection; import io.anuke.mindustry.world.meta.BlockGroup; -import io.anuke.arc.graphics.g2d.Draw; -import io.anuke.arc.scene.ui.layout.Table; -import io.anuke.arc.math.Mathf; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; +import java.io.*; import static io.anuke.mindustry.Vars.content; @@ -90,9 +88,9 @@ public class Sorter extends Block{ Tile a = dest.getNearby(Mathf.mod(dir - 1, 4)); Tile b = dest.getNearby(Mathf.mod(dir + 1, 4)); boolean ac = a != null && !(a.block().instantTransfer && source.block().instantTransfer) && - a.block().acceptItem(item, a, dest); + a.block().acceptItem(item, a, dest); boolean bc = b != null && !(b.block().instantTransfer && source.block().instantTransfer) && - b.block().acceptItem(item, b, dest); + b.block().acceptItem(item, b, dest); if(ac && !bc){ to = a; @@ -104,11 +102,11 @@ public class Sorter extends Block{ if(dest.getDump() == 0){ to = a; if(flip) - dest.setDump((byte) 1); + dest.setDump((byte)1); }else{ to = b; if(flip) - dest.setDump((byte) 0); + dest.setDump((byte)0); } } } diff --git a/core/src/io/anuke/mindustry/world/blocks/power/ImpactReactor.java b/core/src/io/anuke/mindustry/world/blocks/power/ImpactReactor.java index 7446acf1ad..af40e9fe27 100644 --- a/core/src/io/anuke/mindustry/world/blocks/power/ImpactReactor.java +++ b/core/src/io/anuke/mindustry/world/blocks/power/ImpactReactor.java @@ -6,9 +6,7 @@ import io.anuke.arc.graphics.Color; import io.anuke.arc.graphics.g2d.Draw; import io.anuke.arc.graphics.g2d.TextureRegion; import io.anuke.arc.math.Mathf; -import io.anuke.arc.util.Strings; -import io.anuke.arc.util.Time; -import io.anuke.arc.util.Tmp; +import io.anuke.arc.util.*; import io.anuke.mindustry.content.Fx; import io.anuke.mindustry.entities.Damage; import io.anuke.mindustry.entities.Effects; @@ -19,9 +17,7 @@ import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.meta.BlockStat; import io.anuke.mindustry.world.meta.StatUnit; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; +import java.io.*; import static io.anuke.mindustry.Vars.tilesize; @@ -51,10 +47,10 @@ public class ImpactReactor extends PowerGenerator{ super.setBars(); bars.add("poweroutput", entity -> new Bar(() -> - Core.bundle.format("bar.poweroutput", - Strings.fixed(Math.max(entity.block.getPowerProduction(entity.tile) - consumes.getPower().powerPerTick, 0)*60 * entity.timeScale, 1)), - () -> Pal.powerBar, - () -> ((GeneratorEntity)entity).productionEfficiency)); + Core.bundle.format("bar.poweroutput", + Strings.fixed(Math.max(entity.block.getPowerProduction(entity.tile) - consumes.getPower().powerPerTick, 0) * 60 * entity.timeScale, 1)), + () -> Pal.powerBar, + () -> ((GeneratorEntity)entity).productionEfficiency)); } @Override @@ -73,7 +69,7 @@ public class ImpactReactor extends PowerGenerator{ if(entity.cons.valid()){ entity.warmup = Mathf.lerpDelta(entity.warmup, 1f, warmupSpeed); if(Mathf.isEqual(entity.warmup, 1f, 0.001f)){ - entity.warmup =1f; + entity.warmup = 1f; } if(entity.timer.get(timerUse, itemDuration)){ @@ -95,7 +91,7 @@ public class ImpactReactor extends PowerGenerator{ for(int i = 0; i < plasmas; i++){ float r = 29f + Mathf.absin(Time.time(), 2f + i * 1f, 5f - i * 0.5f); - Draw.color(plasma1, plasma2, (float) i / plasmas); + Draw.color(plasma1, plasma2, (float)i / plasmas); Draw.alpha((0.3f + Mathf.absin(Time.time(), 2f + i * 2f, 0.3f + i * 0.05f)) * entity.warmup); Draw.blend(Blending.additive); Draw.rect(name + "-plasma-" + i, tile.drawx(), tile.drawy(), r, r, Time.time() * (12 + i * 6f) * entity.warmup); diff --git a/core/src/io/anuke/mindustry/world/blocks/power/NuclearReactor.java b/core/src/io/anuke/mindustry/world/blocks/power/NuclearReactor.java index 80c1ba1d96..cd98e33184 100644 --- a/core/src/io/anuke/mindustry/world/blocks/power/NuclearReactor.java +++ b/core/src/io/anuke/mindustry/world/blocks/power/NuclearReactor.java @@ -80,7 +80,7 @@ public class NuclearReactor extends PowerGenerator{ Item item = consumes.get(ConsumeType.item).items[0].item; int fuel = entity.items.get(item); - float fullness = (float) fuel / itemCapacity; + float fullness = (float)fuel / itemCapacity; entity.productionEfficiency = fullness; if(fuel > 0){ @@ -104,7 +104,7 @@ public class NuclearReactor extends PowerGenerator{ float smoke = 1.0f + (entity.heat - smokeThreshold) / (1f - smokeThreshold); //ranges from 1.0 to 2.0 if(Mathf.chance(smoke / 20.0 * entity.delta())){ Effects.effect(Fx.reactorsmoke, tile.worldx() + Mathf.range(size * tilesize / 2f), - tile.worldy() + Mathf.random(size * tilesize / 2f)); + tile.worldy() + Mathf.random(size * tilesize / 2f)); } } diff --git a/core/src/io/anuke/mindustry/world/blocks/power/PowerGenerator.java b/core/src/io/anuke/mindustry/world/blocks/power/PowerGenerator.java index c109117fdd..fa0043dbbc 100644 --- a/core/src/io/anuke/mindustry/world/blocks/power/PowerGenerator.java +++ b/core/src/io/anuke/mindustry/world/blocks/power/PowerGenerator.java @@ -7,14 +7,9 @@ import io.anuke.mindustry.entities.type.TileEntity; import io.anuke.mindustry.graphics.Pal; import io.anuke.mindustry.ui.Bar; import io.anuke.mindustry.world.Tile; -import io.anuke.mindustry.world.consumers.ConsumePower; -import io.anuke.mindustry.world.meta.BlockFlag; -import io.anuke.mindustry.world.meta.BlockStat; -import io.anuke.mindustry.world.meta.StatUnit; +import io.anuke.mindustry.world.meta.*; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; +import java.io.*; public class PowerGenerator extends PowerDistributor{ /** The amount of power produced per tick in case of an efficiency of 1.0, which represents 100%. */ @@ -40,7 +35,7 @@ public class PowerGenerator extends PowerDistributor{ if(hasPower && outputsPower && !consumes.hasPower()){ bars.add("power", entity -> new Bar(() -> Core.bundle.format("bar.poweroutput", - Strings.fixed(entity.block.getPowerProduction(entity.tile)*60 * entity.timeScale, 1)), + Strings.fixed(entity.block.getPowerProduction(entity.tile) * 60 * entity.timeScale, 1)), () -> Pal.powerBar, () -> ((GeneratorEntity)entity).productionEfficiency)); } diff --git a/core/src/io/anuke/mindustry/world/blocks/power/PowerGraph.java b/core/src/io/anuke/mindustry/world/blocks/power/PowerGraph.java index 97de582e27..f3a8494104 100644 --- a/core/src/io/anuke/mindustry/world/blocks/power/PowerGraph.java +++ b/core/src/io/anuke/mindustry/world/blocks/power/PowerGraph.java @@ -1,17 +1,12 @@ package io.anuke.mindustry.world.blocks.power; import io.anuke.arc.Core; -import io.anuke.arc.collection.Array; -import io.anuke.arc.collection.IntSet; -import io.anuke.arc.collection.ObjectSet; -import io.anuke.arc.collection.Queue; +import io.anuke.arc.collection.*; import io.anuke.arc.math.Mathf; import io.anuke.arc.math.WindowedMean; import io.anuke.arc.util.Time; import io.anuke.mindustry.world.Tile; -import io.anuke.mindustry.world.consumers.Consume; -import io.anuke.mindustry.world.consumers.ConsumePower; -import io.anuke.mindustry.world.consumers.Consumers; +import io.anuke.mindustry.world.consumers.*; public class PowerGraph{ private final static Queue queue = new Queue<>(); @@ -269,12 +264,12 @@ public class PowerGraph{ @Override public String toString(){ return "PowerGraph{" + - "producers=" + producers + - ", consumers=" + consumers + - ", batteries=" + batteries + - ", all=" + all + - ", lastFrameUpdated=" + lastFrameUpdated + - ", graphID=" + graphID + - '}'; + "producers=" + producers + + ", consumers=" + consumers + + ", batteries=" + batteries + + ", all=" + all + + ", lastFrameUpdated=" + lastFrameUpdated + + ", graphID=" + graphID + + '}'; } } diff --git a/core/src/io/anuke/mindustry/world/blocks/power/PowerNode.java b/core/src/io/anuke/mindustry/world/blocks/power/PowerNode.java index 166eefb351..6c32d91b99 100644 --- a/core/src/io/anuke/mindustry/world/blocks/power/PowerNode.java +++ b/core/src/io/anuke/mindustry/world/blocks/power/PowerNode.java @@ -10,15 +10,11 @@ import io.anuke.arc.math.Angles; import io.anuke.arc.math.Mathf; import io.anuke.arc.math.geom.Intersector; import io.anuke.arc.math.geom.Vector2; -import io.anuke.arc.util.Strings; -import io.anuke.arc.util.Time; -import io.anuke.arc.util.Tmp; +import io.anuke.arc.util.*; import io.anuke.mindustry.entities.type.Player; import io.anuke.mindustry.entities.type.TileEntity; import io.anuke.mindustry.gen.Call; -import io.anuke.mindustry.graphics.Layer; -import io.anuke.mindustry.graphics.Pal; -import io.anuke.mindustry.graphics.Shapes; +import io.anuke.mindustry.graphics.*; import io.anuke.mindustry.ui.Bar; import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.blocks.PowerBlock; @@ -50,7 +46,7 @@ public class PowerNode extends PowerBlock{ @Remote(targets = Loc.both, called = Loc.server, forward = true) public static void linkPowerNodes(Player player, Tile tile, Tile other){ if(tile.entity.power == null || !((PowerNode)tile.block()).linkValid(tile, other) - || tile.entity.power.links.size >= ((PowerNode)tile.block()).maxNodes) return; + || tile.entity.power.links.size >= ((PowerNode)tile.block()).maxNodes) return; TileEntity entity = tile.entity(); @@ -94,10 +90,10 @@ public class PowerNode extends PowerBlock{ public void setBars(){ super.setBars(); bars.add("power", entity -> new Bar(() -> - Core.bundle.format("bar.powerbalance", - ((entity.power.graph.getPowerBalance() >= 0 ? "+" : "") + Strings.fixed(entity.power.graph.getPowerBalance()*60, 1))), - () -> Pal.powerBar, - () -> Mathf.clamp(entity.power.graph.getPowerProduced() / entity.power.graph.getPowerNeeded()))); + Core.bundle.format("bar.powerbalance", + ((entity.power.graph.getPowerBalance() >= 0 ? "+" : "") + Strings.fixed(entity.power.graph.getPowerBalance() * 60, 1))), + () -> Pal.powerBar, + () -> Mathf.clamp(entity.power.graph.getPowerProduced() / entity.power.graph.getPowerNeeded()))); } @Override @@ -153,7 +149,7 @@ public class PowerNode extends PowerBlock{ Lines.stroke(1f); Draw.color(Pal.accent); - Lines.poly(tile.drawx(), tile.drawy(), 50, laserRange*tilesize); + Lines.poly(tile.drawx(), tile.drawy(), 50, laserRange * tilesize); Draw.reset(); } @@ -165,12 +161,12 @@ public class PowerNode extends PowerBlock{ Lines.stroke(1.5f); Lines.circle(tile.drawx(), tile.drawy(), - tile.block().size * tilesize / 2f + 1f + Mathf.absin(Time.time(), 4f, 1f)); + tile.block().size * tilesize / 2f + 1f + Mathf.absin(Time.time(), 4f, 1f)); - Lines.poly(tile.drawx(), tile.drawy(), 50, laserRange*tilesize); + Lines.poly(tile.drawx(), tile.drawy(), 50, laserRange * tilesize); - for(int x = (int) (tile.x - laserRange - 1); x <= tile.x + laserRange + 1; x++){ - for(int y = (int) (tile.y - laserRange - 1); y <= tile.y + laserRange + 1; y++){ + for(int x = (int)(tile.x - laserRange - 1); x <= tile.x + laserRange + 1; x++){ + for(int y = (int)(tile.y - laserRange - 1); y <= tile.y + laserRange + 1; y++){ Tile link = world.tile(x, y); if(link != null) link = link.target(); @@ -179,9 +175,9 @@ public class PowerNode extends PowerBlock{ Draw.color(linked ? Pal.place : Pal.breakInvalid); Lines.circle(link.drawx(), link.drawy(), - link.block().size * tilesize / 2f + 1f + (linked ? 0f : Mathf.absin(Time.time(), 4f, 1f))); + link.block().size * tilesize / 2f + 1f + (linked ? 0f : Mathf.absin(Time.time(), 4f, 1f))); - if((entity.power.links.size >= maxNodes || (link.block() instanceof PowerNode && link.entity.power.links.size >= ((PowerNode) link.block()).maxNodes)) && !linked){ + if((entity.power.links.size >= maxNodes || (link.block() instanceof PowerNode && link.entity.power.links.size >= ((PowerNode)link.block()).maxNodes)) && !linked){ Draw.color(Pal.breakInvalid); Lines.lineAngleCenter(link.drawx(), link.drawy(), 45, link.block().size * Mathf.sqrt2 * tilesize * 0.9f); Draw.color(); @@ -197,7 +193,7 @@ public class PowerNode extends PowerBlock{ public void drawPlace(int x, int y, int rotation, boolean valid){ Lines.stroke(1f); Draw.color(Pal.placing); - Lines.poly(x * tilesize + offset(), y * tilesize + offset(), 50, laserRange*tilesize); + Lines.poly(x * tilesize + offset(), y * tilesize + offset(), 50, laserRange * tilesize); Draw.reset(); } @@ -228,7 +224,7 @@ public class PowerNode extends PowerBlock{ protected boolean linkValid(Tile tile, Tile link, boolean checkMaxNodes){ if(tile == link || link == null || !link.block().hasPower || tile.getTeam() != link.getTeam()) return false; - if(overlaps(tile, link, laserRange*tilesize) || (link.block() instanceof PowerNode && overlaps(link, tile, link.cblock().laserRange*tilesize))){ + if(overlaps(tile, link, laserRange * tilesize) || (link.block() instanceof PowerNode && overlaps(link, tile, link.cblock().laserRange * tilesize))){ if(checkMaxNodes && link.block() instanceof PowerNode){ return link.entity.power.links.size < link.cblock().maxNodes || link.entity.power.links.contains(tile.pos()); } @@ -244,7 +240,7 @@ public class PowerNode extends PowerBlock{ protected void drawLaser(Tile tile, Tile target){ float x1 = tile.drawx(), y1 = tile.drawy(), - x2 = target.drawx(), y2 = target.drawy(); + x2 = target.drawx(), y2 = target.drawy(); float angle1 = Angles.angle(x1, y1, x2, y2); float angle2 = angle1 + 180f; diff --git a/core/src/io/anuke/mindustry/world/blocks/power/SolarGenerator.java b/core/src/io/anuke/mindustry/world/blocks/power/SolarGenerator.java index 96f3109fc9..fd8f9cf642 100644 --- a/core/src/io/anuke/mindustry/world/blocks/power/SolarGenerator.java +++ b/core/src/io/anuke/mindustry/world/blocks/power/SolarGenerator.java @@ -1,8 +1,8 @@ package io.anuke.mindustry.world.blocks.power; +import io.anuke.arc.collection.EnumSet; import io.anuke.mindustry.entities.type.TileEntity; import io.anuke.mindustry.world.meta.StatUnit; -import io.anuke.arc.collection.EnumSet; public class SolarGenerator extends PowerGenerator{ diff --git a/core/src/io/anuke/mindustry/world/blocks/power/ThermalGenerator.java b/core/src/io/anuke/mindustry/world/blocks/power/ThermalGenerator.java index 56bfddf304..be88b2ff01 100644 --- a/core/src/io/anuke/mindustry/world/blocks/power/ThermalGenerator.java +++ b/core/src/io/anuke/mindustry/world/blocks/power/ThermalGenerator.java @@ -26,7 +26,7 @@ public class ThermalGenerator extends PowerGenerator{ @Override public void drawPlace(int x, int y, int rotation, boolean valid){ - drawPlaceText(Core.bundle.formatFloat("bar.efficiency", sumAttribute(Attribute.heat, x, y)*100, 1), x, y, valid); + drawPlaceText(Core.bundle.formatFloat("bar.efficiency", sumAttribute(Attribute.heat, x, y) * 100, 1), x, y, valid); } @Override diff --git a/core/src/io/anuke/mindustry/world/blocks/production/Cultivator.java b/core/src/io/anuke/mindustry/world/blocks/production/Cultivator.java index 5748dd5ea1..955c786520 100644 --- a/core/src/io/anuke/mindustry/world/blocks/production/Cultivator.java +++ b/core/src/io/anuke/mindustry/world/blocks/production/Cultivator.java @@ -2,9 +2,7 @@ package io.anuke.mindustry.world.blocks.production; import io.anuke.arc.Core; import io.anuke.arc.graphics.Color; -import io.anuke.arc.graphics.g2d.Draw; -import io.anuke.arc.graphics.g2d.Lines; -import io.anuke.arc.graphics.g2d.TextureRegion; +import io.anuke.arc.graphics.g2d.*; import io.anuke.arc.math.Mathf; import io.anuke.arc.math.RandomXS128; import io.anuke.arc.util.Time; @@ -15,9 +13,7 @@ import io.anuke.mindustry.ui.Bar; import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.meta.Attribute; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; +import java.io.*; public class Cultivator extends GenericCrafter{ protected static final Color plantColor = Color.valueOf("5541b1"); @@ -54,14 +50,14 @@ public class Cultivator extends GenericCrafter{ super.setBars(); bars.add("multiplier", entity -> new Bar(() -> Core.bundle.formatFloat("bar.efficiency", - ((((CultivatorEntity)entity).boost + 1f) * ((CultivatorEntity)entity).warmup)*100f,1), + ((((CultivatorEntity)entity).boost + 1f) * ((CultivatorEntity)entity).warmup) * 100f, 1), () -> Pal.ammo, () -> ((CultivatorEntity)entity).warmup)); } @Override public void drawPlace(int x, int y, int rotation, boolean valid){ - drawPlaceText(Core.bundle.formatFloat("bar.efficiency", (1+sumAttribute(Attribute.spores, x, y))*100, 1), x, y, valid); + drawPlaceText(Core.bundle.formatFloat("bar.efficiency", (1 + sumAttribute(Attribute.spores, x, y)) * 100, 1), x, y, valid); } @Override diff --git a/core/src/io/anuke/mindustry/world/blocks/production/Drill.java b/core/src/io/anuke/mindustry/world/blocks/production/Drill.java index 4023115276..7105790f00 100644 --- a/core/src/io/anuke/mindustry/world/blocks/production/Drill.java +++ b/core/src/io/anuke/mindustry/world/blocks/production/Drill.java @@ -21,9 +21,7 @@ import io.anuke.mindustry.type.ItemType; import io.anuke.mindustry.ui.Bar; import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Tile; -import io.anuke.mindustry.world.meta.BlockGroup; -import io.anuke.mindustry.world.meta.BlockStat; -import io.anuke.mindustry.world.meta.StatUnit; +import io.anuke.mindustry.world.meta.*; import static io.anuke.mindustry.Vars.content; @@ -34,24 +32,24 @@ public class Drill extends Block{ protected final ObjectIntMap oreCount = new ObjectIntMap<>(); protected final Array itemArray = new Array<>(); - /**Maximum tier of blocks this drill can mine.*/ + /** Maximum tier of blocks this drill can mine. */ protected int tier; - /**Base time to drill one ore, in frames.*/ + /** Base time to drill one ore, in frames. */ protected float drillTime = 300; - /**How many times faster the drill will progress when boosted by liquid.*/ + /** How many times faster the drill will progress when boosted by liquid. */ protected float liquidBoostIntensity = 1.6f; - /**Speed at which the drill speeds up.*/ + /** Speed at which the drill speeds up. */ protected float warmupSpeed = 0.02f; - /**Whether to draw the item this drill is mining.*/ + /** Whether to draw the item this drill is mining. */ protected boolean drawMineItem = false; - /**Effect played when an item is produced. This is colored.*/ + /** Effect played when an item is produced. This is colored. */ protected Effect drillEffect = Fx.mine; - /**Speed the drill bit rotates at.*/ + /** Speed the drill bit rotates at. */ protected float rotateSpeed = 2f; - /**Effect randomly played while drilling.*/ + /** Effect randomly played while drilling. */ protected Effect updateEffect = Fx.pulverizeSmall; - /**Chance the update effect will appear.*/ + /** Chance the update effect will appear. */ protected float updateEffectChance = 0.02f; protected boolean drawRim = false; @@ -226,7 +224,7 @@ public class Drill extends Block{ } if(entity.dominantItems > 0 && entity.progress >= drillTime + hardnessDrillMultiplier * Math.max(totalHardness, 1f) / entity.dominantItems - && tile.entity.items.total() < itemCapacity){ + && tile.entity.items.total() < itemCapacity){ offloadNear(tile, entity.dominantItem); @@ -236,7 +234,7 @@ public class Drill extends Block{ entity.progress = 0f; Effects.effect(drillEffect, entity.dominantItem.color, - entity.x + Mathf.range(size), entity.y + Mathf.range(size)); + entity.x + Mathf.range(size), entity.y + Mathf.range(size)); } } diff --git a/core/src/io/anuke/mindustry/world/blocks/production/GenericCrafter.java b/core/src/io/anuke/mindustry/world/blocks/production/GenericCrafter.java index bffbd56c0d..67215d9b75 100644 --- a/core/src/io/anuke/mindustry/world/blocks/production/GenericCrafter.java +++ b/core/src/io/anuke/mindustry/world/blocks/production/GenericCrafter.java @@ -9,9 +9,7 @@ import io.anuke.mindustry.content.Fx; import io.anuke.mindustry.entities.Effects; import io.anuke.mindustry.entities.Effects.Effect; import io.anuke.mindustry.entities.type.TileEntity; -import io.anuke.mindustry.type.Item; -import io.anuke.mindustry.type.ItemStack; -import io.anuke.mindustry.type.LiquidStack; +import io.anuke.mindustry.type.*; import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.consumers.ConsumeLiquidBase; @@ -19,9 +17,7 @@ import io.anuke.mindustry.world.consumers.ConsumeType; import io.anuke.mindustry.world.meta.BlockStat; import io.anuke.mindustry.world.meta.StatUnit; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; +import java.io.*; public class GenericCrafter extends Block{ protected final int timerDump = timers++; diff --git a/core/src/io/anuke/mindustry/world/blocks/production/GenericSmelter.java b/core/src/io/anuke/mindustry/world/blocks/production/GenericSmelter.java index fcf761f95b..576236cd53 100644 --- a/core/src/io/anuke/mindustry/world/blocks/production/GenericSmelter.java +++ b/core/src/io/anuke/mindustry/world/blocks/production/GenericSmelter.java @@ -2,14 +2,12 @@ package io.anuke.mindustry.world.blocks.production; import io.anuke.arc.Core; import io.anuke.arc.graphics.Color; -import io.anuke.arc.graphics.g2d.Draw; -import io.anuke.arc.graphics.g2d.Fill; -import io.anuke.arc.graphics.g2d.TextureRegion; +import io.anuke.arc.graphics.g2d.*; import io.anuke.arc.math.Mathf; import io.anuke.arc.util.Time; import io.anuke.mindustry.world.Tile; -/**A GenericCrafter with a new glowing region drawn on top.*/ +/** A GenericCrafter with a new glowing region drawn on top. */ public class GenericSmelter extends GenericCrafter{ protected Color flameColor = Color.valueOf("ffc999"); protected TextureRegion topRegion; diff --git a/core/src/io/anuke/mindustry/world/blocks/production/Incinerator.java b/core/src/io/anuke/mindustry/world/blocks/production/Incinerator.java index 23825bf5a8..7e28b8bc67 100644 --- a/core/src/io/anuke/mindustry/world/blocks/production/Incinerator.java +++ b/core/src/io/anuke/mindustry/world/blocks/production/Incinerator.java @@ -1,13 +1,13 @@ package io.anuke.mindustry.world.blocks.production; -import io.anuke.mindustry.entities.Effects; -import io.anuke.mindustry.entities.Effects.Effect; import io.anuke.arc.graphics.Color; import io.anuke.arc.graphics.g2d.Draw; import io.anuke.arc.graphics.g2d.Fill; import io.anuke.arc.math.Mathf; import io.anuke.arc.util.Time; import io.anuke.mindustry.content.Fx; +import io.anuke.mindustry.entities.Effects; +import io.anuke.mindustry.entities.Effects.Effect; import io.anuke.mindustry.entities.type.TileEntity; import io.anuke.mindustry.type.Item; import io.anuke.mindustry.type.Liquid; diff --git a/core/src/io/anuke/mindustry/world/blocks/production/Pump.java b/core/src/io/anuke/mindustry/world/blocks/production/Pump.java index 178a56707c..4dddcd36b0 100644 --- a/core/src/io/anuke/mindustry/world/blocks/production/Pump.java +++ b/core/src/io/anuke/mindustry/world/blocks/production/Pump.java @@ -4,14 +4,11 @@ import io.anuke.arc.Core; import io.anuke.arc.collection.Array; import io.anuke.arc.graphics.g2d.Draw; import io.anuke.arc.graphics.g2d.TextureRegion; -import io.anuke.arc.util.Log; import io.anuke.mindustry.graphics.Layer; import io.anuke.mindustry.type.Liquid; import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.blocks.LiquidBlock; -import io.anuke.mindustry.world.meta.BlockGroup; -import io.anuke.mindustry.world.meta.BlockStat; -import io.anuke.mindustry.world.meta.StatUnit; +import io.anuke.mindustry.world.meta.*; public class Pump extends LiquidBlock{ protected final Array drawTiles = new Array<>(); @@ -19,7 +16,7 @@ public class Pump extends LiquidBlock{ protected final int timerContentCheck = timers++; - /**Pump amount, total.*/ + /** Pump amount, total. */ protected float pumpAmount = 1f; public Pump(String name){ diff --git a/core/src/io/anuke/mindustry/world/blocks/production/SolidPump.java b/core/src/io/anuke/mindustry/world/blocks/production/SolidPump.java index 1c6d396635..9f5c2bcc96 100644 --- a/core/src/io/anuke/mindustry/world/blocks/production/SolidPump.java +++ b/core/src/io/anuke/mindustry/world/blocks/production/SolidPump.java @@ -24,7 +24,7 @@ public class SolidPump extends Pump{ protected Effect updateEffect = Fx.none; protected float updateEffectChance = 0.02f; protected float rotateSpeed = 1f; - /**Attribute that is checked when calculating output.*/ + /** Attribute that is checked when calculating output. */ protected Attribute attribute; public SolidPump(String name){ @@ -42,7 +42,7 @@ public class SolidPump extends Pump{ @Override public void drawPlace(int x, int y, int rotation, boolean valid){ if(attribute != null){ - drawPlaceText(Core.bundle.formatFloat("bar.efficiency", (sumAttribute(attribute, x, y) + 1f)*100, 1), x, y, valid); + drawPlaceText(Core.bundle.formatFloat("bar.efficiency", (sumAttribute(attribute, x, y) + 1f) * 100, 1), x, y, valid); } } diff --git a/core/src/io/anuke/mindustry/world/blocks/sandbox/ItemVoid.java b/core/src/io/anuke/mindustry/world/blocks/sandbox/ItemVoid.java index aa4d55371b..2a59aeab8b 100644 --- a/core/src/io/anuke/mindustry/world/blocks/sandbox/ItemVoid.java +++ b/core/src/io/anuke/mindustry/world/blocks/sandbox/ItemVoid.java @@ -12,7 +12,8 @@ public class ItemVoid extends Block{ } @Override - public void handleItem(Item item, Tile tile, Tile source){} + public void handleItem(Item item, Tile tile, Tile source){ + } @Override public boolean acceptItem(Item item, Tile tile, Tile source){ diff --git a/core/src/io/anuke/mindustry/world/blocks/sandbox/LiquidSource.java b/core/src/io/anuke/mindustry/world/blocks/sandbox/LiquidSource.java index d6212bce5f..9b2371c3ad 100644 --- a/core/src/io/anuke/mindustry/world/blocks/sandbox/LiquidSource.java +++ b/core/src/io/anuke/mindustry/world/blocks/sandbox/LiquidSource.java @@ -16,9 +16,7 @@ import io.anuke.mindustry.type.Liquid; import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Tile; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; +import java.io.*; import static io.anuke.mindustry.Vars.content; import static io.anuke.mindustry.Vars.control; diff --git a/core/src/io/anuke/mindustry/world/blocks/storage/CoreBlock.java b/core/src/io/anuke/mindustry/world/blocks/storage/CoreBlock.java index 7bb4946473..8af1e06eac 100644 --- a/core/src/io/anuke/mindustry/world/blocks/storage/CoreBlock.java +++ b/core/src/io/anuke/mindustry/world/blocks/storage/CoreBlock.java @@ -4,17 +4,13 @@ import io.anuke.annotations.Annotations.Loc; import io.anuke.annotations.Annotations.Remote; import io.anuke.arc.Core; import io.anuke.arc.collection.EnumSet; -import io.anuke.arc.graphics.g2d.Draw; -import io.anuke.arc.graphics.g2d.Lines; -import io.anuke.arc.graphics.g2d.TextureRegion; +import io.anuke.arc.graphics.g2d.*; import io.anuke.arc.math.Mathf; import io.anuke.mindustry.Vars; import io.anuke.mindustry.content.Fx; import io.anuke.mindustry.entities.Effects; import io.anuke.mindustry.entities.traits.SpawnerTrait; -import io.anuke.mindustry.entities.type.Player; -import io.anuke.mindustry.entities.type.TileEntity; -import io.anuke.mindustry.entities.type.Unit; +import io.anuke.mindustry.entities.type.*; import io.anuke.mindustry.gen.Call; import io.anuke.mindustry.graphics.Pal; import io.anuke.mindustry.graphics.Shaders; @@ -63,7 +59,7 @@ public class CoreBlock extends StorageBlock{ } @Override - public void onProximityUpdate(Tile tile) { + public void onProximityUpdate(Tile tile){ for(Tile other : state.teams.get(tile.getTeam()).cores){ if(other != tile){ tile.entity.items = other.entity.items; @@ -128,10 +124,10 @@ public class CoreBlock extends StorageBlock{ Draw.color(Pal.accent); Lines.lineAngleCenter( - tile.drawx() + Mathf.sin(entity.time, 6f, Vars.tilesize / 3f * size), - tile.drawy(), - 90, - size * Vars.tilesize / 2f); + tile.drawx() + Mathf.sin(entity.time, 6f, Vars.tilesize / 3f * size), + tile.drawy(), + 90, + size * Vars.tilesize / 2f); Draw.reset(); } diff --git a/core/src/io/anuke/mindustry/world/blocks/storage/LaunchPad.java b/core/src/io/anuke/mindustry/world/blocks/storage/LaunchPad.java index af01644d1f..71c16f5393 100644 --- a/core/src/io/anuke/mindustry/world/blocks/storage/LaunchPad.java +++ b/core/src/io/anuke/mindustry/world/blocks/storage/LaunchPad.java @@ -20,7 +20,7 @@ import static io.anuke.mindustry.Vars.world; public class LaunchPad extends StorageBlock{ protected final int timerLaunch = timers++; - /**Time inbetween launches.*/ + /** Time inbetween launches. */ protected float launchTime; public LaunchPad(String name){ @@ -47,11 +47,11 @@ public class LaunchPad extends StorageBlock{ super.draw(tile); float progress = Mathf.clamp((tile.entity.items.total() / (float)itemCapacity) * ((tile.entity.timer.getTime(timerLaunch) / (launchTime / tile.entity.timeScale)))); - float scale = size/3f; + float scale = size / 3f; Lines.stroke(2f); Draw.color(Pal.accentBack); - Lines.poly(tile.drawx(), tile.drawy(), 4, scale * 10f * (1f - progress), 45 + 360f*progress); + Lines.poly(tile.drawx(), tile.drawy(), 4, scale * 10f * (1f - progress), 45 + 360f * progress); Draw.color(Pal.accent); diff --git a/core/src/io/anuke/mindustry/world/blocks/storage/Unloader.java b/core/src/io/anuke/mindustry/world/blocks/storage/Unloader.java index 64cf031d6d..f755175992 100644 --- a/core/src/io/anuke/mindustry/world/blocks/storage/Unloader.java +++ b/core/src/io/anuke/mindustry/world/blocks/storage/Unloader.java @@ -14,9 +14,7 @@ import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.blocks.ItemSelection; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; +import java.io.*; import static io.anuke.mindustry.Vars.content; @@ -66,8 +64,8 @@ public class Unloader extends Block{ if(tile.entity.timer.get(timerUnload, speed / entity.timeScale) && tile.entity.items.total() == 0){ for(Tile other : tile.entity.proximity()){ if(other.interactable(tile.getTeam()) && other.block() instanceof StorageBlock && entity.items.total() == 0 && - ((entity.sortItem == null && other.entity.items.total() > 0) || ((StorageBlock) other.block()).hasItem(other, entity.sortItem))){ - offloadNear(tile, ((StorageBlock) other.block()).removeItem(other, entity.sortItem)); + ((entity.sortItem == null && other.entity.items.total() > 0) || ((StorageBlock)other.block()).hasItem(other, entity.sortItem))){ + offloadNear(tile, ((StorageBlock)other.block()).removeItem(other, entity.sortItem)); } } } diff --git a/core/src/io/anuke/mindustry/world/blocks/units/MechPad.java b/core/src/io/anuke/mindustry/world/blocks/units/MechPad.java index bce12a7e28..3a58f0760c 100644 --- a/core/src/io/anuke/mindustry/world/blocks/units/MechPad.java +++ b/core/src/io/anuke/mindustry/world/blocks/units/MechPad.java @@ -3,9 +3,7 @@ package io.anuke.mindustry.world.blocks.units; import io.anuke.annotations.Annotations.Loc; import io.anuke.annotations.Annotations.Remote; import io.anuke.arc.Core; -import io.anuke.arc.graphics.g2d.Draw; -import io.anuke.arc.graphics.g2d.Lines; -import io.anuke.arc.graphics.g2d.TextureRegion; +import io.anuke.arc.graphics.g2d.*; import io.anuke.arc.math.Mathf; import io.anuke.arc.math.geom.Geometry; import io.anuke.arc.util.Time; @@ -26,9 +24,7 @@ import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.meta.BlockStat; import io.anuke.mindustry.world.meta.StatUnit; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; +import java.io.*; import static io.anuke.mindustry.Vars.mobile; import static io.anuke.mindustry.Vars.tilesize; @@ -51,7 +47,7 @@ public class MechPad extends Block{ public void setStats(){ super.setStats(); - stats.add(BlockStat.productionTime, buildTime/60f, StatUnit.seconds); + stats.add(BlockStat.productionTime, buildTime / 60f, StatUnit.seconds); } @Override @@ -66,7 +62,7 @@ public class MechPad extends Block{ @Remote(targets = Loc.both, called = Loc.server) public static void onMechFactoryTap(Player player, Tile tile){ - if(player == null || !(tile.block() instanceof MechPad) || !checkValidTap(tile, player)) return; + if(player == null || !(tile.block() instanceof MechPad) || !checkValidTap(tile, player)) return; MechFactoryEntity entity = tile.entity(); MechPad pad = (MechPad)tile.block(); @@ -87,7 +83,7 @@ public class MechPad extends Block{ if(entity.player == null) return; - Mech result = ((MechPad) tile.block()).mech; + Mech result = ((MechPad)tile.block()).mech; if(entity.player.mech == result){ Mech target = (entity.player.isMobile ? Mechs.starterMobile : Mechs.starterDesktop); @@ -111,16 +107,16 @@ public class MechPad extends Block{ protected static boolean checkValidTap(Tile tile, Player player){ MechFactoryEntity entity = tile.entity(); - return Math.abs(player.x - tile.drawx()) <= tile.block().size * tilesize / 2f && - Math.abs(player.y - tile.drawy()) <= tile.block().size * tilesize / 2f && entity.cons.valid() && entity.player == null; + return Math.abs(player.x - tile.drawx()) <= tile.block().size * tilesize / 2f && + Math.abs(player.y - tile.drawy()) <= tile.block().size * tilesize / 2f && entity.cons.valid() && entity.player == null; } @Override public void drawSelect(Tile tile){ Draw.color(Pal.accent); - for(int i = 0; i < 4; i ++){ - float length = tilesize * size/2f + 3 + Mathf.absin(Time.time(), 5f, 2f); - Draw.rect("transfer-arrow", tile.drawx() + Geometry.d4[i].x * length, tile.drawy() + Geometry.d4[i].y * length, (i+2) * 90); + for(int i = 0; i < 4; i++){ + float length = tilesize * size / 2f + 3 + Mathf.absin(Time.time(), 5f, 2f); + Draw.rect("transfer-arrow", tile.drawx() + Geometry.d4[i].x * length, tile.drawy() + Geometry.d4[i].y * length, (i + 2) * 90); } Draw.color(); } @@ -172,10 +168,10 @@ public class MechPad extends Block{ Draw.color(Pal.accent); Lines.lineAngleCenter( - tile.drawx() + Mathf.sin(entity.time, 6f, Vars.tilesize / 3f * size), - tile.drawy(), - 90, - size * Vars.tilesize / 2f + 1f); + tile.drawx() + Mathf.sin(entity.time, 6f, Vars.tilesize / 3f * size), + tile.drawy(), + 90, + size * Vars.tilesize / 2f + 1f); Draw.reset(); } diff --git a/core/src/io/anuke/mindustry/world/blocks/units/RepairPoint.java b/core/src/io/anuke/mindustry/world/blocks/units/RepairPoint.java index 7b3beb34c6..c0b949d055 100644 --- a/core/src/io/anuke/mindustry/world/blocks/units/RepairPoint.java +++ b/core/src/io/anuke/mindustry/world/blocks/units/RepairPoint.java @@ -3,25 +3,19 @@ package io.anuke.mindustry.world.blocks.units; import io.anuke.arc.Core; import io.anuke.arc.collection.EnumSet; import io.anuke.arc.graphics.Color; -import io.anuke.arc.graphics.g2d.Draw; -import io.anuke.arc.graphics.g2d.Lines; -import io.anuke.arc.graphics.g2d.TextureRegion; +import io.anuke.arc.graphics.g2d.*; import io.anuke.arc.math.Angles; import io.anuke.arc.math.Mathf; import io.anuke.arc.math.geom.Rectangle; import io.anuke.arc.util.Time; +import io.anuke.mindustry.entities.Units; import io.anuke.mindustry.entities.type.TileEntity; import io.anuke.mindustry.entities.type.Unit; -import io.anuke.mindustry.entities.Units; -import io.anuke.mindustry.graphics.Layer; -import io.anuke.mindustry.graphics.Pal; -import io.anuke.mindustry.graphics.Shapes; +import io.anuke.mindustry.graphics.*; import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.consumers.ConsumePower; -import io.anuke.mindustry.world.meta.BlockFlag; -import io.anuke.mindustry.world.meta.BlockStat; -import io.anuke.mindustry.world.meta.StatUnit; +import io.anuke.mindustry.world.meta.*; public class RepairPoint extends Block{ private static Rectangle rect = new Rectangle(); @@ -84,14 +78,14 @@ public class RepairPoint extends Block{ RepairPointEntity entity = tile.entity(); if(entity.target != null && - Angles.angleDist(entity.angleTo(entity.target), entity.rotation) < 30f){ + Angles.angleDist(entity.angleTo(entity.target), entity.rotation) < 30f){ float ang = entity.angleTo(entity.target); float len = 5f; Draw.color(Color.valueOf("e8ffd7")); Shapes.laser("laser", "laser-end", - tile.drawx() + Angles.trnsx(ang, len), tile.drawy() + Angles.trnsy(ang, len), - entity.target.x, entity.target.y, entity.strength); + tile.drawx() + Angles.trnsx(ang, len), tile.drawy() + Angles.trnsy(ang, len), + entity.target.x, entity.target.y, entity.strength); Draw.color(); } } @@ -107,7 +101,7 @@ public class RepairPoint extends Block{ boolean targetIsBeingRepaired = false; if(entity.target != null && (entity.target.isDead() || entity.target.dst(tile) > repairRadius || - entity.target.health >= entity.target.maxHealth())){ + entity.target.health >= entity.target.maxHealth())){ entity.target = null; }else if(entity.target != null){ float relativeConsumption = powerPerEvent / consumePower.powerCapacity; @@ -129,7 +123,7 @@ public class RepairPoint extends Block{ if(entity.timer.get(timerTarget, 20)){ rect.setSize(repairRadius * 2).setCenter(tile.drawx(), tile.drawy()); entity.target = Units.getClosest(tile.getTeam(), tile.drawx(), tile.drawy(), repairRadius, - unit -> unit.health < unit.maxHealth()); + unit -> unit.health < unit.maxHealth()); } } diff --git a/core/src/io/anuke/mindustry/world/blocks/units/UnitFactory.java b/core/src/io/anuke/mindustry/world/blocks/units/UnitFactory.java index 70cc47208b..afe5e8daaf 100644 --- a/core/src/io/anuke/mindustry/world/blocks/units/UnitFactory.java +++ b/core/src/io/anuke/mindustry/world/blocks/units/UnitFactory.java @@ -4,35 +4,25 @@ import io.anuke.annotations.Annotations.Loc; import io.anuke.annotations.Annotations.Remote; import io.anuke.arc.Core; import io.anuke.arc.collection.EnumSet; -import io.anuke.arc.graphics.g2d.Draw; -import io.anuke.arc.graphics.g2d.Lines; -import io.anuke.arc.graphics.g2d.TextureRegion; +import io.anuke.arc.graphics.g2d.*; import io.anuke.arc.math.Mathf; import io.anuke.mindustry.Vars; import io.anuke.mindustry.content.Fx; import io.anuke.mindustry.entities.Effects; -import io.anuke.mindustry.entities.type.BaseUnit; -import io.anuke.mindustry.entities.type.TileEntity; -import io.anuke.mindustry.entities.type.Unit; +import io.anuke.mindustry.entities.type.*; import io.anuke.mindustry.gen.Call; import io.anuke.mindustry.graphics.Pal; import io.anuke.mindustry.graphics.Shaders; import io.anuke.mindustry.net.Net; -import io.anuke.mindustry.type.Item; -import io.anuke.mindustry.type.ItemStack; -import io.anuke.mindustry.type.UnitType; +import io.anuke.mindustry.type.*; import io.anuke.mindustry.ui.Bar; import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.consumers.ConsumeItems; import io.anuke.mindustry.world.consumers.ConsumeType; -import io.anuke.mindustry.world.meta.BlockFlag; -import io.anuke.mindustry.world.meta.BlockStat; -import io.anuke.mindustry.world.meta.StatUnit; +import io.anuke.mindustry.world.meta.*; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; +import java.io.*; public class UnitFactory extends Block{ //for attack mode @@ -61,7 +51,7 @@ public class UnitFactory extends Block{ if(!(tile.entity instanceof UnitFactoryEntity) || !(tile.block() instanceof UnitFactory)) return; UnitFactoryEntity entity = tile.entity(); - UnitFactory factory = (UnitFactory) tile.block(); + UnitFactory factory = (UnitFactory)tile.block(); entity.buildTime = 0f; entity.spawned = spawns; @@ -86,7 +76,7 @@ public class UnitFactory extends Block{ if(consumes.has(ConsumeType.item)){ ConsumeItems cons = consumes.get(ConsumeType.item); for(ItemStack stack : cons.items){ - capacities[stack.item.id] = stack.amount*2; + capacities[stack.item.id] = stack.amount * 2; } } } @@ -122,7 +112,7 @@ public class UnitFactory extends Block{ @Override public void unitRemoved(Tile tile, Unit unit){ UnitFactoryEntity entity = tile.entity(); - entity.spawned --; + entity.spawned--; entity.spawned = Math.max(entity.spawned, 0); } @@ -152,10 +142,10 @@ public class UnitFactory extends Block{ Draw.alpha(entity.speedScl); Lines.lineAngleCenter( - tile.drawx() + Mathf.sin(entity.time, 6f, Vars.tilesize / 2f * size - 2f), - tile.drawy(), - 90, - size * Vars.tilesize - 4f); + tile.drawx() + Mathf.sin(entity.time, 6f, Vars.tilesize / 2f * size - 2f), + tile.drawy(), + 90, + size * Vars.tilesize - 4f); Draw.reset(); @@ -184,7 +174,7 @@ public class UnitFactory extends Block{ entity.speedScl = Mathf.lerpDelta(entity.speedScl, 0f, 0.05f); } //check if grace period had passed - }else if(entity.warmup > produceTime*gracePeriodMultiplier){ + }else if(entity.warmup > produceTime * gracePeriodMultiplier){ float speedMultiplier = Math.min(0.1f + (entity.warmup - produceTime * gracePeriodMultiplier) / speedupTime, maxSpeedup); entity.time += entity.delta() * entity.speedScl; //otherwise, it's an enemy, cheat by not requiring resources diff --git a/core/src/io/anuke/mindustry/world/consumers/Consume.java b/core/src/io/anuke/mindustry/world/consumers/Consume.java index e5ed83c7ac..98ead521d7 100644 --- a/core/src/io/anuke/mindustry/world/consumers/Consume.java +++ b/core/src/io/anuke/mindustry/world/consumers/Consume.java @@ -5,22 +5,26 @@ import io.anuke.mindustry.entities.type.TileEntity; import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.meta.BlockStats; -/**An abstract class that defines a type of resource that a block can consume.*/ +/** An abstract class that defines a type of resource that a block can consume. */ public abstract class Consume{ - /**If true, this consumer will not influence consumer validity.*/ + /** If true, this consumer will not influence consumer validity. */ protected boolean optional; - /**If true, this consumer will be displayed as a boost input.*/ + /** If true, this consumer will be displayed as a boost input. */ protected boolean booster; protected boolean update = true; - /**Apply a filter to items accepted. - * This should set all item IDs that are present in the filter to true.*/ + /** + * Apply a filter to items accepted. + * This should set all item IDs that are present in the filter to true. + */ public void applyItemFilter(boolean[] filter){ } - /**Apply a filter to liquids accepted. - * This should set all liquid IDs that are present in the filter to true.*/ + /** + * Apply a filter to liquids accepted. + * This should set all liquid IDs that are present in the filter to true. + */ public void applyLiquidFilter(boolean[] filter){ } @@ -52,7 +56,7 @@ public abstract class Consume{ public abstract void build(Tile tile, Table table); - /**Called when a consumption is triggered manually.*/ + /** Called when a consumption is triggered manually. */ public void trigger(TileEntity entity){ } diff --git a/core/src/io/anuke/mindustry/world/consumers/ConsumeItemFilter.java b/core/src/io/anuke/mindustry/world/consumers/ConsumeItemFilter.java index 6faf18a27b..f2c9edac07 100644 --- a/core/src/io/anuke/mindustry/world/consumers/ConsumeItemFilter.java +++ b/core/src/io/anuke/mindustry/world/consumers/ConsumeItemFilter.java @@ -6,9 +6,7 @@ import io.anuke.arc.scene.ui.layout.Table; import io.anuke.mindustry.entities.type.TileEntity; import io.anuke.mindustry.type.Item; import io.anuke.mindustry.type.Item.Icon; -import io.anuke.mindustry.ui.ItemImage; -import io.anuke.mindustry.ui.MultiReqImage; -import io.anuke.mindustry.ui.ReqImage; +import io.anuke.mindustry.ui.*; import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.meta.BlockStat; import io.anuke.mindustry.world.meta.BlockStats; @@ -39,7 +37,7 @@ public class ConsumeItemFilter extends Consume{ MultiReqImage image = new MultiReqImage(); list.each(item -> image.add(new ReqImage(new ItemImage(item.icon(Icon.large), 1), () -> tile.entity != null && tile.entity.items != null && tile.entity.items.has(item)))); - table.add(image).size(8*4); + table.add(image).size(8 * 4); } @Override diff --git a/core/src/io/anuke/mindustry/world/consumers/ConsumeItems.java b/core/src/io/anuke/mindustry/world/consumers/ConsumeItems.java index 9f7da16a2d..96f38e4aa3 100644 --- a/core/src/io/anuke/mindustry/world/consumers/ConsumeItems.java +++ b/core/src/io/anuke/mindustry/world/consumers/ConsumeItems.java @@ -33,7 +33,7 @@ public class ConsumeItems extends Consume{ @Override public void build(Tile tile, Table table){ for(ItemStack stack : items){ - table.add(new ReqImage(new ItemImage(stack.item.icon(Icon.large), stack.amount), () -> tile.entity != null && tile.entity.items != null && tile.entity.items.has(stack.item, stack.amount))).size(8*4).padRight(5); + table.add(new ReqImage(new ItemImage(stack.item.icon(Icon.large), stack.amount), () -> tile.entity != null && tile.entity.items != null && tile.entity.items.has(stack.item, stack.amount))).size(8 * 4).padRight(5); } } diff --git a/core/src/io/anuke/mindustry/world/consumers/ConsumeLiquid.java b/core/src/io/anuke/mindustry/world/consumers/ConsumeLiquid.java index 7cb41cce5c..9cc8eba1fb 100644 --- a/core/src/io/anuke/mindustry/world/consumers/ConsumeLiquid.java +++ b/core/src/io/anuke/mindustry/world/consumers/ConsumeLiquid.java @@ -23,7 +23,7 @@ public class ConsumeLiquid extends ConsumeLiquidBase{ @Override public void build(Tile tile, Table table){ - table.add(new ReqImage(liquid.getContentIcon(), () -> valid(tile.entity))).size(8*4); + table.add(new ReqImage(liquid.getContentIcon(), () -> valid(tile.entity))).size(8 * 4); } @Override diff --git a/core/src/io/anuke/mindustry/world/consumers/ConsumeLiquidBase.java b/core/src/io/anuke/mindustry/world/consumers/ConsumeLiquidBase.java index bae0f7a5f0..34190338f2 100644 --- a/core/src/io/anuke/mindustry/world/consumers/ConsumeLiquidBase.java +++ b/core/src/io/anuke/mindustry/world/consumers/ConsumeLiquidBase.java @@ -3,12 +3,14 @@ package io.anuke.mindustry.world.consumers; import io.anuke.mindustry.entities.type.TileEntity; public abstract class ConsumeLiquidBase extends Consume{ - /**amount used per frame*/ + /** amount used per frame */ public final float amount; - /**How much time is taken to use this liquid, in ticks. Used only for visual purposes. + /** + * How much time is taken to use this liquid, in ticks. Used only for visual purposes. * Example: a normal ConsumeLiquid with 10/s and a 10 second timePeriod would display as "100 seconds". * Without a time override, it would display as "10 liquid/second". - * This is used for generic crafters.*/ + * This is used for generic crafters. + */ public float timePeriod = 60; public ConsumeLiquidBase(float amount){ diff --git a/core/src/io/anuke/mindustry/world/consumers/ConsumeLiquidFilter.java b/core/src/io/anuke/mindustry/world/consumers/ConsumeLiquidFilter.java index f0f2d7aaad..6da77814e8 100644 --- a/core/src/io/anuke/mindustry/world/consumers/ConsumeLiquidFilter.java +++ b/core/src/io/anuke/mindustry/world/consumers/ConsumeLiquidFilter.java @@ -33,7 +33,7 @@ public class ConsumeLiquidFilter extends ConsumeLiquidBase{ MultiReqImage image = new MultiReqImage(); list.each(liquid -> image.add(new ReqImage(liquid.getContentIcon(), () -> tile.entity != null && tile.entity.liquids != null && tile.entity.liquids.get(liquid) >= use(tile.entity)))); - table.add(image).size(8*4); + table.add(image).size(8 * 4); } @Override diff --git a/core/src/io/anuke/mindustry/world/consumers/ConsumePower.java b/core/src/io/anuke/mindustry/world/consumers/ConsumePower.java index a3f392d7cd..6aaf0da2a9 100644 --- a/core/src/io/anuke/mindustry/world/consumers/ConsumePower.java +++ b/core/src/io/anuke/mindustry/world/consumers/ConsumePower.java @@ -5,9 +5,7 @@ import io.anuke.arc.scene.ui.layout.Table; import io.anuke.mindustry.entities.type.TileEntity; import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Tile; -import io.anuke.mindustry.world.meta.BlockStat; -import io.anuke.mindustry.world.meta.BlockStats; -import io.anuke.mindustry.world.meta.StatUnit; +import io.anuke.mindustry.world.meta.*; /** Consumer class for blocks which consume power while being connected to a power graph. */ public class ConsumePower extends Consume{ diff --git a/core/src/io/anuke/mindustry/world/consumers/Consumers.java b/core/src/io/anuke/mindustry/world/consumers/Consumers.java index 9960ff1f69..d544e6481e 100644 --- a/core/src/io/anuke/mindustry/world/consumers/Consumers.java +++ b/core/src/io/anuke/mindustry/world/consumers/Consumers.java @@ -2,9 +2,7 @@ package io.anuke.mindustry.world.consumers; import io.anuke.arc.util.Structs; import io.anuke.mindustry.Vars; -import io.anuke.mindustry.type.Item; -import io.anuke.mindustry.type.ItemStack; -import io.anuke.mindustry.type.Liquid; +import io.anuke.mindustry.type.*; import io.anuke.mindustry.world.meta.BlockStats; public class Consumers{ @@ -57,7 +55,7 @@ public class Consumers{ /** * Creates a consumer which stores power and uses it only in case of certain events (e.g. a turret firing). * @param powerCapacity The maximum capacity in power units. - * @param ticksToFill The number of ticks it shall take to fill the buffer. + * @param ticksToFill The number of ticks it shall take to fill the buffer. */ public ConsumePower powerBuffered(float powerCapacity, float ticksToFill){ return add(new ConsumePower(powerCapacity / ticksToFill, powerCapacity, true)); @@ -93,7 +91,7 @@ public class Consumers{ if(map[type.ordinal()] == null){ throw new IllegalArgumentException("Block does not contain consumer of type '" + type + "'!"); } - return (T) map[type.ordinal()]; + return (T)map[type.ordinal()]; } public Consume[] all(){ diff --git a/core/src/io/anuke/mindustry/world/meta/Attribute.java b/core/src/io/anuke/mindustry/world/meta/Attribute.java index 5f761f5359..0604adeba2 100644 --- a/core/src/io/anuke/mindustry/world/meta/Attribute.java +++ b/core/src/io/anuke/mindustry/world/meta/Attribute.java @@ -1,12 +1,12 @@ package io.anuke.mindustry.world.meta; public enum Attribute{ - /** Heat of this block. Used for calculating output of thermal generators.*/ + /** Heat of this block. Used for calculating output of thermal generators. */ heat, - /** Spore content of this block. Used for increasing cultivator yield.*/ + /** Spore content of this block. Used for increasing cultivator yield. */ spores, - /** Water content of this block. Used for increasing water extractor yield.*/ + /** Water content of this block. Used for increasing water extractor yield. */ water, - /** Oil content of this block. Used for increasing oil extractor yield.*/ + /** Oil content of this block. Used for increasing oil extractor yield. */ oil } diff --git a/core/src/io/anuke/mindustry/world/meta/BlockBars.java b/core/src/io/anuke/mindustry/world/meta/BlockBars.java index c47211181f..1e42281ba9 100644 --- a/core/src/io/anuke/mindustry/world/meta/BlockBars.java +++ b/core/src/io/anuke/mindustry/world/meta/BlockBars.java @@ -8,12 +8,13 @@ import io.anuke.mindustry.ui.Bar; public class BlockBars{ private OrderedMap> bars = new OrderedMap<>(); - public void add(String name,Function sup){ + public void add(String name, Function sup){ bars.put(name, sup); } public void remove(String name){ - if(!bars.containsKey(name)) throw new RuntimeException("No bar with name '" + name + "' found; current bars: " + bars.keys().toArray()); + if(!bars.containsKey(name)) + throw new RuntimeException("No bar with name '" + name + "' found; current bars: " + bars.keys().toArray()); bars.remove(name); } diff --git a/core/src/io/anuke/mindustry/world/meta/BlockFlag.java b/core/src/io/anuke/mindustry/world/meta/BlockFlag.java index b5c8339854..716c51d11f 100644 --- a/core/src/io/anuke/mindustry/world/meta/BlockFlag.java +++ b/core/src/io/anuke/mindustry/world/meta/BlockFlag.java @@ -1,13 +1,13 @@ package io.anuke.mindustry.world.meta; public enum BlockFlag{ - /**General important target for all types of units.*/ + /** General important target for all types of units. */ target(0), - /**Producer of important goods.*/ + /** Producer of important goods. */ producer(Float.MAX_VALUE), - /**A turret.*/ + /** A turret. */ turret(Float.MAX_VALUE), - /**Repair point.*/ + /** Repair point. */ repair(Float.MAX_VALUE); public final static BlockFlag[] all = values(); diff --git a/core/src/io/anuke/mindustry/world/meta/BlockStat.java b/core/src/io/anuke/mindustry/world/meta/BlockStat.java index ed2af2abbb..705c19ac3c 100644 --- a/core/src/io/anuke/mindustry/world/meta/BlockStat.java +++ b/core/src/io/anuke/mindustry/world/meta/BlockStat.java @@ -4,7 +4,7 @@ import io.anuke.arc.Core; import java.util.Locale; -/**Describes one type of stat for a block.*/ +/** Describes one type of stat for a block. */ public enum BlockStat{ health(StatCategory.general), size(StatCategory.general), @@ -41,8 +41,7 @@ public enum BlockStat{ ammo(StatCategory.shooting), booster(StatCategory.optional), - boostEffect(StatCategory.optional) - ; + boostEffect(StatCategory.optional); public final StatCategory category; diff --git a/core/src/io/anuke/mindustry/world/meta/BlockStats.java b/core/src/io/anuke/mindustry/world/meta/BlockStats.java index 8487f3b8ed..dbf3ea0afc 100644 --- a/core/src/io/anuke/mindustry/world/meta/BlockStats.java +++ b/core/src/io/anuke/mindustry/world/meta/BlockStats.java @@ -3,47 +3,45 @@ package io.anuke.mindustry.world.meta; import io.anuke.arc.collection.Array; import io.anuke.arc.collection.ObjectMap.Entry; import io.anuke.arc.collection.OrderedMap; -import io.anuke.mindustry.type.Item; -import io.anuke.mindustry.type.ItemStack; -import io.anuke.mindustry.type.Liquid; +import io.anuke.mindustry.type.*; import io.anuke.mindustry.world.meta.values.*; -/**Hold and organizes a list of block stats.*/ +/** Hold and organizes a list of block stats. */ public class BlockStats{ private final OrderedMap>> map = new OrderedMap<>(); private boolean dirty; - /**Adds a single float value with this stat, formatted to 2 decimal places.*/ + /** Adds a single float value with this stat, formatted to 2 decimal places. */ public void add(BlockStat stat, float value, StatUnit unit){ add(stat, new NumberValue(value, unit)); } - /**Adds a single y/n boolean value.*/ + /** Adds a single y/n boolean value. */ public void add(BlockStat stat, boolean value){ add(stat, new BooleanValue(value)); } - /**Adds an item value.*/ + /** Adds an item value. */ public void add(BlockStat stat, Item item){ add(stat, new ItemListValue(new ItemStack(item, 1))); } - /**Adds an item value.*/ + /** Adds an item value. */ public void add(BlockStat stat, ItemStack item){ add(stat, new ItemListValue(item)); } - /**Adds an item value.*/ + /** Adds an item value. */ public void add(BlockStat stat, Liquid liquid, float amount, boolean perSecond){ add(stat, new LiquidValue(liquid, amount, perSecond)); } - /**Adds a single string value with this stat.*/ + /** Adds a single string value with this stat. */ public void add(BlockStat stat, String format, Object... args){ add(stat, new StringValue(format, args)); } - /**Adds a stat value.*/ + /** Adds a stat value. */ public void add(BlockStat stat, StatValue value){ if(!map.containsKey(stat.category)){ map.put(stat.category, new OrderedMap<>()); @@ -54,7 +52,7 @@ public class BlockStats{ dirty = true; } - /**Removes a stat, if it exists.*/ + /** Removes a stat, if it exists. */ public void remove(BlockStat stat){ if(!map.containsKey(stat.category) || !map.get(stat.category).containsKey(stat)){ throw new RuntimeException("No stat entry found: \"" + stat + "\" in block."); diff --git a/core/src/io/anuke/mindustry/world/meta/StatCategory.java b/core/src/io/anuke/mindustry/world/meta/StatCategory.java index 0080d5daf5..5a498f0a45 100644 --- a/core/src/io/anuke/mindustry/world/meta/StatCategory.java +++ b/core/src/io/anuke/mindustry/world/meta/StatCategory.java @@ -1,6 +1,6 @@ package io.anuke.mindustry.world.meta; -/**A specific category for a stat.*/ +/** A specific category for a stat. */ public enum StatCategory{ general, power, diff --git a/core/src/io/anuke/mindustry/world/meta/values/AmmoListValue.java b/core/src/io/anuke/mindustry/world/meta/values/AmmoListValue.java index a24788e4c9..5b05b47881 100644 --- a/core/src/io/anuke/mindustry/world/meta/values/AmmoListValue.java +++ b/core/src/io/anuke/mindustry/world/meta/values/AmmoListValue.java @@ -28,7 +28,7 @@ public class AmmoListValue implements StatValue{ table.row(); for(T t : map.keys()){ BulletType type = map.get(t); - table.addImage(icon(t)).size(3*8).padRight(4).right().top(); + table.addImage(icon(t)).size(3 * 8).padRight(4).right().top(); table.add(t.localizedName()).padRight(10).left().top(); table.table("underline", bt -> { bt.left().defaults().padRight(3).left(); @@ -41,8 +41,10 @@ public class AmmoListValue implements StatValue{ sep(bt, Core.bundle.format("bullet.splashdamage", (int)type.splashDamage, Strings.fixed(type.splashDamageRadius / tilesize, 1))); } - if(!Mathf.isEqual(type.ammoMultiplier, 1f)) sep(bt, Core.bundle.format("bullet.multiplier", (int)type.ammoMultiplier)); - if(!Mathf.isEqual(type.reloadMultiplier, 1f)) sep(bt, Core.bundle.format("bullet.reload", Strings.fixed(type.reloadMultiplier, 1))); + if(!Mathf.isEqual(type.ammoMultiplier, 1f)) + sep(bt, Core.bundle.format("bullet.multiplier", (int)type.ammoMultiplier)); + if(!Mathf.isEqual(type.reloadMultiplier, 1f)) + sep(bt, Core.bundle.format("bullet.reload", Strings.fixed(type.reloadMultiplier, 1))); if(type.knockback > 0){ sep(bt, Core.bundle.format("bullet.knockback", Strings.fixed(type.knockback, 1))); diff --git a/core/src/io/anuke/mindustry/world/meta/values/BooleanValue.java b/core/src/io/anuke/mindustry/world/meta/values/BooleanValue.java index 4d8e144590..49e2967e7e 100644 --- a/core/src/io/anuke/mindustry/world/meta/values/BooleanValue.java +++ b/core/src/io/anuke/mindustry/world/meta/values/BooleanValue.java @@ -1,7 +1,7 @@ package io.anuke.mindustry.world.meta.values; -import io.anuke.mindustry.world.meta.StatValue; import io.anuke.arc.scene.ui.layout.Table; +import io.anuke.mindustry.world.meta.StatValue; public class BooleanValue implements StatValue{ private final boolean value; diff --git a/core/src/io/anuke/mindustry/world/meta/values/LiquidFilterValue.java b/core/src/io/anuke/mindustry/world/meta/values/LiquidFilterValue.java index e4315ae0a2..e30c2b0ba5 100644 --- a/core/src/io/anuke/mindustry/world/meta/values/LiquidFilterValue.java +++ b/core/src/io/anuke/mindustry/world/meta/values/LiquidFilterValue.java @@ -1,11 +1,11 @@ package io.anuke.mindustry.world.meta.values; import io.anuke.arc.collection.Array; +import io.anuke.arc.function.Predicate; +import io.anuke.arc.scene.ui.layout.Table; import io.anuke.mindustry.type.Liquid; import io.anuke.mindustry.ui.LiquidDisplay; import io.anuke.mindustry.world.meta.StatValue; -import io.anuke.arc.function.Predicate; -import io.anuke.arc.scene.ui.layout.Table; import static io.anuke.mindustry.Vars.content; diff --git a/core/src/io/anuke/mindustry/world/meta/values/NumberValue.java b/core/src/io/anuke/mindustry/world/meta/values/NumberValue.java index fa2d3371ee..11080bc7b3 100644 --- a/core/src/io/anuke/mindustry/world/meta/values/NumberValue.java +++ b/core/src/io/anuke/mindustry/world/meta/values/NumberValue.java @@ -1,9 +1,9 @@ package io.anuke.mindustry.world.meta.values; -import io.anuke.mindustry.world.meta.StatUnit; -import io.anuke.mindustry.world.meta.StatValue; import io.anuke.arc.scene.ui.layout.Table; import io.anuke.arc.util.Strings; +import io.anuke.mindustry.world.meta.StatUnit; +import io.anuke.mindustry.world.meta.StatValue; /** * A stat that is a number with a unit attacked. @@ -20,7 +20,7 @@ public class NumberValue implements StatValue{ @Override public void display(Table table){ - int precision = Math.abs((int) value - value) <= 0.001f ? 0 : Math.abs((int) (value * 10) - value * 10) <= 0.001f ? 1 : 2; + int precision = Math.abs((int)value - value) <= 0.001f ? 0 : Math.abs((int)(value * 10) - value * 10) <= 0.001f ? 1 : 2; table.add(Strings.fixed(value, precision)); table.add((unit.space ? " " : "") + unit.localized()); diff --git a/core/src/io/anuke/mindustry/world/meta/values/StringValue.java b/core/src/io/anuke/mindustry/world/meta/values/StringValue.java index 830d897ab6..1b90d6b2ca 100644 --- a/core/src/io/anuke/mindustry/world/meta/values/StringValue.java +++ b/core/src/io/anuke/mindustry/world/meta/values/StringValue.java @@ -1,8 +1,8 @@ package io.anuke.mindustry.world.meta.values; -import io.anuke.mindustry.world.meta.StatValue; import io.anuke.arc.scene.ui.layout.Table; import io.anuke.arc.util.Strings; +import io.anuke.mindustry.world.meta.StatValue; public class StringValue implements StatValue{ private final String value; diff --git a/core/src/io/anuke/mindustry/world/modules/BlockModule.java b/core/src/io/anuke/mindustry/world/modules/BlockModule.java index 3d3e003b4e..377ba9c099 100644 --- a/core/src/io/anuke/mindustry/world/modules/BlockModule.java +++ b/core/src/io/anuke/mindustry/world/modules/BlockModule.java @@ -1,11 +1,10 @@ package io.anuke.mindustry.world.modules; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; +import java.io.*; -/**A class that represents compartmentalized tile entity state.*/ +/** A class that represents compartmentalized tile entity state. */ public abstract class BlockModule{ public abstract void write(DataOutput stream) throws IOException; + public abstract void read(DataInput stream) throws IOException; } diff --git a/core/src/io/anuke/mindustry/world/modules/ConsumeModule.java b/core/src/io/anuke/mindustry/world/modules/ConsumeModule.java index 9323375e71..c7a3c09b17 100644 --- a/core/src/io/anuke/mindustry/world/modules/ConsumeModule.java +++ b/core/src/io/anuke/mindustry/world/modules/ConsumeModule.java @@ -3,9 +3,7 @@ package io.anuke.mindustry.world.modules; import io.anuke.mindustry.entities.type.TileEntity; import io.anuke.mindustry.world.consumers.Consume; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; +import java.io.*; public class ConsumeModule extends BlockModule{ private boolean valid, optionalValid; diff --git a/core/src/io/anuke/mindustry/world/modules/ItemModule.java b/core/src/io/anuke/mindustry/world/modules/ItemModule.java index 5ff7e1ba40..e3df51d758 100644 --- a/core/src/io/anuke/mindustry/world/modules/ItemModule.java +++ b/core/src/io/anuke/mindustry/world/modules/ItemModule.java @@ -3,9 +3,7 @@ package io.anuke.mindustry.world.modules; import io.anuke.mindustry.type.Item; import io.anuke.mindustry.type.ItemStack; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; +import java.io.*; import java.util.Arrays; import static io.anuke.mindustry.Vars.content; @@ -15,7 +13,7 @@ public class ItemModule extends BlockModule{ private int[] items = new int[content.items().size]; private int total; - private int id = lastID ++; + private int id = lastID++; public void forEach(ItemConsumer cons){ for(int i = 0; i < items.length; i++){ @@ -98,8 +96,8 @@ public class ItemModule extends BlockModule{ public void addAll(ItemModule items){ for(int i = 0; i < items.items.length; i++){ - this.items[i] += items.items[i]; - total += items.items[i]; + this.items[i] += items.items[i]; + total += items.items[i]; } } diff --git a/core/src/io/anuke/mindustry/world/modules/LiquidModule.java b/core/src/io/anuke/mindustry/world/modules/LiquidModule.java index d963b9328f..33b02b85a7 100644 --- a/core/src/io/anuke/mindustry/world/modules/LiquidModule.java +++ b/core/src/io/anuke/mindustry/world/modules/LiquidModule.java @@ -2,9 +2,8 @@ package io.anuke.mindustry.world.modules; import io.anuke.mindustry.type.Liquid; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; +import java.io.*; + import static io.anuke.mindustry.Vars.content; public class LiquidModule extends BlockModule{ @@ -12,12 +11,12 @@ public class LiquidModule extends BlockModule{ private float total; private Liquid current = content.liquid(0); - /**Returns total amount of liquids.*/ + /** Returns total amount of liquids. */ public float total(){ return total; } - /**Last recieved or loaded liquid. Only valid for liquid modules with 1 type of liquid.*/ + /** Last recieved or loaded liquid. Only valid for liquid modules with 1 type of liquid. */ public Liquid current(){ return current; } diff --git a/core/src/io/anuke/mindustry/world/modules/PowerModule.java b/core/src/io/anuke/mindustry/world/modules/PowerModule.java index d7aa590517..a51e469064 100644 --- a/core/src/io/anuke/mindustry/world/modules/PowerModule.java +++ b/core/src/io/anuke/mindustry/world/modules/PowerModule.java @@ -4,19 +4,19 @@ import io.anuke.annotations.Annotations.NonNull; import io.anuke.arc.collection.IntArray; import io.anuke.mindustry.world.blocks.power.PowerGraph; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; +import java.io.*; public class PowerModule extends BlockModule{ - /** In case of unbuffered consumers, this is the percentage (1.0f = 100%) of the demanded power which can be supplied. - * Blocks will work at a reduced efficiency if this is not equal to 1.0f. - * In case of buffered consumers, this is the percentage of power stored in relation to the maximum capacity. + /** + * In case of unbuffered consumers, this is the percentage (1.0f = 100%) of the demanded power which can be supplied. + * Blocks will work at a reduced efficiency if this is not equal to 1.0f. + * In case of buffered consumers, this is the percentage of power stored in relation to the maximum capacity. */ public float satisfaction = 0.0f; /** Specifies power which is required additionally, e.g. while a force projector is being shot at. */ public float extraUse = 0f; - public @NonNull PowerGraph graph = new PowerGraph(); + public @NonNull + PowerGraph graph = new PowerGraph(); public IntArray links = new IntArray(); @Override diff --git a/desktop/build.gradle b/desktop/build.gradle index 2c8771239c..641a72cb01 100644 --- a/desktop/build.gradle +++ b/desktop/build.gradle @@ -6,8 +6,9 @@ sourceSets.main.java.srcDirs = ["src/"] project.ext.mainClassName = "io.anuke.mindustry.desktop.DesktopLauncher" project.ext.assetsDir = new File("../core/assets") -import com.badlogicgames.packr.PackrConfig + import com.badlogicgames.packr.Packr +import com.badlogicgames.packr.PackrConfig def JDK_DIR = "$System.env.PACKR_DIR" def ICON_DIR = new File("core/assets/sprites/icon.icns") @@ -146,7 +147,7 @@ task packrZip(){ } } } - + finalizedBy "clearOut" if(project.hasProperty("platform")){ diff --git a/desktop/packr_minimize.json b/desktop/packr_minimize.json index 0f3ad13771..8be61942cc 100644 --- a/desktop/packr_minimize.json +++ b/desktop/packr_minimize.json @@ -3,24 +3,23 @@ { "archive": "jre/lib/rt.jar", "paths": [ - - "javax/transaction", - "javax/tools", - "javax/swing", - "javax/sql", - "javax/smartcardio", - "javax/rmi", - "javax/print", - "javax/naming", - "javax/management", - "javax/lang", - "javax/jws", - "javax/swing", - "javax/imageio", - "javax/annotation", - "javax/activity", - "javax/activation", - "javax/accessibility", + "javax/transaction", + "javax/tools", + "javax/swing", + "javax/sql", + "javax/smartcardio", + "javax/rmi", + "javax/print", + "javax/naming", + "javax/management", + "javax/lang", + "javax/jws", + "javax/swing", + "javax/imageio", + "javax/annotation", + "javax/activity", + "javax/activation", + "javax/accessibility", "com/sun/corba", "com/sun/jmx", "com/sun/org", @@ -37,9 +36,7 @@ "com/sun/media", "com/sun/naming", "java/awt", - - "com/sun/org/apache/xpath", - + "com/sun/org/apache/xpath", "com/sun/rowset", "com/sun/script", "sun/applet", diff --git a/desktop/src/io/anuke/mindustry/desktop/CrashHandler.java b/desktop/src/io/anuke/mindustry/desktop/CrashHandler.java index d8ddeefd67..24a0fa4529 100644 --- a/desktop/src/io/anuke/mindustry/desktop/CrashHandler.java +++ b/desktop/src/io/anuke/mindustry/desktop/CrashHandler.java @@ -57,8 +57,8 @@ public class CrashHandler{ dialog(() -> TinyFileDialogs.tinyfd_messageBox("oh no", e.getMessage().contains("Couldn't create window") ? "A graphics initialization error has occured! Try to update your graphics drivers.\nReport this to the developer." : "Your graphics card does not support OpenGL 2.0!\n" + - "Try to update your graphics drivers.\n\n" + - "(If that doesn't work, your computer just doesn't support Mindustry.)", "ok", "error", true)); + "Try to update your graphics drivers.\n\n" + + "(If that doesn't work, your computer just doesn't support Mindustry.)", "ok", "error", true)); badGPU = true; } @@ -93,12 +93,12 @@ public class CrashHandler{ try{ Path path = Paths.get(OS.getAppDataDirectoryString(Vars.appName), "crashes", - "crash-report-" + DateTimeFormatter.ofPattern("MM_dd_yyyy_HH_mm_ss").format(LocalDateTime.now()) + ".txt"); + "crash-report-" + DateTimeFormatter.ofPattern("MM_dd_yyyy_HH_mm_ss").format(LocalDateTime.now()) + ".txt"); Files.createDirectories(Paths.get(OS.getAppDataDirectoryString(Vars.appName), "crashes")); Files.write(path, parseException(e).getBytes()); if(!badGPU){ - dialog(() -> TinyFileDialogs.tinyfd_messageBox("oh no", "A crash has occured. It has been saved in:\n" + path.toAbsolutePath().toString(), "ok", "error", true)); + dialog(() -> TinyFileDialogs.tinyfd_messageBox("oh no", "A crash has occured. It has been saved in:\n" + path.toAbsolutePath().toString(), "ok", "error", true)); } }catch(Throwable t){ Log.err("Failed to save local crash report."); @@ -116,7 +116,10 @@ public class CrashHandler{ }); //sleep for 10 seconds or until crash report is sent - try{ Thread.sleep(10000); }catch(InterruptedException ignored){} + try{ + Thread.sleep(10000); + }catch(InterruptedException ignored){ + } } private static void dialog(Runnable r){ diff --git a/desktop/src/io/anuke/mindustry/desktop/DesktopPlatform.java b/desktop/src/io/anuke/mindustry/desktop/DesktopPlatform.java index f433a4de9e..95f98560ed 100644 --- a/desktop/src/io/anuke/mindustry/desktop/DesktopPlatform.java +++ b/desktop/src/io/anuke/mindustry/desktop/DesktopPlatform.java @@ -1,8 +1,6 @@ package io.anuke.mindustry.desktop; -import club.minnced.discord.rpc.DiscordEventHandlers; -import club.minnced.discord.rpc.DiscordRPC; -import club.minnced.discord.rpc.DiscordRichPresence; +import club.minnced.discord.rpc.*; import io.anuke.arc.collection.Array; import io.anuke.arc.files.FileHandle; import io.anuke.arc.function.Consumer; @@ -85,7 +83,8 @@ public class DesktopPlatform extends Platform{ try{ Enumeration e = NetworkInterface.getNetworkInterfaces(); NetworkInterface out; - for(out = e.nextElement(); (out.getHardwareAddress() == null || !validAddress(out.getHardwareAddress())) && e.hasMoreElements(); out = e.nextElement()) ; + for(out = e.nextElement(); (out.getHardwareAddress() == null || !validAddress(out.getHardwareAddress())) && e.hasMoreElements(); out = e.nextElement()) + ; byte[] bytes = out.getHardwareAddress(); byte[] result = new byte[8]; diff --git a/ios/build.gradle b/ios/build.gradle index d0bfc1752f..4859a5c758 100644 --- a/ios/build.gradle +++ b/ios/build.gradle @@ -1,10 +1,10 @@ -sourceSets.main.java.srcDirs = [ "src/" ] +sourceSets.main.java.srcDirs = ["src/"] sourceCompatibility = '1.8' [compileJava, compileTestJava]*.options*.encoding = 'UTF-8' -ext { - mainClassName = "io.anuke.mindustry.IOSLauncher" +ext{ + mainClassName = "io.anuke.mindustry.IOSLauncher" } launchIPhoneSimulator.dependsOn build @@ -12,6 +12,6 @@ launchIPadSimulator.dependsOn build launchIOSDevice.dependsOn build createIPA.dependsOn build -robovm { - archs = "thumbv7:arm64" +robovm{ + archs = "thumbv7:arm64" } \ No newline at end of file diff --git a/ios/data/Assets.xcassets/AppIcon.appiconset/Contents.json b/ios/data/Assets.xcassets/AppIcon.appiconset/Contents.json index 3f350d6fd8..2210d686de 100644 --- a/ios/data/Assets.xcassets/AppIcon.appiconset/Contents.json +++ b/ios/data/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -1,116 +1,116 @@ { - "images" : [ + "images": [ { - "size" : "20x20", - "idiom" : "iphone", - "filename" : "icon-40.png", - "scale" : "2x" + "size": "20x20", + "idiom": "iphone", + "filename": "icon-40.png", + "scale": "2x" }, { - "size" : "20x20", - "idiom" : "iphone", - "filename" : "icon-60.png", - "scale" : "3x" + "size": "20x20", + "idiom": "iphone", + "filename": "icon-60.png", + "scale": "3x" }, { - "size" : "29x29", - "idiom" : "iphone", - "filename" : "icon-58.png", - "scale" : "2x" + "size": "29x29", + "idiom": "iphone", + "filename": "icon-58.png", + "scale": "2x" }, { - "size" : "29x29", - "idiom" : "iphone", - "filename" : "icon-87.png", - "scale" : "3x" + "size": "29x29", + "idiom": "iphone", + "filename": "icon-87.png", + "scale": "3x" }, { - "size" : "40x40", - "idiom" : "iphone", - "filename" : "icon-80.png", - "scale" : "2x" + "size": "40x40", + "idiom": "iphone", + "filename": "icon-80.png", + "scale": "2x" }, { - "size" : "40x40", - "idiom" : "iphone", - "filename" : "icon-120.png", - "scale" : "3x" + "size": "40x40", + "idiom": "iphone", + "filename": "icon-120.png", + "scale": "3x" }, { - "size" : "60x60", - "idiom" : "iphone", - "filename" : "icon-120.png", - "scale" : "2x" + "size": "60x60", + "idiom": "iphone", + "filename": "icon-120.png", + "scale": "2x" }, { - "size" : "60x60", - "idiom" : "iphone", - "filename" : "icon-180.png", - "scale" : "3x" + "size": "60x60", + "idiom": "iphone", + "filename": "icon-180.png", + "scale": "3x" }, { - "size" : "20x20", - "idiom" : "ipad", - "filename" : "icon-20.png", - "scale" : "1x" + "size": "20x20", + "idiom": "ipad", + "filename": "icon-20.png", + "scale": "1x" }, { - "size" : "20x20", - "idiom" : "ipad", - "filename" : "icon-40.png", - "scale" : "2x" + "size": "20x20", + "idiom": "ipad", + "filename": "icon-40.png", + "scale": "2x" }, { - "size" : "29x29", - "idiom" : "ipad", - "filename" : "icon-29.png", - "scale" : "1x" + "size": "29x29", + "idiom": "ipad", + "filename": "icon-29.png", + "scale": "1x" }, { - "size" : "29x29", - "idiom" : "ipad", - "filename" : "icon-58.png", - "scale" : "2x" + "size": "29x29", + "idiom": "ipad", + "filename": "icon-58.png", + "scale": "2x" }, { - "size" : "40x40", - "idiom" : "ipad", - "filename" : "icon-40.png", - "scale" : "1x" + "size": "40x40", + "idiom": "ipad", + "filename": "icon-40.png", + "scale": "1x" }, { - "size" : "40x40", - "idiom" : "ipad", - "filename" : "icon-80.png", - "scale" : "2x" + "size": "40x40", + "idiom": "ipad", + "filename": "icon-80.png", + "scale": "2x" }, { - "size" : "76x76", - "idiom" : "ipad", - "filename" : "icon-76.png", - "scale" : "1x" + "size": "76x76", + "idiom": "ipad", + "filename": "icon-76.png", + "scale": "1x" }, { - "size" : "76x76", - "idiom" : "ipad", - "filename" : "icon-152.png", - "scale" : "2x" + "size": "76x76", + "idiom": "ipad", + "filename": "icon-152.png", + "scale": "2x" }, { - "size" : "83.5x83.5", - "idiom" : "ipad", - "filename" : "icon-167.png", - "scale" : "2x" + "size": "83.5x83.5", + "idiom": "ipad", + "filename": "icon-167.png", + "scale": "2x" }, { - "size" : "1024x1024", - "idiom" : "ios-marketing", - "filename" : "icon-main.png", - "scale" : "1x" + "size": "1024x1024", + "idiom": "ios-marketing", + "filename": "icon-main.png", + "scale": "1x" } ], - "info" : { - "version" : 1, - "author" : "xcode" + "info": { + "version": 1, + "author": "xcode" } } \ No newline at end of file diff --git a/ios/data/Assets.xcassets/Contents.json b/ios/data/Assets.xcassets/Contents.json index da4a164c91..121dee67a6 100644 --- a/ios/data/Assets.xcassets/Contents.json +++ b/ios/data/Assets.xcassets/Contents.json @@ -1,6 +1,6 @@ { - "info" : { - "version" : 1, - "author" : "xcode" + "info": { + "version": 1, + "author": "xcode" } } \ No newline at end of file diff --git a/ios/robovm.xml b/ios/robovm.xml index a7a06eeb22..146861dd40 100644 --- a/ios/robovm.xml +++ b/ios/robovm.xml @@ -1,49 +1,49 @@ - ${app.executable} - ${app.mainclass} - ios - thumbv7 - ios - Info.plist.xml - - - ../core/assets - - ** - - true - - - data - - - - net.jpountz.lz4.** - io.anuke.arc.scene.** - io.anuke.mindustry.gen.Call - io.anuke.mindustry.net.** - com.android.okhttp.HttpHandler - com.android.okhttp.HttpsHandler - com.android.org.conscrypt.** - com.android.org.bouncycastle.jce.provider.BouncyCastleProvider - com.android.org.bouncycastle.jcajce.provider.keystore.BC$Mappings - com.android.org.bouncycastle.jcajce.provider.keystore.bc.BcKeyStoreSpi - com.android.org.bouncycastle.jcajce.provider.keystore.bc.BcKeyStoreSpi$Std - com.android.org.bouncycastle.jce.provider.PKIXCertPathValidatorSpi - com.android.org.bouncycastle.crypto.digests.AndroidDigestFactoryOpenSSL - org.apache.harmony.security.provider.cert.DRLCertFactory - org.apache.harmony.security.provider.crypto.CryptoProvider - - - z - - - UIKit - OpenGLES - QuartzCore - CoreGraphics - OpenAL - AudioToolbox - AVFoundation - + ${app.executable} + ${app.mainclass} + ios + thumbv7 + ios + Info.plist.xml + + + ../core/assets + + ** + + true + + + data + + + + net.jpountz.lz4.** + io.anuke.arc.scene.** + io.anuke.mindustry.gen.Call + io.anuke.mindustry.net.** + com.android.okhttp.HttpHandler + com.android.okhttp.HttpsHandler + com.android.org.conscrypt.** + com.android.org.bouncycastle.jce.provider.BouncyCastleProvider + com.android.org.bouncycastle.jcajce.provider.keystore.BC$Mappings + com.android.org.bouncycastle.jcajce.provider.keystore.bc.BcKeyStoreSpi + com.android.org.bouncycastle.jcajce.provider.keystore.bc.BcKeyStoreSpi$Std + com.android.org.bouncycastle.jce.provider.PKIXCertPathValidatorSpi + com.android.org.bouncycastle.crypto.digests.AndroidDigestFactoryOpenSSL + org.apache.harmony.security.provider.cert.DRLCertFactory + org.apache.harmony.security.provider.crypto.CryptoProvider + + + z + + + UIKit + OpenGLES + QuartzCore + CoreGraphics + OpenAL + AudioToolbox + AVFoundation + diff --git a/ios/src/io/anuke/mindustry/IOSLauncher.java b/ios/src/io/anuke/mindustry/IOSLauncher.java index 7ba5f28f03..3f795ee768 100644 --- a/ios/src/io/anuke/mindustry/IOSLauncher.java +++ b/ios/src/io/anuke/mindustry/IOSLauncher.java @@ -6,12 +6,12 @@ import io.anuke.arc.Core; import io.anuke.arc.files.FileHandle; import io.anuke.arc.scene.ui.layout.Unit; import io.anuke.arc.util.Strings; -import io.anuke.net.KryoClient; -import io.anuke.net.KryoServer; import io.anuke.mindustry.core.Platform; import io.anuke.mindustry.game.Saves.SaveSlot; import io.anuke.mindustry.io.SaveIO; import io.anuke.mindustry.net.Net; +import io.anuke.net.KryoClient; +import io.anuke.net.KryoServer; import org.robovm.apple.foundation.NSAutoreleasePool; import org.robovm.apple.foundation.NSURL; import org.robovm.apple.uikit.*; @@ -22,11 +22,11 @@ import java.util.Collections; import static io.anuke.mindustry.Vars.*; import static org.robovm.apple.foundation.NSPathUtilities.getDocumentsDirectory; -public class IOSLauncher extends IOSApplication.Delegate { +public class IOSLauncher extends IOSApplication.Delegate{ private boolean forced; @Override - protected IOSApplication createApplication() { + protected IOSApplication createApplication(){ Net.setClientProvider(new KryoClient()); Net.setServerProvider(new KryoServer()); @@ -36,7 +36,7 @@ public class IOSLauncher extends IOSApplication.Delegate { Unit.dp.addition = -0.5f; } - Platform.instance = new Platform() { + Platform.instance = new Platform(){ @Override public void shareFile(FileHandle file){ @@ -72,14 +72,14 @@ public class IOSLauncher extends IOSApplication.Delegate { } @Override - public boolean openURL(UIApplication app, NSURL url, UIApplicationOpenURLOptions options) { + public boolean openURL(UIApplication app, NSURL url, UIApplicationOpenURLOptions options){ System.out.println("Opened URL: " + url.getPath()); openURL(url); return false; } @Override - public boolean didFinishLaunching(UIApplication application, UIApplicationLaunchOptions options) { + public boolean didFinishLaunching(UIApplication application, UIApplicationLaunchOptions options){ boolean b = super.didFinishLaunching(application, options); if(options != null && options.has(UIApplicationLaunchOptions.Keys.URL())){ @@ -102,7 +102,7 @@ public class IOSLauncher extends IOSApplication.Delegate { try{ SaveSlot slot = control.saves.importSave(file); ui.load.runLoadSave(slot); - }catch (IOException e){ + }catch(IOException e){ ui.showError(Core.bundle.format("save.import.fail", Strings.parseException(e, false))); } }else{ @@ -111,7 +111,7 @@ public class IOSLauncher extends IOSApplication.Delegate { }else if(file.extension().equalsIgnoreCase(mapExtension)){ //open map Core.app.post(() -> { - if (!ui.editor.isShown()) { + if(!ui.editor.isShown()){ ui.editor.show(); } @@ -121,7 +121,7 @@ public class IOSLauncher extends IOSApplication.Delegate { }); } - public static void main(String[] argv) { + public static void main(String[] argv){ NSAutoreleasePool pool = new NSAutoreleasePool(); UIApplication.main(argv, null, IOSLauncher.class); pool.close(); diff --git a/net/src/io/anuke/net/ByteSerializer.java b/net/src/io/anuke/net/ByteSerializer.java index a841d71994..4d01745afe 100644 --- a/net/src/io/anuke/net/ByteSerializer.java +++ b/net/src/io/anuke/net/ByteSerializer.java @@ -15,8 +15,8 @@ public class ByteSerializer implements Serialization{ @Override public void write(ByteBuffer byteBuffer, Object o){ if(o instanceof FrameworkMessage){ - byteBuffer.put((byte) -2); //code for framework message - FrameworkSerializer.write(byteBuffer, (FrameworkMessage) o); + byteBuffer.put((byte)-2); //code for framework message + FrameworkSerializer.write(byteBuffer, (FrameworkMessage)o); }else{ if(!(o instanceof Packet)) throw new RuntimeException("All sent objects must implement be Packets! Class: " + o.getClass()); @@ -24,7 +24,7 @@ public class ByteSerializer implements Serialization{ if(id == -1) throw new RuntimeException("Unregistered class: " + o.getClass()); byteBuffer.put(id); - ((Packet) o).write(byteBuffer); + ((Packet)o).write(byteBuffer); } } @@ -34,7 +34,7 @@ public class ByteSerializer implements Serialization{ if(id == -2){ return FrameworkSerializer.read(byteBuffer); }else{ - Packet packet = Pools.obtain((Class) Registrator.getByID(id).type, (Supplier) Registrator.getByID(id).constructor); + Packet packet = Pools.obtain((Class)Registrator.getByID(id).type, (Supplier)Registrator.getByID(id).constructor); packet.read(byteBuffer); return packet; } @@ -47,7 +47,7 @@ public class ByteSerializer implements Serialization{ @Override public void writeLength(ByteBuffer byteBuffer, int i){ - byteBuffer.putShort((short) i); + byteBuffer.putShort((short)i); } @Override diff --git a/net/src/io/anuke/net/FrameworkSerializer.java b/net/src/io/anuke/net/FrameworkSerializer.java index 6cc45e005e..9e7b472e37 100644 --- a/net/src/io/anuke/net/FrameworkSerializer.java +++ b/net/src/io/anuke/net/FrameworkSerializer.java @@ -9,28 +9,28 @@ public class FrameworkSerializer{ public static void write(ByteBuffer buffer, FrameworkMessage message){ if(message instanceof Ping){ - Ping p = (Ping) message; + Ping p = (Ping)message; - buffer.put((byte) 0); + buffer.put((byte)0); buffer.putInt(p.id); - buffer.put(p.isReply ? 1 : (byte) 0); + buffer.put(p.isReply ? 1 : (byte)0); }else if(message instanceof DiscoverHost){ - DiscoverHost p = (DiscoverHost) message; + DiscoverHost p = (DiscoverHost)message; - buffer.put((byte) 1); + buffer.put((byte)1); }else if(message instanceof KeepAlive){ - KeepAlive p = (KeepAlive) message; + KeepAlive p = (KeepAlive)message; - buffer.put((byte) 2); + buffer.put((byte)2); }else if(message instanceof RegisterUDP){ - RegisterUDP p = (RegisterUDP) message; + RegisterUDP p = (RegisterUDP)message; - buffer.put((byte) 3); + buffer.put((byte)3); buffer.putInt(p.connectionID); }else if(message instanceof RegisterTCP){ - RegisterTCP p = (RegisterTCP) message; + RegisterTCP p = (RegisterTCP)message; - buffer.put((byte) 4); + buffer.put((byte)4); buffer.putInt(p.connectionID); } } diff --git a/net/src/io/anuke/net/KryoClient.java b/net/src/io/anuke/net/KryoClient.java index 844ab361f8..2c24b2e687 100644 --- a/net/src/io/anuke/net/KryoClient.java +++ b/net/src/io/anuke/net/KryoClient.java @@ -5,24 +5,17 @@ import io.anuke.arc.Core; import io.anuke.arc.collection.Array; import io.anuke.arc.function.Consumer; import io.anuke.arc.util.pooling.Pools; -import io.anuke.mindustry.net.Host; -import io.anuke.mindustry.net.Net; +import io.anuke.mindustry.net.*; import io.anuke.mindustry.net.Net.ClientProvider; import io.anuke.mindustry.net.Net.SendMode; -import io.anuke.mindustry.net.NetworkIO; import io.anuke.mindustry.net.Packets.Connect; import io.anuke.mindustry.net.Packets.Disconnect; import net.jpountz.lz4.LZ4Factory; import net.jpountz.lz4.LZ4FastDecompressor; import java.io.IOException; -import java.net.DatagramPacket; -import java.net.DatagramSocket; -import java.net.InetAddress; -import java.net.NetworkInterface; -import java.nio.BufferOverflowException; -import java.nio.BufferUnderflowException; -import java.nio.ByteBuffer; +import java.net.*; +import java.nio.*; import java.nio.channels.ClosedSelectorException; import static io.anuke.mindustry.Vars.netClient; diff --git a/net/src/io/anuke/net/KryoCore.java b/net/src/io/anuke/net/KryoCore.java index 59792bf67f..3e4be3ab3f 100644 --- a/net/src/io/anuke/net/KryoCore.java +++ b/net/src/io/anuke/net/KryoCore.java @@ -61,6 +61,6 @@ public class KryoCore{ } private static int calculateLag(){ - return fakeLagMin + (int) (Math.random() * (fakeLagMax - fakeLagMin)); + return fakeLagMin + (int)(Math.random() * (fakeLagMax - fakeLagMin)); } } diff --git a/net/src/io/anuke/net/KryoServer.java b/net/src/io/anuke/net/KryoServer.java index 47b495958a..5304913a6d 100644 --- a/net/src/io/anuke/net/KryoServer.java +++ b/net/src/io/anuke/net/KryoServer.java @@ -1,11 +1,8 @@ package io.anuke.net; import com.dosse.upnp.UPnP; -import com.esotericsoftware.kryonet.Connection; -import com.esotericsoftware.kryonet.FrameworkMessage; -import com.esotericsoftware.kryonet.Listener; +import com.esotericsoftware.kryonet.*; import com.esotericsoftware.kryonet.Listener.LagListener; -import com.esotericsoftware.kryonet.Server; import com.esotericsoftware.kryonet.util.InputStreamSender; import io.anuke.arc.Core; import io.anuke.arc.collection.Array; @@ -15,10 +12,7 @@ import io.anuke.mindustry.Vars; import io.anuke.mindustry.net.*; import io.anuke.mindustry.net.Net.SendMode; import io.anuke.mindustry.net.Net.ServerProvider; -import io.anuke.mindustry.net.Packets.Connect; -import io.anuke.mindustry.net.Packets.Disconnect; -import io.anuke.mindustry.net.Packets.StreamBegin; -import io.anuke.mindustry.net.Packets.StreamChunk; +import io.anuke.mindustry.net.Packets.*; import net.jpountz.lz4.LZ4Compressor; import net.jpountz.lz4.LZ4Factory; diff --git a/server/build.gradle b/server/build.gradle index 09b14a55e8..2148cae4ca 100644 --- a/server/build.gradle +++ b/server/build.gradle @@ -1,7 +1,7 @@ apply plugin: "java" sourceCompatibility = 1.8 -sourceSets.main.java.srcDirs = [ "src/" ] +sourceSets.main.java.srcDirs = ["src/"] project.ext.mainClassName = "io.anuke.mindustry.server.ServerLauncher" project.ext.assetsDir = new File("../core/assets") @@ -10,18 +10,18 @@ ext.getServerFolder = { return "../deploy/${appName}-server-${getVersionString()}" } -task run(dependsOn: classes, type: JavaExec) { +task run(dependsOn: classes, type: JavaExec){ main = project.mainClassName classpath = sourceSets.main.runtimeClasspath standardInput = System.in workingDir = project.assetsDir ignoreExitValue = true - if (project.hasProperty("appArgs")) { + if(project.hasProperty("appArgs")){ args Eval.me(appArgs) } } -task debug(dependsOn: classes, type: JavaExec) { +task debug(dependsOn: classes, type: JavaExec){ main = project.mainClassName classpath = sourceSets.main.runtimeClasspath standardInput = System.in @@ -30,10 +30,10 @@ task debug(dependsOn: classes, type: JavaExec) { debug = true } -task dist(type: Jar) { +task dist(type: Jar){ from files(sourceSets.main.output.classesDirs) from files(sourceSets.main.output.resourcesDir) - from {configurations.compile.collect {zipTree(it)}} + from{ configurations.compile.collect{ zipTree(it) } } from files(project.assetsDir) exclude("sprites/**") exclude("fonts/**") @@ -41,8 +41,8 @@ task dist(type: Jar) { exclude("bundles/**") writeVersion() - - manifest { + + manifest{ attributes 'Main-Class': project.mainClassName } } diff --git a/server/src/io/anuke/mindustry/server/CrashHandler.java b/server/src/io/anuke/mindustry/server/CrashHandler.java index 9537a1d6bb..3e65ffb84c 100644 --- a/server/src/io/anuke/mindustry/server/CrashHandler.java +++ b/server/src/io/anuke/mindustry/server/CrashHandler.java @@ -12,9 +12,7 @@ import io.anuke.mindustry.net.Net; import java.io.PrintWriter; import java.io.StringWriter; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; +import java.nio.file.*; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; @@ -55,7 +53,7 @@ public class CrashHandler{ try{ Path path = Paths.get(OS.getAppDataDirectoryString(Vars.appName), "crashes", - "crash-report-" + DateTimeFormatter.ofPattern("MM-dd-yyyy-HH:mm:ss").format(LocalDateTime.now()) + ".txt"); + "crash-report-" + DateTimeFormatter.ofPattern("MM-dd-yyyy-HH:mm:ss").format(LocalDateTime.now()) + ".txt"); Files.createDirectories(Paths.get(OS.getAppDataDirectoryString(Vars.appName), "crashes")); Files.write(path, parseException(e).getBytes()); @@ -70,7 +68,10 @@ public class CrashHandler{ Net.http(Vars.crashReportURL, "POST", value.toJson(OutputType.json), r -> System.exit(1), t -> System.exit(1)); //sleep forever - try{ Thread.sleep(Long.MAX_VALUE); }catch(InterruptedException ignored){} + try{ + Thread.sleep(Long.MAX_VALUE); + }catch(InterruptedException ignored){ + } } private static String parseException(Throwable e){ diff --git a/server/src/io/anuke/mindustry/server/MindustryServer.java b/server/src/io/anuke/mindustry/server/MindustryServer.java index 94a3a01587..0f61363859 100644 --- a/server/src/io/anuke/mindustry/server/MindustryServer.java +++ b/server/src/io/anuke/mindustry/server/MindustryServer.java @@ -3,9 +3,7 @@ package io.anuke.mindustry.server; import io.anuke.arc.ApplicationListener; import io.anuke.arc.Core; import io.anuke.mindustry.Vars; -import io.anuke.mindustry.core.Logic; -import io.anuke.mindustry.core.NetServer; -import io.anuke.mindustry.core.World; +import io.anuke.mindustry.core.*; import io.anuke.mindustry.game.Content; import io.anuke.mindustry.io.BundleLoader; diff --git a/server/src/io/anuke/mindustry/server/ServerControl.java b/server/src/io/anuke/mindustry/server/ServerControl.java index 27933b3bb7..5af2f4fc4c 100644 --- a/server/src/io/anuke/mindustry/server/ServerControl.java +++ b/server/src/io/anuke/mindustry/server/ServerControl.java @@ -1,16 +1,12 @@ package io.anuke.mindustry.server; -import io.anuke.arc.ApplicationListener; -import io.anuke.arc.Core; -import io.anuke.arc.Events; +import io.anuke.arc.*; import io.anuke.arc.collection.Array; import io.anuke.arc.collection.Array.ArrayIterable; import io.anuke.arc.collection.ObjectSet; import io.anuke.arc.files.FileHandle; import io.anuke.arc.util.*; -import io.anuke.arc.util.CommandHandler.Command; -import io.anuke.arc.util.CommandHandler.Response; -import io.anuke.arc.util.CommandHandler.ResponseType; +import io.anuke.arc.util.CommandHandler.*; import io.anuke.arc.util.Timer.Task; import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.entities.Effects; @@ -50,13 +46,13 @@ public class ServerControl implements ApplicationListener{ public ServerControl(String[] args){ Core.settings.defaults( - "shufflemode", "normal", - "bans", "", - "admins", "", - "shuffle", true, - "crashreport", false, - "port", port, - "logging", true + "shufflemode", "normal", + "bans", "", + "admins", "", + "shuffle", true, + "crashreport", false, + "port", port, + "logging", true ); Log.setLogger(new LogHandler(){ @@ -94,8 +90,10 @@ public class ServerControl implements ApplicationListener{ }); Time.setDeltaProvider(() -> Core.graphics.getDeltaTime() * 60f); - Effects.setScreenShakeProvider((a, b) -> {}); - Effects.setEffectProvider((a, b, c, d, e, f) -> {}); + Effects.setScreenShakeProvider((a, b) -> { + }); + Effects.setEffectProvider((a, b, c, d, e, f) -> { + }); registerCommands(); @@ -144,8 +142,8 @@ public class ServerControl implements ApplicationListener{ Call.onInfoMessage((state.rules.pvp ? "[YELLOW]The " + event.winner.name() + " team is victorious![]" : "[SCARLET]Game over![]") - + "\nNext selected map:[accent] "+map.name()+"[]" - + (map.tags.containsKey("author") && !map.tags.get("author").trim().isEmpty() ? " by[accent] " + map.author() + "[]" : "") + "."+ + + "\nNext selected map:[accent] " + map.name() + "[]" + + (map.tags.containsKey("author") && !map.tags.get("author").trim().isEmpty() ? " by[accent] " + map.author() + "[]" : "") + "." + "\nNew game begins in " + roundExtraTime + " seconds."); info("Selected next map to be {0}.", map.name()); @@ -280,10 +278,10 @@ public class ServerControl implements ApplicationListener{ if(state.rules.waves){ info("&ly {0} enemies.", unitGroups[Team.red.ordinal()].size()); }else{ - info("&ly {0} seconds until next wave.", (int) (state.wavetime / 60)); + info("&ly {0} seconds until next wave.", (int)(state.wavetime / 60)); } - info(" &ly{0} FPS, {1} MB used.", (int)(60f/Time.delta()), Core.app.getJavaHeap() / 1024 / 1024); + info(" &ly{0} FPS, {1} MB used.", (int)(60f / Time.delta()), Core.app.getJavaHeap() / 1024 / 1024); if(playerGroup.size() > 0){ info(" &lyPlayers: {0}", playerGroup.size()); @@ -321,7 +319,7 @@ public class ServerControl implements ApplicationListener{ err("Not playing. Host first."); return; } - + try{ Team team = arg.length == 0 ? Team.blue : Team.valueOf(arg[0]); @@ -329,13 +327,13 @@ public class ServerControl implements ApplicationListener{ err("That team has no cores."); return; } - + for(Item item : content.items()){ if(item.type == ItemType.material){ state.teams.get(team).cores.first().entity.items.set(item, state.teams.get(team).cores.first().block().itemCapacity); } } - + info("Core filled."); }catch(IllegalArgumentException ignored){ err("No such team exists."); @@ -357,9 +355,9 @@ public class ServerControl implements ApplicationListener{ }); handler.register("strict", "", "Disables or enables strict mode", arg -> { - boolean value = arg[0].equalsIgnoreCase("on"); - netServer.admins.setStrict(value); - info("Strict mode is now {0}.", netServer.admins.getStrict() ? "on" : "off"); + boolean value = arg[0].equalsIgnoreCase("on"); + netServer.admins.setStrict(value); + info("Strict mode is now {0}.", netServer.admins.getStrict() ? "on" : "off"); }); handler.register("allow-custom-clients", "[on/off]", "Allow or disallow custom clients.", arg -> { @@ -595,7 +593,7 @@ public class ServerControl implements ApplicationListener{ int i = 0; for(PlayerInfo info : infos){ - info("&lc[{0}] Trace info for player '{1}' / UUID {2}", i ++, info.lastName, info.id); + info("&lc[{0}] Trace info for player '{1}' / UUID {2}", i++, info.lastName, info.id); info(" &lyall names used: {0}", info.names); info(" &lyIP: {0}", info.lastIP); info(" &lyall IPs used: {0}", info.ips); @@ -706,14 +704,14 @@ public class ServerControl implements ApplicationListener{ private void logToFile(String text){ if(currentLogFile != null && currentLogFile.length() > maxLogLength){ String date = DateTimeFormatter.ofPattern("MM-dd-yyyy | HH:mm:ss").format(LocalDateTime.now()); - currentLogFile.writeString("[End of log file. Date: "+ date + "]\n", true); + currentLogFile.writeString("[End of log file. Date: " + date + "]\n", true); currentLogFile = null; } if(currentLogFile == null){ int i = 0; while(logFolder.child("log-" + i + ".txt").length() >= maxLogLength){ - i ++; + i++; } currentLogFile = logFolder.child("log-" + i + ".txt"); diff --git a/settings.gradle b/settings.gradle index be98da3db5..dd3c19e139 100644 --- a/settings.gradle +++ b/settings.gradle @@ -20,7 +20,7 @@ if(new File(settingsDir, 'local.properties').exists()){ } if(!hasProperty("release")){ - if (new File(settingsDir, '../Arc').exists()) { + if(new File(settingsDir, '../Arc').exists()){ use(':Arc', '../Arc') use(':Arc:arc-core', '../Arc/arc-core') use(':Arc:extensions', '../Arc/extensions') @@ -33,7 +33,7 @@ if(!hasProperty("release")){ use(':Arc:backends:backend-robovm', '../Arc/backends/backend-robovm') use(':Arc:backends:backend-headless', '../Arc/backends/backend-headless') } - if (new File(settingsDir, '../debug').exists()) { + if(new File(settingsDir, '../debug').exists()){ use(':debug', '../debug') } }else{ diff --git a/tests/src/test/java/ApplicationTests.java b/tests/src/test/java/ApplicationTests.java index 95484142d7..ef40719bf4 100644 --- a/tests/src/test/java/ApplicationTests.java +++ b/tests/src/test/java/ApplicationTests.java @@ -87,7 +87,7 @@ public class ApplicationTests{ @BeforeEach void resetWorld(){ - Time.setDeltaProvider(() -> 1f); + Time.setDeltaProvider(() -> 1f); logic.reset(); state.set(State.menu); } @@ -138,8 +138,8 @@ public class ApplicationTests{ int by = 4; world.setBlock(world.tile(bx, by), Blocks.coreShard, Team.blue); assertEquals(world.tile(bx, by).getTeam(), Team.blue); - for(int x = bx-1; x <= bx + 1; x++){ - for(int y = by-1; y <= by + 1; y++){ + for(int x = bx - 1; x <= bx + 1; x++){ + for(int y = by - 1; y <= by + 1; y++){ if(x == bx && by == y){ assertEquals(world.tile(x, y).block(), Blocks.coreShard); }else{ @@ -247,8 +247,8 @@ public class ApplicationTests{ void buildingOverlap(){ initBuilding(); - Spirit d1 = (Spirit) UnitTypes.spirit.create(Team.blue); - Spirit d2 = (Spirit) UnitTypes.spirit.create(Team.blue); + Spirit d1 = (Spirit)UnitTypes.spirit.create(Team.blue); + Spirit d2 = (Spirit)UnitTypes.spirit.create(Team.blue); d1.set(10f, 20f); d2.set(10f, 20f); @@ -302,8 +302,8 @@ public class ApplicationTests{ void buildingDestruction(){ initBuilding(); - Spirit d1 = (Spirit) UnitTypes.spirit.create(Team.blue); - Spirit d2 = (Spirit) UnitTypes.spirit.create(Team.blue); + Spirit d1 = (Spirit)UnitTypes.spirit.create(Team.blue); + Spirit d2 = (Spirit)UnitTypes.spirit.create(Team.blue); d1.set(10f, 20f); d2.set(10f, 20f); @@ -340,7 +340,7 @@ public class ApplicationTests{ } int i = 0; - for(int x = 5; x < tiles.length && i < content.blocks().size;){ + for(int x = 5; x < tiles.length && i < content.blocks().size; ){ Block block = content.block(i++); if(block.buildVisibility.get()){ tiles[x][5].setBlock(block); diff --git a/tests/src/test/java/WorldTests.java b/tests/src/test/java/WorldTests.java index ab89865ecf..2b4f480bfa 100644 --- a/tests/src/test/java/WorldTests.java +++ b/tests/src/test/java/WorldTests.java @@ -2,26 +2,24 @@ import io.anuke.arc.util.Time; import io.anuke.mindustry.content.Blocks; import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.world.Tile; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.*; import static io.anuke.mindustry.Vars.*; import static org.junit.jupiter.api.Assertions.assertEquals; -public class WorldTests { +public class WorldTests{ static Tile[][] tiles; @BeforeAll static void launchApplication(){ - ApplicationTests.launchApplication(); - world.createTiles(10,10); + ApplicationTests.launchApplication(); + world.createTiles(10, 10); tiles = world.getTiles(); } @BeforeEach void resetWorld(){ - Time.setDeltaProvider(() -> 1f); + Time.setDeltaProvider(() -> 1f); logic.reset(); state.set(State.menu); } @@ -31,8 +29,8 @@ public class WorldTests { fillWith(Blocks.rocks.id); world.addDarkness(tiles); - for(int x = 0; x < tiles.length; x++) { - for (int y = 0; y < tiles[0].length; y++) { + for(int x = 0; x < tiles.length; x++){ + for(int y = 0; y < tiles[0].length; y++){ assertEquals(4, tiles[x][y].getRotation()); } } @@ -43,8 +41,8 @@ public class WorldTests { fillWith(Blocks.copperWall.id); world.addDarkness(tiles); - for(int x = 0; x < tiles.length; x++) { - for (int y = 0; y < tiles[0].length; y++) { + for(int x = 0; x < tiles.length; x++){ + for(int y = 0; y < tiles[0].length; y++){ assertEquals(0, tiles[x][y].getRotation()); } } @@ -55,8 +53,8 @@ public class WorldTests { fillWith(Blocks.air.id); world.addDarkness(tiles); - for(int x = 0; x < tiles.length; x++) { - for (int y = 0; y < tiles[0].length; y++) { + for(int x = 0; x < tiles.length; x++){ + for(int y = 0; y < tiles[0].length; y++){ assertEquals(0, tiles[x][y].getRotation()); } } @@ -67,8 +65,8 @@ public class WorldTests { fillWith(Blocks.cliffs.id); world.addDarkness(tiles); - for(int x = 0; x < tiles.length; x++) { - for (int y = 0; y < tiles[0].length; y++) { + for(int x = 0; x < tiles.length; x++){ + for(int y = 0; y < tiles[0].length; y++){ assertEquals(0, tiles[x][y].getRotation()); } } @@ -80,8 +78,8 @@ public class WorldTests { tiles[5][5] = new Tile(5, 5, (byte)0, Blocks.copperWall.id, (byte)0, (byte)0); world.addDarkness(tiles); - for(int x = 0; x < tiles.length; x++) { - for (int y = 0; y < tiles[0].length; y++) { + for(int x = 0; x < tiles.length; x++){ + for(int y = 0; y < tiles[0].length; y++){ byte darkness = tiles[x][y].getRotation(); int distance = Math.abs(x - 5) + Math.abs(y - 5); assertEquals(Math.min(Math.max(distance - 1, 0), 4), darkness); @@ -95,8 +93,8 @@ public class WorldTests { tiles[7][7] = new Tile(5, 5, (byte)0, Blocks.copperWall.id, (byte)0, (byte)0); world.addDarkness(tiles); - for(int x = 0; x < tiles.length; x++) { - for (int y = 0; y < tiles[0].length; y++) { + for(int x = 0; x < tiles.length; x++){ + for(int y = 0; y < tiles[0].length; y++){ byte darkness = tiles[x][y].getRotation(); int distance = Math.abs(x - 7) + Math.abs(y - 7); assertEquals(Math.min(Math.max(distance - 1, 0), 4), darkness); @@ -105,8 +103,8 @@ public class WorldTests { } private static void fillWith(byte tileID){ - for(int x = 0; x < tiles.length; x++) { - for (int y = 0; y < tiles[0].length; y++) { + for(int x = 0; x < tiles.length; x++){ + for(int y = 0; y < tiles[0].length; y++){ tiles[x][y] = new Tile(x, y, (byte)0, tileID, (byte)0, (byte)0); } } diff --git a/tests/src/test/java/ZoneTests.java b/tests/src/test/java/ZoneTests.java index 1807f1e453..39e9d640e2 100644 --- a/tests/src/test/java/ZoneTests.java +++ b/tests/src/test/java/ZoneTests.java @@ -1,6 +1,7 @@ import io.anuke.arc.collection.Array; import io.anuke.arc.collection.ObjectSet; -import io.anuke.arc.util.*; +import io.anuke.arc.util.Structs; +import io.anuke.arc.util.Time; import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.type.Item; import io.anuke.mindustry.type.Zone; @@ -21,7 +22,7 @@ public class ZoneTests{ @BeforeEach void resetWorld(){ - Time.setDeltaProvider(() -> 1f); + Time.setDeltaProvider(() -> 1f); logic.reset(); state.set(State.menu); } diff --git a/tests/src/test/java/power/FakeGraphics.java b/tests/src/test/java/power/FakeGraphics.java index 3006810379..bce7d8fbff 100644 --- a/tests/src/test/java/power/FakeGraphics.java +++ b/tests/src/test/java/power/FakeGraphics.java @@ -2,9 +2,7 @@ package power; import io.anuke.arc.Graphics; import io.anuke.arc.Graphics.Cursor.SystemCursor; -import io.anuke.arc.graphics.GL20; -import io.anuke.arc.graphics.GL30; -import io.anuke.arc.graphics.Pixmap; +import io.anuke.arc.graphics.*; import io.anuke.arc.graphics.glutils.GLVersion; public class FakeGraphics extends Graphics{ diff --git a/tests/src/test/java/power/ItemLiquidGeneratorTests.java b/tests/src/test/java/power/ItemLiquidGeneratorTests.java index decffc8884..19342611fc 100644 --- a/tests/src/test/java/power/ItemLiquidGeneratorTests.java +++ b/tests/src/test/java/power/ItemLiquidGeneratorTests.java @@ -7,9 +7,7 @@ import io.anuke.mindustry.type.Item; import io.anuke.mindustry.type.Liquid; import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.blocks.power.ItemLiquidGenerator; -import org.junit.jupiter.api.DynamicTest; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestFactory; +import org.junit.jupiter.api.*; import java.util.ArrayList; @@ -61,8 +59,8 @@ public class ItemLiquidGeneratorTests extends PowerTestFixture{ // Execute all tests for the case where only liquids are accepted and for the case where liquids and items are accepted (but supply only liquids) InputType[] inputTypesToBeTested = new InputType[]{ - InputType.liquids, - InputType.any + InputType.liquids, + InputType.any }; ArrayList tests = new ArrayList<>(); @@ -103,8 +101,8 @@ public class ItemLiquidGeneratorTests extends PowerTestFixture{ // Execute all tests for the case where only items are accepted and for the case where liquids and items are accepted (but supply only items) InputType[] inputTypesToBeTested = new InputType[]{ - InputType.items, - InputType.any + InputType.items, + InputType.any }; ArrayList tests = new ArrayList<>(); @@ -171,7 +169,7 @@ public class ItemLiquidGeneratorTests extends PowerTestFixture{ generator.update(tile); assertEquals(0.0f, entity.productionEfficiency, "Duration: " + currentDuration); } - + enum InputType{ items, liquids, diff --git a/tests/src/test/java/power/PowerTestFixture.java b/tests/src/test/java/power/PowerTestFixture.java index 2265efb4e5..d9e36dd318 100644 --- a/tests/src/test/java/power/PowerTestFixture.java +++ b/tests/src/test/java/power/PowerTestFixture.java @@ -12,19 +12,17 @@ import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.blocks.PowerBlock; import io.anuke.mindustry.world.blocks.power.Battery; import io.anuke.mindustry.world.blocks.power.PowerGenerator; -import io.anuke.mindustry.world.modules.ConsumeModule; -import io.anuke.mindustry.world.modules.ItemModule; -import io.anuke.mindustry.world.modules.LiquidModule; -import io.anuke.mindustry.world.modules.PowerModule; +import io.anuke.mindustry.world.modules.*; import org.junit.jupiter.api.BeforeAll; import java.lang.reflect.Field; -/** This class provides objects commonly used by power related unit tests. - * For now, this is a helper with static methods, but this might change. - * - * Note: All tests which subclass this will run with a fixed delta of 0.5! - * */ +/** + * This class provides objects commonly used by power related unit tests. + * For now, this is a helper with static methods, but this might change. + *

+ * Note: All tests which subclass this will run with a fixed delta of 0.5! + */ public class PowerTestFixture{ public static final float smallRoundingTolerance = Mathf.FLOAT_ROUNDING_ERROR; public static final float mediumRoundingTolerance = Mathf.FLOAT_ROUNDING_ERROR * 10; @@ -62,10 +60,11 @@ public class PowerTestFixture{ consumes.powerBuffered(capacity, ticksToFill); }}; } + /** * Creates a fake tile on the given location using the given block. - * @param x The X coordinate. - * @param y The y coordinate. + * @param x The X coordinate. + * @param y The y coordinate. * @param block The block on the tile. * @return The created tile or null in case of exceptions. */ diff --git a/tests/src/test/java/power/PowerTests.java b/tests/src/test/java/power/PowerTests.java index 491c609113..7e15dc4e4b 100644 --- a/tests/src/test/java/power/PowerTests.java +++ b/tests/src/test/java/power/PowerTests.java @@ -30,25 +30,27 @@ public class PowerTests extends PowerTestFixture{ @Nested class PowerGraphTests{ - /** Tests the satisfaction of a single consumer after a single update of the power graph which contains a single producer. - * - * Assumption: When the consumer requests zero power, satisfaction does not change. Default is 0.0f. + /** + * Tests the satisfaction of a single consumer after a single update of the power graph which contains a single producer. + *

+ * Assumption: When the consumer requests zero power, satisfaction does not change. Default is 0.0f. */ @TestFactory DynamicTest[] directConsumerSatisfactionIsAsExpected(){ return new DynamicTest[]{ - // Note: Unfortunately, the display names are not yet output through gradle. See https://github.com/gradle/gradle/issues/5975 - // That's why we inject the description into the test method for now. - // Additional Note: If you don't see any labels in front of the values supplied as function parameters, use a better IDE like IntelliJ IDEA. - dynamicTest("01", () -> simulateDirectConsumption(0.0f, 1.0f, 0.0f, "0.0 produced, 1.0 consumed (no power available)")), - dynamicTest("02", () -> simulateDirectConsumption(0.0f, 0.0f, 1.0f, "0.0 produced, 0.0 consumed (no power anywhere)")), - dynamicTest("03", () -> simulateDirectConsumption(1.0f, 0.0f, 1.0f, "1.0 produced, 0.0 consumed (no power requested)")), - dynamicTest("04", () -> simulateDirectConsumption(1.0f, 1.0f, 1.0f, "1.0 produced, 1.0 consumed (stable consumption)")), - dynamicTest("05", () -> simulateDirectConsumption(0.5f, 1.0f, 0.5f, "0.5 produced, 1.0 consumed (power shortage)")), - dynamicTest("06", () -> simulateDirectConsumption(1.0f, 0.5f, 1.0f, "1.0 produced, 0.5 consumed (power excess)")), - dynamicTest("07", () -> simulateDirectConsumption(0.09f, 0.09f - Mathf.FLOAT_ROUNDING_ERROR / 10.0f, 1.0f, "floating point inaccuracy (stable consumption)")) + // Note: Unfortunately, the display names are not yet output through gradle. See https://github.com/gradle/gradle/issues/5975 + // That's why we inject the description into the test method for now. + // Additional Note: If you don't see any labels in front of the values supplied as function parameters, use a better IDE like IntelliJ IDEA. + dynamicTest("01", () -> simulateDirectConsumption(0.0f, 1.0f, 0.0f, "0.0 produced, 1.0 consumed (no power available)")), + dynamicTest("02", () -> simulateDirectConsumption(0.0f, 0.0f, 1.0f, "0.0 produced, 0.0 consumed (no power anywhere)")), + dynamicTest("03", () -> simulateDirectConsumption(1.0f, 0.0f, 1.0f, "1.0 produced, 0.0 consumed (no power requested)")), + dynamicTest("04", () -> simulateDirectConsumption(1.0f, 1.0f, 1.0f, "1.0 produced, 1.0 consumed (stable consumption)")), + dynamicTest("05", () -> simulateDirectConsumption(0.5f, 1.0f, 0.5f, "0.5 produced, 1.0 consumed (power shortage)")), + dynamicTest("06", () -> simulateDirectConsumption(1.0f, 0.5f, 1.0f, "1.0 produced, 0.5 consumed (power excess)")), + dynamicTest("07", () -> simulateDirectConsumption(0.09f, 0.09f - Mathf.FLOAT_ROUNDING_ERROR / 10.0f, 1.0f, "floating point inaccuracy (stable consumption)")) }; } + void simulateDirectConsumption(float producedPower, float requiredPower, float expectedSatisfaction, String parameterDescription){ Tile producerTile = createFakeTile(0, 0, createFakeProducerBlock(producedPower)); producerTile.entity().productionEfficiency = 1f; @@ -70,29 +72,30 @@ public class PowerTests extends PowerTestFixture{ @TestFactory DynamicTest[] bufferedConsumerSatisfactionIsAsExpected(){ return new DynamicTest[]{ - // Note: powerPerTick may not be 0 in any of the test cases. This would equal a "ticksToFill" of infinite. - // Note: Due to a fixed delta of 0.5, only half of what is defined here will in fact be produced/consumed. Keep this in mind when defining expectedSatisfaction! - dynamicTest("01", () -> simulateBufferedConsumption(0.0f, 0.0f, 0.1f, 0.0f, 0.0f, "Empty Buffer, No power anywhere")), - dynamicTest("02", () -> simulateBufferedConsumption(0.0f, 1.0f, 0.1f, 0.0f, 0.0f, "Empty Buffer, No power provided")), - dynamicTest("03", () -> simulateBufferedConsumption(1.0f, 0.0f, 0.1f, 0.0f, 0.0f, "Empty Buffer, No power requested")), - dynamicTest("04", () -> simulateBufferedConsumption(1.0f, 1.0f, 1.0f, 0.0f, 0.5f, "Empty Buffer, Stable Power, One tick to fill")), - dynamicTest("05", () -> simulateBufferedConsumption(2.0f, 1.0f, 2.0f, 0.0f, 1.0f, "Empty Buffer, Stable Power, One delta to fill")), - dynamicTest("06", () -> simulateBufferedConsumption(1.0f, 1.0f, 0.1f, 0.0f, 0.05f, "Empty Buffer, Stable Power, multiple ticks to fill")), - dynamicTest("07", () -> simulateBufferedConsumption(1.2f, 0.5f, 1.0f, 0.0f, 1.0f, "Empty Buffer, Power excess, one delta to fill")), - dynamicTest("08", () -> simulateBufferedConsumption(1.0f, 0.5f, 0.1f, 0.0f, 0.1f, "Empty Buffer, Power excess, multiple ticks to fill")), - dynamicTest("09", () -> simulateBufferedConsumption(1.0f, 1.0f, 2.0f, 0.0f, 0.5f, "Empty Buffer, Power shortage, one delta to fill")), - dynamicTest("10", () -> simulateBufferedConsumption(0.5f, 1.0f, 0.1f, 0.0f, 0.05f, "Empty Buffer, Power shortage, multiple ticks to fill")), - dynamicTest("11", () -> simulateBufferedConsumption(0.0f, 1.0f, 0.1f, 0.5f, 0.5f, "Unchanged buffer with no power produced")), - dynamicTest("12", () -> simulateBufferedConsumption(1.0f, 1.0f, 0.1f, 1.0f, 1.0f, "Unchanged buffer when already full")), - dynamicTest("13", () -> simulateBufferedConsumption(0.2f, 1.0f, 0.5f, 0.5f, 0.6f, "Half buffer, power shortage")), - dynamicTest("14", () -> simulateBufferedConsumption(1.0f, 1.0f, 0.5f, 0.9f, 1.0f, "Buffer does not get exceeded")), - dynamicTest("15", () -> simulateBufferedConsumption(2.0f, 1.0f, 1.0f, 0.5f, 1.0f, "Half buffer, filled with excess")) + // Note: powerPerTick may not be 0 in any of the test cases. This would equal a "ticksToFill" of infinite. + // Note: Due to a fixed delta of 0.5, only half of what is defined here will in fact be produced/consumed. Keep this in mind when defining expectedSatisfaction! + dynamicTest("01", () -> simulateBufferedConsumption(0.0f, 0.0f, 0.1f, 0.0f, 0.0f, "Empty Buffer, No power anywhere")), + dynamicTest("02", () -> simulateBufferedConsumption(0.0f, 1.0f, 0.1f, 0.0f, 0.0f, "Empty Buffer, No power provided")), + dynamicTest("03", () -> simulateBufferedConsumption(1.0f, 0.0f, 0.1f, 0.0f, 0.0f, "Empty Buffer, No power requested")), + dynamicTest("04", () -> simulateBufferedConsumption(1.0f, 1.0f, 1.0f, 0.0f, 0.5f, "Empty Buffer, Stable Power, One tick to fill")), + dynamicTest("05", () -> simulateBufferedConsumption(2.0f, 1.0f, 2.0f, 0.0f, 1.0f, "Empty Buffer, Stable Power, One delta to fill")), + dynamicTest("06", () -> simulateBufferedConsumption(1.0f, 1.0f, 0.1f, 0.0f, 0.05f, "Empty Buffer, Stable Power, multiple ticks to fill")), + dynamicTest("07", () -> simulateBufferedConsumption(1.2f, 0.5f, 1.0f, 0.0f, 1.0f, "Empty Buffer, Power excess, one delta to fill")), + dynamicTest("08", () -> simulateBufferedConsumption(1.0f, 0.5f, 0.1f, 0.0f, 0.1f, "Empty Buffer, Power excess, multiple ticks to fill")), + dynamicTest("09", () -> simulateBufferedConsumption(1.0f, 1.0f, 2.0f, 0.0f, 0.5f, "Empty Buffer, Power shortage, one delta to fill")), + dynamicTest("10", () -> simulateBufferedConsumption(0.5f, 1.0f, 0.1f, 0.0f, 0.05f, "Empty Buffer, Power shortage, multiple ticks to fill")), + dynamicTest("11", () -> simulateBufferedConsumption(0.0f, 1.0f, 0.1f, 0.5f, 0.5f, "Unchanged buffer with no power produced")), + dynamicTest("12", () -> simulateBufferedConsumption(1.0f, 1.0f, 0.1f, 1.0f, 1.0f, "Unchanged buffer when already full")), + dynamicTest("13", () -> simulateBufferedConsumption(0.2f, 1.0f, 0.5f, 0.5f, 0.6f, "Half buffer, power shortage")), + dynamicTest("14", () -> simulateBufferedConsumption(1.0f, 1.0f, 0.5f, 0.9f, 1.0f, "Buffer does not get exceeded")), + dynamicTest("15", () -> simulateBufferedConsumption(2.0f, 1.0f, 1.0f, 0.5f, 1.0f, "Half buffer, filled with excess")) }; } + void simulateBufferedConsumption(float producedPower, float maxBuffer, float powerConsumedPerTick, float initialSatisfaction, float expectedSatisfaction, String parameterDescription){ Tile producerTile = createFakeTile(0, 0, createFakeProducerBlock(producedPower)); producerTile.entity().productionEfficiency = 1f; - Tile bufferedConsumerTile = createFakeTile(0, 1, createFakeBufferedConsumer(maxBuffer, maxBuffer > 0.0f ? maxBuffer/powerConsumedPerTick : 1.0f)); + Tile bufferedConsumerTile = createFakeTile(0, 1, createFakeBufferedConsumer(maxBuffer, maxBuffer > 0.0f ? maxBuffer / powerConsumedPerTick : 1.0f)); bufferedConsumerTile.entity.power.satisfaction = initialSatisfaction; PowerGraph powerGraph = new PowerGraph(); @@ -113,24 +116,26 @@ public class PowerTests extends PowerTestFixture{ assertEquals(expectedSatisfaction, bufferedConsumerTile.entity.power.satisfaction, Mathf.FLOAT_ROUNDING_ERROR, parameterDescription + ": Satisfaction of buffered consumer did not match"); } - /** Tests the satisfaction of a single direct consumer after a single update of the power graph which contains a single producer and a single battery. - * The used battery is created with a maximum capacity of 100 and receives ten power per tick. + /** + * Tests the satisfaction of a single direct consumer after a single update of the power graph which contains a single producer and a single battery. + * The used battery is created with a maximum capacity of 100 and receives ten power per tick. */ @TestFactory DynamicTest[] batteryCapacityIsAsExpected(){ return new DynamicTest[]{ - // Note: expectedBatteryCapacity is currently adjusted to a delta of 0.5! (FakeThreadHandler sets it to that) - dynamicTest("01", () -> simulateDirectConsumptionWithBattery(10.0f, 0.0f, 0.0f, 5.0f, 0.0f, "Empty battery, no consumer")), - dynamicTest("02", () -> simulateDirectConsumptionWithBattery(10.0f, 0.0f, 94.999f, 99.999f, 0.0f, "Battery almost full after update, no consumer")), - dynamicTest("03", () -> simulateDirectConsumptionWithBattery(10.0f, 0.0f, 100.0f, 100.0f, 0.0f, "Full battery, no consumer")), - dynamicTest("04", () -> simulateDirectConsumptionWithBattery(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, "No producer, no consumer, empty battery")), - dynamicTest("05", () -> simulateDirectConsumptionWithBattery(0.0f, 0.0f, 100.0f, 100.0f, 0.0f, "No producer, no consumer, full battery")), - dynamicTest("06", () -> simulateDirectConsumptionWithBattery(0.0f, 10.0f, 0.0f, 0.0f, 0.0f, "No producer, empty battery")), - dynamicTest("07", () -> simulateDirectConsumptionWithBattery(0.0f, 10.0f, 100.0f, 95.0f, 1.0f, "No producer, full battery")), - dynamicTest("08", () -> simulateDirectConsumptionWithBattery(0.0f, 10.0f, 2.5f, 0.0f, 0.5f, "No producer, low battery")), - dynamicTest("09", () -> simulateDirectConsumptionWithBattery(5.0f, 10.0f, 5.0f, 0.0f, 1.0f, "Producer + Battery = Consumed")), + // Note: expectedBatteryCapacity is currently adjusted to a delta of 0.5! (FakeThreadHandler sets it to that) + dynamicTest("01", () -> simulateDirectConsumptionWithBattery(10.0f, 0.0f, 0.0f, 5.0f, 0.0f, "Empty battery, no consumer")), + dynamicTest("02", () -> simulateDirectConsumptionWithBattery(10.0f, 0.0f, 94.999f, 99.999f, 0.0f, "Battery almost full after update, no consumer")), + dynamicTest("03", () -> simulateDirectConsumptionWithBattery(10.0f, 0.0f, 100.0f, 100.0f, 0.0f, "Full battery, no consumer")), + dynamicTest("04", () -> simulateDirectConsumptionWithBattery(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, "No producer, no consumer, empty battery")), + dynamicTest("05", () -> simulateDirectConsumptionWithBattery(0.0f, 0.0f, 100.0f, 100.0f, 0.0f, "No producer, no consumer, full battery")), + dynamicTest("06", () -> simulateDirectConsumptionWithBattery(0.0f, 10.0f, 0.0f, 0.0f, 0.0f, "No producer, empty battery")), + dynamicTest("07", () -> simulateDirectConsumptionWithBattery(0.0f, 10.0f, 100.0f, 95.0f, 1.0f, "No producer, full battery")), + dynamicTest("08", () -> simulateDirectConsumptionWithBattery(0.0f, 10.0f, 2.5f, 0.0f, 0.5f, "No producer, low battery")), + dynamicTest("09", () -> simulateDirectConsumptionWithBattery(5.0f, 10.0f, 5.0f, 0.0f, 1.0f, "Producer + Battery = Consumed")), }; } + void simulateDirectConsumptionWithBattery(float producedPower, float requestedPower, float initialBatteryCapacity, float expectedBatteryCapacity, float expectedSatisfaction, String parameterDescription){ PowerGraph powerGraph = new PowerGraph(); @@ -145,7 +150,7 @@ public class PowerTests extends PowerTestFixture{ powerGraph.add(directConsumerTile); } float maxCapacity = 100f; - Tile batteryTile = createFakeTile(0, 2, createFakeBattery(maxCapacity, 10 )); + Tile batteryTile = createFakeTile(0, 2, createFakeBattery(maxCapacity, 10)); batteryTile.entity.power.satisfaction = initialBatteryCapacity / maxCapacity; powerGraph.add(batteryTile); diff --git a/tools/build.gradle b/tools/build.gradle index c5db3b5503..c161ff6ea1 100644 --- a/tools/build.gradle +++ b/tools/build.gradle @@ -1,19 +1,19 @@ apply plugin: "java" sourceCompatibility = 1.8 -sourceSets.main.java.srcDirs = [ "src/" ] +sourceSets.main.java.srcDirs = ["src/"] import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.tools.texturepacker.TexturePacker import javax.imageio.ImageIO -import java.awt.image.BufferedImage +import java.awt.image.BufferedImage def outFolder = "../core/assets-raw/sprites_out/" def genFolder = "../core/assets-raw/sprites_out/generated/" def doAntialias = !project.hasProperty("disableAntialias") -def antialias = {File file -> +def antialias = { File file -> if(!doAntialias || file.lastModified() <= 1000) return def image = ImageIO.read(file) @@ -28,7 +28,7 @@ def antialias = {File file -> def sum = new Color() def suma = new Color() - for (int x = 0; x < image.getWidth(); x++){ + for(int x = 0; x < image.getWidth(); x++){ for(int y = 0; y < image.getHeight(); y++){ int A = getRGB(x - 1, y + 1), @@ -41,28 +41,28 @@ def antialias = {File file -> H = getRGB(x, y - 1), I = getRGB(x + 1, y - 1) - int p1=E, p2=E, p3=E, p4=E, p5=E, p6=E, p7=E, p8=E, p9=E - if (D==B && D!=H && B!=F) p1=D - if ((D==B && D!=H && B!=F && E!=C) || (B==F && B!=D && F!=H && E!=A)) p2=B - if (B==F && B!=D && F!=H) p3=F - if ((H==D && H!=F && D!=B && E!=A) || (D==B && D!=H && B!=F && E!=G)) p4=D - p5=E - if ((B==F && B!=D && F!=H && E!=I) || (F==H && F!=B && H!=D && E!=C)) p6=F - if (H==D && H!=F && D!=B) p7=D - if ((F==H && F!=B && H!=D && E!=G) || (H==D && H!=F && D!=B && E!=I)) p8=H - if (F==H && F!=B && H!=D) p9=F + int p1 = E, p2 = E, p3 = E, p4 = E, p5 = E, p6 = E, p7 = E, p8 = E, p9 = E + if(D == B && D != H && B != F) p1 = D + if((D == B && D != H && B != F && E != C) || (B == F && B != D && F != H && E != A)) p2 = B + if(B == F && B != D && F != H) p3 = F + if((H == D && H != F && D != B && E != A) || (D == B && D != H && B != F && E != G)) p4 = D + p5 = E + if((B == F && B != D && F != H && E != I) || (F == H && F != B && H != D && E != C)) p6 = F + if(H == D && H != F && D != B) p7 = D + if((F == H && F != B && H != D && E != G) || (H == D && H != F && D != B && E != I)) p8 = H + if(F == H && F != B && H != D) p9 = F suma.set(0) [p1, p2, p3, p4, p5, p6, p7, p8, p9].each{ val -> Color.argb8888ToColor(color, val) - suma.r += color.r*color.a - suma.g += color.g*color.a - suma.b += color.b*color.a + suma.r += color.r * color.a + suma.g += color.g * color.a + suma.b += color.b * color.a suma.a += color.a } - suma.mul(suma.a <= 0.001f ? 0f : (float)(1f / suma.a)) + suma.mul(suma.a <= 0.001f ? 0f : (float) (1f / suma.a)) float total = 0 sum.set(0) @@ -70,7 +70,7 @@ def antialias = {File file -> [p1, p2, p3, p4, p5, p6, p7, p8, p9].each{ val -> Color.argb8888ToColor(color, val) float a = color.a - color.lerp(suma, (float)(1f - a)) + color.lerp(suma, (float) (1f - a)) sum.r += color.r sum.g += color.g sum.b += color.b @@ -78,7 +78,7 @@ def antialias = {File file -> total += 1f } - sum.mul((float)(1f / total)) + sum.mul((float) (1f / total)) int result = Color.argb8888(sum) out.setRGB(x, y, result) sum.set(0) @@ -90,25 +90,25 @@ def antialias = {File file -> task swapColors(){ doLast{ - if (project.hasProperty("colors")) { + if(project.hasProperty("colors")){ def carr = new File(getProperty("colors")).text.split("\n") def map = [:] def swaps = 0 - carr.each{str -> map[Color.argb8888(Color.valueOf(str.split("=")[0]))] = Color.argb8888(Color.valueOf(str.split("=")[1]))} + carr.each{ str -> map[Color.argb8888(Color.valueOf(str.split("=")[0]))] = Color.argb8888(Color.valueOf(str.split("=")[1])) } def tmpc = new Color() - fileTree(dir: '../core/assets-raw/sprites', include: "**/*.png").visit { file -> + fileTree(dir: '../core/assets-raw/sprites', include: "**/*.png").visit{ file -> if(file.isDirectory()) return - swaps ++ + swaps++ def img = ImageIO.read(file.file) - for (x in (0..img.getWidth()-1)) { - for (y in (0..img.getHeight()-1)) { + for(x in (0..img.getWidth() - 1)){ + for(y in (0..img.getHeight() - 1)){ def c = img.getRGB(x, y) Color.argb8888ToColor(tmpc, c) if(tmpc.a < 0.1f) continue if(map.containsKey(c)){ - img.setRGB(x, y, (int)map.get(c)) + img.setRGB(x, y, (int) map.get(c)) } } } @@ -123,10 +123,10 @@ task swapColors(){ task scaleSprites4x(){ doLast{ - fileTree(dir: '../core/assets-raw/sprites_out/', include: "**/*.png").visit { file -> + fileTree(dir: '../core/assets-raw/sprites_out/', include: "**/*.png").visit{ file -> if(file.isDirectory() || file.toString().contains("/ui/")) return - for(int iteration in 0..1) { + for(int iteration in 0..1){ def image = ImageIO.read(file.file) def scaled = new BufferedImage(image.getWidth() * 2, image.getHeight() * 2, BufferedImage.TYPE_INT_ARGB) @@ -135,8 +135,8 @@ task scaleSprites4x(){ return image.getRGB(Math.max(Math.min(ix, image.width - 1), 0), Math.max(Math.min(iy, image.height - 1), 0)) } - for (int x = 0; x < image.getWidth(); x++) { - for (int y = 0; y < image.getHeight(); y++) { + for(int x = 0; x < image.getWidth(); x++){ + for(int y = 0; y < image.getHeight(); y++){ int p = image.getRGB(x, y) int p1 = p, p2 = p, p3 = p, p4 = p @@ -148,16 +148,16 @@ task scaleSprites4x(){ F = getRGB(x + 1, y), G = getRGB(x - 1, y - 1), H = getRGB(x, y - 1), - I = getRGB(x + 1, y - 1), + I = getRGB(x + 1, y - 1), J = getRGB(x, y + 2), K = getRGB(x - 2, y), L = getRGB(x + 2, y), M = getRGB(x, y - 2) - if (B==D && B!=F && D!=H && (E!=A || E==C || E==G || A==J || A==K)) p1 = B - if (B==F & B!=D & F!=H && (E!=C || E==A || E==I || C==J || C==L)) p2 = F - if (D==H & B!=D & F!=H && (E!=G || E==A || E==I || G==K || G==M)) p3 = D - if (F==H & B!=F & D!=H && (E!=I || E==C || E==G || I==L || I==M)) p4 = H + if(B == D && B != F && D != H && (E != A || E == C || E == G || A == J || A == K)) p1 = B + if(B == F & B != D & F != H && (E != C || E == A || E == I || C == J || C == L)) p2 = F + if(D == H & B != D & F != H && (E != G || E == A || E == I || G == K || G == M)) p3 = D + if(F == H & B != F & D != H && (E != I || E == C || E == G || I == L || I == M)) p4 = H scaled.setRGB(x * 2, y * 2 + 1, p1) scaled.setRGB(x * 2 + 1, y * 2 + 1, p2) @@ -183,7 +183,7 @@ task scaleSprites(){ into "../core/assets-raw/sprites_out/" } } - + dependsOn 'scaleSprites4x' } @@ -202,7 +202,7 @@ task pack(){ TexturePacker.process("core/assets-raw/sprites_out/", "core/assets/sprites/", "sprites.atlas") delete{ - delete fileTree(dir: '../core/assets-raw/sprites_out/' , include: '**/pack.json') + delete fileTree(dir: '../core/assets-raw/sprites_out/', include: '**/pack.json') } copy{ @@ -214,12 +214,12 @@ task pack(){ TexturePacker.process("core/assets-raw/sprites_out/", "core/assets/sprites/", "sprites_fallback.atlas") } - + } task cleanup(){ - doLast { - delete { + doLast{ + delete{ delete genFolder delete outFolder } @@ -250,16 +250,16 @@ task antialiasGen(){ } } -task genSprites(dependsOn: classes, type: JavaExec) { +task genSprites(dependsOn: classes, type: JavaExec){ finalizedBy 'antialiasGen' - + main = "io.anuke.mindustry.ImagePacker" classpath = sourceSets.main.runtimeClasspath standardInput = System.in workingDir = genFolder } -task updateBundles(dependsOn: classes, type: JavaExec) { +task updateBundles(dependsOn: classes, type: JavaExec){ file(genFolder).mkdirs() main = "io.anuke.mindustry.BundleLauncher" diff --git a/tools/src/io/anuke/mindustry/BundleLauncher.java b/tools/src/io/anuke/mindustry/BundleLauncher.java index 732cbf244d..69b0e525b9 100644 --- a/tools/src/io/anuke/mindustry/BundleLauncher.java +++ b/tools/src/io/anuke/mindustry/BundleLauncher.java @@ -7,15 +7,10 @@ import io.anuke.arc.util.Log; import io.anuke.arc.util.Strings; import io.anuke.arc.util.io.PropertiesUtils; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; +import java.io.*; +import java.nio.file.*; -public class BundleLauncher { +public class BundleLauncher{ public static void main(String[] args) throws Exception{ File file = new File("bundle.properties"); @@ -24,8 +19,9 @@ public class BundleLauncher { Array removals = new Array<>(); Files.walk(Paths.get("")).forEach(child -> { - try { - if (child.getFileName().toString().equals("bundle.properties") || Files.isDirectory(child) || child.toString().contains("output")) return; + try{ + if(child.getFileName().toString().equals("bundle.properties") || Files.isDirectory(child) || child.toString().contains("output")) + return; Log.info("Parsing bundle: {0}", child); @@ -49,7 +45,7 @@ public class BundleLauncher { for(String key : base.orderedKeys()){ if(!other.containsKey(key) || other.get(key).trim().isEmpty()){ other.put(key, base.get(key)); - added ++; + added++; Log.info("&lc- Adding missing key '{0}'...", key); } } @@ -70,7 +66,7 @@ public class BundleLauncher { Files.write(child, result.toString().getBytes(Strings.utf8)); - }catch (IOException e){ + }catch(IOException e){ throw new RuntimeException(e); } }); diff --git a/tools/src/io/anuke/mindustry/Generators.java b/tools/src/io/anuke/mindustry/Generators.java index b1295559fb..ac72116aac 100644 --- a/tools/src/io/anuke/mindustry/Generators.java +++ b/tools/src/io/anuke/mindustry/Generators.java @@ -6,10 +6,7 @@ import io.anuke.arc.graphics.g2d.TextureRegion; import io.anuke.arc.math.Mathf; import io.anuke.arc.util.Log; import io.anuke.mindustry.ImagePacker.GenRegion; -import io.anuke.mindustry.type.ContentType; -import io.anuke.mindustry.type.Item; -import io.anuke.mindustry.type.Mech; -import io.anuke.mindustry.type.UnitType; +import io.anuke.mindustry.type.*; import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Block.Icon; import io.anuke.mindustry.world.blocks.Floor; @@ -22,7 +19,7 @@ import java.nio.file.Paths; import static io.anuke.mindustry.Vars.content; import static io.anuke.mindustry.Vars.tilesize; -public class Generators { +public class Generators{ public static void generate(){ @@ -54,7 +51,7 @@ public class Generators { Image last = null; if(block.outlineIcon){ int radius = 3; - GenRegion region = (GenRegion)regions[regions.length-1]; + GenRegion region = (GenRegion)regions[regions.length - 1]; Image base = ImagePacker.get(region); Image out = last = new Image(region.getWidth(), region.getHeight()); for(int x = 0; x < out.width(); x++){ @@ -93,7 +90,7 @@ public class Generators { int i = 0; for(TextureRegion region : regions){ - i ++; + i++; if(i != regions.length || last == null){ image.draw(region); }else{ @@ -163,7 +160,7 @@ public class Generators { image.drawCenter(mech.region); } - int off = image.width()/2 - mech.weapon.region.getWidth()/2; + int off = image.width() / 2 - mech.weapon.region.getWidth() / 2; image.draw(mech.weapon.region, -(int)mech.weaponOffsetX + off, (int)mech.weaponOffsetY + off, false, false); image.draw(mech.weapon.region, (int)mech.weaponOffsetX + off, (int)mech.weaponOffsetY + off, true, false); @@ -189,8 +186,8 @@ public class Generators { for(boolean b : Mathf.booleans){ image.draw(type.weapon.region, - (int)(Mathf.sign(b) * type.weapon.width / Draw.scl + image.width()/2 - type.weapon.region.getWidth()/2), - (int)(type.weaponOffsetY / Draw.scl + image.height()/2f - type.weapon.region.getHeight()/2f), + (int)(Mathf.sign(b) * type.weapon.width / Draw.scl + image.width() / 2 - type.weapon.region.getWidth() / 2), + (int)(type.weaponOffsetY / Draw.scl + image.height() / 2f - type.weapon.region.getHeight() / 2f), b, false); } @@ -205,15 +202,15 @@ public class Generators { OreBlock ore = (OreBlock)block; Item item = ore.itemDrop; - for (int i = 0; i < 3; i++) { + for(int i = 0; i < 3; i++){ //get base image to draw on Image image = new Image(32, 32); - Image shadow = ImagePacker.get(item.name + (i+1)); + Image shadow = ImagePacker.get(item.name + (i + 1)); - int offset = image.width()/tilesize; + int offset = image.width() / tilesize; - for (int x = 0; x < image.width(); x++) { - for (int y = offset; y < image.height(); y++) { + for(int x = 0; x < image.width(); x++){ + for(int y = offset; y < image.height(); y++){ Color color = shadow.getColor(x, y - offset); //draw semi transparent background @@ -224,9 +221,9 @@ public class Generators { } } - image.draw(ImagePacker.get(item.name + (i+1))); - image.save("../blocks/environment/ore-" + item.name + (i+1)); - image.save("../editor/editor-ore-" + item.name + (i+1)); + image.draw(ImagePacker.get(item.name + (i + 1))); + image.save("../blocks/environment/ore-" + item.name + (i + 1)); + image.save("../editor/editor-ore-" + item.name + (i + 1)); //save icons image.save(block.name + "-icon-full"); @@ -263,7 +260,8 @@ public class Generators { result.save("../blocks/environment/" + floor.name + "-edge"); - }catch(Exception ignored){} + }catch(Exception ignored){ + } } }); } diff --git a/tools/src/io/anuke/mindustry/Image.java b/tools/src/io/anuke/mindustry/Image.java index d64214501c..5759f5ba68 100644 --- a/tools/src/io/anuke/mindustry/Image.java +++ b/tools/src/io/anuke/mindustry/Image.java @@ -12,7 +12,7 @@ import java.io.File; import java.io.IOException; import java.util.ArrayList; -class Image { +class Image{ private static ArrayList toDispose = new ArrayList<>(); private BufferedImage image; @@ -63,31 +63,31 @@ class Image { graphics.fillRect(x, y, 1, 1); } - /**Draws a region at the top left corner.*/ + /** Draws a region at the top left corner. */ void draw(TextureRegion region){ draw(region, 0, 0, false, false); } - /**Draws a region at the center.*/ + /** Draws a region at the center. */ void drawCenter(TextureRegion region){ - draw(region, (width() - region.getWidth())/2, (height() - region.getHeight())/2, false, false); + draw(region, (width() - region.getWidth()) / 2, (height() - region.getHeight()) / 2, false, false); } - /**Draws a region at the center.*/ + /** Draws a region at the center. */ void drawCenter(TextureRegion region, boolean flipx, boolean flipy){ - draw(region, (width() - region.getWidth())/2, (height() - region.getHeight())/2, flipx, flipy); + draw(region, (width() - region.getWidth()) / 2, (height() - region.getHeight()) / 2, flipx, flipy); } void drawScaled(Image image){ graphics.drawImage(image.image.getScaledInstance(width(), height(), java.awt.Image.SCALE_AREA_AVERAGING), 0, 0, width(), height(), null); } - /**Draws an image at the top left corner.*/ + /** Draws an image at the top left corner. */ void draw(Image image){ draw(image, 0, 0); } - /**Draws an image at the coordinates specified.*/ + /** Draws an image at the coordinates specified. */ void draw(Image image, int x, int y){ graphics.drawImage(image.image, x, y, null); } @@ -102,21 +102,21 @@ class Image { int ofx = 0, ofy = 0; graphics.drawImage(ImagePacker.get(region).image, - x, y, - x + region.getWidth(), - y + region.getHeight(), - (flipx ? region.getWidth() : 0) + ofx, - (flipy ? region.getHeight() : 0) + ofy, - (flipx ? 0 : region.getWidth()) + ofx, - (flipy ? 0 : region.getHeight()) + ofy, - null); + x, y, + x + region.getWidth(), + y + region.getHeight(), + (flipx ? region.getWidth() : 0) + ofx, + (flipy ? region.getHeight() : 0) + ofy, + (flipx ? 0 : region.getWidth()) + ofx, + (flipy ? 0 : region.getHeight()) + ofy, + null); } - /** @param name Name of texture file name to create, without any extensions.*/ + /** @param name Name of texture file name to create, without any extensions. */ void save(String name){ - try { + try{ ImageIO.write(image, "png", new File(name + ".png")); - }catch (IOException e){ + }catch(IOException e){ throw new RuntimeException(e); } } diff --git a/tools/src/io/anuke/mindustry/ImagePacker.java b/tools/src/io/anuke/mindustry/ImagePacker.java index 6ec867511a..119e4d217e 100644 --- a/tools/src/io/anuke/mindustry/ImagePacker.java +++ b/tools/src/io/anuke/mindustry/ImagePacker.java @@ -2,23 +2,17 @@ package io.anuke.mindustry; import io.anuke.arc.Core; import io.anuke.arc.collection.ObjectMap; -import io.anuke.arc.graphics.g2d.Draw; -import io.anuke.arc.graphics.g2d.TextureAtlas; +import io.anuke.arc.graphics.g2d.*; import io.anuke.arc.graphics.g2d.TextureAtlas.AtlasRegion; -import io.anuke.arc.graphics.g2d.TextureRegion; -import io.anuke.arc.util.Log; +import io.anuke.arc.util.*; import io.anuke.arc.util.Log.LogHandler; import io.anuke.arc.util.Log.NoopLogHandler; -import io.anuke.arc.util.Strings; -import io.anuke.arc.util.Time; import io.anuke.mindustry.core.ContentLoader; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; +import java.nio.file.*; public class ImagePacker{ static ObjectMap regionCache = new ObjectMap<>(); @@ -91,12 +85,12 @@ public class ImagePacker{ } @Override - public boolean has(String s) { + public boolean has(String s){ return regionCache.containsKey(s); } }; - Draw.scl = 1f/Core.atlas.find("scale_marker").getWidth(); + Draw.scl = 1f / Core.atlas.find("scale_marker").getWidth(); Time.mark(); Generators.generate();