From b434c37f01a7ed7f36038a13868efbf5dbb2a4a7 Mon Sep 17 00:00:00 2001 From: Anuken Date: Tue, 29 May 2018 15:24:47 -0400 Subject: [PATCH] Rewrite of all static initialization code --- build.gradle | 1 + core/src/io/anuke/mindustry/Mindustry.java | 8 +- core/src/io/anuke/mindustry/Vars.java | 95 ++-- .../io/anuke/mindustry/content/AmmoTypes.java | 227 ++++----- .../src/io/anuke/mindustry/content/Items.java | 119 ++--- .../io/anuke/mindustry/content/Liquids.java | 71 +-- .../src/io/anuke/mindustry/content/Mechs.java | 13 +- .../io/anuke/mindustry/content/Recipes.java | 7 +- .../mindustry/content/StatusEffects.java | 165 ++++--- .../io/anuke/mindustry/content/UnitTypes.java | 14 +- .../mindustry/content/UpgradeRecipes.java | 37 -- .../io/anuke/mindustry/content/Weapons.java | 23 +- .../mindustry/content/blocks/Blocks.java | 290 +++++------ .../content/blocks/CraftingBlocks.java | 350 ++++++------- .../mindustry/content/blocks/DebugBlocks.java | 219 +++++---- .../content/blocks/DefenseBlocks.java | 97 ++-- .../content/blocks/DistributionBlocks.java | 82 ++-- .../content/blocks/LiquidBlocks.java | 69 +-- .../mindustry/content/blocks/PowerBlocks.java | 151 +++--- .../content/blocks/ProductionBlocks.java | 171 +++---- .../content/blocks/StorageBlocks.java | 34 +- .../mindustry/content/blocks/UnitBlocks.java | 59 +-- .../content/blocks/WeaponBlocks.java | 302 ++++++------ .../content/bullets/ArtilleryBullets.java | 141 +++--- .../content/bullets/FlakBullets.java | 57 ++- .../content/bullets/MissileBullets.java | 45 +- .../content/bullets/ShellBullets.java | 225 ++++----- .../content/bullets/StandardBullets.java | 81 +-- .../content/bullets/TurretBullets.java | 248 +++++----- .../anuke/mindustry/content/fx/BlockFx.java | 463 +++++++++--------- .../anuke/mindustry/content/fx/BulletFx.java | 143 +++--- .../mindustry/content/fx/EnvironmentFx.java | 130 ++--- .../mindustry/content/fx/ExplosionFx.java | 133 ++--- .../src/io/anuke/mindustry/content/fx/Fx.java | 74 +-- .../anuke/mindustry/content/fx/ShootFx.java | 315 ++++++------ .../io/anuke/mindustry/content/fx/UnitFx.java | 23 +- .../anuke/mindustry/core/ContentLoader.java | 78 +-- .../io/anuke/mindustry/core/NetClient.java | 4 - .../src/io/anuke/mindustry/core/Renderer.java | 2 + core/src/io/anuke/mindustry/core/UI.java | 2 +- .../io/anuke/mindustry/entities/Player.java | 2 +- .../mindustry/graphics/OverlayRenderer.java | 2 +- .../io/anuke/mindustry/graphics/Shaders.java | 36 +- .../anuke/mindustry/input/AndroidInput.java | 65 ++- .../anuke/mindustry/input/InputHandler.java | 4 +- core/src/io/anuke/mindustry/io/Version.java | 12 +- .../io/anuke/mindustry/net/ClientDebug.java | 51 -- core/src/io/anuke/mindustry/net/Net.java | 2 - .../io/anuke/mindustry/net/ServerDebug.java | 65 --- .../io/anuke/mindustry/type/ContentList.java | 5 + core/src/io/anuke/mindustry/ui/Links.java | 26 +- .../mindustry/ui/fragments/DebugFragment.java | 3 +- .../mindustry/ui/fragments/HudFragment.java | 2 +- .../mindustry/ui/fragments/MenuFragment.java | 7 +- .../io/anuke/mindustry/world/ColorMapper.java | 67 ++- .../anuke/mindustry/world/WorldGenerator.java | 7 - .../anuke/mindustry/desktop/CrashHandler.java | 8 +- .../mindustry/desktop/DesktopPlatform.java | 8 +- kryonet/src/io/anuke/kryonet/KryoServer.java | 1 - .../mindustry/server/MindustryServer.java | 9 +- 60 files changed, 2605 insertions(+), 2545 deletions(-) delete mode 100644 core/src/io/anuke/mindustry/content/UpgradeRecipes.java delete mode 100644 core/src/io/anuke/mindustry/net/ClientDebug.java delete mode 100644 core/src/io/anuke/mindustry/net/ServerDebug.java create mode 100644 core/src/io/anuke/mindustry/type/ContentList.java diff --git a/build.gradle b/build.gradle index bcb0f36006..b029469fa7 100644 --- a/build.gradle +++ b/build.gradle @@ -86,6 +86,7 @@ project(":desktop") { compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop" compile "com.badlogicgames.gdx:gdx-controllers-lwjgl3:$gdxVersion" compile 'com.github.MinnDevelopment:java-discord-rpc:v2.0.0' + compile 'com.yuvimasory:orange-extensions:1.3.0' } } diff --git a/core/src/io/anuke/mindustry/Mindustry.java b/core/src/io/anuke/mindustry/Mindustry.java index 817dcb0756..af57148619 100644 --- a/core/src/io/anuke/mindustry/Mindustry.java +++ b/core/src/io/anuke/mindustry/Mindustry.java @@ -1,12 +1,6 @@ package io.anuke.mindustry; -import com.badlogic.gdx.Gdx; -import com.badlogic.gdx.files.FileHandle; -import com.badlogic.gdx.graphics.Pixmap; -import com.badlogic.gdx.graphics.Pixmap.Filter; -import com.badlogic.gdx.graphics.PixmapIO; import io.anuke.mindustry.core.*; -import io.anuke.mindustry.core.ContentLoader; import io.anuke.mindustry.io.BundleLoader; import io.anuke.ucore.modules.ModuleCore; import io.anuke.ucore.util.Log; @@ -17,6 +11,8 @@ public class Mindustry extends ModuleCore { @Override public void init(){ + Vars.init(); + debug = Platform.instance.isDebug(); Log.setUseColors(false); diff --git a/core/src/io/anuke/mindustry/Vars.java b/core/src/io/anuke/mindustry/Vars.java index 0eb1ff2508..ec718622f4 100644 --- a/core/src/io/anuke/mindustry/Vars.java +++ b/core/src/io/anuke/mindustry/Vars.java @@ -5,17 +5,15 @@ import com.badlogic.gdx.Gdx; import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.graphics.Color; import io.anuke.mindustry.core.*; -import io.anuke.mindustry.entities.bullet.Bullet; import io.anuke.mindustry.entities.Player; import io.anuke.mindustry.entities.TileEntity; +import io.anuke.mindustry.entities.bullet.Bullet; import io.anuke.mindustry.entities.effect.Fire; import io.anuke.mindustry.entities.effect.Puddle; import io.anuke.mindustry.entities.effect.Shield; -import io.anuke.mindustry.core.Platform; import io.anuke.mindustry.entities.units.BaseUnit; import io.anuke.mindustry.game.Team; -import io.anuke.mindustry.net.ClientDebug; -import io.anuke.mindustry.net.ServerDebug; +import io.anuke.mindustry.io.Version; import io.anuke.ucore.entities.EffectEntity; import io.anuke.ucore.entities.Entities; import io.anuke.ucore.entities.Entity; @@ -29,52 +27,43 @@ public class Vars{ public static final boolean testMobile = true; //shorthand for whether or not this is running on android or ios - public static final boolean mobile = (Gdx.app.getType() == ApplicationType.Android) || - Gdx.app.getType() == ApplicationType.iOS || testMobile; - public static final boolean ios = Gdx.app.getType() == ApplicationType.iOS; - public static final boolean android = Gdx.app.getType() == ApplicationType.Android; + public static boolean mobile; + public static boolean ios; + public static boolean android; //shorthand for whether or not this is running on GWT - public static final boolean gwt = (Gdx.app.getType() == ApplicationType.WebGL); - //whether to send block state change events to players - public static final boolean syncBlockState = false; - //how far away from the player blocks can be placed - public static final float placerange = 66; + public static boolean gwt; + //respawn time in frames public static final float respawnduration = 60*4; //time between waves in frames (on normal mode) - public static final float wavespace = 60*60*(mobile ? 1 : 1); + public static final float wavespace = 60*60; //waves can last no longer than 3 minutes, otherwise the next one spawns public static final float maxwavespace = 60*60*4f; - //advance time the pathfinding starts at - public static final float aheadPathfinding = 60*15; - //how far away from spawn points the player can't place blocks - public static final float enemyspawnspace = 65; public static final float coreBuildRange = 400f; //discord group URL public static final String discordURL = "https://discord.gg/BKADYds"; public static final String releasesURL = "https://api.github.com/repos/Anuken/Mindustry/releases"; + //directory for user-created map data - public static final FileHandle customMapDirectory = OS.getAppDataDirectory("Mindustry").child("maps/"); + public static FileHandle customMapDirectory; //save file directory - public static final FileHandle saveDirectory = OS.getAppDataDirectory("Mindustry").child("saves/"); - public static final String mapExtension = "mmap"; - public static final String saveExtension = "msav"; + public static FileHandle saveDirectory; + public static String mapExtension = "mmap"; + public static String saveExtension = "msav"; //scale of the font - public static float fontscale = Math.max(Unit.dp.scl(1f)/2f, 0.5f); + public static float fontScale; //camera zoom displayed on startup - public static final int baseCameraScale = Math.round(Unit.dp.scl(4)); + public static int baseCameraScale; //how much the zoom changes every zoom button press (unused?) - public static final int zoomScale = Math.round(Unit.dp.scl(1)); + public static int zoomScale; //if true, player speed will be increased, massive amounts of resources will be given on start, and other debug options will be available public static boolean debug = false; public static boolean debugNet = true; public static boolean console = false; //whether the player can clip through walls public static boolean noclip = false; - //whether to draw chunk borders - public static boolean debugChunks = false; //whether turrets have infinite ammo (only with debug) public static boolean infiniteAmmo = true; //whether to show paths of enemies @@ -130,10 +119,7 @@ public class Vars{ public static final int webPort = 6568; public static GameState state; - public static final ThreadHandler threads = new ThreadHandler(Platform.instance.getThreadProvider()); - - public static final ServerDebug serverDebug = new ServerDebug(); - public static final ClientDebug clientDebug = new ClientDebug(); + public static ThreadHandler threads; public static Control control; public static Logic logic; @@ -146,19 +132,46 @@ public class Vars{ public static Player[] players = {}; - public static final EntityGroup playerGroup = Entities.addGroup(Player.class).enableMapping(); - public static final EntityGroup tileGroup = Entities.addGroup(TileEntity.class, false); - public static final EntityGroup bulletGroup = Entities.addGroup(Bullet.class); - public static final EntityGroup shieldGroup = Entities.addGroup(Shield.class, false); - public static final EntityGroup effectGroup = Entities.addGroup(EffectEntity.class, false); - public static final EntityGroup groundEffectGroup = Entities.addGroup(Entity.class, false); - public static final EntityGroup puddleGroup = Entities.addGroup(Puddle.class, false); - public static final EntityGroup airItemGroup = Entities.addGroup(Fire.class, false); - public static final EntityGroup[] unitGroups = new EntityGroup[Team.values().length]; + public static EntityGroup playerGroup; + public static EntityGroup tileGroup; + public static EntityGroup bulletGroup; + public static EntityGroup shieldGroup; + public static EntityGroup effectGroup; + public static EntityGroup groundEffectGroup; + public static EntityGroup puddleGroup; + public static EntityGroup airItemGroup; + public static EntityGroup[] unitGroups; + + public static void init(){ + Version.init(); + + playerGroup = Entities.addGroup(Player.class).enableMapping(); + tileGroup = Entities.addGroup(TileEntity.class, false); + bulletGroup = Entities.addGroup(Bullet.class); + shieldGroup = Entities.addGroup(Shield.class, false); + effectGroup = Entities.addGroup(EffectEntity.class, false); + groundEffectGroup = Entities.addGroup(Entity.class, false); + puddleGroup = Entities.addGroup(Puddle.class, false); + airItemGroup = Entities.addGroup(Fire.class, false); + unitGroups = new EntityGroup[Team.values().length]; + + threads = new ThreadHandler(Platform.instance.getThreadProvider()); - static{ for(Team team : Team.values()){ unitGroups[team.ordinal()] = Entities.addGroup(BaseUnit.class).enableMapping(); } + + mobile = (Gdx.app.getType() == ApplicationType.Android) || + Gdx.app.getType() == ApplicationType.iOS || testMobile; + ios = Gdx.app.getType() == ApplicationType.iOS; + android = Gdx.app.getType() == ApplicationType.Android; + gwt = Gdx.app.getType() == ApplicationType.WebGL; + + customMapDirectory = OS.getAppDataDirectory("Mindustry").child("maps/"); + saveDirectory = OS.getAppDataDirectory("Mindustry").child("saves/"); + + fontScale = Math.max(Unit.dp.scl(1f)/2f, 0.5f); + baseCameraScale = Math.round(Unit.dp.scl(4)); + zoomScale = Math.round(Unit.dp.scl(1)); } } diff --git a/core/src/io/anuke/mindustry/content/AmmoTypes.java b/core/src/io/anuke/mindustry/content/AmmoTypes.java index 36b02e9370..547914b18c 100644 --- a/core/src/io/anuke/mindustry/content/AmmoTypes.java +++ b/core/src/io/anuke/mindustry/content/AmmoTypes.java @@ -3,156 +3,161 @@ package io.anuke.mindustry.content; import io.anuke.mindustry.content.bullets.*; import io.anuke.mindustry.content.fx.ShootFx; import io.anuke.mindustry.type.AmmoType; +import io.anuke.mindustry.type.ContentList; -public class AmmoTypes { - //TODO add definitions for all ammo types - public static final AmmoType +public class AmmoTypes implements ContentList { + public static AmmoType bulletIron, bulletLead, bulletSteel, bulletThorium, bulletSilicon, bulletThermite, flakLead, flakExplosive, flakPlastic, flakSurge, shellLead, shellExplosive, shellPlastic, shellThorium, missileExplosive, missileIncindiary, missileSurge, artilleryLead, artilleryThorium, artilleryPlastic, artilleryHoming, artilleryIncindiary, basicFlame, lancerLaser, lightning, spectreLaser, meltdownLaser, fuseShotgun, oil, water, lava, cryofluid; - //bullets + @Override + public void load() { - bulletIron = new AmmoType(Items.iron, StandardBullets.iron, 5){{ - shootEffect = ShootFx.shootSmall; - smokeEffect = ShootFx.shootSmallSmoke; - }}, + //bullets - bulletLead = new AmmoType(Items.lead, StandardBullets.lead, 5){{ - shootEffect = ShootFx.shootSmall; - smokeEffect = ShootFx.shootSmallSmoke; - }}, + bulletIron = new AmmoType(Items.iron, StandardBullets.iron, 5) {{ + shootEffect = ShootFx.shootSmall; + smokeEffect = ShootFx.shootSmallSmoke; + }}; - bulletSteel = new AmmoType(Items.steel, StandardBullets.steel, 5){{ - shootEffect = ShootFx.shootSmall; - smokeEffect = ShootFx.shootSmallSmoke; - }}, + bulletLead = new AmmoType(Items.lead, StandardBullets.lead, 5) {{ + shootEffect = ShootFx.shootSmall; + smokeEffect = ShootFx.shootSmallSmoke; + }}; - bulletThorium = new AmmoType(Items.thorium, StandardBullets.thorium, 5){{ - shootEffect = ShootFx.shootSmall; - smokeEffect = ShootFx.shootSmallSmoke; - }}, + bulletSteel = new AmmoType(Items.steel, StandardBullets.steel, 5) {{ + shootEffect = ShootFx.shootSmall; + smokeEffect = ShootFx.shootSmallSmoke; + }}; - bulletSilicon = new AmmoType(Items.silicon, StandardBullets.homing, 5){{ - shootEffect = ShootFx.shootSmall; - smokeEffect = ShootFx.shootSmallSmoke; - }}, + bulletThorium = new AmmoType(Items.thorium, StandardBullets.thorium, 5) {{ + shootEffect = ShootFx.shootSmall; + smokeEffect = ShootFx.shootSmallSmoke; + }}; - bulletThermite = new AmmoType(Items.thermite, StandardBullets.tracer, 5){{ - shootEffect = ShootFx.shootSmall; - smokeEffect = ShootFx.shootSmallSmoke; - }}, + bulletSilicon = new AmmoType(Items.silicon, StandardBullets.homing, 5) {{ + shootEffect = ShootFx.shootSmall; + smokeEffect = ShootFx.shootSmallSmoke; + }}; - //flak + bulletThermite = new AmmoType(Items.thermite, StandardBullets.tracer, 5) {{ + shootEffect = ShootFx.shootSmall; + smokeEffect = ShootFx.shootSmallSmoke; + }}; - flakLead = new AmmoType(Items.lead, FlakBullets.lead, 5){{ - shootEffect = ShootFx.shootSmall; - smokeEffect = ShootFx.shootSmallSmoke; - }}, + //flak - flakExplosive = new AmmoType(Items.blastCompound, FlakBullets.explosive, 5){{ - shootEffect = ShootFx.shootSmall; - smokeEffect = ShootFx.shootSmallSmoke; - }}, + flakLead = new AmmoType(Items.lead, FlakBullets.lead, 5) {{ + shootEffect = ShootFx.shootSmall; + smokeEffect = ShootFx.shootSmallSmoke; + }}; - flakPlastic = new AmmoType(Items.plastic, FlakBullets.plastic, 5){{ - shootEffect = ShootFx.shootSmall; - smokeEffect = ShootFx.shootSmallSmoke; - }}, + flakExplosive = new AmmoType(Items.blastCompound, FlakBullets.explosive, 5) {{ + shootEffect = ShootFx.shootSmall; + smokeEffect = ShootFx.shootSmallSmoke; + }}; - flakSurge = new AmmoType(Items.surgealloy, FlakBullets.surge, 5){{ - shootEffect = ShootFx.shootSmall; - smokeEffect = ShootFx.shootSmallSmoke; - }}, + flakPlastic = new AmmoType(Items.plastic, FlakBullets.plastic, 5) {{ + shootEffect = ShootFx.shootSmall; + smokeEffect = ShootFx.shootSmallSmoke; + }}; - //shells + flakSurge = new AmmoType(Items.surgealloy, FlakBullets.surge, 5) {{ + shootEffect = ShootFx.shootSmall; + smokeEffect = ShootFx.shootSmallSmoke; + }}; - shellLead = new AmmoType(Items.lead, ShellBullets.lead, 1){{ - shootEffect = ShootFx.shootBig2; - smokeEffect = ShootFx.shootBigSmoke2; - }}, + //shells - shellExplosive = new AmmoType(Items.blastCompound, ShellBullets.explosive, 1){{ - shootEffect = ShootFx.shootBig2; - smokeEffect = ShootFx.shootBigSmoke2; - }}, + shellLead = new AmmoType(Items.lead, ShellBullets.lead, 1) {{ + shootEffect = ShootFx.shootBig2; + smokeEffect = ShootFx.shootBigSmoke2; + }}; - shellPlastic = new AmmoType(Items.plastic, ShellBullets.plastic, 1){{ - shootEffect = ShootFx.shootBig2; - smokeEffect = ShootFx.shootBigSmoke2; - }}, + shellExplosive = new AmmoType(Items.blastCompound, ShellBullets.explosive, 1) {{ + shootEffect = ShootFx.shootBig2; + smokeEffect = ShootFx.shootBigSmoke2; + }}; - shellThorium = new AmmoType(Items.thorium, ShellBullets.thorium, 1){{ - shootEffect = ShootFx.shootBig2; - smokeEffect = ShootFx.shootBigSmoke2; - }}, + shellPlastic = new AmmoType(Items.plastic, ShellBullets.plastic, 1) {{ + shootEffect = ShootFx.shootBig2; + smokeEffect = ShootFx.shootBigSmoke2; + }}; - //missiles + shellThorium = new AmmoType(Items.thorium, ShellBullets.thorium, 1) {{ + shootEffect = ShootFx.shootBig2; + smokeEffect = ShootFx.shootBigSmoke2; + }}; - missileExplosive = new AmmoType(Items.blastCompound, MissileBullets.explosive, 1){{ - shootEffect = ShootFx.shootBig2; - smokeEffect = ShootFx.shootBigSmoke2; - }}, + //missiles - missileIncindiary = new AmmoType(Items.thermite, MissileBullets.incindiary, 1){{ - shootEffect = ShootFx.shootBig2; - smokeEffect = ShootFx.shootBigSmoke2; - }}, + missileExplosive = new AmmoType(Items.blastCompound, MissileBullets.explosive, 1) {{ + shootEffect = ShootFx.shootBig2; + smokeEffect = ShootFx.shootBigSmoke2; + }}; - missileSurge = new AmmoType(Items.surgealloy, MissileBullets.surge, 1){{ - shootEffect = ShootFx.shootBig2; - smokeEffect = ShootFx.shootBigSmoke2; - }}, + missileIncindiary = new AmmoType(Items.thermite, MissileBullets.incindiary, 1) {{ + shootEffect = ShootFx.shootBig2; + smokeEffect = ShootFx.shootBigSmoke2; + }}; - //artillery + missileSurge = new AmmoType(Items.surgealloy, MissileBullets.surge, 1) {{ + shootEffect = ShootFx.shootBig2; + smokeEffect = ShootFx.shootBigSmoke2; + }}; - artilleryLead = new AmmoType(Items.lead, ArtilleryBullets.lead, 1){{ - shootEffect = ShootFx.shootBig2; - smokeEffect = ShootFx.shootBigSmoke2; - }}, + //artillery - artilleryThorium = new AmmoType(Items.thorium, ArtilleryBullets.thorium, 1){{ - shootEffect = ShootFx.shootBig2; - smokeEffect = ShootFx.shootBigSmoke2; - }}, + artilleryLead = new AmmoType(Items.lead, ArtilleryBullets.lead, 1) {{ + shootEffect = ShootFx.shootBig2; + smokeEffect = ShootFx.shootBigSmoke2; + }}; - artilleryPlastic = new AmmoType(Items.plastic, ArtilleryBullets.plastic, 1){{ - shootEffect = ShootFx.shootBig2; - smokeEffect = ShootFx.shootBigSmoke2; - }}, + artilleryThorium = new AmmoType(Items.thorium, ArtilleryBullets.thorium, 1) {{ + shootEffect = ShootFx.shootBig2; + smokeEffect = ShootFx.shootBigSmoke2; + }}; - artilleryHoming = new AmmoType(Items.silicon, ArtilleryBullets.homing, 1){{ - shootEffect = ShootFx.shootBig2; - smokeEffect = ShootFx.shootBigSmoke2; - }}, + artilleryPlastic = new AmmoType(Items.plastic, ArtilleryBullets.plastic, 1) {{ + shootEffect = ShootFx.shootBig2; + smokeEffect = ShootFx.shootBigSmoke2; + }}; - artilleryIncindiary = new AmmoType(Items.thermite, ArtilleryBullets.incindiary, 1){{ - shootEffect = ShootFx.shootBig2; - smokeEffect = ShootFx.shootBigSmoke2; - }}, + artilleryHoming = new AmmoType(Items.silicon, ArtilleryBullets.homing, 1) {{ + shootEffect = ShootFx.shootBig2; + smokeEffect = ShootFx.shootBigSmoke2; + }}; - //flame + artilleryIncindiary = new AmmoType(Items.thermite, ArtilleryBullets.incindiary, 1) {{ + shootEffect = ShootFx.shootBig2; + smokeEffect = ShootFx.shootBigSmoke2; + }}; - basicFlame = new AmmoType(Liquids.oil, TurretBullets.basicFlame, 0.3f){{ - shootEffect = ShootFx.shootSmallFlame; - }}, + //flame - //power + basicFlame = new AmmoType(Liquids.oil, TurretBullets.basicFlame, 0.3f) {{ + shootEffect = ShootFx.shootSmallFlame; + }}; - lancerLaser = new AmmoType(TurretBullets.lancerLaser), + //power - lightning = new AmmoType(TurretBullets.lightning), + lancerLaser = new AmmoType(TurretBullets.lancerLaser); - spectreLaser = new AmmoType(TurretBullets.lancerLaser), + lightning = new AmmoType(TurretBullets.lightning); - meltdownLaser = new AmmoType(TurretBullets.lancerLaser), + spectreLaser = new AmmoType(TurretBullets.lancerLaser); - fuseShotgun = new AmmoType(Items.iron, TurretBullets.fuseShot, 0.1f), + meltdownLaser = new AmmoType(TurretBullets.lancerLaser); - //liquid + fuseShotgun = new AmmoType(Items.iron, TurretBullets.fuseShot, 0.1f); - oil = new AmmoType(Liquids.oil, TurretBullets.oilShot, 0.3f), + //liquid - water = new AmmoType(Liquids.water, TurretBullets.waterShot, 0.3f), + oil = new AmmoType(Liquids.oil, TurretBullets.oilShot, 0.3f); - lava = new AmmoType(Liquids.lava, TurretBullets.lavaShot, 0.3f), + water = new AmmoType(Liquids.water, TurretBullets.waterShot, 0.3f); - cryofluid = new AmmoType(Liquids.cryofluid, TurretBullets.cryoShot, 0.3f); + lava = new AmmoType(Liquids.lava, TurretBullets.lavaShot, 0.3f); + + cryofluid = new AmmoType(Liquids.cryofluid, TurretBullets.cryoShot, 0.3f); + + } } diff --git a/core/src/io/anuke/mindustry/content/Items.java b/core/src/io/anuke/mindustry/content/Items.java index 89b1f844a1..b0f7252325 100644 --- a/core/src/io/anuke/mindustry/content/Items.java +++ b/core/src/io/anuke/mindustry/content/Items.java @@ -1,78 +1,83 @@ package io.anuke.mindustry.content; import com.badlogic.gdx.graphics.Color; +import io.anuke.mindustry.type.ContentList; import io.anuke.mindustry.type.Item; import io.anuke.mindustry.type.ItemType; -public class Items { - public static final Item +public class Items implements ContentList{ + public static Item stone, iron, lead, coal, steel, titanium, thorium, silicon, plastic, surgealloy, biomatter, sand, blastCompound, thermite; - stone = new Item("stone", Color.valueOf("777777")) {{ - hardness = 3; - }}, + @Override + public void load() { - iron = new Item("iron", Color.valueOf("bc8271")){{ - type = ItemType.material; - hardness = 1; - }}, + stone = new Item("stone", Color.valueOf("777777")) {{ + hardness = 3; + }}; - lead = new Item("lead", Color.valueOf("8e85a2")){{ - type = ItemType.material; - hardness = 1; - }}, + iron = new Item("iron", Color.valueOf("bc8271")) {{ + type = ItemType.material; + hardness = 1; + }}; - coal = new Item("coal", Color.valueOf("272727")) {{ - explosiveness = 0.2f; - flammability = 0.5f; - fluxiness = 0.3f; - hardness = 2; - }}, + lead = new Item("lead", Color.valueOf("8e85a2")) {{ + type = ItemType.material; + hardness = 1; + }}; - steel = new Item("steel", Color.valueOf("e2e2e2")){{ - type = ItemType.material; - }}, + coal = new Item("coal", Color.valueOf("272727")) {{ + explosiveness = 0.2f; + flammability = 0.5f; + fluxiness = 0.3f; + hardness = 2; + }}; - titanium = new Item("titanium", Color.valueOf("8da1e3")){{ - type = ItemType.material; - hardness = 3; - }}, + steel = new Item("steel", Color.valueOf("e2e2e2")) {{ + type = ItemType.material; + }}; - thorium = new Item("thorium", Color.valueOf("f9a3c7")) {{ - type = ItemType.material; - explosiveness = 0.1f; - hardness = 4; - }}, + titanium = new Item("titanium", Color.valueOf("8da1e3")) {{ + type = ItemType.material; + hardness = 3; + }}; - silicon = new Item("silicon", Color.valueOf("53565c")){{ - type = ItemType.material; - }}, + thorium = new Item("thorium", Color.valueOf("f9a3c7")) {{ + type = ItemType.material; + explosiveness = 0.1f; + hardness = 4; + }}; - plastic = new Item("plastic", Color.valueOf("e9ead3")){{ - type = ItemType.material; - flammability = 0.2f; - explosiveness = 0.1f; - }}, + silicon = new Item("silicon", Color.valueOf("53565c")) {{ + type = ItemType.material; + }}; - surgealloy = new Item("surge-alloy", Color.valueOf("b4d5c7")){{ - type = ItemType.material; - }}, + plastic = new Item("plastic", Color.valueOf("e9ead3")) {{ + type = ItemType.material; + flammability = 0.2f; + explosiveness = 0.1f; + }}; - biomatter = new Item("biomatter", Color.valueOf("648b55")) {{ - flammability = 0.4f; - fluxiness = 0.2f; - }}, + surgealloy = new Item("surge-alloy", Color.valueOf("b4d5c7")) {{ + type = ItemType.material; + }}; - sand = new Item("sand", Color.valueOf("e3d39e")){{ - fluxiness = 0.5f; - }}, + biomatter = new Item("biomatter", Color.valueOf("648b55")) {{ + flammability = 0.4f; + fluxiness = 0.2f; + }}; - blastCompound = new Item("blast-compound", Color.valueOf("ff795e")){{ - flammability = 0.2f; - explosiveness = 0.6f; - }}, + sand = new Item("sand", Color.valueOf("e3d39e")) {{ + fluxiness = 0.5f; + }}; - thermite = new Item("thermite", Color.valueOf("ff795e")){{ - flammability = 0.7f; - explosiveness = 0.2f; - }}; + blastCompound = new Item("blast-compound", Color.valueOf("ff795e")) {{ + flammability = 0.2f; + explosiveness = 0.6f; + }}; + + thermite = new Item("thermite", Color.valueOf("ff795e")) {{ + flammability = 0.7f; + explosiveness = 0.2f; + }}; + } } diff --git a/core/src/io/anuke/mindustry/content/Liquids.java b/core/src/io/anuke/mindustry/content/Liquids.java index 8a74d5beaf..32942b9905 100644 --- a/core/src/io/anuke/mindustry/content/Liquids.java +++ b/core/src/io/anuke/mindustry/content/Liquids.java @@ -1,39 +1,48 @@ package io.anuke.mindustry.content; import com.badlogic.gdx.graphics.Color; +import io.anuke.mindustry.type.ContentList; import io.anuke.mindustry.type.Liquid; -public class Liquids { +public class Liquids implements ContentList { + public static Liquid none, water, lava, oil, cryofluid; - public static final Liquid + @Override + public void load() { - none = new Liquid("none", Color.CLEAR), - water = new Liquid("water", Color.valueOf("486acd")) { - { - heatCapacity = 0.4f; - effect = StatusEffects.wet; - } - }, - lava = new Liquid("lava", Color.valueOf("e37341")) { - { - temperature = 0.8f; - viscosity = 0.8f; - effect = StatusEffects.melting; - } - }, - oil = new Liquid("oil", Color.valueOf("313131")) { - { - viscosity = 0.7f; - flammability = 0.6f; - explosiveness = 0.6f; - effect = StatusEffects.oiled; - } - }, - cryofluid = new Liquid("cryofluid", Color.SKY) { - { - heatCapacity = 0.75f; - temperature = 0.5f; - effect = StatusEffects.freezing; - } - }; + none = new Liquid("none", Color.CLEAR); + + water = new Liquid("water", Color.valueOf("486acd")) { + { + heatCapacity = 0.4f; + effect = StatusEffects.wet; + } + }; + + lava = new Liquid("lava", Color.valueOf("e37341")) { + { + temperature = 0.8f; + viscosity = 0.8f; + effect = StatusEffects.melting; + } + }; + + oil = new Liquid("oil", Color.valueOf("313131")) { + { + viscosity = 0.7f; + flammability = 0.6f; + explosiveness = 0.6f; + effect = StatusEffects.oiled; + } + }; + + cryofluid = new Liquid("cryofluid", Color.SKY) { + { + heatCapacity = 0.75f; + temperature = 0.5f; + effect = StatusEffects.freezing; + } + }; + + } } diff --git a/core/src/io/anuke/mindustry/content/Mechs.java b/core/src/io/anuke/mindustry/content/Mechs.java index f758e4c13d..4e32490a6b 100644 --- a/core/src/io/anuke/mindustry/content/Mechs.java +++ b/core/src/io/anuke/mindustry/content/Mechs.java @@ -1,10 +1,15 @@ package io.anuke.mindustry.content; +import io.anuke.mindustry.type.ContentList; import io.anuke.mindustry.type.Mech; -public class Mechs { - public static final Mech +public class Mechs implements ContentList { + public static Mech standard, standardShip; - standard = new Mech("standard-mech", false), - standardShip = new Mech("standard-ship", true); + @Override + public void load() { + + standard = new Mech("standard-mech", false); + standardShip = new Mech("standard-ship", true); + } } diff --git a/core/src/io/anuke/mindustry/content/Recipes.java b/core/src/io/anuke/mindustry/content/Recipes.java index 64345dc9f3..3fa5eba724 100644 --- a/core/src/io/anuke/mindustry/content/Recipes.java +++ b/core/src/io/anuke/mindustry/content/Recipes.java @@ -1,12 +1,15 @@ package io.anuke.mindustry.content; import io.anuke.mindustry.content.blocks.*; +import io.anuke.mindustry.type.ContentList; import io.anuke.mindustry.type.ItemStack; import io.anuke.mindustry.type.Recipe; import static io.anuke.mindustry.type.Section.*; -public class Recipes { - static { +public class Recipes implements ContentList{ + + @Override + public void load (){ new Recipe(defense, DefenseBlocks.ironwall, new ItemStack(Items.iron, 12)); new Recipe(defense, DefenseBlocks.steelwall, new ItemStack(Items.steel, 12)); new Recipe(defense, DefenseBlocks.titaniumwall, new ItemStack(Items.titanium, 12)); diff --git a/core/src/io/anuke/mindustry/content/StatusEffects.java b/core/src/io/anuke/mindustry/content/StatusEffects.java index 0a13de525b..680e00364e 100644 --- a/core/src/io/anuke/mindustry/content/StatusEffects.java +++ b/core/src/io/anuke/mindustry/content/StatusEffects.java @@ -4,118 +4,121 @@ import io.anuke.mindustry.content.fx.EnvironmentFx; import io.anuke.mindustry.entities.StatusController.TransitionResult; import io.anuke.mindustry.entities.StatusEffect; import io.anuke.mindustry.entities.Unit; +import io.anuke.mindustry.type.ContentList; import io.anuke.ucore.core.Effects; import io.anuke.ucore.core.Timers; import io.anuke.ucore.util.Mathf; -public class StatusEffects { - public static final StatusEffect +public class StatusEffects implements ContentList { + public static StatusEffect none, burning, freezing, wet, melting, oiled; - none = new StatusEffect(0), + @Override + public void load() { - burning = new StatusEffect(4*60f){ - { - oppositeScale = 0.5f; - } + none = new StatusEffect(0); - @Override - public TransitionResult getTransition(Unit unit, StatusEffect to, float time, float newTime, TransitionResult result){ - if(to == oiled){ - unit.damage(1f); - Effects.effect(EnvironmentFx.burning, unit.x + Mathf.range(unit.getSize()/2f), unit.y + Mathf.range(unit.getSize()/2f)); - return result.set(this, Math.min(time + newTime, baseDuration + oiled.baseDuration)); + burning = new StatusEffect(4 * 60f) { + { + oppositeScale = 0.5f; } - return super.getTransition(unit, to, time, newTime, result); - } + @Override + public TransitionResult getTransition(Unit unit, StatusEffect to, float time, float newTime, TransitionResult result) { + if (to == oiled) { + unit.damage(1f); + Effects.effect(EnvironmentFx.burning, unit.x + Mathf.range(unit.getSize() / 2f), unit.y + Mathf.range(unit.getSize() / 2f)); + return result.set(this, Math.min(time + newTime, baseDuration + oiled.baseDuration)); + } - @Override - public void update(Unit unit, float time){ - unit.damagePeriodic(0.04f); - - if(Mathf.chance(Timers.delta() * 0.2f)){ - Effects.effect(EnvironmentFx.burning, unit.x + Mathf.range(unit.getSize()/2f), unit.y + Mathf.range(unit.getSize()/2f)); + return super.getTransition(unit, to, time, newTime, result); } - } - }, + @Override + public void update(Unit unit, float time) { + unit.damagePeriodic(0.04f); - freezing = new StatusEffect(5*60f){ - { - oppositeScale = 0.4f; - } + if (Mathf.chance(Timers.delta() * 0.2f)) { + Effects.effect(EnvironmentFx.burning, unit.x + Mathf.range(unit.getSize() / 2f), unit.y + Mathf.range(unit.getSize() / 2f)); + } - @Override - public void update(Unit unit, float time){ - unit.velocity.scl(0.7f); - - if(Mathf.chance(Timers.delta() * 0.15f)){ - Effects.effect(EnvironmentFx.freezing, unit.x + Mathf.range(unit.getSize()/2f), unit.y + Mathf.range(unit.getSize()/2f)); } - } - }, + }; - wet = new StatusEffect(3*60f){ - { - oppositeScale = 0.5f; - } - - @Override - public void update(Unit unit, float time){ - if(Mathf.chance(Timers.delta() * 0.15f)){ - Effects.effect(EnvironmentFx.wet, unit.x + Mathf.range(unit.getSize()/2f), unit.y + Mathf.range(unit.getSize()/2f)); + freezing = new StatusEffect(5 * 60f) { + { + oppositeScale = 0.4f; } - unit.velocity.scl(0.999f); - } - }, + @Override + public void update(Unit unit, float time) { + unit.velocity.scl(0.7f); - melting = new StatusEffect(5*60f){ - { - oppositeScale = 0.2f; - } + if (Mathf.chance(Timers.delta() * 0.15f)) { + Effects.effect(EnvironmentFx.freezing, unit.x + Mathf.range(unit.getSize() / 2f), unit.y + Mathf.range(unit.getSize() / 2f)); + } + } + }; - @Override - public TransitionResult getTransition(Unit unit, StatusEffect to, float time, float newTime, TransitionResult result){ - if(to == oiled){ - return result.set(this, Math.min(time + newTime/2f, baseDuration)); + wet = new StatusEffect(3 * 60f) { + { + oppositeScale = 0.5f; } - return super.getTransition(unit, to, time, newTime, result); - } + @Override + public void update(Unit unit, float time) { + if (Mathf.chance(Timers.delta() * 0.15f)) { + Effects.effect(EnvironmentFx.wet, unit.x + Mathf.range(unit.getSize() / 2f), unit.y + Mathf.range(unit.getSize() / 2f)); + } - @Override - public void update(Unit unit, float time){ - unit.velocity.scl(0.8f); - unit.damagePeriodic(0.1f); - - if(Mathf.chance(Timers.delta() * 0.2f)){ - Effects.effect(EnvironmentFx.melting, unit.x + Mathf.range(unit.getSize()/2f), unit.y + Mathf.range(unit.getSize()/2f)); + unit.velocity.scl(0.999f); } - } - }, + }; - oiled = new StatusEffect(4*60f){ - @Override - public void update(Unit unit, float time){ - if(Mathf.chance(Timers.delta() * 0.15f)){ - Effects.effect(EnvironmentFx.oily, unit.x + Mathf.range(unit.getSize()/2f), unit.y + Mathf.range(unit.getSize()/2f)); + melting = new StatusEffect(5 * 60f) { + { + oppositeScale = 0.2f; } - unit.velocity.scl(0.6f); - } + @Override + public TransitionResult getTransition(Unit unit, StatusEffect to, float time, float newTime, TransitionResult result) { + if (to == oiled) { + return result.set(this, Math.min(time + newTime / 2f, baseDuration)); + } - @Override - public TransitionResult getTransition(Unit unit, StatusEffect to, float time, float newTime, TransitionResult result){ - if(to == melting || to == burning){ - return result.set(to, newTime + time); + return super.getTransition(unit, to, time, newTime, result); } - return result.set(to, newTime); - } - }; + @Override + public void update(Unit unit, float time) { + unit.velocity.scl(0.8f); + unit.damagePeriodic(0.1f); + + if (Mathf.chance(Timers.delta() * 0.2f)) { + Effects.effect(EnvironmentFx.melting, unit.x + Mathf.range(unit.getSize() / 2f), unit.y + Mathf.range(unit.getSize() / 2f)); + } + } + }; + + oiled = new StatusEffect(4 * 60f) { + @Override + public void update(Unit unit, float time) { + if (Mathf.chance(Timers.delta() * 0.15f)) { + Effects.effect(EnvironmentFx.oily, unit.x + Mathf.range(unit.getSize() / 2f), unit.y + Mathf.range(unit.getSize() / 2f)); + } + + unit.velocity.scl(0.6f); + } + + @Override + public TransitionResult getTransition(Unit unit, StatusEffect to, float time, float newTime, TransitionResult result) { + if (to == melting || to == burning) { + return result.set(to, newTime + time); + } + + return result.set(to, newTime); + } + }; - static{ melting.setOpposites(wet, freezing); wet.setOpposites(burning); freezing.setOpposites(burning, melting); diff --git a/core/src/io/anuke/mindustry/content/UnitTypes.java b/core/src/io/anuke/mindustry/content/UnitTypes.java index 848ab059fd..b4f4bc8bfe 100644 --- a/core/src/io/anuke/mindustry/content/UnitTypes.java +++ b/core/src/io/anuke/mindustry/content/UnitTypes.java @@ -4,11 +4,15 @@ import io.anuke.mindustry.entities.units.UnitType; import io.anuke.mindustry.entities.units.types.Drone; import io.anuke.mindustry.entities.units.types.Scout; import io.anuke.mindustry.entities.units.types.Vtol; +import io.anuke.mindustry.type.ContentList; -public class UnitTypes { - public static final UnitType +public class UnitTypes implements ContentList { + public static UnitType drone, scout, vtol; - drone = new Drone(), - scout = new Scout(), - vtol = new Vtol(); + @Override + public void load() { + drone = new Drone(); + scout = new Scout(); + vtol = new Vtol(); + } } diff --git a/core/src/io/anuke/mindustry/content/UpgradeRecipes.java b/core/src/io/anuke/mindustry/content/UpgradeRecipes.java deleted file mode 100644 index 5813e52e48..0000000000 --- a/core/src/io/anuke/mindustry/content/UpgradeRecipes.java +++ /dev/null @@ -1,37 +0,0 @@ -package io.anuke.mindustry.content; - -import com.badlogic.gdx.utils.ObjectMap; -import com.badlogic.gdx.utils.ObjectMap.Entries; -import io.anuke.mindustry.type.Item; -import io.anuke.mindustry.type.ItemStack; -import io.anuke.mindustry.type.Upgrade; -import io.anuke.ucore.util.Mathf; - -public class UpgradeRecipes { - private static final ObjectMap recipes = Mathf.map( - /* - Weapons.triblaster, list(stack(Items.iron, 60), stack(Items.steel, 80)), - Weapons.clustergun, list(stack(Items.iron, 300), stack(Items.steel, 80)), - Weapons.vulcan, list(stack(Items.iron, 100), stack(Items.steel, 150), stack(Items.titanium, 80)), - Weapons.beam, list(stack(Items.steel, 260), stack(Items.titanium, 160), stack(Items.surgealloy, 120)), - Weapons.shockgun, list(stack(Items.steel, 240), stack(Items.titanium, 160), stack(Items.surgealloy, 160))*/ - ); - - private static final ItemStack[] empty = {}; - - public static ItemStack[] get(Upgrade upgrade){ - return recipes.get(upgrade, empty); - } - - public static Entries getAllRecipes(){ - return recipes.entries(); - } - - private static ItemStack[] list(ItemStack... stacks){ - return stacks; - } - - private static ItemStack stack(Item item, int amount){ - return new ItemStack(item, amount); - } -} diff --git a/core/src/io/anuke/mindustry/content/Weapons.java b/core/src/io/anuke/mindustry/content/Weapons.java index 509477e3d8..f7a840a19d 100644 --- a/core/src/io/anuke/mindustry/content/Weapons.java +++ b/core/src/io/anuke/mindustry/content/Weapons.java @@ -1,16 +1,21 @@ package io.anuke.mindustry.content; import io.anuke.mindustry.content.fx.ShootFx; +import io.anuke.mindustry.type.ContentList; import io.anuke.mindustry.type.Weapon; -public class Weapons { - public static final Weapon +public class Weapons implements ContentList { + public static Weapon blaster; - blaster = new Weapon("blaster") {{ - length = 1.5f; - reload = 15f; - roundrobin = true; - ejectEffect = ShootFx.shellEjectSmall; - setAmmo(AmmoTypes.bulletIron); - }}; + @Override + public void load() { + + blaster = new Weapon("blaster") {{ + length = 1.5f; + reload = 15f; + roundrobin = true; + ejectEffect = ShootFx.shellEjectSmall; + setAmmo(AmmoTypes.bulletIron); + }}; + } } diff --git a/core/src/io/anuke/mindustry/content/blocks/Blocks.java b/core/src/io/anuke/mindustry/content/blocks/Blocks.java index 3edb9021bf..2e681dd7b2 100644 --- a/core/src/io/anuke/mindustry/content/blocks/Blocks.java +++ b/core/src/io/anuke/mindustry/content/blocks/Blocks.java @@ -5,193 +5,193 @@ import io.anuke.mindustry.content.Items; import io.anuke.mindustry.content.Liquids; import io.anuke.mindustry.content.StatusEffects; import io.anuke.mindustry.graphics.CacheLayer; +import io.anuke.mindustry.type.ContentList; import io.anuke.mindustry.type.ItemStack; import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.blocks.types.*; -public class Blocks { - public static final Block +public class Blocks implements ContentList{ + public static Block air, spawn, blockpart, build1, build2, build3, build4, build5, build6, defaultFloor, space, metalfloor, deepwater, water, lava, oil, stone, blackstone, iron, lead, coal, titanium, thorium, dirt, sand, ice, snow, grass, sandblock, snowblock, stoneblock, blackstoneblock, grassblock, mossblock, shrub, rock, icerock, blackrock, dirtblock; - air = new Block("air") { - //don't draw - public void draw(Tile tile) {} - }, + @Override + public void load() { + air = new Block("air") { + //don't draw + public void draw(Tile tile) {} + }; - //player/enemy spawnpoint? - spawn = new Block("spawn"), + //player/enemy spawnpoint? + spawn = new Block("spawn"); - blockpart = new BlockPart(), + blockpart = new BlockPart(); - build1 = new BuildBlock("build1"), + build1 = new BuildBlock("build1"); - build2 = new BuildBlock("build2"), + build2 = new BuildBlock("build2"); - build3 = new BuildBlock("build3"), + build3 = new BuildBlock("build3"); - build4 = new BuildBlock("build4"), + build4 = new BuildBlock("build4"); - build5 = new BuildBlock("build5"), + build5 = new BuildBlock("build5"); - build6 = new BuildBlock("build6"), + build6 = new BuildBlock("build6"); - defaultFloor = new Floor("defaultfloor") {{ - }}, + defaultFloor = new Floor("defaultfloor"); - space = new Floor("space") {{ - placeableOn = false; - variants = 0; - cacheLayer = CacheLayer.space; - solid = true; - }}, + space = new Floor("space") {{ + placeableOn = false; + variants = 0; + cacheLayer = CacheLayer.space; + solid = true; + }}; - metalfloor = new Floor("metalfloor"){{ - variants = 6; - }}, + metalfloor = new Floor("metalfloor") {{ + variants = 6; + }}; - deepwater = new Floor("deepwater") {{ - placeableOn = false; - liquidColor = Color.valueOf("546bb3"); - speedMultiplier = 0.2f; - variants = 0; - liquidDrop = Liquids.water; - liquid = true; - status = StatusEffects.wet; - statusIntensity = 1f; - drownTime = 140f; - cacheLayer = CacheLayer.water; - }}, + deepwater = new Floor("deepwater") {{ + placeableOn = false; + liquidColor = Color.valueOf("546bb3"); + speedMultiplier = 0.2f; + variants = 0; + liquidDrop = Liquids.water; + liquid = true; + status = StatusEffects.wet; + statusIntensity = 1f; + drownTime = 140f; + cacheLayer = CacheLayer.water; + }}; - water = new Floor("water") {{ - placeableOn = false; - liquidColor = Color.valueOf("546bb3"); - speedMultiplier = 0.5f; - variants = 0; - status = StatusEffects.wet; - statusIntensity = 0.9f; - liquidDrop = Liquids.water; - liquid = true; - cacheLayer = CacheLayer.water; - }}, + water = new Floor("water") {{ + placeableOn = false; + liquidColor = Color.valueOf("546bb3"); + speedMultiplier = 0.5f; + variants = 0; + status = StatusEffects.wet; + statusIntensity = 0.9f; + liquidDrop = Liquids.water; + liquid = true; + cacheLayer = CacheLayer.water; + }}; - lava = new Floor("lava") {{ - placeableOn = false; - liquidColor = Color.valueOf("ed5334"); - speedMultiplier = 0.2f; - damageTaken = 0.1f; - status = StatusEffects.melting; - statusIntensity = 0.8f; - variants = 0; - liquidDrop = Liquids.lava; - liquid = true; - cacheLayer = CacheLayer.lava; - }}, + lava = new Floor("lava") {{ + placeableOn = false; + liquidColor = Color.valueOf("ed5334"); + speedMultiplier = 0.2f; + damageTaken = 0.1f; + status = StatusEffects.melting; + statusIntensity = 0.8f; + variants = 0; + liquidDrop = Liquids.lava; + liquid = true; + cacheLayer = CacheLayer.lava; + }}; - oil = new Floor("oil") {{ - placeableOn = false; - liquidColor = Color.valueOf("292929"); - status = StatusEffects.oiled; - statusIntensity = 1f; - speedMultiplier = 0.2f; - variants = 0; - liquidDrop = Liquids.oil; - liquid = true; - cacheLayer = CacheLayer.oil; - }}, + oil = new Floor("oil") {{ + placeableOn = false; + liquidColor = Color.valueOf("292929"); + status = StatusEffects.oiled; + statusIntensity = 1f; + speedMultiplier = 0.2f; + variants = 0; + liquidDrop = Liquids.oil; + liquid = true; + cacheLayer = CacheLayer.oil; + }}; - stone = new Floor("stone") {{ - drops = new ItemStack(Items.stone, 1); - blends = block -> block != this && !(block instanceof Ore); - }}, + stone = new Floor("stone") {{ + drops = new ItemStack(Items.stone, 1); + blends = block -> block != this && !(block instanceof Ore); + }}; - blackstone = new Floor("blackstone") {{ - drops = new ItemStack(Items.stone, 1); - }}, + blackstone = new Floor("blackstone") {{ + drops = new ItemStack(Items.stone, 1); + }}; - iron = new Ore("iron") {{ - drops = new ItemStack(Items.iron, 1); - }}, + iron = new Ore("iron") {{ + drops = new ItemStack(Items.iron, 1); + }}; - lead = new Ore("lead") {{ - drops = new ItemStack(Items.lead, 1); - }}, + lead = new Ore("lead") {{ + drops = new ItemStack(Items.lead, 1); + }}; - coal = new Ore("coal") {{ - drops = new ItemStack(Items.coal, 1); - }}, + coal = new Ore("coal") {{ + drops = new ItemStack(Items.coal, 1); + }}; - titanium = new Ore("titanium") {{ - drops = new ItemStack(Items.titanium, 1); - }}, + titanium = new Ore("titanium") {{ + drops = new ItemStack(Items.titanium, 1); + }}; - thorium = new Ore("thorium") {{ - drops = new ItemStack(Items.thorium, 1); - }}, + thorium = new Ore("thorium") {{ + drops = new ItemStack(Items.thorium, 1); + }}; - dirt = new Floor("dirt") { - }, + dirt = new Floor("dirt"); - sand = new Floor("sand") {{ - drops = new ItemStack(Items.sand, 1); - }}, + sand = new Floor("sand") {{ + drops = new ItemStack(Items.sand, 1); + }}; - ice = new Floor("ice") {{ - dragMultiplier = 0.2f; - }}, + ice = new Floor("ice") {{ + dragMultiplier = 0.2f; + }}; - snow = new Floor("snow") { - }, + snow = new Floor("snow"); - grass = new Floor("grass") { - }, + grass = new Floor("grass"); - sandblock = new StaticBlock("sandblock") {{ - solid = true; - variants = 3; - }}, + sandblock = new StaticBlock("sandblock") {{ + solid = true; + variants = 3; + }}; - snowblock = new StaticBlock("snowblock") {{ - solid = true; - variants = 3; - }}, + snowblock = new StaticBlock("snowblock") {{ + solid = true; + variants = 3; + }}; - stoneblock = new StaticBlock("stoneblock") {{ - solid = true; - variants = 3; - }}, + stoneblock = new StaticBlock("stoneblock") {{ + solid = true; + variants = 3; + }}; - blackstoneblock = new StaticBlock("blackstoneblock") {{ - solid = true; - variants = 3; - }}, + blackstoneblock = new StaticBlock("blackstoneblock") {{ + solid = true; + variants = 3; + }}; - grassblock = new StaticBlock("grassblock") {{ - solid = true; - variants = 2; - }}, + grassblock = new StaticBlock("grassblock") {{ + solid = true; + variants = 2; + }}; - mossblock = new StaticBlock("mossblock") {{ - solid = true; - }}, + mossblock = new StaticBlock("mossblock") {{ + solid = true; + }}; - shrub = new Rock("shrub"), + shrub = new Rock("shrub"); - rock = new Rock("rock") {{ - variants = 2; - varyShadow = true; - }}, + rock = new Rock("rock") {{ + variants = 2; + varyShadow = true; + }}; - icerock = new Rock("icerock") {{ - variants = 2; - varyShadow = true; - }}, + icerock = new Rock("icerock") {{ + variants = 2; + varyShadow = true; + }}; - blackrock = new Rock("blackrock") {{ - variants = 1; - varyShadow = true; - }}, + blackrock = new Rock("blackrock") {{ + variants = 1; + varyShadow = true; + }}; - dirtblock = new StaticBlock("dirtblock") {{ - solid = true; - }}; + dirtblock = new StaticBlock("dirtblock") {{ + solid = true; + }}; + } } diff --git a/core/src/io/anuke/mindustry/content/blocks/CraftingBlocks.java b/core/src/io/anuke/mindustry/content/blocks/CraftingBlocks.java index 4c0a49d7dc..1c39ad9ebc 100644 --- a/core/src/io/anuke/mindustry/content/blocks/CraftingBlocks.java +++ b/core/src/io/anuke/mindustry/content/blocks/CraftingBlocks.java @@ -4,199 +4,203 @@ import com.badlogic.gdx.graphics.Color; import io.anuke.mindustry.content.Items; import io.anuke.mindustry.content.Liquids; import io.anuke.mindustry.content.fx.BlockFx; +import io.anuke.mindustry.type.ContentList; import io.anuke.mindustry.type.Item; import io.anuke.mindustry.type.ItemStack; import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.blocks.types.production.*; -public class CraftingBlocks { - public static final Block +public class CraftingBlocks implements ContentList { + public static Block smelter, alloysmelter, siliconsmelter, poweralloysmelter, powersmelter, cryofluidmixer, melter, separator, centrifuge, plasticFormer, biomatterCompressor, pulverizer, oilRefinery, stoneFormer, weaponFactory, incinerator; - smelter = new Smelter("smelter") {{ - health = 70; - inputs = new Item[]{Items.iron}; - fuel = Items.coal; - result = Items.steel; - craftTime = 25f; - }}, + @Override + public void load() { + smelter = new Smelter("smelter") {{ + health = 70; + inputs = new Item[]{Items.iron}; + fuel = Items.coal; + result = Items.steel; + craftTime = 25f; + }}; - alloysmelter = new Smelter("alloysmelter") {{ - health = 90; - inputs = new Item[]{Items.titanium, Items.steel}; - fuel = Items.coal; - result = Items.surgealloy; - burnDuration = 45f; - craftTime = 25f; - flameColor = Color.valueOf("fd896e"); - }}, + alloysmelter = new Smelter("alloysmelter") {{ + health = 90; + inputs = new Item[]{Items.titanium, Items.steel}; + fuel = Items.coal; + result = Items.surgealloy; + burnDuration = 45f; + craftTime = 25f; + flameColor = Color.valueOf("fd896e"); + }}; - siliconsmelter = new PowerSmelter("siliconsmelter") {{ - health = 90; - craftEffect = BlockFx.smeltsmoke; - inputs = new ItemStack[]{new ItemStack(Items.coal, 1), new ItemStack(Items.sand, 2)}; - result = Items.silicon; - powerUse = 0.05f; - craftTime = 35f; - size = 2; - hasLiquids = false; - flameColor = Color.valueOf("ffef99"); - }}, + siliconsmelter = new PowerSmelter("siliconsmelter") {{ + health = 90; + craftEffect = BlockFx.smeltsmoke; + inputs = new ItemStack[]{new ItemStack(Items.coal, 1), new ItemStack(Items.sand, 2)}; + result = Items.silicon; + powerUse = 0.05f; + craftTime = 35f; + size = 2; + hasLiquids = false; + flameColor = Color.valueOf("ffef99"); + }}; - poweralloysmelter = new PowerSmelter("poweralloysmelter") {{ - health = 90; - craftEffect = BlockFx.smeltsmoke; - inputs = new ItemStack[]{new ItemStack(Items.titanium, 4), new ItemStack(Items.thorium, 4)}; - result = Items.surgealloy; - powerUse = 0.3f; - craftTime = 25f; - size = 2; - }}, + poweralloysmelter = new PowerSmelter("poweralloysmelter") {{ + health = 90; + craftEffect = BlockFx.smeltsmoke; + inputs = new ItemStack[]{new ItemStack(Items.titanium, 4), new ItemStack(Items.thorium, 4)}; + result = Items.surgealloy; + powerUse = 0.3f; + craftTime = 25f; + size = 2; + }}; - powersmelter = new PowerSmelter("powersmelter") {{ - health = 90; - craftEffect = BlockFx.smeltsmoke; - inputs = new ItemStack[]{new ItemStack(Items.coal, 1), new ItemStack(Items.iron, 1)}; - result = Items.steel; - powerUse = 0.1f; - craftTime = 25f; - size = 2; - }}, + powersmelter = new PowerSmelter("powersmelter") {{ + health = 90; + craftEffect = BlockFx.smeltsmoke; + inputs = new ItemStack[]{new ItemStack(Items.coal, 1), new ItemStack(Items.iron, 1)}; + result = Items.steel; + powerUse = 0.1f; + craftTime = 25f; + size = 2; + }}; - cryofluidmixer = new LiquidMixer("cryofluidmixer") {{ - health = 200; - inputLiquid = Liquids.water; - outputLiquid = Liquids.cryofluid; - inputItem = Items.titanium; - liquidPerItem = 50f; - itemCapacity = 50; - powerUse = 0.1f; - size = 2; - }}, + cryofluidmixer = new LiquidMixer("cryofluidmixer") {{ + health = 200; + inputLiquid = Liquids.water; + outputLiquid = Liquids.cryofluid; + inputItem = Items.titanium; + liquidPerItem = 50f; + itemCapacity = 50; + powerUse = 0.1f; + size = 2; + }}; - melter = new PowerCrafter("melter") {{ - health = 200; - outputLiquid = Liquids.lava; - outputLiquidAmount = 0.05f; - input = new ItemStack(Items.stone, 1); - itemCapacity = 50; - craftTime = 10f; - powerUse = 0.1f; - hasLiquids = hasPower = true; - }}, + melter = new PowerCrafter("melter") {{ + health = 200; + outputLiquid = Liquids.lava; + outputLiquidAmount = 0.05f; + input = new ItemStack(Items.stone, 1); + itemCapacity = 50; + craftTime = 10f; + powerUse = 0.1f; + hasLiquids = hasPower = true; + }}; - separator = new Separator("separator") {{ - liquid = Liquids.water; - item = Items.stone; - results = new Item[]{ - null, null, null, null, null, null, null, null, null, null, - Items.sand, Items.sand, Items.sand, Items.sand, Items.sand, Items.sand, Items.sand, Items.sand, Items.sand, Items.sand, - Items.stone, Items.stone, Items.stone, Items.stone, Items.stone, Items.stone, Items.stone, Items.stone, Items.stone, - Items.iron, Items.iron, Items.iron, Items.iron, - Items.lead, Items.lead, - Items.coal, Items.coal, - Items.titanium - }; - liquidUse = 0.2f; - filterTime = 40f; - itemCapacity = 40; - health = 50; - }}, + separator = new Separator("separator") {{ + liquid = Liquids.water; + item = Items.stone; + results = new Item[]{ + null, null, null, null, null, null, null, null, null, null, + Items.sand, Items.sand, Items.sand, Items.sand, Items.sand, Items.sand, Items.sand, Items.sand, Items.sand, Items.sand, + Items.stone, Items.stone, Items.stone, Items.stone, Items.stone, Items.stone, Items.stone, Items.stone, Items.stone, + Items.iron, Items.iron, Items.iron, Items.iron, + Items.lead, Items.lead, + Items.coal, Items.coal, + Items.titanium + }; + liquidUse = 0.2f; + filterTime = 40f; + itemCapacity = 40; + health = 50; + }}; - centrifuge = new Separator("centrifuge") {{ - liquid = Liquids.water; - item = Items.stone; - results = new Item[]{ - null, null, null, null, null, null, null, null, null, null, null, null, null, - Items.sand, Items.sand, Items.sand, Items.sand, Items.sand, Items.sand, Items.sand, Items.sand, Items.sand, Items.sand, Items.sand, Items.sand, - Items.stone, Items.stone, Items.stone, Items.stone, Items.stone, Items.stone, Items.stone, Items.stone, Items.stone, Items.stone, Items.stone, - Items.iron, Items.iron, Items.iron, Items.iron, Items.iron, - Items.lead, Items.lead, Items.lead, - Items.coal, Items.coal, Items.coal, - Items.titanium, Items.titanium, - Items.thorium, - }; + centrifuge = new Separator("centrifuge") {{ + liquid = Liquids.water; + item = Items.stone; + results = new Item[]{ + null, null, null, null, null, null, null, null, null, null, null, null, null, + Items.sand, Items.sand, Items.sand, Items.sand, Items.sand, Items.sand, Items.sand, Items.sand, Items.sand, Items.sand, Items.sand, Items.sand, + Items.stone, Items.stone, Items.stone, Items.stone, Items.stone, Items.stone, Items.stone, Items.stone, Items.stone, Items.stone, Items.stone, + Items.iron, Items.iron, Items.iron, Items.iron, Items.iron, + Items.lead, Items.lead, Items.lead, + Items.coal, Items.coal, Items.coal, + Items.titanium, Items.titanium, + Items.thorium, + }; - liquidUse = 0.3f; - hasPower = true; - powerUse = 0.2f; - filterTime = 15f; - itemCapacity = 60; - health = 50*4; - spinnerLength = 1.5f; - spinnerRadius = 3.5f; - spinnerThickness = 1.5f; - spinnerSpeed = 3f; - size = 2; - }}, + liquidUse = 0.3f; + hasPower = true; + powerUse = 0.2f; + filterTime = 15f; + itemCapacity = 60; + health = 50 * 4; + spinnerLength = 1.5f; + spinnerRadius = 3.5f; + spinnerThickness = 1.5f; + spinnerSpeed = 3f; + size = 2; + }}; - plasticFormer = new PlasticFormer("plasticformer") {{ - inputLiquid = Liquids.oil; - liquidUse = 0.3f; - liquidCapacity = 60f; - powerUse = 0.5f; - craftTime = 80f; - output = Items.plastic; - itemCapacity = 30; - size = 2; - health = 320; - hasPower = hasLiquids = true; - craftEffect = BlockFx.formsmoke; - updateEffect = BlockFx.plasticburn; - }}, + plasticFormer = new PlasticFormer("plasticformer") {{ + inputLiquid = Liquids.oil; + liquidUse = 0.3f; + liquidCapacity = 60f; + powerUse = 0.5f; + craftTime = 80f; + output = Items.plastic; + itemCapacity = 30; + size = 2; + health = 320; + hasPower = hasLiquids = true; + craftEffect = BlockFx.formsmoke; + updateEffect = BlockFx.plasticburn; + }}; - biomatterCompressor = new Compressor("biomattercompressor") {{ - input = new ItemStack(Items.biomatter, 1); - liquidCapacity = 60f; - itemCapacity = 50; - powerUse = 0.06f; - craftTime = 25f; - outputLiquid = Liquids.oil; - outputLiquidAmount = 0.1f; - size = 2; - health = 320; - hasLiquids = true; - }}, + biomatterCompressor = new Compressor("biomattercompressor") {{ + input = new ItemStack(Items.biomatter, 1); + liquidCapacity = 60f; + itemCapacity = 50; + powerUse = 0.06f; + craftTime = 25f; + outputLiquid = Liquids.oil; + outputLiquidAmount = 0.1f; + size = 2; + health = 320; + hasLiquids = true; + }}; - pulverizer = new Pulverizer("pulverizer") {{ - inputItem = new ItemStack(Items.stone, 2); - itemCapacity = 40; - powerUse = 0.2f; - output = Items.sand; - health = 80; - craftEffect = BlockFx.pulverize; - craftTime = 60f; - updateEffect = BlockFx.pulverizeSmall; - hasItems = hasPower = true; - }}, + pulverizer = new Pulverizer("pulverizer") {{ + inputItem = new ItemStack(Items.stone, 2); + itemCapacity = 40; + powerUse = 0.2f; + output = Items.sand; + health = 80; + craftEffect = BlockFx.pulverize; + craftTime = 60f; + updateEffect = BlockFx.pulverizeSmall; + hasItems = hasPower = true; + }}; - oilRefinery = new GenericCrafter("oilrefinery") {{ - inputLiquid = Liquids.oil; - powerUse = 0.05f; - liquidUse = 0.1f; - liquidCapacity = 56f; - output = Items.coal; - health = 80; - craftEffect = BlockFx.purifyoil; - hasItems = hasLiquids = hasPower = true; - }}, + oilRefinery = new GenericCrafter("oilrefinery") {{ + inputLiquid = Liquids.oil; + powerUse = 0.05f; + liquidUse = 0.1f; + liquidCapacity = 56f; + output = Items.coal; + health = 80; + craftEffect = BlockFx.purifyoil; + hasItems = hasLiquids = hasPower = true; + }}; - stoneFormer = new GenericCrafter("stoneformer") {{ - inputLiquid = Liquids.lava; - liquidUse = 1f; - liquidCapacity = 21f; - craftTime = 14; - output = Items.stone; - health = 80; - craftEffect = BlockFx.purifystone; - hasLiquids = hasItems = true; - }}, + stoneFormer = new GenericCrafter("stoneformer") {{ + inputLiquid = Liquids.lava; + liquidUse = 1f; + liquidCapacity = 21f; + craftTime = 14; + output = Items.stone; + health = 80; + craftEffect = BlockFx.purifystone; + hasLiquids = hasItems = true; + }}; - weaponFactory = new WeaponFactory("weaponfactory") {{ - size = 2; - health = 250; - }}, + weaponFactory = new WeaponFactory("weaponfactory") {{ + size = 2; + health = 250; + }}; - incinerator = new Incinerator("incinerator") {{ - health = 90; - }}; + incinerator = new Incinerator("incinerator") {{ + health = 90; + }}; + } } diff --git a/core/src/io/anuke/mindustry/content/blocks/DebugBlocks.java b/core/src/io/anuke/mindustry/content/blocks/DebugBlocks.java index aeb791eb9f..138ce21d7a 100644 --- a/core/src/io/anuke/mindustry/content/blocks/DebugBlocks.java +++ b/core/src/io/anuke/mindustry/content/blocks/DebugBlocks.java @@ -3,6 +3,7 @@ package io.anuke.mindustry.content.blocks; import com.badlogic.gdx.utils.Array; import io.anuke.mindustry.content.Liquids; import io.anuke.mindustry.entities.TileEntity; +import io.anuke.mindustry.type.ContentList; import io.anuke.mindustry.type.Item; import io.anuke.mindustry.type.Liquid; import io.anuke.mindustry.world.Block; @@ -19,137 +20,141 @@ import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; -public class DebugBlocks { - public static final Block +public class DebugBlocks implements ContentList{ + public static Block powerVoid, powerInfinite, itemSource, liquidSource, itemVoid; - powerVoid = new PowerBlock("powervoid") { - { - powerCapacity = Float.MAX_VALUE; - } - }, + @Override + public void load() { + powerVoid = new PowerBlock("powervoid") { + { + powerCapacity = Float.MAX_VALUE; + } + }; - powerInfinite = new PowerDistributor("powerinfinite") { - { - powerCapacity = 10000f; - powerSpeed = 100f; - } + powerInfinite = new PowerDistributor("powerinfinite") { + { + powerCapacity = 10000f; + powerSpeed = 100f; + } - @Override - public void update(Tile tile){ - super.update(tile); - tile.entity.power.amount = powerCapacity; - } - }, + @Override + public void update(Tile tile) { + super.update(tile); + tile.entity.power.amount = powerCapacity; + } + }; - itemSource = new Sorter("itemsource"){ - @Override - public void update(Tile tile) { - SorterEntity entity = tile.entity(); - entity.items.items[entity.sortItem.id] = 1; - tryDump(tile, entity.sortItem); - } + itemSource = new Sorter("itemsource") { + @Override + public void update(Tile tile) { + SorterEntity entity = tile.entity(); + entity.items.items[entity.sortItem.id] = 1; + tryDump(tile, entity.sortItem); + } - @Override - public boolean acceptItem(Item item, Tile tile, Tile source){ - return false; - } - }, + @Override + public boolean acceptItem(Item item, Tile tile, Tile source) { + return false; + } + }; - liquidSource = new Block("liquidsource"){ - { - update = true; - solid = true; - hasLiquids = true; - liquidCapacity = 100f; - } + liquidSource = new Block("liquidsource") { + { + update = true; + solid = true; + hasLiquids = true; + liquidCapacity = 100f; + } - @Override - public boolean isConfigurable(Tile tile) { - return true; - } + @Override + public boolean isConfigurable(Tile tile) { + return true; + } - @Override - public void update(Tile tile) { - LiquidSourceEntity entity = tile.entity(); + @Override + public void update(Tile tile) { + LiquidSourceEntity entity = tile.entity(); - tile.entity.liquids.amount = liquidCapacity; - tile.entity.liquids.liquid = entity.source; - tryDumpLiquid(tile); - } + tile.entity.liquids.amount = liquidCapacity; + tile.entity.liquids.liquid = entity.source; + tryDumpLiquid(tile); + } - @Override - public void draw(Tile tile){ - super.draw(tile); + @Override + public void draw(Tile tile) { + super.draw(tile); - LiquidSourceEntity entity = tile.entity(); + LiquidSourceEntity entity = tile.entity(); - Draw.color(entity.source.color); - Draw.rect("blank", tile.worldx(), tile.worldy(), 4f, 4f); - Draw.color(); - } + Draw.color(entity.source.color); + Draw.rect("blank", tile.worldx(), tile.worldy(), 4f, 4f); + Draw.color(); + } - @Override - public void buildTable(Tile tile, Table table){ - LiquidSourceEntity entity = tile.entity(); + @Override + public void buildTable(Tile tile, Table table) { + LiquidSourceEntity entity = tile.entity(); - Array items = Liquid.all(); + Array items = Liquid.all(); - ButtonGroup group = new ButtonGroup<>(); - Table cont = new Table(); - cont.margin(4); - cont.marginBottom(5); + ButtonGroup group = new ButtonGroup<>(); + Table cont = new Table(); + cont.margin(4); + cont.marginBottom(5); - cont.add().colspan(4).height(50f * (int)(items.size/4f + 1f)); - cont.row(); + cont.add().colspan(4).height(50f * (int) (items.size / 4f + 1f)); + cont.row(); - for(int i = 0; i < items.size; i ++){ - if(i == 0) continue; - final int f = i; - ImageButton button = cont.addImageButton("white", "toggle", 24, () -> { - entity.source = items.get(f); - }).size(38, 42).padBottom(-5.1f).group(group).get(); - button.getStyle().imageUpColor = items.get(i).color; - button.setChecked(entity.source.id == f); + for (int i = 0; i < items.size; i++) { + if (i == 0) continue; + final int f = i; + ImageButton button = cont.addImageButton("white", "toggle", 24, () -> { + entity.source = items.get(f); + }).size(38, 42).padBottom(-5.1f).group(group).get(); + button.getStyle().imageUpColor = items.get(i).color; + button.setChecked(entity.source.id == f); - if(i%4 == 3){ - cont.row(); + if (i % 4 == 3) { + cont.row(); + } + } + + table.add(cont); + } + + @Override + public TileEntity getEntity() { + return new LiquidSourceEntity(); + } + + class LiquidSourceEntity extends TileEntity { + public Liquid source = Liquids.water; + + @Override + public void write(DataOutputStream stream) throws IOException { + stream.writeByte(source.id); + } + + @Override + public void read(DataInputStream stream) throws IOException { + source = Liquid.getByID(stream.readByte()); } } + }; - table.add(cont); - } - - @Override - public TileEntity getEntity(){ - return new LiquidSourceEntity(); - } - - class LiquidSourceEntity extends TileEntity{ - public Liquid source = Liquids.water; - - @Override - public void write(DataOutputStream stream) throws IOException { - stream.writeByte(source.id); + itemVoid = new Block("itemvoid") { + { + update = solid = true; } @Override - public void read(DataInputStream stream) throws IOException { - source = Liquid.getByID(stream.readByte()); + public void handleItem(Item item, Tile tile, Tile source) { } - } - }, - itemVoid = new Block("itemvoid"){ - { - update = solid = true; - } - - @Override - public void handleItem(Item item, Tile tile, Tile source) {} - - @Override - public boolean acceptItem(Item item, Tile tile, Tile source){ - return true; - } - }; + @Override + public boolean acceptItem(Item item, Tile tile, Tile source) { + return true; + } + }; + } } diff --git a/core/src/io/anuke/mindustry/content/blocks/DefenseBlocks.java b/core/src/io/anuke/mindustry/content/blocks/DefenseBlocks.java index e9d5d29627..f250b6522d 100644 --- a/core/src/io/anuke/mindustry/content/blocks/DefenseBlocks.java +++ b/core/src/io/anuke/mindustry/content/blocks/DefenseBlocks.java @@ -1,66 +1,71 @@ package io.anuke.mindustry.content.blocks; import io.anuke.mindustry.content.fx.BlockFx; +import io.anuke.mindustry.type.ContentList; import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.blocks.types.Wall; -import io.anuke.mindustry.world.blocks.types.defense.*; +import io.anuke.mindustry.world.blocks.types.defense.Door; +import io.anuke.mindustry.world.blocks.types.defense.ShieldedWallBlock; -public class DefenseBlocks { - static final int wallHealthMultiplier = 4; +public class DefenseBlocks implements ContentList { + public static Block stonewall, ironwall, steelwall, titaniumwall, diriumwall, compositewall, steelwalllarge, titaniumwalllarge, diriumwalllarge, titaniumshieldwall, door, largedoor; - public static final Block + @Override + public void load() { + int wallHealthMultiplier = 4; - stonewall = new Wall("stonewall") {{ - health = 40 * wallHealthMultiplier; - }}, + stonewall = new Wall("stonewall") {{ + health = 40 * wallHealthMultiplier; + }}; - ironwall = new Wall("ironwall") {{ - health = 80 * wallHealthMultiplier; - }}, + ironwall = new Wall("ironwall") {{ + health = 80 * wallHealthMultiplier; + }}; - steelwall = new Wall("steelwall") {{ - health = 110 * wallHealthMultiplier; - }}, + steelwall = new Wall("steelwall") {{ + health = 110 * wallHealthMultiplier; + }}; - titaniumwall = new Wall("titaniumwall") {{ - health = 150 * wallHealthMultiplier; - }}, + titaniumwall = new Wall("titaniumwall") {{ + health = 150 * wallHealthMultiplier; + }}; - diriumwall = new Wall("duriumwall") {{ - health = 190 * wallHealthMultiplier; - }}, + diriumwall = new Wall("duriumwall") {{ + health = 190 * wallHealthMultiplier; + }}; - compositewall = new Wall("compositewall") {{ - health = 270 * wallHealthMultiplier; - }}, + compositewall = new Wall("compositewall") {{ + health = 270 * wallHealthMultiplier; + }}; - steelwalllarge = new Wall("steelwall-large") {{ - health = 110 * 4 * wallHealthMultiplier; - size = 2; - }}, + steelwalllarge = new Wall("steelwall-large") {{ + health = 110 * 4 * wallHealthMultiplier; + size = 2; + }}; - titaniumwalllarge = new Wall("titaniumwall-large") {{ - health = 150 * 4 * wallHealthMultiplier; - size = 2; - }}, + titaniumwalllarge = new Wall("titaniumwall-large") {{ + health = 150 * 4 * wallHealthMultiplier; + size = 2; + }}; - diriumwalllarge = new Wall("duriumwall-large") {{ - health = 190 * 4 * wallHealthMultiplier; - size = 2; - }}, + diriumwalllarge = new Wall("duriumwall-large") {{ + health = 190 * 4 * wallHealthMultiplier; + size = 2; + }}; - titaniumshieldwall = new ShieldedWallBlock("titaniumshieldwall") {{ - health = 150 * wallHealthMultiplier; - }}, + titaniumshieldwall = new ShieldedWallBlock("titaniumshieldwall") {{ + health = 150 * wallHealthMultiplier; + }}; - door = new Door("door") {{ - health = 90 * wallHealthMultiplier; - }}, + door = new Door("door") {{ + health = 90 * wallHealthMultiplier; + }}; - largedoor = new Door("door-large") {{ - openfx = BlockFx.dooropenlarge; - closefx = BlockFx.doorcloselarge; - health = 90 * 4 * wallHealthMultiplier; - size = 2; - }}; + largedoor = new Door("door-large") {{ + openfx = BlockFx.dooropenlarge; + closefx = BlockFx.doorcloselarge; + health = 90 * 4 * wallHealthMultiplier; + size = 2; + }}; + } } diff --git a/core/src/io/anuke/mindustry/content/blocks/DistributionBlocks.java b/core/src/io/anuke/mindustry/content/blocks/DistributionBlocks.java index f17074fc84..90aec4bf89 100644 --- a/core/src/io/anuke/mindustry/content/blocks/DistributionBlocks.java +++ b/core/src/io/anuke/mindustry/content/blocks/DistributionBlocks.java @@ -1,51 +1,55 @@ package io.anuke.mindustry.content.blocks; +import io.anuke.mindustry.type.ContentList; import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.blocks.types.distribution.*; -public class DistributionBlocks{ - - public static final Block - - conveyor = new Conveyor("conveyor"){{ - health = 40; - speed = 0.02f; - }}, - - steelconveyor = new Conveyor("steelconveyor"){{ - health = 55; - speed = 0.04f; - }}, - - pulseconveyor = new Conveyor("poweredconveyor"){{ - health = 75; - speed = 0.09f; - }}, - - router = new Router("router"), +public class DistributionBlocks implements ContentList{ + public static Block conveyor, steelconveyor, pulseconveyor, router, multiplexer, junction, bridgeconveyor, laserconveyor, sorter, splitter, overflowgate; - multiplexer = new Router("multiplexer"){{ - size = 2; - itemCapacity = 80; - }}, - - junction = new Junction("junction"){{ - speed = 26; - capacity = 32; - }}, + @Override + public void load() { - bridgeconveyor = new BufferedItemBridge("bridgeconveyor"){{ - range = 3; - hasPower = false; - }}, + conveyor = new Conveyor("conveyor") {{ + health = 40; + speed = 0.02f; + }}; - laserconveyor = new ItemBridge("laserconveyor"){{ - range = 7; - }}, + steelconveyor = new Conveyor("steelconveyor") {{ + health = 55; + speed = 0.04f; + }}; - sorter = new Sorter("sorter"), + pulseconveyor = new Conveyor("poweredconveyor") {{ + health = 75; + speed = 0.09f; + }}; - splitter = new Splitter("splitter"), + router = new Router("router"); - overflowgate = new OverflowGate("overflowgate"); + multiplexer = new Router("multiplexer") {{ + size = 2; + itemCapacity = 80; + }}; + + junction = new Junction("junction") {{ + speed = 26; + capacity = 32; + }}; + + bridgeconveyor = new BufferedItemBridge("bridgeconveyor") {{ + range = 3; + hasPower = false; + }}; + + laserconveyor = new ItemBridge("laserconveyor") {{ + range = 7; + }}; + + sorter = new Sorter("sorter"); + + splitter = new Splitter("splitter"); + + overflowgate = new OverflowGate("overflowgate"); + } } diff --git a/core/src/io/anuke/mindustry/content/blocks/LiquidBlocks.java b/core/src/io/anuke/mindustry/content/blocks/LiquidBlocks.java index 9d5a286a3d..11fa206a66 100644 --- a/core/src/io/anuke/mindustry/content/blocks/LiquidBlocks.java +++ b/core/src/io/anuke/mindustry/content/blocks/LiquidBlocks.java @@ -1,48 +1,53 @@ package io.anuke.mindustry.content.blocks; +import io.anuke.mindustry.type.ContentList; import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.blocks.types.distribution.*; import io.anuke.mindustry.world.blocks.types.production.Pump; -public class LiquidBlocks { - public static final Block +public class LiquidBlocks implements ContentList{ + public static Block pump, fluxpump, conduit, pulseconduit, liquidrouter, liquidtank, liquidjunction, bridgeconduit, laserconduit; - pump = new Pump("pump") {{ - pumpAmount = 0.1f; - }}, + @Override + public void load() { - fluxpump = new Pump("fluxpump") {{ - pumpAmount = 0.2f; - }}, + pump = new Pump("pump") {{ + pumpAmount = 0.1f; + }}; - conduit = new Conduit("conduit") {{ - health = 45; - }}, + fluxpump = new Pump("fluxpump") {{ + pumpAmount = 0.2f; + }}; - pulseconduit = new Conduit("pulseconduit") {{ - liquidCapacity = 16f; - liquidFlowFactor = 4.9f; - health = 65; - }}, + conduit = new Conduit("conduit") {{ + health = 45; + }}; - liquidrouter = new LiquidRouter("liquidrouter") {{ - liquidCapacity = 40f; - }}, + pulseconduit = new Conduit("pulseconduit") {{ + liquidCapacity = 16f; + liquidFlowFactor = 4.9f; + health = 65; + }}; - liquidtank = new LiquidRouter("liquidtank") {{ - size = 3; - liquidCapacity = 1500f; - health = 500; - }}, + liquidrouter = new LiquidRouter("liquidrouter") {{ + liquidCapacity = 40f; + }}; - liquidjunction = new LiquidJunction("liquidjunction"), + liquidtank = new LiquidRouter("liquidtank") {{ + size = 3; + liquidCapacity = 1500f; + health = 500; + }}; - bridgeconduit = new LiquidExtendingBridge("bridgeconduit"){{ - range = 3; - hasPower = false; - }}, + liquidjunction = new LiquidJunction("liquidjunction"); - laserconduit = new LiquidBridge("laserconduit"){{ - range = 7; - }}; + bridgeconduit = new LiquidExtendingBridge("bridgeconduit") {{ + range = 3; + hasPower = false; + }}; + + laserconduit = new LiquidBridge("laserconduit") {{ + range = 7; + }}; + } } diff --git a/core/src/io/anuke/mindustry/content/blocks/PowerBlocks.java b/core/src/io/anuke/mindustry/content/blocks/PowerBlocks.java index 1d008f8ba9..b5cb9c926c 100644 --- a/core/src/io/anuke/mindustry/content/blocks/PowerBlocks.java +++ b/core/src/io/anuke/mindustry/content/blocks/PowerBlocks.java @@ -1,99 +1,104 @@ package io.anuke.mindustry.content.blocks; import io.anuke.mindustry.content.fx.BlockFx; +import io.anuke.mindustry.type.ContentList; import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.blocks.types.defense.RepairTurret; import io.anuke.mindustry.world.blocks.types.defense.ShieldBlock; import io.anuke.mindustry.world.blocks.types.distribution.Teleporter; import io.anuke.mindustry.world.blocks.types.power.*; -public class PowerBlocks { - public static final Block +public class PowerBlocks implements ContentList { + public static Block combustiongenerator, thermalgenerator, liquidcombustiongenerator, rtgenerator, solarpanel, largesolarpanel, nuclearReactor, fusionReactor, repairturret, megarepairturret, shieldgenerator, battery, batteryLarge, powernode, powernodelarge, teleporter; - combustiongenerator = new BurnerGenerator("combustiongenerator") {{ - powerOutput = 0.04f; - powerCapacity = 40f; - }}, + @Override + public void load() { + combustiongenerator = new BurnerGenerator("combustiongenerator") {{ + powerOutput = 0.04f; + powerCapacity = 40f; + }}; - thermalgenerator = new LiquidHeatGenerator("thermalgenerator") {{ - maxLiquidGenerate = 0.5f; - powerPerLiquid = 0.08f; - powerCapacity = 40f; - generateEffect = BlockFx.redgeneratespark; - }}, + thermalgenerator = new LiquidHeatGenerator("thermalgenerator") {{ + maxLiquidGenerate = 0.5f; + powerPerLiquid = 0.08f; + powerCapacity = 40f; + generateEffect = BlockFx.redgeneratespark; + }}; - liquidcombustiongenerator = new LiquidBurnerGenerator("liquidcombustiongenerator") {{ - maxLiquidGenerate = 0.4f; - powerPerLiquid = 0.12f; - powerCapacity = 40f; - }}, + liquidcombustiongenerator = new LiquidBurnerGenerator("liquidcombustiongenerator") {{ + maxLiquidGenerate = 0.4f; + powerPerLiquid = 0.12f; + powerCapacity = 40f; + }}; - rtgenerator = new DecayGenerator("rtgenerator") {{ - powerCapacity = 40f; - powerOutput = 0.02f; - itemDuration = 500f; - }}, + rtgenerator = new DecayGenerator("rtgenerator") {{ + powerCapacity = 40f; + powerOutput = 0.02f; + itemDuration = 500f; + }}; - solarpanel = new SolarGenerator("solarpanel") {{ - generation = 0.003f; - }}, + solarpanel = new SolarGenerator("solarpanel") {{ + generation = 0.003f; + }}; - largesolarpanel = new SolarGenerator("largesolarpanel") {{ - size = 3; - generation = 0.012f; - }}, + largesolarpanel = new SolarGenerator("largesolarpanel") {{ + size = 3; + generation = 0.012f; + }}; - nuclearReactor = new NuclearReactor("nuclearreactor") {{ - size = 3; - health = 600; - }}, + nuclearReactor = new NuclearReactor("nuclearreactor") {{ + size = 3; + health = 600; + }}; - fusionReactor = new FusionReactor("fusionreactor") {{ - size = 4; - health = 600; - }}, + fusionReactor = new FusionReactor("fusionreactor") {{ + size = 4; + health = 600; + }}; - repairturret = new RepairTurret("repairturret") {{ - range = 30; - reload = 20f; - health = 60; - powerUsed = 0.08f; - }}, + repairturret = new RepairTurret("repairturret") {{ + range = 30; + reload = 20f; + health = 60; + powerUsed = 0.08f; + }}; - megarepairturret = new RepairTurret("megarepairturret") {{ - range = 44; - reload = 12f; - health = 90; - powerUsed = 0.13f; - size = 2; - }}, + megarepairturret = new RepairTurret("megarepairturret") {{ + range = 44; + reload = 12f; + health = 90; + powerUsed = 0.13f; + size = 2; + }}; - shieldgenerator = new ShieldBlock("shieldgenerator") {{ - health = 400; - }}, + shieldgenerator = new ShieldBlock("shieldgenerator") {{ + health = 400; + }}; - battery = new PowerGenerator("battery") {{ - powerCapacity = 320f; - hasItems = false; - }}, + battery = new PowerGenerator("battery") {{ + powerCapacity = 320f; + hasItems = false; + }}; - batteryLarge = new PowerGenerator("batterylarge") {{ - size = 3; - powerCapacity = 2000f; - hasItems = false; - }}, + batteryLarge = new PowerGenerator("batterylarge") {{ + size = 3; + powerCapacity = 2000f; + hasItems = false; + }}; - powernode = new PowerDistributor("powernode"){{ - shadow = "shadow-round-1"; - }}, + powernode = new PowerDistributor("powernode") {{ + shadow = "shadow-round-1"; + }}; - powernodelarge = new PowerDistributor("powernodelarge"){{ - size = 2; - powerSpeed = 1f; - maxNodes = 5; - laserRange = 7.5f; - shadow = "powernodelarge-shadow"; - }}, + powernodelarge = new PowerDistributor("powernodelarge") {{ + size = 2; + powerSpeed = 1f; + maxNodes = 5; + laserRange = 7.5f; + shadow = "powernodelarge-shadow"; + }}; - teleporter = new Teleporter("teleporter"); + teleporter = new Teleporter("teleporter"); + + } } diff --git a/core/src/io/anuke/mindustry/content/blocks/ProductionBlocks.java b/core/src/io/anuke/mindustry/content/blocks/ProductionBlocks.java index b75783bbe5..6324135fc9 100644 --- a/core/src/io/anuke/mindustry/content/blocks/ProductionBlocks.java +++ b/core/src/io/anuke/mindustry/content/blocks/ProductionBlocks.java @@ -4,103 +4,108 @@ import com.badlogic.gdx.graphics.Color; import io.anuke.mindustry.content.Items; import io.anuke.mindustry.content.Liquids; import io.anuke.mindustry.content.fx.BlockFx; +import io.anuke.mindustry.type.ContentList; import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.blocks.types.production.Cultivator; import io.anuke.mindustry.world.blocks.types.production.Drill; import io.anuke.mindustry.world.blocks.types.production.Fracker; import io.anuke.mindustry.world.blocks.types.production.SolidPump; -public class ProductionBlocks { - public static final Block +public class ProductionBlocks implements ContentList { + public static Block ironDrill, reinforcedDrill, steelDrill, titaniumDrill, laserdrill, nucleardrill, plasmadrill, waterextractor, oilextractor, cultivator; - ironDrill = new Drill("irondrill") {{ - tier = 1; - drillTime = 400; - }}, + @Override + public void load() { + ironDrill = new Drill("irondrill") {{ + tier = 1; + drillTime = 400; + }}; - reinforcedDrill = new Drill("reinforceddrill") {{ - tier = 2; - drillTime = 360; - }}, + reinforcedDrill = new Drill("reinforceddrill") {{ + tier = 2; + drillTime = 360; + }}; - steelDrill = new Drill("steeldrill") {{ - tier = 3; - drillTime = 320; - }}, + steelDrill = new Drill("steeldrill") {{ + tier = 3; + drillTime = 320; + }}; - titaniumDrill = new Drill("titaniumdrill") {{ - tier = 4; - drillTime = 280; - }}, + titaniumDrill = new Drill("titaniumdrill") {{ + tier = 4; + drillTime = 280; + }}; - laserdrill = new Drill("laserdrill") {{ - drillTime = 220; - size = 2; - powerUse = 0.2f; - hasPower = true; - tier = 5; - updateEffect = BlockFx.pulverizeMedium; - drillEffect = BlockFx.mineBig; - }}, + laserdrill = new Drill("laserdrill") {{ + drillTime = 220; + size = 2; + powerUse = 0.2f; + hasPower = true; + tier = 5; + updateEffect = BlockFx.pulverizeMedium; + drillEffect = BlockFx.mineBig; + }}; - nucleardrill = new Drill("nucleardrill") {{ - drillTime = 160; - size = 3; - powerUse = 0.5f; - drawRim = true; - hasPower = true; - tier = 5; - updateEffect = BlockFx.pulverizeRed; - updateEffectChance = 0.03f; - drillEffect = BlockFx.mineHuge; - rotateSpeed = 6f; - warmupSpeed = 0.01f; - }}, + nucleardrill = new Drill("nucleardrill") {{ + drillTime = 160; + size = 3; + powerUse = 0.5f; + drawRim = true; + hasPower = true; + tier = 5; + updateEffect = BlockFx.pulverizeRed; + updateEffectChance = 0.03f; + drillEffect = BlockFx.mineHuge; + rotateSpeed = 6f; + warmupSpeed = 0.01f; + }}; - plasmadrill = new Drill("plasmadrill") {{ - heatColor = Color.valueOf("ff461b"); - drillTime = 110; - size = 4; - powerUse = 0.7f; - hasLiquids = true; - hasPower = true; - tier = 5; - rotateSpeed = 9f; - drawRim = true; - updateEffect = BlockFx.pulverizeRedder; - updateEffectChance = 0.04f; - drillEffect = BlockFx.mineHuge; - warmupSpeed = 0.005f; - }}, + plasmadrill = new Drill("plasmadrill") {{ + heatColor = Color.valueOf("ff461b"); + drillTime = 110; + size = 4; + powerUse = 0.7f; + hasLiquids = true; + hasPower = true; + tier = 5; + rotateSpeed = 9f; + drawRim = true; + updateEffect = BlockFx.pulverizeRedder; + updateEffectChance = 0.04f; + drillEffect = BlockFx.mineHuge; + warmupSpeed = 0.005f; + }}; - waterextractor = new SolidPump("waterextractor") {{ - result = Liquids.water; - powerUse = 0.2f; - pumpAmount = 0.1f; - size = 2; - liquidCapacity = 30f; - rotateSpeed = 1.4f; - }}, + waterextractor = new SolidPump("waterextractor") {{ + result = Liquids.water; + powerUse = 0.2f; + pumpAmount = 0.1f; + size = 2; + liquidCapacity = 30f; + rotateSpeed = 1.4f; + }}; - oilextractor = new Fracker("oilextractor") {{ - result = Liquids.oil; - inputLiquid = Liquids.water; - updateEffect = BlockFx.pulverize; - updateEffectChance = 0.05f; - inputLiquidUse = 0.3f; - powerUse = 0.6f; - pumpAmount = 0.06f; - size = 3; - liquidCapacity = 30f; - }}, + oilextractor = new Fracker("oilextractor") {{ + result = Liquids.oil; + inputLiquid = Liquids.water; + updateEffect = BlockFx.pulverize; + updateEffectChance = 0.05f; + inputLiquidUse = 0.3f; + powerUse = 0.6f; + pumpAmount = 0.06f; + size = 3; + liquidCapacity = 30f; + }}; - cultivator = new Cultivator("cultivator") {{ - result = Items.biomatter; - inputLiquid = Liquids.water; - liquidUse = 0.2f; - drillTime = 260; - size = 2; - hasLiquids = true; - hasPower = true; - }}; + cultivator = new Cultivator("cultivator") {{ + result = Items.biomatter; + inputLiquid = Liquids.water; + liquidUse = 0.2f; + drillTime = 260; + size = 2; + hasLiquids = true; + hasPower = true; + }}; + + } } diff --git a/core/src/io/anuke/mindustry/content/blocks/StorageBlocks.java b/core/src/io/anuke/mindustry/content/blocks/StorageBlocks.java index c192ab2c2f..6669b3419c 100644 --- a/core/src/io/anuke/mindustry/content/blocks/StorageBlocks.java +++ b/core/src/io/anuke/mindustry/content/blocks/StorageBlocks.java @@ -1,28 +1,32 @@ package io.anuke.mindustry.content.blocks; +import io.anuke.mindustry.type.ContentList; import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.blocks.types.storage.CoreBlock; import io.anuke.mindustry.world.blocks.types.storage.SortedUnloader; import io.anuke.mindustry.world.blocks.types.storage.Unloader; import io.anuke.mindustry.world.blocks.types.storage.Vault; -public class StorageBlocks { - public static final Block +public class StorageBlocks implements ContentList { + public static Block core, vault, unloader, sortedunloader; - core = new CoreBlock("core"){{ - health = 800; - }}, + @Override + public void load() { + core = new CoreBlock("core") {{ + health = 800; + }}; - vault = new Vault("vault"){{ - size = 3; - health = 600; - }}, + vault = new Vault("vault") {{ + size = 3; + health = 600; + }}; - unloader = new Unloader("unloader"){{ - speed = 5; - }}, + unloader = new Unloader("unloader") {{ + speed = 5; + }}; - sortedunloader = new SortedUnloader("sortedunloader"){{ - speed = 5; - }}; + sortedunloader = new SortedUnloader("sortedunloader") {{ + speed = 5; + }}; + } } diff --git a/core/src/io/anuke/mindustry/content/blocks/UnitBlocks.java b/core/src/io/anuke/mindustry/content/blocks/UnitBlocks.java index bab6d9167c..51bd3b799c 100644 --- a/core/src/io/anuke/mindustry/content/blocks/UnitBlocks.java +++ b/core/src/io/anuke/mindustry/content/blocks/UnitBlocks.java @@ -1,46 +1,33 @@ package io.anuke.mindustry.content.blocks; +import io.anuke.mindustry.type.ContentList; import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.blocks.types.units.RepairPoint; import io.anuke.mindustry.world.blocks.types.units.ResupplyPoint; -public class UnitBlocks { - public static final Block -/* - droneFactory = new UnitFactory("dronefactory"){{ - type = UnitTypes.drone; - produceTime = 200; - size = 2; - requirements = new ItemStack[]{ - new ItemStack(Items.stone, 5) - }; - }}, +public class UnitBlocks implements ContentList { + public static Block resupplyPoint, repairPoint, droneFactory; - vtolFactory = new UnitFactory("vtolfactory"){{ - type = UnitTypes.vtol; - produceTime = 200; - size = 2; - requirements = new ItemStack[]{ - new ItemStack(Items.stone, 5) - }; - }}, + @Override + public void load() { + /* + droneFactory = new UnitFactory("dronefactory") {{ + type = UnitTypes.drone; + produceTime = 200; + size = 2; + requirements = new ItemStack[]{ + new ItemStack(Items.stone, 5) + }; + }};*/ - walkerFactory = new UnitFactory("walkerfactory"){{ - type = UnitTypes.scout; - produceTime = 20; - size = 2; - requirements = new ItemStack[]{ - new ItemStack(Items.stone, 1) - }; - }},*/ + resupplyPoint = new ResupplyPoint("resupplypoint") {{ + shadow = "shadow-round-1"; + itemCapacity = 30; + }}; - resupplyPoint = new ResupplyPoint("resupplypoint"){{ - shadow = "shadow-round-1"; - itemCapacity = 30; - }}, - - repairPoint = new RepairPoint("repairpoint"){{ - shadow = "shadow-round-1"; - repairSpeed = 0.1f; - }}; + repairPoint = new RepairPoint("repairpoint") {{ + shadow = "shadow-round-1"; + repairSpeed = 0.1f; + }}; + } } diff --git a/core/src/io/anuke/mindustry/content/blocks/WeaponBlocks.java b/core/src/io/anuke/mindustry/content/blocks/WeaponBlocks.java index f456c260d7..ace2a144f1 100644 --- a/core/src/io/anuke/mindustry/content/blocks/WeaponBlocks.java +++ b/core/src/io/anuke/mindustry/content/blocks/WeaponBlocks.java @@ -4,6 +4,7 @@ import com.badlogic.gdx.graphics.Color; import io.anuke.mindustry.content.AmmoTypes; import io.anuke.mindustry.content.fx.ShootFx; import io.anuke.mindustry.type.AmmoType; +import io.anuke.mindustry.type.ContentList; import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.blocks.types.defense.turrets.*; import io.anuke.ucore.graphics.Draw; @@ -11,167 +12,170 @@ import io.anuke.ucore.util.Angles; import io.anuke.ucore.util.Mathf; import io.anuke.ucore.util.Strings; -public class WeaponBlocks{ - public static Block - - duo = new DoubleTurret("duo"){{ - ammoTypes = new AmmoType[]{AmmoTypes.bulletIron, AmmoTypes.bulletLead, AmmoTypes.bulletSteel, AmmoTypes.bulletThermite}; - reload = 25f; - restitution = 0.03f; - ammoUseEffect = ShootFx.shellEjectSmall; - }}, - - scatter = new BurstTurret("scatter") {{ - ammoTypes = new AmmoType[]{AmmoTypes.flakLead, AmmoTypes.flakExplosive, AmmoTypes.flakPlastic}; - ammoPerShot = 1; - shots = 3; - reload = 60f; - restitution = 0.03f; - recoil = 1.5f; - burstSpacing = 6f; - ammoUseEffect = ShootFx.shellEjectSmall; - }}, - - scorch = new LiquidTurret("scorch"){{ - ammoTypes = new AmmoType[]{AmmoTypes.basicFlame}; - recoil = 0f; - reload = 5f; - shootCone = 50f; - ammoUseEffect = ShootFx.shellEjectSmall; +public class WeaponBlocks implements ContentList { + public static Block duo, scatter, scorch, hail, wave, crux, lancer, arc, swarmer, ripple, cyclone, fuse, spectre, eraser, meltdown; - drawer = (tile, entity) -> Draw.rect(entity.target != null ? name + "-shoot" : name, tile.drawx() + tr2.x, tile.drawy() + tr2.y, entity.rotation - 90); - }}, + @Override + public void load() { + duo = new DoubleTurret("duo") {{ + ammoTypes = new AmmoType[]{AmmoTypes.bulletIron, AmmoTypes.bulletLead, AmmoTypes.bulletSteel, AmmoTypes.bulletThermite}; + reload = 25f; + restitution = 0.03f; + ammoUseEffect = ShootFx.shellEjectSmall; + }}; - hail = new ItemTurret("hail") {{ - ammoTypes = new AmmoType[]{AmmoTypes.artilleryLead, AmmoTypes.artilleryHoming, AmmoTypes.artilleryIncindiary}; - }}, + scatter = new BurstTurret("scatter") {{ + ammoTypes = new AmmoType[]{AmmoTypes.flakLead, AmmoTypes.flakExplosive, AmmoTypes.flakPlastic}; + ammoPerShot = 1; + shots = 3; + reload = 60f; + restitution = 0.03f; + recoil = 1.5f; + burstSpacing = 6f; + ammoUseEffect = ShootFx.shellEjectSmall; + }}; - wave = new LiquidTurret("wave") {{ - ammoTypes = new AmmoType[]{AmmoTypes.water, AmmoTypes.lava, AmmoTypes.cryofluid, AmmoTypes.oil}; - size = 2; - recoil = 0f; - reload = 4f; - inaccuracy = 5f; - shootCone = 50f; - shootEffect = ShootFx.shootLiquid; - range = 70f; + scorch = new LiquidTurret("scorch") {{ + ammoTypes = new AmmoType[]{AmmoTypes.basicFlame}; + recoil = 0f; + reload = 5f; + shootCone = 50f; + ammoUseEffect = ShootFx.shellEjectSmall; - drawer = (tile, entity) -> { - Draw.rect(name, tile.drawx() + tr2.x, tile.drawy() + tr2.y, entity.rotation - 90); + drawer = (tile, entity) -> Draw.rect(entity.target != null ? name + "-shoot" : name, tile.drawx() + tr2.x, tile.drawy() + tr2.y, entity.rotation - 90); + }}; - Draw.color(entity.liquids.liquid.color); - Draw.alpha(entity.liquids.amount/liquidCapacity); - Draw.rect(name + "-liquid", tile.drawx() + tr2.x, tile.drawy() + tr2.y, entity.rotation - 90); - Draw.color(); - }; - }}, - - crux = new ItemTurret("crux"){{ - size = 2; - range = 100f; - ammoTypes = new AmmoType[]{AmmoTypes.shellExplosive, AmmoTypes.shellLead, AmmoTypes.shellPlastic, AmmoTypes.shellThorium}; - reload = 70f; - restitution = 0.03f; - ammoEjectBack = 3f; - cooldown = 0.03f; - recoil = 3f; - shootShake = 2f; - ammoUseEffect = ShootFx.shellEjectBig; + hail = new ItemTurret("hail") {{ + ammoTypes = new AmmoType[]{AmmoTypes.artilleryLead, AmmoTypes.artilleryHoming, AmmoTypes.artilleryIncindiary}; + }}; - drawer = (tile, entity) -> { - Draw.rect(name, tile.drawx() + tr2.x, tile.drawy() + tr2.y, entity.rotation - 90); - float offsetx = (int)(Mathf.abscurve(Mathf.curve(entity.reload/reload, 0.3f, 0.2f)) * 3f); - float offsety = -(int)(Mathf.abscurve(Mathf.curve(entity.reload/reload, 0.3f, 0.2f)) * 2f); + wave = new LiquidTurret("wave") {{ + ammoTypes = new AmmoType[]{AmmoTypes.water, AmmoTypes.lava, AmmoTypes.cryofluid, AmmoTypes.oil}; + size = 2; + recoil = 0f; + reload = 4f; + inaccuracy = 5f; + shootCone = 50f; + shootEffect = ShootFx.shootLiquid; + range = 70f; - for(int i : Mathf.signs){ - float rot = entity.rotation + 90*i; - Draw.rect(name + "-panel-" + Strings.dir(i), - tile.drawx() + tr2.x + Angles.trnsx(rot, offsetx, offsety), - tile.drawy() + tr2.y + Angles.trnsy(rot, -offsetx, offsety), entity.rotation - 90); - } - }; - }}, - - lancer = new LaserTurret("lancer"){{ - range = 70f; - chargeTime = 70f; - chargeMaxDelay = 30f; - chargeEffects = 7; - shootType = AmmoTypes.lancerLaser; - recoil = 2f; - reload = 130f; - cooldown = 0.03f; - shootEffect = ShootFx.lancerLaserShoot; - smokeEffect = ShootFx.lancerLaserShootSmoke; - chargeEffect = ShootFx.lancerLaserCharge; - chargeBeginEffect = ShootFx.lancerLaserChargeBegin; - heatColor = Color.RED; - size = 2; - }}, - - arc = new LaserTurret("arc"){{ - shootType = AmmoTypes.lightning; - reload = 100f; - chargeTime = 70f; - shootShake = 1f; - chargeMaxDelay = 30f; - chargeEffects = 7; - shootEffect = ShootFx.lightningShoot; - chargeEffect = ShootFx.lightningCharge; - chargeBeginEffect = ShootFx.lancerLaserChargeBegin; - heatColor = Color.RED; - recoil = 3f; - size = 2; - }}, + drawer = (tile, entity) -> { + Draw.rect(name, tile.drawx() + tr2.x, tile.drawy() + tr2.y, entity.rotation - 90); - swarmer = new ItemTurret("swarmer") {{ - ammoTypes = new AmmoType[]{AmmoTypes.missileExplosive, AmmoTypes.missileIncindiary, AmmoTypes.missileSurge}; - size = 2; - }}, + Draw.color(entity.liquids.liquid.color); + Draw.alpha(entity.liquids.amount / liquidCapacity); + Draw.rect(name + "-liquid", tile.drawx() + tr2.x, tile.drawy() + tr2.y, entity.rotation - 90); + Draw.color(); + }; + }}; - ripple = new ItemTurret("ripple") {{ - ammoTypes = new AmmoType[]{AmmoTypes.artilleryLead, AmmoTypes.artilleryHoming, AmmoTypes.artilleryIncindiary, AmmoTypes.artilleryPlastic, AmmoTypes.artilleryThorium}; - size = 3; - }}, + crux = new ItemTurret("crux") {{ + size = 2; + range = 100f; + ammoTypes = new AmmoType[]{AmmoTypes.shellExplosive, AmmoTypes.shellLead, AmmoTypes.shellPlastic, AmmoTypes.shellThorium}; + reload = 70f; + restitution = 0.03f; + ammoEjectBack = 3f; + cooldown = 0.03f; + recoil = 3f; + shootShake = 2f; + ammoUseEffect = ShootFx.shellEjectBig; - cyclone = new ItemTurret("cyclone") {{ - ammoTypes = new AmmoType[]{AmmoTypes.flakLead, AmmoTypes.flakExplosive, AmmoTypes.flakPlastic, AmmoTypes.flakSurge}; - size = 3; - }}, + drawer = (tile, entity) -> { + Draw.rect(name, tile.drawx() + tr2.x, tile.drawy() + tr2.y, entity.rotation - 90); + float offsetx = (int) (Mathf.abscurve(Mathf.curve(entity.reload / reload, 0.3f, 0.2f)) * 3f); + float offsety = -(int) (Mathf.abscurve(Mathf.curve(entity.reload / reload, 0.3f, 0.2f)) * 2f); - fuse = new ItemTurret("fuse") {{ - //TODO make it use power - ammoTypes = new AmmoType[]{AmmoTypes.fuseShotgun}; - size = 3; - }}, + for (int i : Mathf.signs) { + float rot = entity.rotation + 90 * i; + Draw.rect(name + "-panel-" + Strings.dir(i), + tile.drawx() + tr2.x + Angles.trnsx(rot, offsetx, offsety), + tile.drawy() + tr2.y + Angles.trnsy(rot, -offsetx, offsety), entity.rotation - 90); + } + }; + }}; - spectre = new LaserTurret("spectre") {{ - range = 70f; - chargeTime = 70f; - chargeMaxDelay = 30f; - chargeEffects = 7; - shootType = AmmoTypes.spectreLaser; - recoil = 2f; - reload = 130f; - cooldown = 0.03f; - shootEffect = ShootFx.lancerLaserShoot; - smokeEffect = ShootFx.lancerLaserShootSmoke; - chargeEffect = ShootFx.lancerLaserCharge; - chargeBeginEffect = ShootFx.lancerLaserChargeBegin; - heatColor = Color.RED; - size = 3; - }}, + lancer = new LaserTurret("lancer") {{ + range = 70f; + chargeTime = 70f; + chargeMaxDelay = 30f; + chargeEffects = 7; + shootType = AmmoTypes.lancerLaser; + recoil = 2f; + reload = 130f; + cooldown = 0.03f; + shootEffect = ShootFx.lancerLaserShoot; + smokeEffect = ShootFx.lancerLaserShootSmoke; + chargeEffect = ShootFx.lancerLaserCharge; + chargeBeginEffect = ShootFx.lancerLaserChargeBegin; + heatColor = Color.RED; + size = 2; + }}; - eraser = new ItemTurret("eraser"){{ - ammoTypes = new AmmoType[]{AmmoTypes.bulletIron, AmmoTypes.bulletLead, AmmoTypes.bulletSteel, AmmoTypes.bulletThermite, AmmoTypes.bulletThorium, AmmoTypes.bulletSilicon}; - reload = 25f; - restitution = 0.03f; - ammoUseEffect = ShootFx.shellEjectSmall; - size = 4; - }}, + arc = new LaserTurret("arc") {{ + shootType = AmmoTypes.lightning; + reload = 100f; + chargeTime = 70f; + shootShake = 1f; + chargeMaxDelay = 30f; + chargeEffects = 7; + shootEffect = ShootFx.lightningShoot; + chargeEffect = ShootFx.lightningCharge; + chargeBeginEffect = ShootFx.lancerLaserChargeBegin; + heatColor = Color.RED; + recoil = 3f; + size = 2; + }}; - meltdown = new PowerTurret("meltdown") {{ - shootType = AmmoTypes.meltdownLaser; - size = 4; - }}; + swarmer = new ItemTurret("swarmer") {{ + ammoTypes = new AmmoType[]{AmmoTypes.missileExplosive, AmmoTypes.missileIncindiary, AmmoTypes.missileSurge}; + size = 2; + }}; + + ripple = new ItemTurret("ripple") {{ + ammoTypes = new AmmoType[]{AmmoTypes.artilleryLead, AmmoTypes.artilleryHoming, AmmoTypes.artilleryIncindiary, AmmoTypes.artilleryPlastic, AmmoTypes.artilleryThorium}; + size = 3; + }}; + + cyclone = new ItemTurret("cyclone") {{ + ammoTypes = new AmmoType[]{AmmoTypes.flakLead, AmmoTypes.flakExplosive, AmmoTypes.flakPlastic, AmmoTypes.flakSurge}; + size = 3; + }}; + + fuse = new ItemTurret("fuse") {{ + //TODO make it use power + ammoTypes = new AmmoType[]{AmmoTypes.fuseShotgun}; + size = 3; + }}; + + spectre = new LaserTurret("spectre") {{ + range = 70f; + chargeTime = 70f; + chargeMaxDelay = 30f; + chargeEffects = 7; + shootType = AmmoTypes.spectreLaser; + recoil = 2f; + reload = 130f; + cooldown = 0.03f; + shootEffect = ShootFx.lancerLaserShoot; + smokeEffect = ShootFx.lancerLaserShootSmoke; + chargeEffect = ShootFx.lancerLaserCharge; + chargeBeginEffect = ShootFx.lancerLaserChargeBegin; + heatColor = Color.RED; + size = 3; + }}; + + eraser = new ItemTurret("eraser") {{ + ammoTypes = new AmmoType[]{AmmoTypes.bulletIron, AmmoTypes.bulletLead, AmmoTypes.bulletSteel, AmmoTypes.bulletThermite, AmmoTypes.bulletThorium, AmmoTypes.bulletSilicon}; + reload = 25f; + restitution = 0.03f; + ammoUseEffect = ShootFx.shellEjectSmall; + size = 4; + }}; + + meltdown = new PowerTurret("meltdown") {{ + shootType = AmmoTypes.meltdownLaser; + size = 4; + }}; + } } diff --git a/core/src/io/anuke/mindustry/content/bullets/ArtilleryBullets.java b/core/src/io/anuke/mindustry/content/bullets/ArtilleryBullets.java index ff21b1f2c3..4309f59f84 100644 --- a/core/src/io/anuke/mindustry/content/bullets/ArtilleryBullets.java +++ b/core/src/io/anuke/mindustry/content/bullets/ArtilleryBullets.java @@ -3,79 +3,84 @@ package io.anuke.mindustry.content.bullets; import io.anuke.mindustry.content.fx.BulletFx; import io.anuke.mindustry.entities.bullet.BasicBulletType; import io.anuke.mindustry.entities.bullet.BulletType; +import io.anuke.mindustry.type.ContentList; -public class ArtilleryBullets { - public static final BulletType +public class ArtilleryBullets implements ContentList{ + public static BulletType lead, thorium, plastic, homing, incindiary, surge; - lead = new BasicBulletType(3f, 0) { - { - hiteffect = BulletFx.flakExplosion; - knockback = 0.8f; - lifetime = 90f; - drag = 0.01f; - bulletWidth = bulletHeight = 9f; - bulletSprite = "frag"; - bulletShrink = 0.1f; - } - }, + @Override + public void load() { - thorium = new BasicBulletType(3f, 0) { - { - hiteffect = BulletFx.flakExplosion; - knockback = 0.8f; - lifetime = 90f; - drag = 0.01f; - bulletWidth = bulletHeight = 9f; - bulletSprite = "frag"; - bulletShrink = 0.1f; - } - }, + lead = new BasicBulletType(3f, 0) { + { + hiteffect = BulletFx.flakExplosion; + knockback = 0.8f; + lifetime = 90f; + drag = 0.01f; + bulletWidth = bulletHeight = 9f; + bulletSprite = "frag"; + bulletShrink = 0.1f; + } + }; - plastic = new BasicBulletType(3f, 0) { - { - hiteffect = BulletFx.flakExplosion; - knockback = 0.8f; - lifetime = 90f; - drag = 0.01f; - bulletWidth = bulletHeight = 9f; - bulletSprite = "frag"; - bulletShrink = 0.1f; - } - }, + thorium = new BasicBulletType(3f, 0) { + { + hiteffect = BulletFx.flakExplosion; + knockback = 0.8f; + lifetime = 90f; + drag = 0.01f; + bulletWidth = bulletHeight = 9f; + bulletSprite = "frag"; + bulletShrink = 0.1f; + } + }; - homing = new BasicBulletType(3f, 0) { - { - hiteffect = BulletFx.flakExplosion; - knockback = 0.8f; - lifetime = 90f; - drag = 0.01f; - bulletWidth = bulletHeight = 9f; - bulletSprite = "frag"; - bulletShrink = 0.1f; - } - }, + plastic = new BasicBulletType(3f, 0) { + { + hiteffect = BulletFx.flakExplosion; + knockback = 0.8f; + lifetime = 90f; + drag = 0.01f; + bulletWidth = bulletHeight = 9f; + bulletSprite = "frag"; + bulletShrink = 0.1f; + } + }; - incindiary = new BasicBulletType(3f, 0) { - { - hiteffect = BulletFx.flakExplosion; - knockback = 0.8f; - lifetime = 90f; - drag = 0.01f; - bulletWidth = bulletHeight = 9f; - bulletSprite = "frag"; - bulletShrink = 0.1f; - } - }, + homing = new BasicBulletType(3f, 0) { + { + hiteffect = BulletFx.flakExplosion; + knockback = 0.8f; + lifetime = 90f; + drag = 0.01f; + bulletWidth = bulletHeight = 9f; + bulletSprite = "frag"; + bulletShrink = 0.1f; + } + }; - surge = new BasicBulletType(3f, 0) { - { - hiteffect = BulletFx.flakExplosion; - knockback = 0.8f; - lifetime = 90f; - drag = 0.01f; - bulletWidth = bulletHeight = 9f; - bulletSprite = "frag"; - bulletShrink = 0.1f; - } - }; + incindiary = new BasicBulletType(3f, 0) { + { + hiteffect = BulletFx.flakExplosion; + knockback = 0.8f; + lifetime = 90f; + drag = 0.01f; + bulletWidth = bulletHeight = 9f; + bulletSprite = "frag"; + bulletShrink = 0.1f; + } + }; + + surge = new BasicBulletType(3f, 0) { + { + hiteffect = BulletFx.flakExplosion; + knockback = 0.8f; + lifetime = 90f; + drag = 0.01f; + bulletWidth = bulletHeight = 9f; + bulletSprite = "frag"; + bulletShrink = 0.1f; + } + }; + } } diff --git a/core/src/io/anuke/mindustry/content/bullets/FlakBullets.java b/core/src/io/anuke/mindustry/content/bullets/FlakBullets.java index caecaf1388..b151fd75f8 100644 --- a/core/src/io/anuke/mindustry/content/bullets/FlakBullets.java +++ b/core/src/io/anuke/mindustry/content/bullets/FlakBullets.java @@ -2,35 +2,40 @@ package io.anuke.mindustry.content.bullets; import io.anuke.mindustry.entities.bullet.BasicBulletType; import io.anuke.mindustry.entities.bullet.BulletType; +import io.anuke.mindustry.type.ContentList; -public class FlakBullets { - public static final BulletType +public class FlakBullets implements ContentList { + public static BulletType lead, plastic, explosive, surge; - lead = new BasicBulletType(3f, 5) { - { - bulletWidth = 7f; - bulletHeight = 9f; - } - }, + @Override + public void load() { - plastic = new BasicBulletType(3f, 5) { - { - bulletWidth = 7f; - bulletHeight = 9f; - } - }, + lead = new BasicBulletType(3f, 5) { + { + bulletWidth = 7f; + bulletHeight = 9f; + } + }; - explosive = new BasicBulletType(3f, 5) { - { - bulletWidth = 7f; - bulletHeight = 9f; - } - }, + plastic = new BasicBulletType(3f, 5) { + { + bulletWidth = 7f; + bulletHeight = 9f; + } + }; - surge = new BasicBulletType(3f, 5) { - { - bulletWidth = 7f; - bulletHeight = 9f; - } - }; + explosive = new BasicBulletType(3f, 5) { + { + bulletWidth = 7f; + bulletHeight = 9f; + } + }; + + surge = new BasicBulletType(3f, 5) { + { + bulletWidth = 7f; + bulletHeight = 9f; + } + }; + } } diff --git a/core/src/io/anuke/mindustry/content/bullets/MissileBullets.java b/core/src/io/anuke/mindustry/content/bullets/MissileBullets.java index 1e76cc0997..aa86e87c37 100644 --- a/core/src/io/anuke/mindustry/content/bullets/MissileBullets.java +++ b/core/src/io/anuke/mindustry/content/bullets/MissileBullets.java @@ -2,28 +2,33 @@ package io.anuke.mindustry.content.bullets; import io.anuke.mindustry.entities.bullet.BasicBulletType; import io.anuke.mindustry.entities.bullet.BulletType; +import io.anuke.mindustry.type.ContentList; -public class MissileBullets { - public static final BulletType +public class MissileBullets implements ContentList { + public static BulletType explosive, incindiary, surge; - explosive = new BasicBulletType(3f, 5) { - { - bulletWidth = 7f; - bulletHeight = 9f; - } - }, + @Override + public void load() { - incindiary = new BasicBulletType(3f, 5) { - { - bulletWidth = 7f; - bulletHeight = 9f; - } - }, + explosive = new BasicBulletType(3f, 5) { + { + bulletWidth = 7f; + bulletHeight = 9f; + } + }; - surge = new BasicBulletType(3f, 5) { - { - bulletWidth = 7f; - bulletHeight = 9f; - } - }; + incindiary = new BasicBulletType(3f, 5) { + { + bulletWidth = 7f; + bulletHeight = 9f; + } + }; + + surge = new BasicBulletType(3f, 5) { + { + bulletWidth = 7f; + bulletHeight = 9f; + } + }; + } } diff --git a/core/src/io/anuke/mindustry/content/bullets/ShellBullets.java b/core/src/io/anuke/mindustry/content/bullets/ShellBullets.java index 474b0f3973..a93c2e1fd0 100644 --- a/core/src/io/anuke/mindustry/content/bullets/ShellBullets.java +++ b/core/src/io/anuke/mindustry/content/bullets/ShellBullets.java @@ -4,124 +4,129 @@ import io.anuke.mindustry.content.fx.BulletFx; import io.anuke.mindustry.content.fx.Fx; import io.anuke.mindustry.entities.bullet.BasicBulletType; import io.anuke.mindustry.entities.bullet.BulletType; +import io.anuke.mindustry.type.ContentList; -public class ShellBullets { - public static final BulletType +public class ShellBullets implements ContentList { + public static BulletType lead, leadShard, thorium, thoriumShard, plastic, plasticShard, explosive, explosiveShard, incindiary; - lead = new BasicBulletType(3f, 0) { - { - hiteffect = BulletFx.flakExplosion; - knockback = 0.8f; - lifetime = 90f; - drag = 0.01f; - bulletWidth = bulletHeight = 9f; - fragBullet = leadShard; - bulletSprite = "frag"; - bulletShrink = 0.1f; - } - }, + @Override + public void load() { - leadShard = new BasicBulletType(3f, 0) { - { - drag = 0.1f; - hiteffect = Fx.none; - despawneffect = Fx.none; - hitsize = 4; - lifetime = 20f; - bulletWidth = 9f; - bulletHeight = 11f; - bulletShrink = 1f; - } - }, + lead = new BasicBulletType(3f, 0) { + { + hiteffect = BulletFx.flakExplosion; + knockback = 0.8f; + lifetime = 90f; + drag = 0.01f; + bulletWidth = bulletHeight = 9f; + fragBullet = leadShard; + bulletSprite = "frag"; + bulletShrink = 0.1f; + } + }; - thorium = new BasicBulletType(3f, 0) { - { - hiteffect = BulletFx.flakExplosion; - knockback = 0.8f; - lifetime = 90f; - drag = 0.01f; - bulletWidth = bulletHeight = 9f; - fragBullet = leadShard; - bulletSprite = "frag"; - bulletShrink = 0.1f; - } - }, + leadShard = new BasicBulletType(3f, 0) { + { + drag = 0.1f; + hiteffect = Fx.none; + despawneffect = Fx.none; + hitsize = 4; + lifetime = 20f; + bulletWidth = 9f; + bulletHeight = 11f; + bulletShrink = 1f; + } + }; - thoriumShard = new BasicBulletType(3f, 0) { - { - drag = 0.1f; - hiteffect = Fx.none; - despawneffect = Fx.none; - hitsize = 4; - lifetime = 20f; - bulletWidth = 9f; - bulletHeight = 11f; - bulletShrink = 1f; - } - }, + thorium = new BasicBulletType(3f, 0) { + { + hiteffect = BulletFx.flakExplosion; + knockback = 0.8f; + lifetime = 90f; + drag = 0.01f; + bulletWidth = bulletHeight = 9f; + fragBullet = leadShard; + bulletSprite = "frag"; + bulletShrink = 0.1f; + } + }; - plastic = new BasicBulletType(3f, 0) { - { - hiteffect = BulletFx.flakExplosion; - knockback = 0.8f; - lifetime = 90f; - drag = 0.01f; - bulletWidth = bulletHeight = 9f; - fragBullet = leadShard; - bulletSprite = "frag"; - bulletShrink = 0.1f; - } - }, + thoriumShard = new BasicBulletType(3f, 0) { + { + drag = 0.1f; + hiteffect = Fx.none; + despawneffect = Fx.none; + hitsize = 4; + lifetime = 20f; + bulletWidth = 9f; + bulletHeight = 11f; + bulletShrink = 1f; + } + }; - plasticShard = new BasicBulletType(3f, 0) { - { - drag = 0.1f; - hiteffect = Fx.none; - despawneffect = Fx.none; - hitsize = 4; - lifetime = 20f; - bulletWidth = 9f; - bulletHeight = 11f; - bulletShrink = 1f; - } - }, + plastic = new BasicBulletType(3f, 0) { + { + hiteffect = BulletFx.flakExplosion; + knockback = 0.8f; + lifetime = 90f; + drag = 0.01f; + bulletWidth = bulletHeight = 9f; + fragBullet = leadShard; + bulletSprite = "frag"; + bulletShrink = 0.1f; + } + }; - explosive = new BasicBulletType(3f, 0) { - { - hiteffect = BulletFx.flakExplosion; - knockback = 0.8f; - lifetime = 90f; - drag = 0.01f; - bulletWidth = bulletHeight = 9f; - fragBullet = leadShard; - bulletSprite = "frag"; - bulletShrink = 0.1f; - } - }, + plasticShard = new BasicBulletType(3f, 0) { + { + drag = 0.1f; + hiteffect = Fx.none; + despawneffect = Fx.none; + hitsize = 4; + lifetime = 20f; + bulletWidth = 9f; + bulletHeight = 11f; + bulletShrink = 1f; + } + }; - explosiveShard = new BasicBulletType(3f, 0) { - { - drag = 0.1f; - hiteffect = Fx.none; - despawneffect = Fx.none; - hitsize = 4; - lifetime = 20f; - bulletWidth = 9f; - bulletHeight = 11f; - bulletShrink = 1f; - } - }, + explosive = new BasicBulletType(3f, 0) { + { + hiteffect = BulletFx.flakExplosion; + knockback = 0.8f; + lifetime = 90f; + drag = 0.01f; + bulletWidth = bulletHeight = 9f; + fragBullet = leadShard; + bulletSprite = "frag"; + bulletShrink = 0.1f; + } + }; - incindiary = new BasicBulletType(3f, 0) { - { - hiteffect = BulletFx.flakExplosion; - knockback = 0.8f; - lifetime = 90f; - drag = 0.01f; - bulletWidth = bulletHeight = 9f; - fragBullet = leadShard; - bulletSprite = "frag"; - bulletShrink = 0.1f; - } - }; + explosiveShard = new BasicBulletType(3f, 0) { + { + drag = 0.1f; + hiteffect = Fx.none; + despawneffect = Fx.none; + hitsize = 4; + lifetime = 20f; + bulletWidth = 9f; + bulletHeight = 11f; + bulletShrink = 1f; + } + }; + + incindiary = new BasicBulletType(3f, 0) { + { + hiteffect = BulletFx.flakExplosion; + knockback = 0.8f; + lifetime = 90f; + drag = 0.01f; + bulletWidth = bulletHeight = 9f; + fragBullet = leadShard; + bulletSprite = "frag"; + bulletShrink = 0.1f; + } + }; + } } diff --git a/core/src/io/anuke/mindustry/content/bullets/StandardBullets.java b/core/src/io/anuke/mindustry/content/bullets/StandardBullets.java index a1d8019b56..d0a9dd2e7e 100644 --- a/core/src/io/anuke/mindustry/content/bullets/StandardBullets.java +++ b/core/src/io/anuke/mindustry/content/bullets/StandardBullets.java @@ -2,49 +2,54 @@ package io.anuke.mindustry.content.bullets; import io.anuke.mindustry.entities.bullet.BasicBulletType; import io.anuke.mindustry.entities.bullet.BulletType; +import io.anuke.mindustry.type.ContentList; -public class StandardBullets { - public static final BulletType +public class StandardBullets implements ContentList { + public static BulletType iron, lead, steel, thorium, homing, tracer; - iron = new BasicBulletType(3f, 5) { - { - bulletWidth = 7f; - bulletHeight = 9f; - } - }, + @Override + public void load() { - lead = new BasicBulletType(3f, 5) { - { - bulletWidth = 7f; - bulletHeight = 9f; - } - }, + iron = new BasicBulletType(3f, 5) { + { + bulletWidth = 7f; + bulletHeight = 9f; + } + }; - steel = new BasicBulletType(3f, 5) { - { - bulletWidth = 7f; - bulletHeight = 9f; - } - }, + lead = new BasicBulletType(3f, 5) { + { + bulletWidth = 7f; + bulletHeight = 9f; + } + }; - thorium = new BasicBulletType(3f, 5) { - { - bulletWidth = 7f; - bulletHeight = 9f; - } - }, + steel = new BasicBulletType(3f, 5) { + { + bulletWidth = 7f; + bulletHeight = 9f; + } + }; - homing = new BasicBulletType(3f, 5) { - { - bulletWidth = 7f; - bulletHeight = 9f; - } - }, + thorium = new BasicBulletType(3f, 5) { + { + bulletWidth = 7f; + bulletHeight = 9f; + } + }; - tracer = new BasicBulletType(3f, 5) { - { - bulletWidth = 7f; - bulletHeight = 9f; - } - }; + homing = new BasicBulletType(3f, 5) { + { + bulletWidth = 7f; + bulletHeight = 9f; + } + }; + + tracer = new BasicBulletType(3f, 5) { + { + bulletWidth = 7f; + bulletHeight = 9f; + } + }; + } } diff --git a/core/src/io/anuke/mindustry/content/bullets/TurretBullets.java b/core/src/io/anuke/mindustry/content/bullets/TurretBullets.java index 4dbfb29e57..d5e3a94bb5 100644 --- a/core/src/io/anuke/mindustry/content/bullets/TurretBullets.java +++ b/core/src/io/anuke/mindustry/content/bullets/TurretBullets.java @@ -13,6 +13,7 @@ import io.anuke.mindustry.entities.effect.DamageArea; import io.anuke.mindustry.entities.effect.Fire; import io.anuke.mindustry.entities.effect.Lightning; import io.anuke.mindustry.graphics.Palette; +import io.anuke.mindustry.type.ContentList; import io.anuke.mindustry.world.Tile; import io.anuke.ucore.core.Effects; import io.anuke.ucore.core.Timers; @@ -23,147 +24,152 @@ import io.anuke.ucore.util.Mathf; import static io.anuke.mindustry.Vars.world; -public class TurretBullets { +public class TurretBullets implements ContentList { + public static BulletType fireball, basicFlame, lancerLaser, fuseShot, waterShot, cryoShot, lavaShot, oilShot, lightning; - public static final BulletType + @Override + public void load() { - fireball = new BulletType(1f, 1) { - { - pierce = true; - hitTiles = false; - drag = 0.3f; - } + fireball = new BulletType(1f, 1) { + { + pierce = true; + hitTiles = false; + drag = 0.3f; + } - @Override - public void init(Bullet b) { - b.velocity.setLength(0.6f + Mathf.random(2f)); - } + @Override + public void init(Bullet b) { + b.velocity.setLength(0.6f + Mathf.random(2f)); + } - @Override - public void draw(Bullet b) { - //TODO add color to the bullet depending on the color of the flame it came from - Draw.color(Palette.lightFlame, Palette.darkFlame, Color.GRAY, b.fin()); - Fill.circle(b.x, b.y, 3f * b.fout()); - Draw.reset(); - } + @Override + public void draw(Bullet b) { + //TODO add color to the bullet depending on the color of the flame it came from + Draw.color(Palette.lightFlame, Palette.darkFlame, Color.GRAY, b.fin()); + Fill.circle(b.x, b.y, 3f * b.fout()); + Draw.reset(); + } - @Override - public void update(Bullet b) { - if(Mathf.chance(0.04 * Timers.delta())){ - Tile tile = world.tileWorld(b.x, b.y); - if(tile != null){ - Fire.create(tile); + @Override + public void update(Bullet b) { + if (Mathf.chance(0.04 * Timers.delta())) { + Tile tile = world.tileWorld(b.x, b.y); + if (tile != null) { + Fire.create(tile); + } + } + + if (Mathf.chance(0.1 * Timers.delta())) { + Effects.effect(EnvironmentFx.fireballsmoke, b.x, b.y); + } + + if (Mathf.chance(0.1 * Timers.delta())) { + Effects.effect(EnvironmentFx.ballfire, b.x, b.y); } } + }; - if(Mathf.chance(0.1 * Timers.delta())){ - Effects.effect(EnvironmentFx.fireballsmoke, b.x, b.y); + basicFlame = new BulletType(2f, 0) { + { + hitsize = 7f; + lifetime = 30f; + pierce = true; + drag = 0.07f; + hiteffect = BulletFx.hitFlameSmall; + despawneffect = Fx.none; + status = StatusEffects.burning; } - if(Mathf.chance(0.1 * Timers.delta())){ - Effects.effect(EnvironmentFx.ballfire, b.x, b.y); + @Override + public void draw(Bullet b) { } - } - }, + }; - basicFlame = new BulletType(2f, 0) { - { - hitsize = 7f; - lifetime = 30f; - pierce = true; - drag = 0.07f; - hiteffect = BulletFx.hitFlameSmall; - despawneffect = Fx.none; - status = StatusEffects.burning; - } + lancerLaser = new BulletType(0.001f, 1) { + Color[] colors = {Palette.lancerLaser.cpy().mul(1f, 1f, 1f, 0.4f), Palette.lancerLaser, Color.WHITE}; + float[] tscales = {1f, 0.7f, 0.5f, 0.2f}; + float[] lenscales = {1f, 1.1f, 1.13f, 1.14f}; + float length = 70f; - @Override - public void draw(Bullet b) {} - }, + { + hiteffect = BulletFx.hitLancer; + despawneffect = Fx.none; + hitsize = 4; + lifetime = 16f; + pierce = true; + } - lancerLaser = new BulletType(0.001f, 1) { - Color[] colors = {Palette.lancerLaser.cpy().mul(1f, 1f, 1f, 0.4f), Palette.lancerLaser, Color.WHITE}; - float[] tscales = {1f, 0.7f, 0.5f, 0.2f}; - float[] lenscales = {1f, 1.1f, 1.13f, 1.14f}; - float length = 70f; + @Override + public void init(Bullet b) { + DamageArea.collideLine(b, b.team, hiteffect, b.x, b.y, b.angle(), length); + } - { - hiteffect = BulletFx.hitLancer; - despawneffect = Fx.none; - hitsize = 4; - lifetime = 16f; - pierce = true; - } + @Override + public void draw(Bullet b) { + float f = Mathf.curve(b.fin(), 0f, 0.2f); + float baseLen = length * f; - @Override - public void init(Bullet b) { - DamageArea.collideLine(b, b.team, hiteffect, b.x, b.y, b.angle(), length); - } - - @Override - public void draw(Bullet b) { - float f = Mathf.curve(b.fin(), 0f, 0.2f); - float baseLen = length * f; - - Lines.lineAngle(b.x, b.y, b.angle(), baseLen); - for(int s = 0; s < 3; s ++) { - Draw.color(colors[s]); - for (int i = 0; i < tscales.length; i++) { - Lines.stroke(7f * b.fout() * (s == 0 ? 1.5f : s == 1 ? 1f : 0.3f) * tscales[i]); - Lines.lineAngle(b.x, b.y, b.angle(), baseLen * lenscales[i]); + Lines.lineAngle(b.x, b.y, b.angle(), baseLen); + for (int s = 0; s < 3; s++) { + Draw.color(colors[s]); + for (int i = 0; i < tscales.length; i++) { + Lines.stroke(7f * b.fout() * (s == 0 ? 1.5f : s == 1 ? 1f : 0.3f) * tscales[i]); + Lines.lineAngle(b.x, b.y, b.angle(), baseLen * lenscales[i]); + } } + Draw.reset(); } - Draw.reset(); - } - }, + }; - fuseShot = new BulletType(0.01f, 100) { - //TODO - }, + fuseShot = new BulletType(0.01f, 100) { + //TODO + }; - waterShot = new LiquidBulletType(Liquids.water) { - { - status = StatusEffects.wet; - statusIntensity = 0.5f; - knockback = 0.65f; - } - }, - cryoShot = new LiquidBulletType(Liquids.cryofluid) { - { - status = StatusEffects.freezing; - statusIntensity = 0.5f; - } - }, - lavaShot = new LiquidBulletType(Liquids.lava) { - { - damage = 4; - speed = 1.9f; - drag = 0.03f; - status = StatusEffects.melting; - statusIntensity = 0.5f; - } - }, - oilShot = new LiquidBulletType(Liquids.oil) { - { - speed = 2f; - drag = 0.03f; - status = StatusEffects.oiled; - statusIntensity = 0.5f; - } - }, - lightning = new BulletType(0.001f, 5) { - { - lifetime = 1; - despawneffect = Fx.none; - hiteffect = BulletFx.hitLancer; - } + waterShot = new LiquidBulletType(Liquids.water) { + { + status = StatusEffects.wet; + statusIntensity = 0.5f; + knockback = 0.65f; + } + }; + cryoShot = new LiquidBulletType(Liquids.cryofluid) { + { + status = StatusEffects.freezing; + statusIntensity = 0.5f; + } + }; + lavaShot = new LiquidBulletType(Liquids.lava) { + { + damage = 4; + speed = 1.9f; + drag = 0.03f; + status = StatusEffects.melting; + statusIntensity = 0.5f; + } + }; + oilShot = new LiquidBulletType(Liquids.oil) { + { + speed = 2f; + drag = 0.03f; + status = StatusEffects.oiled; + statusIntensity = 0.5f; + } + }; + lightning = new BulletType(0.001f, 5) { + { + lifetime = 1; + despawneffect = Fx.none; + hiteffect = BulletFx.hitLancer; + } - @Override - public void draw(Bullet b) {} + @Override + public void draw(Bullet b) { + } - @Override - public void init(Bullet b) { - Lightning.create(b.team, hiteffect, Palette.lancerLaser, damage, b.x, b.y, b.angle(), 30); - } - }; + @Override + public void init(Bullet b) { + Lightning.create(b.team, hiteffect, Palette.lancerLaser, damage, b.x, b.y, b.angle(), 30); + } + }; + } } diff --git a/core/src/io/anuke/mindustry/content/fx/BlockFx.java b/core/src/io/anuke/mindustry/content/fx/BlockFx.java index c540365659..40d6019086 100644 --- a/core/src/io/anuke/mindustry/content/fx/BlockFx.java +++ b/core/src/io/anuke/mindustry/content/fx/BlockFx.java @@ -3,6 +3,7 @@ package io.anuke.mindustry.content.fx; import com.badlogic.gdx.graphics.Color; import io.anuke.mindustry.entities.effect.GroundEffectEntity.GroundEffect; import io.anuke.mindustry.graphics.Palette; +import io.anuke.mindustry.type.ContentList; import io.anuke.ucore.core.Effects.Effect; import io.anuke.ucore.graphics.Draw; import io.anuke.ucore.graphics.Fill; @@ -14,260 +15,264 @@ import io.anuke.ucore.util.Tmp; import static io.anuke.mindustry.Vars.tilesize; -public class BlockFx { - public static final Effect +public class BlockFx implements ContentList{ + public static Effect reactorsmoke, nuclearsmoke, nuclearcloud, redgeneratespark, generatespark, fuelburn, plasticburn, pulverize, pulverizeRed, pulverizeRedder, pulverizeSmall, pulverizeMedium, producesmoke, smeltsmoke, formsmoke, blastsmoke, lava, dooropen, doorclose, dooropenlarge, doorcloselarge, purify, purifyoil, purifystone, generate, mine, mineBig, mineHuge, smelt, teleportActivate, teleport, teleportOut, ripple, bubble; - reactorsmoke = new Effect(17, e -> { - Angles.randLenVectors(e.id, 4, e.fin()*8f, (x, y)->{ - float size = 1f+e.fout()*5f; - Draw.color(Color.LIGHT_GRAY, Color.GRAY, e.fin()); - Draw.rect("circle", e.x + x, e.y + y, size, size); + @Override + public void load() { + + reactorsmoke = new Effect(17, e -> { + Angles.randLenVectors(e.id, 4, e.fin() * 8f, (x, y) -> { + float size = 1f + e.fout() * 5f; + Draw.color(Color.LIGHT_GRAY, Color.GRAY, e.fin()); + Draw.rect("circle", e.x + x, e.y + y, size, size); + Draw.reset(); + }); + }); + nuclearsmoke = new Effect(40, e -> { + Angles.randLenVectors(e.id, 4, e.fin() * 13f, (x, y) -> { + float size = e.fslope() * 4f; + Draw.color(Color.LIGHT_GRAY, Color.GRAY, e.fin()); + Draw.rect("circle", e.x + x, e.y + y, size, size); + Draw.reset(); + }); + }); + nuclearcloud = new Effect(90, 200f, e -> { + Angles.randLenVectors(e.id, 10, e.finpow() * 90f, (x, y) -> { + float size = e.fout() * 14f; + Draw.color(Color.LIME, Color.GRAY, e.fin()); + Draw.rect("circle", e.x + x, e.y + y, size, size); + Draw.reset(); + }); + }); + redgeneratespark = new Effect(18, e -> { + Angles.randLenVectors(e.id, 5, e.fin() * 8f, (x, y) -> { + float len = e.fout() * 4f; + Draw.color(Color.valueOf("fbb97f"), Color.GRAY, e.fin()); + //Draw.alpha(e.fout()); + Draw.rect("circle", e.x + x, e.y + y, len, len); + Draw.reset(); + }); + }); + generatespark = new Effect(18, e -> { + Angles.randLenVectors(e.id, 5, e.fin() * 8f, (x, y) -> { + float len = e.fout() * 4f; + Draw.color(Color.valueOf("d2b29c"), Color.GRAY, e.fin()); + Draw.rect("circle", e.x + x, e.y + y, len, len); + Draw.reset(); + }); + }); + fuelburn = new Effect(23, e -> { + Angles.randLenVectors(e.id, 5, e.fin() * 9f, (x, y) -> { + float len = e.fout() * 4f; + Draw.color(Color.LIGHT_GRAY, Color.GRAY, e.fin()); + Draw.rect("circle", e.x + x, e.y + y, len, len); + Draw.reset(); + }); + }); + plasticburn = new Effect(40, e -> { + Angles.randLenVectors(e.id, 5, 3f + e.fin() * 5f, (x, y) -> { + Draw.color(Color.valueOf("e9ead3"), Color.GRAY, e.fin()); + Fill.circle(e.x + x, e.y + y, e.fout() * 1f); + Draw.reset(); + }); + }); + pulverize = new Effect(40, e -> { + Angles.randLenVectors(e.id, 5, 3f + e.fin() * 8f, (x, y) -> { + Draw.color(Palette.stoneGray); + Fill.poly(e.x + x, e.y + y, 4, e.fout() * 2f + 0.5f, 45); + Draw.reset(); + }); + }); + pulverizeRed = new Effect(40, e -> { + Angles.randLenVectors(e.id, 5, 3f + e.fin() * 8f, (x, y) -> { + Draw.color(Color.valueOf("ffa480"), Palette.stoneGray, e.fin()); + Fill.poly(e.x + x, e.y + y, 4, e.fout() * 2f + 0.5f, 45); + Draw.reset(); + }); + }); + pulverizeRedder = new Effect(40, e -> { + Angles.randLenVectors(e.id, 5, 3f + e.fin() * 9f, (x, y) -> { + Draw.color(Color.valueOf("ff7b69"), Palette.stoneGray, e.fin()); + Fill.poly(e.x + x, e.y + y, 4, e.fout() * 2.5f + 0.5f, 45); + Draw.reset(); + }); + }); + pulverizeSmall = new Effect(30, e -> { + Angles.randLenVectors(e.id, 3, e.fin() * 5f, (x, y) -> { + Draw.color(Palette.stoneGray); + Fill.poly(e.x + x, e.y + y, 4, e.fout() * 1f + 0.5f, 45); + Draw.reset(); + }); + }); + pulverizeMedium = new Effect(30, e -> { + Angles.randLenVectors(e.id, 5, 3f + e.fin() * 8f, (x, y) -> { + Draw.color(Palette.stoneGray); + Fill.poly(e.x + x, e.y + y, 4, e.fout() * 1f + 0.5f, 45); + Draw.reset(); + }); + }); + producesmoke = new Effect(12, e -> { + Angles.randLenVectors(e.id, 8, 4f + e.fin() * 18f, (x, y) -> { + Draw.color(Color.WHITE, Palette.accent, e.fin()); + Fill.poly(e.x + x, e.y + y, 4, 1f + e.fout() * 3f, 45); + Draw.reset(); + }); + }); + smeltsmoke = new Effect(15, e -> { + Angles.randLenVectors(e.id, 6, 4f + e.fin() * 5f, (x, y) -> { + Draw.color(Color.WHITE, e.color, e.fin()); + Fill.poly(e.x + x, e.y + y, 4, 0.5f + e.fout() * 2f, 45); + Draw.reset(); + }); + }); + formsmoke = new Effect(40, e -> { + Angles.randLenVectors(e.id, 6, 5f + e.fin() * 8f, (x, y) -> { + Draw.color(Color.valueOf("f1e479"), Color.LIGHT_GRAY, e.fin()); + Fill.poly(e.x + x, e.y + y, 4, 0.2f + e.fout() * 2f, 45); + Draw.reset(); + }); + }); + blastsmoke = new Effect(26, e -> { + Angles.randLenVectors(e.id, 12, 1f + e.fin() * 23f, (x, y) -> { + float size = 2f + e.fout() * 6f; + Draw.color(Color.LIGHT_GRAY, Color.DARK_GRAY, e.fin()); + Draw.rect("circle", e.x + x, e.y + y, size, size); + Draw.reset(); + }); + }); + lava = new Effect(18, e -> { + Angles.randLenVectors(e.id, 3, 1f + e.fin() * 10f, (x, y) -> { + float size = e.fslope() * 4f; + Draw.color(Color.ORANGE, Color.GRAY, e.fin()); + Draw.rect("circle", e.x + x, e.y + y, size, size); + Draw.reset(); + }); + }); + dooropen = new Effect(10, e -> { + Lines.stroke(e.fout() * 1.6f); + Lines.square(e.x, e.y, tilesize / 2f + e.fin() * 2f); Draw.reset(); }); - }), - nuclearsmoke = new Effect(40, e -> { - Angles.randLenVectors(e.id, 4, e.fin()*13f, (x, y)->{ - float size = e.fslope()*4f; - Draw.color(Color.LIGHT_GRAY, Color.GRAY, e.fin()); - Draw.rect("circle", e.x + x, e.y + y, size, size); + doorclose = new Effect(10, e -> { + Lines.stroke(e.fout() * 1.6f); + Lines.square(e.x, e.y, tilesize / 2f + e.fout() * 2f); Draw.reset(); }); - }), - nuclearcloud = new Effect(90, 200f, e -> { - Angles.randLenVectors(e.id, 10, e.finpow()*90f, (x, y)->{ - float size = e.fout()*14f; - Draw.color(Color.LIME, Color.GRAY, e.fin()); - Draw.rect("circle", e.x + x, e.y + y, size, size); + dooropenlarge = new Effect(10, e -> { + Lines.stroke(e.fout() * 1.6f); + Lines.square(e.x, e.y, tilesize + e.fin() * 2f); Draw.reset(); }); - }), - redgeneratespark = new Effect(18, e -> { - Angles.randLenVectors(e.id, 5, e.fin()*8f, (x, y)->{ - float len = e.fout()*4f; - Draw.color(Color.valueOf("fbb97f"), Color.GRAY, e.fin()); - //Draw.alpha(e.fout()); - Draw.rect("circle", e.x + x, e.y + y, len, len); + doorcloselarge = new Effect(10, e -> { + Lines.stroke(e.fout() * 1.6f); + Lines.square(e.x, e.y, tilesize + e.fout() * 2f); Draw.reset(); }); - }), - generatespark = new Effect(18, e -> { - Angles.randLenVectors(e.id, 5, e.fin()*8f, (x, y)->{ - float len = e.fout()*4f; - Draw.color(Color.valueOf("d2b29c"), Color.GRAY, e.fin()); - Draw.rect("circle", e.x + x, e.y + y, len, len); + purify = new Effect(10, e -> { + Draw.color(Color.ROYAL, Color.GRAY, e.fin()); + Lines.stroke(2f); + Lines.spikes(e.x, e.y, e.fin() * 4f, 2, 6); Draw.reset(); }); - }), - fuelburn = new Effect(23, e -> { - Angles.randLenVectors(e.id, 5, e.fin()*9f, (x, y)->{ - float len = e.fout()*4f; - Draw.color(Color.LIGHT_GRAY, Color.GRAY, e.fin()); - Draw.rect("circle", e.x + x, e.y + y, len, len); + purifyoil = new Effect(10, e -> { + Draw.color(Color.BLACK, Color.GRAY, e.fin()); + Lines.stroke(2f); + Lines.spikes(e.x, e.y, e.fin() * 4f, 2, 6); Draw.reset(); }); - }), - plasticburn = new Effect(40, e -> { - Angles.randLenVectors(e.id, 5, 3f + e.fin()*5f, (x, y)->{ - Draw.color(Color.valueOf("e9ead3"), Color.GRAY, e.fin()); - Fill.circle(e.x + x, e.y + y, e.fout()*1f); - Draw.reset(); - }); - }), - pulverize = new Effect(40, e -> { - Angles.randLenVectors(e.id, 5, 3f + e.fin()*8f, (x, y)->{ - Draw.color(Palette.stoneGray); - Fill.poly(e.x + x, e.y + y, 4, e.fout() * 2f + 0.5f, 45); - Draw.reset(); - }); - }), - pulverizeRed = new Effect(40, e -> { - Angles.randLenVectors(e.id, 5, 3f + e.fin()*8f, (x, y)->{ - Draw.color(Color.valueOf("ffa480"), Palette.stoneGray, e.fin()); - Fill.poly(e.x + x, e.y + y, 4, e.fout() * 2f + 0.5f, 45); - Draw.reset(); - }); - }), - pulverizeRedder = new Effect(40, e -> { - Angles.randLenVectors(e.id, 5, 3f + e.fin()*9f, (x, y)->{ - Draw.color(Color.valueOf("ff7b69"), Palette.stoneGray, e.fin()); - Fill.poly(e.x + x, e.y + y, 4, e.fout() * 2.5f + 0.5f, 45); - Draw.reset(); - }); - }), - pulverizeSmall = new Effect(30, e -> { - Angles.randLenVectors(e.id, 3, e.fin()*5f, (x, y)->{ - Draw.color(Palette.stoneGray); - Fill.poly(e.x + x, e.y + y, 4, e.fout() * 1f + 0.5f, 45); - Draw.reset(); - }); - }), - pulverizeMedium = new Effect(30, e -> { - Angles.randLenVectors(e.id, 5, 3f + e.fin()*8f, (x, y)->{ - Draw.color(Palette.stoneGray); - Fill.poly(e.x + x, e.y + y, 4, e.fout() * 1f + 0.5f, 45); - Draw.reset(); - }); - }), - producesmoke = new Effect(12, e -> { - Angles.randLenVectors(e.id, 8, 4f + e.fin()*18f, (x, y)->{ - Draw.color(Color.WHITE, Palette.accent, e.fin()); - Fill.poly(e.x + x, e.y + y, 4, 1f+e.fout()*3f, 45); - Draw.reset(); - }); - }), - smeltsmoke = new Effect(15, e -> { - Angles.randLenVectors(e.id, 6, 4f + e.fin()*5f, (x, y)->{ - Draw.color(Color.WHITE, e.color, e.fin()); - Fill.poly(e.x + x, e.y + y, 4, 0.5f+e.fout()*2f, 45); - Draw.reset(); - }); - }), - formsmoke = new Effect(40, e -> { - Angles.randLenVectors(e.id, 6, 5f + e.fin()*8f, (x, y)->{ - Draw.color(Color.valueOf("f1e479"), Color.LIGHT_GRAY, e.fin()); - Fill.poly(e.x + x, e.y + y, 4, 0.2f+e.fout()*2f, 45); - Draw.reset(); - }); - }), - blastsmoke = new Effect(26, e -> { - Angles.randLenVectors(e.id, 12, 1f + e.fin()*23f, (x, y)->{ - float size = 2f+e.fout()*6f; - Draw.color(Color.LIGHT_GRAY, Color.DARK_GRAY, e.fin()); - Draw.rect("circle", e.x + x, e.y + y, size, size); - Draw.reset(); - }); - }), - lava = new Effect(18, e -> { - Angles.randLenVectors(e.id, 3, 1f + e.fin()*10f, (x, y)->{ - float size = e.fslope()*4f; + purifystone = new Effect(10, e -> { Draw.color(Color.ORANGE, Color.GRAY, e.fin()); - Draw.rect("circle", e.x + x, e.y + y, size, size); + Lines.stroke(2f); + Lines.spikes(e.x, e.y, e.fin() * 4f, 2, 6); Draw.reset(); }); - }), - dooropen = new Effect(10, e -> { - Lines.stroke(e.fout() * 1.6f); - Lines.square(e.x, e.y, tilesize / 2f + e.fin() * 2f); - Draw.reset(); - }), - doorclose= new Effect(10, e -> { - Lines.stroke(e.fout() * 1.6f); - Lines.square(e.x, e.y, tilesize / 2f + e.fout() * 2f); - Draw.reset(); - }), - dooropenlarge = new Effect(10, e -> { - Lines.stroke(e.fout() * 1.6f); - Lines.square(e.x, e.y, tilesize + e.fin() * 2f); - Draw.reset(); - }), - doorcloselarge = new Effect(10, e -> { - Lines.stroke(e.fout() * 1.6f); - Lines.square(e.x, e.y, tilesize + e.fout() * 2f); - Draw.reset(); - }), - purify = new Effect(10, e -> { - Draw.color(Color.ROYAL, Color.GRAY, e.fin()); - Lines.stroke(2f); - Lines.spikes(e.x, e.y, e.fin() * 4f, 2, 6); - Draw.reset(); - }), - purifyoil = new Effect(10, e -> { - Draw.color(Color.BLACK, Color.GRAY, e.fin()); - Lines.stroke(2f); - Lines.spikes(e.x, e.y, e.fin() * 4f, 2, 6); - Draw.reset(); - }), - purifystone = new Effect(10, e -> { - Draw.color(Color.ORANGE, Color.GRAY, e.fin()); - Lines.stroke(2f); - Lines.spikes(e.x, e.y, e.fin() * 4f, 2, 6); - Draw.reset(); - }), - generate = new Effect(11, e -> { - Draw.color(Color.ORANGE, Color.YELLOW, e.fin()); - Lines.stroke(1f); - Lines.spikes(e.x, e.y, e.fin() * 5f, 2, 8); - Draw.reset(); - }), - mine = new Effect(20, e -> { - Angles.randLenVectors(e.id, 6, 3f + e.fin()*6f, (x, y)->{ - Draw.color(e.color, Color.LIGHT_GRAY, e.fin()); - Fill.poly(e.x + x, e.y + y, 4, e.fout() * 2f, 45); + generate = new Effect(11, e -> { + Draw.color(Color.ORANGE, Color.YELLOW, e.fin()); + Lines.stroke(1f); + Lines.spikes(e.x, e.y, e.fin() * 5f, 2, 8); Draw.reset(); }); - }), - mineBig = new Effect(30, e -> { - Angles.randLenVectors(e.id, 6, 4f + e.fin()*8f, (x, y)->{ - Draw.color(e.color, Color.LIGHT_GRAY, e.fin()); - Fill.poly(e.x + x, e.y + y, 4, e.fout() * 2f + 0.2f, 45); + mine = new Effect(20, e -> { + Angles.randLenVectors(e.id, 6, 3f + e.fin() * 6f, (x, y) -> { + Draw.color(e.color, Color.LIGHT_GRAY, e.fin()); + Fill.poly(e.x + x, e.y + y, 4, e.fout() * 2f, 45); + Draw.reset(); + }); + }); + mineBig = new Effect(30, e -> { + Angles.randLenVectors(e.id, 6, 4f + e.fin() * 8f, (x, y) -> { + Draw.color(e.color, Color.LIGHT_GRAY, e.fin()); + Fill.poly(e.x + x, e.y + y, 4, e.fout() * 2f + 0.2f, 45); + Draw.reset(); + }); + }); + mineHuge = new Effect(40, e -> { + Angles.randLenVectors(e.id, 8, 5f + e.fin() * 10f, (x, y) -> { + Draw.color(e.color, Color.LIGHT_GRAY, e.fin()); + Fill.poly(e.x + x, e.y + y, 4, e.fout() * 2f + 0.5f, 45); + Draw.reset(); + }); + }); + smelt = new Effect(20, e -> { + Angles.randLenVectors(e.id, 6, 2f + e.fin() * 5f, (x, y) -> { + Draw.color(Color.WHITE, e.color, e.fin()); + Fill.poly(e.x + x, e.y + y, 4, 0.5f + e.fout() * 2f, 45); + Draw.reset(); + }); + }); + teleportActivate = new Effect(50, e -> { + Draw.color(e.color); + + e.scaled(8f, e2 -> { + Lines.stroke(e2.fout() * 4f); + Lines.circle(e2.x, e2.y, 4f + e2.fin() * 27f); + }); + + Lines.stroke(e.fout() * 2f); + + Angles.randLenVectors(e.id, 30, 4f + 40f * e.fin(), (x, y) -> { + Lines.lineAngle(e.x + x, e.y + y, Mathf.atan2(x, y), e.fin() * 4f + 1f); + }); + Draw.reset(); }); - }), - mineHuge = new Effect(40, e -> { - Angles.randLenVectors(e.id, 8, 5f + e.fin()*10f, (x, y)->{ - Draw.color(e.color, Color.LIGHT_GRAY, e.fin()); - Fill.poly(e.x + x, e.y + y, 4, e.fout() * 2f + 0.5f, 45); + teleport = new Effect(60, e -> { + Draw.color(e.color); + Lines.stroke(e.fin() * 2f); + Lines.circle(e.x, e.y, 7f + e.fout() * 8f); + + Angles.randLenVectors(e.id, 20, 6f + 20f * e.fout(), (x, y) -> { + Lines.lineAngle(e.x + x, e.y + y, Mathf.atan2(x, y), e.fin() * 4f + 1f); + }); + Draw.reset(); }); - }), - smelt = new Effect(20, e -> { - Angles.randLenVectors(e.id, 6, 2f + e.fin()*5f, (x, y)->{ - Draw.color(Color.WHITE, e.color, e.fin()); - Fill.poly(e.x + x, e.y + y, 4, 0.5f+e.fout()*2f, 45); + teleportOut = new Effect(20, e -> { + Draw.color(e.color); + Lines.stroke(e.fout() * 2f); + Lines.circle(e.x, e.y, 7f + e.fin() * 8f); + + Angles.randLenVectors(e.id, 20, 4f + 20f * e.fin(), (x, y) -> { + Lines.lineAngle(e.x + x, e.y + y, Mathf.atan2(x, y), e.fslope() * 4f + 1f); + }); + Draw.reset(); }); - }), - teleportActivate = new Effect(50, e -> { - Draw.color(e.color); - - e.scaled(8f, e2 -> { - Lines.stroke(e2.fout()*4f); - Lines.circle(e2.x, e2.y, 4f + e2.fin()*27f); + ripple = new GroundEffect(false, 30, e -> { + Draw.color(Hue.shift(Tmp.c1.set(e.color), 2, 0.1f)); + Lines.stroke(e.fout() + 0.4f); + Lines.circle(e.x, e.y, 2f + e.fin() * 4f); + Draw.reset(); }); - Lines.stroke(e.fout()*2f); - - Angles.randLenVectors(e.id, 30, 4f + 40f * e.fin(), (x, y) -> { - Lines.lineAngle(e.x + x, e.y + y, Mathf.atan2(x, y), e.fin()*4f + 1f); + bubble = new Effect(20, e -> { + Draw.color(Hue.shift(Tmp.c1.set(e.color), 2, 0.1f)); + Lines.stroke(e.fout() + 0.2f); + Angles.randLenVectors(e.id, 2, 8f, (x, y) -> { + Lines.circle(e.x + x, e.y + y, 1f + e.fin() * 3f); + }); + Draw.reset(); }); - - Draw.reset(); - }), - teleport = new Effect(60, e -> { - Draw.color(e.color); - Lines.stroke(e.fin()*2f); - Lines.circle(e.x, e.y, 7f + e.fout()*8f); - - Angles.randLenVectors(e.id, 20, 6f + 20f * e.fout(), (x, y) -> { - Lines.lineAngle(e.x + x, e.y + y, Mathf.atan2(x, y), e.fin()*4f + 1f); - }); - - Draw.reset(); - }), - teleportOut = new Effect(20, e -> { - Draw.color(e.color); - Lines.stroke(e.fout()*2f); - Lines.circle(e.x, e.y, 7f + e.fin()*8f); - - Angles.randLenVectors(e.id, 20, 4f + 20f * e.fin(), (x, y) -> { - Lines.lineAngle(e.x + x, e.y + y, Mathf.atan2(x, y), e.fslope()*4f + 1f); - }); - - Draw.reset(); - }), - ripple = new GroundEffect(false, 30, e -> { - Draw.color(Hue.shift(Tmp.c1.set(e.color), 2, 0.1f)); - Lines.stroke(e.fout() + 0.4f); - Lines.circle(e.x, e.y, 2f + e.fin()*4f); - Draw.reset(); - }), - - bubble = new Effect(20, e -> { - Draw.color(Hue.shift(Tmp.c1.set(e.color), 2, 0.1f)); - Lines.stroke(e.fout() + 0.2f); - Angles.randLenVectors(e.id, 2, 8f, (x, y) -> { - Lines.circle(e.x + x, e.y + y, 1f + e.fin() * 3f); - }); - Draw.reset(); - }); + } } diff --git a/core/src/io/anuke/mindustry/content/fx/BulletFx.java b/core/src/io/anuke/mindustry/content/fx/BulletFx.java index 85ae4eb0a2..901cda1070 100644 --- a/core/src/io/anuke/mindustry/content/fx/BulletFx.java +++ b/core/src/io/anuke/mindustry/content/fx/BulletFx.java @@ -2,6 +2,7 @@ package io.anuke.mindustry.content.fx; import com.badlogic.gdx.graphics.Color; import io.anuke.mindustry.graphics.Palette; +import io.anuke.mindustry.type.ContentList; import io.anuke.ucore.core.Effects.Effect; import io.anuke.ucore.graphics.Draw; import io.anuke.ucore.graphics.Fill; @@ -9,101 +10,105 @@ import io.anuke.ucore.graphics.Lines; import io.anuke.ucore.util.Angles; import io.anuke.ucore.util.Mathf; -public class BulletFx { - public static final Effect +public class BulletFx implements ContentList { + public static Effect hitBulletSmall, hitBulletBig, hitFlameSmall, hitLiquid, hitLancer, despawn, flakExplosion; - hitBulletSmall = new Effect(14, e -> { - Draw.color(Color.WHITE, Palette.lightOrange, e.fin()); - Lines.stroke(0.5f + e.fout()); + @Override + public void load() { - Angles.randLenVectors(e.id, 5, e.fin()*15f, e.rotation, 50f, (x, y) -> { - float ang = Mathf.atan2(x, y); - Lines.lineAngle(e.x + x, e.y + y, ang, e.fout()*3 + 1f); + hitBulletSmall = new Effect(14, e -> { + Draw.color(Color.WHITE, Palette.lightOrange, e.fin()); + Lines.stroke(0.5f + e.fout()); + + Angles.randLenVectors(e.id, 5, e.fin() * 15f, e.rotation, 50f, (x, y) -> { + float ang = Mathf.atan2(x, y); + Lines.lineAngle(e.x + x, e.y + y, ang, e.fout() * 3 + 1f); + }); + + Draw.reset(); }); - Draw.reset(); - }), + hitBulletBig = new Effect(13, e -> { + Draw.color(Color.WHITE, Palette.lightOrange, e.fin()); + Lines.stroke(0.5f + e.fout() * 1.5f); - hitBulletBig = new Effect(13, e -> { - Draw.color(Color.WHITE, Palette.lightOrange, e.fin()); - Lines.stroke(0.5f + e.fout()*1.5f); + Angles.randLenVectors(e.id, 8, e.finpow() * 30f, e.rotation, 50f, (x, y) -> { + float ang = Mathf.atan2(x, y); + Lines.lineAngle(e.x + x, e.y + y, ang, e.fout() * 4 + 1.5f); + }); - Angles.randLenVectors(e.id, 8, e.finpow()*30f, e.rotation, 50f, (x, y) -> { - float ang = Mathf.atan2(x, y); - Lines.lineAngle(e.x + x, e.y + y, ang, e.fout()*4 + 1.5f); + Draw.reset(); }); - Draw.reset(); - }), + hitFlameSmall = new Effect(14, e -> { + Draw.color(Palette.lightFlame, Palette.darkFlame, e.fin()); + Lines.stroke(0.5f + e.fout()); - hitFlameSmall = new Effect(14, e -> { - Draw.color(Palette.lightFlame, Palette.darkFlame, e.fin()); - Lines.stroke(0.5f + e.fout()); + Angles.randLenVectors(e.id, 5, e.fin() * 15f, e.rotation, 50f, (x, y) -> { + float ang = Mathf.atan2(x, y); + Lines.lineAngle(e.x + x, e.y + y, ang, e.fout() * 3 + 1f); + }); - Angles.randLenVectors(e.id, 5, e.fin()*15f, e.rotation, 50f, (x, y) -> { - float ang = Mathf.atan2(x, y); - Lines.lineAngle(e.x + x, e.y + y, ang, e.fout()*3 + 1f); + Draw.reset(); }); - Draw.reset(); - }), + hitLiquid = new Effect(16, e -> { + Draw.color(e.color); - hitLiquid = new Effect(16, e -> { - Draw.color(e.color); + Angles.randLenVectors(e.id, 5, e.fin() * 15f, e.rotation + 180f, 60f, (x, y) -> { + Fill.circle(e.x + x, e.y + y, e.fout() * 2f); + }); - Angles.randLenVectors(e.id, 5, e.fin()*15f, e.rotation + 180f, 60f, (x, y) -> { - Fill.circle(e.x + x, e.y + y, e.fout() * 2f); + Draw.reset(); }); - Draw.reset(); - }), + hitLancer = new Effect(12, e -> { + Draw.color(Color.WHITE); + Lines.stroke(e.fout() * 1.5f); - hitLancer = new Effect(12, e -> { - Draw.color(Color.WHITE); - Lines.stroke(e.fout()*1.5f); + Angles.randLenVectors(e.id, 8, e.finpow() * 17f, e.rotation, 360f, (x, y) -> { + float ang = Mathf.atan2(x, y); + Lines.lineAngle(e.x + x, e.y + y, ang, e.fout() * 4 + 1f); + }); - Angles.randLenVectors(e.id, 8, e.finpow()*17f, e.rotation, 360f, (x, y) -> { - float ang = Mathf.atan2(x, y); - Lines.lineAngle(e.x + x, e.y + y, ang, e.fout()*4 + 1f); + Draw.reset(); }); - Draw.reset(); - }), + despawn = new Effect(12, e -> { + Draw.color(Palette.lighterOrange, Color.GRAY, e.fin()); + Lines.stroke(e.fout()); - despawn = new Effect(12, e -> { - Draw.color(Palette.lighterOrange, Color.GRAY, e.fin()); - Lines.stroke(e.fout()); + Angles.randLenVectors(e.id, 7, e.fin() * 7f, e.rotation, 40f, (x, y) -> { + float ang = Mathf.atan2(x, y); + Lines.lineAngle(e.x + x, e.y + y, ang, e.fout() * 2 + 1f); + }); - Angles.randLenVectors(e.id, 7, e.fin()*7f, e.rotation, 40f, (x, y) -> { - float ang = Mathf.atan2(x, y); - Lines.lineAngle(e.x + x, e.y + y, ang, e.fout()*2 + 1f); + Draw.reset(); }); - Draw.reset(); - }), + flakExplosion = new Effect(20, e -> { - flakExplosion = new Effect(20, e -> { + Draw.color(Palette.bulletYellow); + e.scaled(6, i -> { + Lines.stroke(3f * i.fout()); + Lines.circle(e.x, e.y, 3f + i.fin() * 10f); + }); - Draw.color(Palette.bulletYellow); - e.scaled(6, i -> { - Lines.stroke(3f * i.fout()); - Lines.circle(e.x, e.y, 3f + i.fin()*10f); + Draw.color(Color.GRAY); + + Angles.randLenVectors(e.id, 5, 2f + 23f * e.finpow(), (x, y) -> { + Fill.circle(e.x + x, e.y + y, e.fout() * 3f + 0.5f); + }); + + Draw.color(Palette.lighterOrange); + Lines.stroke(1f * e.fout()); + + Angles.randLenVectors(e.id + 1, 4, 1f + 23f * e.finpow(), (x, y) -> { + Lines.lineAngle(e.x + x, e.y + y, Mathf.atan2(x, y), 1f + e.fout() * 3f); + }); + + Draw.reset(); }); - - Draw.color(Color.GRAY); - - Angles.randLenVectors(e.id, 5, 2f + 23f * e.finpow(), (x, y) ->{ - Fill.circle(e.x + x, e.y + y, e.fout()*3f + 0.5f); - }); - - Draw.color(Palette.lighterOrange); - Lines.stroke(1f * e.fout()); - - Angles.randLenVectors(e.id + 1, 4, 1f + 23f * e.finpow(), (x, y) -> { - Lines.lineAngle(e.x + x, e.y + y, Mathf.atan2(x, y), 1f + e.fout()*3f); - }); - - Draw.reset(); - }); + } } diff --git a/core/src/io/anuke/mindustry/content/fx/EnvironmentFx.java b/core/src/io/anuke/mindustry/content/fx/EnvironmentFx.java index d513637067..fdf5f0720d 100644 --- a/core/src/io/anuke/mindustry/content/fx/EnvironmentFx.java +++ b/core/src/io/anuke/mindustry/content/fx/EnvironmentFx.java @@ -3,113 +3,117 @@ package io.anuke.mindustry.content.fx; import com.badlogic.gdx.graphics.Color; import io.anuke.mindustry.content.Liquids; import io.anuke.mindustry.graphics.Palette; +import io.anuke.mindustry.type.ContentList; import io.anuke.ucore.core.Effects.Effect; import io.anuke.ucore.graphics.Draw; import io.anuke.ucore.graphics.Fill; import io.anuke.ucore.util.Angles; import io.anuke.ucore.util.Mathf; -public class EnvironmentFx { +public class EnvironmentFx implements ContentList { + public static Effect burning, fire, smoke, steam, fireballsmoke, ballfire, freezing, melting, wet, oily; - public static final Effect + @Override + public void load() { - burning = new Effect(35f, e -> { - Draw.color(Palette.lightFlame, Palette.darkFlame, e.fin()); + burning = new Effect(35f, e -> { + Draw.color(Palette.lightFlame, Palette.darkFlame, e.fin()); - Angles.randLenVectors(e.id, 3, 2f + e.fin()*7f, (x, y) -> { - Fill.circle(e.x + x, e.y + y, 0.1f + e.fout() * 1.4f); + Angles.randLenVectors(e.id, 3, 2f + e.fin() * 7f, (x, y) -> { + Fill.circle(e.x + x, e.y + y, 0.1f + e.fout() * 1.4f); + }); + + Draw.color(); }); - Draw.color(); - }), + fire = new Effect(35f, e -> { + Draw.color(Palette.lightFlame, Palette.darkFlame, e.fin()); - fire = new Effect(35f, e -> { - Draw.color(Palette.lightFlame, Palette.darkFlame, e.fin()); + Angles.randLenVectors(e.id, 2, 2f + e.fin() * 7f, (x, y) -> { + Fill.circle(e.x + x, e.y + y, 0.2f + e.fslope() * 1.5f); + }); - Angles.randLenVectors(e.id, 2, 2f + e.fin()*7f, (x, y) -> { - Fill.circle(e.x + x, e.y + y, 0.2f + e.fslope() * 1.5f); + Draw.color(); }); - Draw.color(); - }), + smoke = new Effect(35f, e -> { + Draw.color(Color.GRAY); - smoke = new Effect(35f, e -> { - Draw.color(Color.GRAY); + Angles.randLenVectors(e.id, 1, 2f + e.fin() * 7f, (x, y) -> { + Fill.circle(e.x + x, e.y + y, 0.2f + e.fslope() * 1.5f); + }); - Angles.randLenVectors(e.id, 1, 2f + e.fin()*7f, (x, y) -> { - Fill.circle(e.x + x, e.y + y, 0.2f + e.fslope() * 1.5f); + Draw.color(); }); - Draw.color(); - }), + steam = new Effect(35f, e -> { + Draw.color(Color.LIGHT_GRAY); - steam = new Effect(35f, e -> { - Draw.color(Color.LIGHT_GRAY); + Angles.randLenVectors(e.id, 2, 2f + e.fin() * 7f, (x, y) -> { + Fill.circle(e.x + x, e.y + y, 0.2f + e.fslope() * 1.5f); + }); - Angles.randLenVectors(e.id, 2, 2f + e.fin()*7f, (x, y) -> { - Fill.circle(e.x + x, e.y + y, 0.2f + e.fslope() * 1.5f); + Draw.color(); }); - Draw.color(); - }), + fireballsmoke = new Effect(25f, e -> { + Draw.color(Color.GRAY); - fireballsmoke = new Effect(25f, e -> { - Draw.color(Color.GRAY); + Angles.randLenVectors(e.id, 1, 2f + e.fin() * 7f, (x, y) -> { + Fill.circle(e.x + x, e.y + y, 0.2f + e.fout() * 1.5f); + }); - Angles.randLenVectors(e.id, 1, 2f + e.fin()*7f, (x, y) -> { - Fill.circle(e.x + x, e.y + y, 0.2f + e.fout() * 1.5f); + Draw.color(); }); - Draw.color(); - }), + ballfire = new Effect(25f, e -> { + Draw.color(Palette.lightFlame, Palette.darkFlame, e.fin()); - ballfire = new Effect(25f, e -> { - Draw.color(Palette.lightFlame, Palette.darkFlame, e.fin()); + Angles.randLenVectors(e.id, 2, 2f + e.fin() * 7f, (x, y) -> { + Fill.circle(e.x + x, e.y + y, 0.2f + e.fout() * 1.5f); + }); - Angles.randLenVectors(e.id, 2, 2f + e.fin()*7f, (x, y) -> { - Fill.circle(e.x + x, e.y + y, 0.2f + e.fout() * 1.5f); + Draw.color(); }); - Draw.color(); - }), + freezing = new Effect(40f, e -> { + Draw.color(Liquids.cryofluid.color); - freezing = new Effect(40f, e -> { - Draw.color(Liquids.cryofluid.color); + Angles.randLenVectors(e.id, 2, 1f + e.fin() * 2f, (x, y) -> { + Fill.circle(e.x + x, e.y + y, e.fout() * 1.2f); + }); - Angles.randLenVectors(e.id, 2, 1f + e.fin()*2f, (x, y) -> { - Fill.circle(e.x + x, e.y + y, e.fout() * 1.2f); + Draw.color(); }); - Draw.color(); - }), + melting = new Effect(40f, e -> { + Draw.color(Liquids.lava.color, Color.WHITE, e.fout() / 5f + Mathf.randomSeedRange(e.id, 0.12f)); - melting = new Effect(40f, e -> { - Draw.color(Liquids.lava.color, Color.WHITE, e.fout()/5f + Mathf.randomSeedRange(e.id, 0.12f)); + Angles.randLenVectors(e.id, 2, 1f + e.fin() * 3f, (x, y) -> { + Fill.circle(e.x + x, e.y + y, .2f + e.fout() * 1.2f); + }); - Angles.randLenVectors(e.id, 2, 1f + e.fin()*3f, (x, y) -> { - Fill.circle(e.x + x, e.y + y, .2f + e.fout() * 1.2f); + Draw.color(); }); - Draw.color(); - }), + wet = new Effect(40f, e -> { + Draw.color(Liquids.water.color); - wet = new Effect(40f, e -> { - Draw.color(Liquids.water.color); + Angles.randLenVectors(e.id, 2, 1f + e.fin() * 2f, (x, y) -> { + Fill.circle(e.x + x, e.y + y, e.fout() * 1f); + }); - Angles.randLenVectors(e.id, 2, 1f + e.fin()*2f, (x, y) -> { - Fill.circle(e.x + x, e.y + y, e.fout() * 1f); + Draw.color(); }); - Draw.color(); - }), + oily = new Effect(42f, e -> { + Draw.color(Liquids.oil.color); - oily = new Effect(42f, e -> { - Draw.color(Liquids.oil.color); + Angles.randLenVectors(e.id, 2, 1f + e.fin() * 2f, (x, y) -> { + Fill.circle(e.x + x, e.y + y, e.fout() * 1f); + }); - Angles.randLenVectors(e.id, 2, 1f + e.fin()*2f, (x, y) -> { - Fill.circle(e.x + x, e.y + y, e.fout() * 1f); + Draw.color(); }); - - Draw.color(); - }); + } } diff --git a/core/src/io/anuke/mindustry/content/fx/ExplosionFx.java b/core/src/io/anuke/mindustry/content/fx/ExplosionFx.java index fa783b7536..fea870d73e 100644 --- a/core/src/io/anuke/mindustry/content/fx/ExplosionFx.java +++ b/core/src/io/anuke/mindustry/content/fx/ExplosionFx.java @@ -2,6 +2,7 @@ package io.anuke.mindustry.content.fx; import com.badlogic.gdx.graphics.Color; import io.anuke.mindustry.graphics.Palette; +import io.anuke.mindustry.type.ContentList; import io.anuke.ucore.core.Effects.Effect; import io.anuke.ucore.graphics.Draw; import io.anuke.ucore.graphics.Fill; @@ -9,84 +10,88 @@ import io.anuke.ucore.graphics.Lines; import io.anuke.ucore.util.Angles; import io.anuke.ucore.util.Mathf; -public class ExplosionFx { - public static final Effect +public class ExplosionFx implements ContentList { + public static Effect shockwave, bigShockwave, nuclearShockwave, explosion, blockExplosion, blockExplosionSmoke; - shockwave = new Effect(10f, 80f, e -> { - Draw.color(Color.WHITE, Color.LIGHT_GRAY, e.fin()); - Lines.stroke(e.fout()*2f + 0.2f); - Lines.circle(e.x, e.y, e.fin()*28f); - Draw.reset(); - }), + @Override + public void load() { - bigShockwave = new Effect(10f, 80f, e -> { - Draw.color(Color.WHITE, Color.LIGHT_GRAY, e.fin()); - Lines.stroke(e.fout()*3f); - Lines.circle(e.x, e.y, e.fin()*50f); - Draw.reset(); - }), - - nuclearShockwave = new Effect(10f, 200f, e -> { - Draw.color(Color.WHITE, Color.LIGHT_GRAY, e.fin()); - Lines.stroke(e.fout()*3f + 0.2f); - Lines.poly(e.x, e.y, 40, e.fin()*140f); - Draw.reset(); - }), - - explosion = new Effect(30, e -> { - e.scaled(7, i -> { - Lines.stroke(3f * i.fout()); - Lines.circle(e.x, e.y, 3f + i.fin()*10f); + shockwave = new Effect(10f, 80f, e -> { + Draw.color(Color.WHITE, Color.LIGHT_GRAY, e.fin()); + Lines.stroke(e.fout() * 2f + 0.2f); + Lines.circle(e.x, e.y, e.fin() * 28f); + Draw.reset(); }); - Draw.color(Color.GRAY); - - Angles.randLenVectors(e.id, 6, 2f + 19f * e.finpow(), (x, y) ->{ - Fill.circle(e.x + x, e.y + y, e.fout()*3f + 0.5f); - Fill.circle(e.x + x/2f, e.y + y/2f, e.fout()*1f); + bigShockwave = new Effect(10f, 80f, e -> { + Draw.color(Color.WHITE, Color.LIGHT_GRAY, e.fin()); + Lines.stroke(e.fout() * 3f); + Lines.circle(e.x, e.y, e.fin() * 50f); + Draw.reset(); }); - Draw.color(Palette.lighterOrange, Palette.lightOrange, Color.GRAY, e.fin()); - Lines.stroke(1.5f * e.fout()); - - Angles.randLenVectors(e.id + 1, 8, 1f + 23f * e.finpow(), (x, y) -> { - Lines.lineAngle(e.x + x, e.y + y, Mathf.atan2(x, y), 1f + e.fout()*3f); + nuclearShockwave = new Effect(10f, 200f, e -> { + Draw.color(Color.WHITE, Color.LIGHT_GRAY, e.fin()); + Lines.stroke(e.fout() * 3f + 0.2f); + Lines.poly(e.x, e.y, 40, e.fin() * 140f); + Draw.reset(); }); - Draw.reset(); - }), + explosion = new Effect(30, e -> { + e.scaled(7, i -> { + Lines.stroke(3f * i.fout()); + Lines.circle(e.x, e.y, 3f + i.fin() * 10f); + }); - blockExplosion = new Effect(30, e -> { - e.scaled(7, i -> { - Lines.stroke(3.1f * i.fout()); - Lines.circle(e.x, e.y, 3f + i.fin()*14f); + Draw.color(Color.GRAY); + + Angles.randLenVectors(e.id, 6, 2f + 19f * e.finpow(), (x, y) -> { + Fill.circle(e.x + x, e.y + y, e.fout() * 3f + 0.5f); + Fill.circle(e.x + x / 2f, e.y + y / 2f, e.fout() * 1f); + }); + + Draw.color(Palette.lighterOrange, Palette.lightOrange, Color.GRAY, e.fin()); + Lines.stroke(1.5f * e.fout()); + + Angles.randLenVectors(e.id + 1, 8, 1f + 23f * e.finpow(), (x, y) -> { + Lines.lineAngle(e.x + x, e.y + y, Mathf.atan2(x, y), 1f + e.fout() * 3f); + }); + + Draw.reset(); }); - Draw.color(Color.GRAY); + blockExplosion = new Effect(30, e -> { + e.scaled(7, i -> { + Lines.stroke(3.1f * i.fout()); + Lines.circle(e.x, e.y, 3f + i.fin() * 14f); + }); - Angles.randLenVectors(e.id, 6, 2f + 19f * e.finpow(), (x, y) ->{ - Fill.circle(e.x + x, e.y + y, e.fout()*3f + 0.5f); - Fill.circle(e.x + x/2f, e.y + y/2f, e.fout()*1f); + Draw.color(Color.GRAY); + + Angles.randLenVectors(e.id, 6, 2f + 19f * e.finpow(), (x, y) -> { + Fill.circle(e.x + x, e.y + y, e.fout() * 3f + 0.5f); + Fill.circle(e.x + x / 2f, e.y + y / 2f, e.fout() * 1f); + }); + + Draw.color(Palette.lighterOrange, Palette.lightOrange, Color.GRAY, e.fin()); + Lines.stroke(1.7f * e.fout()); + + Angles.randLenVectors(e.id + 1, 9, 1f + 23f * e.finpow(), (x, y) -> { + Lines.lineAngle(e.x + x, e.y + y, Mathf.atan2(x, y), 1f + e.fout() * 3f); + }); + + Draw.reset(); }); - Draw.color(Palette.lighterOrange, Palette.lightOrange, Color.GRAY, e.fin()); - Lines.stroke(1.7f * e.fout()); + blockExplosionSmoke = new Effect(30, e -> { + Draw.color(Color.GRAY); - Angles.randLenVectors(e.id + 1, 9, 1f + 23f * e.finpow(), (x, y) -> { - Lines.lineAngle(e.x + x, e.y + y, Mathf.atan2(x, y), 1f + e.fout()*3f); + Angles.randLenVectors(e.id, 6, 4f + 30f * e.finpow(), (x, y) -> { + Fill.circle(e.x + x, e.y + y, e.fout() * 3f); + Fill.circle(e.x + x / 2f, e.y + y / 2f, e.fout() * 1f); + }); + + Draw.reset(); }); - - Draw.reset(); - }), - - blockExplosionSmoke = new Effect(30, e -> { - Draw.color(Color.GRAY); - - Angles.randLenVectors(e.id, 6, 4f + 30f * e.finpow(), (x, y) ->{ - Fill.circle(e.x + x, e.y + y, e.fout()*3f); - Fill.circle(e.x + x/2f, e.y + y/2f, e.fout()*1f); - }); - - Draw.reset(); - }); + } } diff --git a/core/src/io/anuke/mindustry/content/fx/Fx.java b/core/src/io/anuke/mindustry/content/fx/Fx.java index 01c9dafece..907950bb05 100644 --- a/core/src/io/anuke/mindustry/content/fx/Fx.java +++ b/core/src/io/anuke/mindustry/content/fx/Fx.java @@ -2,6 +2,7 @@ package io.anuke.mindustry.content.fx; import com.badlogic.gdx.graphics.Color; import io.anuke.mindustry.graphics.Palette; +import io.anuke.mindustry.type.ContentList; import io.anuke.ucore.core.Effects.Effect; import io.anuke.ucore.graphics.Draw; import io.anuke.ucore.graphics.Fill; @@ -10,44 +11,47 @@ import io.anuke.ucore.util.Angles; import static io.anuke.mindustry.Vars.tilesize; -public class Fx{ +public class Fx implements ContentList { + public static Effect none, placeBlock, breakBlock, smoke, spawn; - - public static final Effect + @Override + public void load() { - none = new Effect(0, 0f, e->{}), - - placeBlock = new Effect(16, e -> { - Draw.color(Palette.accent); - Lines.stroke(3f - e.fin() * 2f); - Lines.square(e.x, e.y, tilesize / 2f * (float)(e.data) + e.fin() * 3f); - Draw.reset(); - }), - - breakBlock = new Effect(12, e -> { - float data = (float)(e.data); - - Draw.color(Palette.remove); - Lines.stroke(3f - e.fin() * 2f); - Lines.square(e.x, e.y, tilesize / 2f * data + e.fin() * 3f); - - Angles.randLenVectors(e.id, 3 + (int)(data*3), data*2f + (tilesize * data) * e.finpow(), (x, y) -> { - Fill.square(e.x + x, e.y + y, 1f + e.fout()*(3f+data)); + none = new Effect(0, 0f, e -> { }); - Draw.reset(); - }), - smoke = new Effect(100, e -> { - Draw.color(Color.GRAY, new Color(0.3f, 0.3f, 0.3f, 1f), e.fin()); - float size = 7f-e.fin()*7f; - Draw.rect("circle", e.x, e.y, size, size); - Draw.reset(); - }), + placeBlock = new Effect(16, e -> { + Draw.color(Palette.accent); + Lines.stroke(3f - e.fin() * 2f); + Lines.square(e.x, e.y, tilesize / 2f * (float) (e.data) + e.fin() * 3f); + Draw.reset(); + }); - spawn = new Effect(23, e -> { - Lines.stroke(2f); - Draw.color(Color.DARK_GRAY, Color.SCARLET, e.fin()); - Lines.circle(e.x, e.y, 7f - e.fin() * 6f); - Draw.reset(); - }); + breakBlock = new Effect(12, e -> { + float data = (float) (e.data); + + Draw.color(Palette.remove); + Lines.stroke(3f - e.fin() * 2f); + Lines.square(e.x, e.y, tilesize / 2f * data + e.fin() * 3f); + + Angles.randLenVectors(e.id, 3 + (int) (data * 3), data * 2f + (tilesize * data) * e.finpow(), (x, y) -> { + Fill.square(e.x + x, e.y + y, 1f + e.fout() * (3f + data)); + }); + Draw.reset(); + }); + + smoke = new Effect(100, e -> { + Draw.color(Color.GRAY, new Color(0.3f, 0.3f, 0.3f, 1f), e.fin()); + float size = 7f - e.fin() * 7f; + Draw.rect("circle", e.x, e.y, size, size); + Draw.reset(); + }); + + spawn = new Effect(23, e -> { + Lines.stroke(2f); + Draw.color(Color.DARK_GRAY, Color.SCARLET, e.fin()); + Lines.circle(e.x, e.y, 7f - e.fin() * 6f); + Draw.reset(); + }); + } } diff --git a/core/src/io/anuke/mindustry/content/fx/ShootFx.java b/core/src/io/anuke/mindustry/content/fx/ShootFx.java index 13c659f221..d47a94e7aa 100644 --- a/core/src/io/anuke/mindustry/content/fx/ShootFx.java +++ b/core/src/io/anuke/mindustry/content/fx/ShootFx.java @@ -3,6 +3,7 @@ package io.anuke.mindustry.content.fx; import com.badlogic.gdx.graphics.Color; import io.anuke.mindustry.entities.effect.GroundEffectEntity.GroundEffect; import io.anuke.mindustry.graphics.Palette; +import io.anuke.mindustry.type.ContentList; import io.anuke.ucore.core.Effects.Effect; import io.anuke.ucore.graphics.Draw; import io.anuke.ucore.graphics.Fill; @@ -11,202 +12,206 @@ import io.anuke.ucore.graphics.Shapes; import io.anuke.ucore.util.Angles; import io.anuke.ucore.util.Mathf; -public class ShootFx { - public static final Effect +public class ShootFx implements ContentList { + public static Effect shootSmall, shootSmallSmoke, shootBig, shootBig2, shootBigSmoke, shootBigSmoke2, shootSmallFlame, shootLiquid, shellEjectSmall, shellEjectMedium, shellEjectBig, lancerLaserShoot, lancerLaserShootSmoke, lancerLaserCharge, lancerLaserChargeBegin, lightningCharge, lightningShoot; - shootSmall = new Effect(8, e -> { - Draw.color(Palette.lighterOrange, Palette.lightOrange, e.fin()); - float w = 1f + 5 * e.fout(); - Shapes.tri(e.x, e.y, w, 15f * e.fout(), e.rotation); - Shapes.tri(e.x, e.y, w, 3f * e.fout(), e.rotation + 180f); - Draw.reset(); - }), + @Override + public void load() { - shootSmallSmoke = new Effect(20f, e -> { - Draw.color(Palette.lighterOrange, Color.LIGHT_GRAY, Color.GRAY, e.fin()); - - Angles.randLenVectors(e.id, 5, e.finpow()*6f, e.rotation, 20f, (x, y) -> { - Fill.circle(e.x + x, e.y + y, e.fout()*1.5f); + shootSmall = new Effect(8, e -> { + Draw.color(Palette.lighterOrange, Palette.lightOrange, e.fin()); + float w = 1f + 5 * e.fout(); + Shapes.tri(e.x, e.y, w, 15f * e.fout(), e.rotation); + Shapes.tri(e.x, e.y, w, 3f * e.fout(), e.rotation + 180f); + Draw.reset(); }); - Draw.reset(); - }), + shootSmallSmoke = new Effect(20f, e -> { + Draw.color(Palette.lighterOrange, Color.LIGHT_GRAY, Color.GRAY, e.fin()); - shootBig = new Effect(9, e -> { - Draw.color(Palette.lighterOrange, Palette.lightOrange, e.fin()); - float w = 1.2f + 7 * e.fout(); - Shapes.tri(e.x, e.y, w, 25f * e.fout(), e.rotation); - Shapes.tri(e.x, e.y, w, 4f * e.fout(), e.rotation + 180f); - Draw.reset(); - }), + Angles.randLenVectors(e.id, 5, e.finpow() * 6f, e.rotation, 20f, (x, y) -> { + Fill.circle(e.x + x, e.y + y, e.fout() * 1.5f); + }); - shootBig2 = new Effect(10, e -> { - Draw.color(Palette.lightOrange, Color.GRAY, e.fin()); - float w = 1.2f + 8 * e.fout(); - Shapes.tri(e.x, e.y, w, 29f * e.fout(), e.rotation); - Shapes.tri(e.x, e.y, w, 5f * e.fout(), e.rotation + 180f); - Draw.reset(); - }), - - shootBigSmoke = new Effect(17f, e -> { - Draw.color(Palette.lighterOrange, Color.LIGHT_GRAY, Color.GRAY, e.fin()); - - Angles.randLenVectors(e.id, 8, e.finpow()*19f, e.rotation, 10f, (x, y) -> { - Fill.circle(e.x + x, e.y + y, e.fout()*2f + 0.2f); + Draw.reset(); }); - Draw.reset(); - }), - - shootBigSmoke2 = new Effect(18f, e -> { - Draw.color(Palette.lightOrange, Color.LIGHT_GRAY, Color.GRAY, e.fin()); - - Angles.randLenVectors(e.id, 9, e.finpow()*23f, e.rotation, 20f, (x, y) -> { - Fill.circle(e.x + x, e.y + y, e.fout()*2.4f + 0.2f); + shootBig = new Effect(9, e -> { + Draw.color(Palette.lighterOrange, Palette.lightOrange, e.fin()); + float w = 1.2f + 7 * e.fout(); + Shapes.tri(e.x, e.y, w, 25f * e.fout(), e.rotation); + Shapes.tri(e.x, e.y, w, 4f * e.fout(), e.rotation + 180f); + Draw.reset(); }); - Draw.reset(); - }), - - shootSmallFlame = new Effect(30f, e -> { - Draw.color(Palette.lightFlame, Palette.darkFlame, Color.GRAY, e.fin()); - - Angles.randLenVectors(e.id, 8, e.finpow()*26f, e.rotation, 10f, (x, y) -> { - Fill.circle(e.x + x, e.y + y, 0.65f + e.fout()*1.5f); + shootBig2 = new Effect(10, e -> { + Draw.color(Palette.lightOrange, Color.GRAY, e.fin()); + float w = 1.2f + 8 * e.fout(); + Shapes.tri(e.x, e.y, w, 29f * e.fout(), e.rotation); + Shapes.tri(e.x, e.y, w, 5f * e.fout(), e.rotation + 180f); + Draw.reset(); }); - Draw.reset(); - }), + shootBigSmoke = new Effect(17f, e -> { + Draw.color(Palette.lighterOrange, Color.LIGHT_GRAY, Color.GRAY, e.fin()); - shootLiquid = new Effect(40f, e -> { - Draw.color(e.color, Color.WHITE, e.fout()/6f + Mathf.randomSeedRange(e.id, 0.1f)); + Angles.randLenVectors(e.id, 8, e.finpow() * 19f, e.rotation, 10f, (x, y) -> { + Fill.circle(e.x + x, e.y + y, e.fout() * 2f + 0.2f); + }); - Angles.randLenVectors(e.id, 6, e.finpow()*60f, e.rotation, 11f, (x, y) -> { - Fill.circle(e.x + x, e.y + y, 0.5f + e.fout()*2.5f); + Draw.reset(); }); - Draw.reset(); - }), + shootBigSmoke2 = new Effect(18f, e -> { + Draw.color(Palette.lightOrange, Color.LIGHT_GRAY, Color.GRAY, e.fin()); - shellEjectSmall = new GroundEffect(30f, 400f, e -> { - Draw.color(Palette.lightOrange, Color.LIGHT_GRAY, Palette.lightishGray, e.fin()); - float rot = Math.abs(e.rotation) + 90f; + Angles.randLenVectors(e.id, 9, e.finpow() * 23f, e.rotation, 20f, (x, y) -> { + Fill.circle(e.x + x, e.y + y, e.fout() * 2.4f + 0.2f); + }); - int i = Mathf.sign(e.rotation); + Draw.reset(); + }); - float len = (2f + e.finpow()*6f) * i; - float lr = rot + e.fin()*30f*i; - Draw.rect("white", - 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); + shootSmallFlame = new Effect(30f, e -> { + Draw.color(Palette.lightFlame, Palette.darkFlame, Color.GRAY, e.fin()); - Draw.color(); - }), + Angles.randLenVectors(e.id, 8, e.finpow() * 26f, e.rotation, 10f, (x, y) -> { + Fill.circle(e.x + x, e.y + y, 0.65f + e.fout() * 1.5f); + }); - shellEjectMedium = new GroundEffect(34f, 400f, e -> { - Draw.color(Palette.lightOrange, Color.LIGHT_GRAY, Palette.lightishGray, e.fin()); - float rot = e.rotation + 90f; - for(int i : Mathf.signs){ - float len = (2f + e.finpow()*10f) * i; - float lr = rot + e.fin()*20f*i; - Draw.rect("casing", + Draw.reset(); + }); + + shootLiquid = new Effect(40f, e -> { + Draw.color(e.color, Color.WHITE, e.fout() / 6f + Mathf.randomSeedRange(e.id, 0.1f)); + + Angles.randLenVectors(e.id, 6, e.finpow() * 60f, e.rotation, 11f, (x, y) -> { + Fill.circle(e.x + x, e.y + y, 0.5f + e.fout() * 2.5f); + }); + + Draw.reset(); + }); + + shellEjectSmall = new GroundEffect(30f, 400f, e -> { + Draw.color(Palette.lightOrange, Color.LIGHT_GRAY, Palette.lightishGray, e.fin()); + float rot = Math.abs(e.rotation) + 90f; + + int i = Mathf.sign(e.rotation); + + float len = (2f + e.finpow() * 6f) * i; + float lr = rot + e.fin() * 30f * i; + Draw.rect("white", 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); - } + 1f, 2f, rot + e.fin() * 50f * i); - Draw.color(Color.LIGHT_GRAY, Color.GRAY, e.fin()); + Draw.color(); + }); - for(int i : Mathf.signs){ - Angles.randLenVectors(e.id, 4, 1f + e.finpow()*11f, e.rotation + 90f*i, 20f, (x, y) -> { - Fill.circle(e.x + x, e.y + y, e.fout()*1.5f); + shellEjectMedium = new GroundEffect(34f, 400f, e -> { + Draw.color(Palette.lightOrange, Color.LIGHT_GRAY, Palette.lightishGray, e.fin()); + float rot = e.rotation + 90f; + for (int i : Mathf.signs) { + float len = (2f + e.finpow() * 10f) * i; + float lr = rot + e.fin() * 20f * i; + Draw.rect("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); + } + + Draw.color(Color.LIGHT_GRAY, Color.GRAY, e.fin()); + + for (int i : Mathf.signs) { + Angles.randLenVectors(e.id, 4, 1f + e.finpow() * 11f, e.rotation + 90f * i, 20f, (x, y) -> { + Fill.circle(e.x + x, e.y + y, e.fout() * 1.5f); + }); + } + + Draw.color(); + }); + + shellEjectBig = new GroundEffect(22f, 400f, e -> { + Draw.color(Palette.lightOrange, Color.LIGHT_GRAY, Palette.lightishGray, e.fin()); + float rot = e.rotation + 90f; + for (int i : Mathf.signs) { + float len = (4f + e.finpow() * 8f) * i; + float lr = rot + Mathf.randomSeedRange(e.id + i + 6, 20f * e.fin()) * i; + Draw.rect("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())); + } + + Draw.color(Color.LIGHT_GRAY); + + for (int i : Mathf.signs) { + Angles.randLenVectors(e.id, 4, -e.finpow() * 15f, e.rotation + 90f * i, 25f, (x, y) -> { + Fill.circle(e.x + x, e.y + y, e.fout() * 2f); + }); + } + + Draw.color(); + }); + + lancerLaserShoot = new Effect(21f, e -> { + Draw.color(Palette.lancerLaser); + + for (int i : Mathf.signs) { + Shapes.tri(e.x, e.y, 4f * e.fout(), 29f, e.rotation + 90f * i); + } + + Draw.reset(); + }); + + lancerLaserShootSmoke = new Effect(26f, e -> { + Draw.color(Palette.lancerLaser); + + Angles.randLenVectors(e.id, 7, 80f, e.rotation, 0f, (x, y) -> { + Lines.lineAngle(e.x + x, e.y + y, Mathf.atan2(x, y), e.fout() * 9f); }); - } - Draw.color(); - }), + Draw.reset(); + }); - shellEjectBig = new GroundEffect(22f, 400f, e -> { - Draw.color(Palette.lightOrange, Color.LIGHT_GRAY, Palette.lightishGray, e.fin()); - float rot = e.rotation + 90f; - for(int i : Mathf.signs){ - float len = (4f + e.finpow()*8f) * i; - float lr = rot + Mathf.randomSeedRange(e.id + i + 6, 20f * e.fin())*i; - Draw.rect("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())); - } + lancerLaserCharge = new Effect(38f, e -> { + Draw.color(Palette.lancerLaser); - Draw.color(Color.LIGHT_GRAY); - - for(int i : Mathf.signs){ - Angles.randLenVectors(e.id, 4, -e.finpow()*15f, e.rotation + 90f*i, 25f, (x, y) -> { - Fill.circle(e.x + x, e.y + y, e.fout()*2f); + Angles.randLenVectors(e.id, 2, 1f + 20f * e.fout(), e.rotation, 120f, (x, y) -> { + Lines.lineAngle(e.x + x, e.y + y, Mathf.atan2(x, y), e.fslope() * 3f + 1f); }); - } - Draw.color(); - }), - - lancerLaserShoot = new Effect(21f, e -> { - Draw.color(Palette.lancerLaser); - - for(int i : Mathf.signs){ - Shapes.tri(e.x, e.y, 4f * e.fout(), 29f, e.rotation + 90f*i); - } - - Draw.reset(); - }), - - lancerLaserShootSmoke = new Effect(26f, e -> { - Draw.color(Palette.lancerLaser); - - Angles.randLenVectors(e.id, 7, 80f, e.rotation, 0f, (x, y) -> { - Lines.lineAngle(e.x + x, e.y + y, Mathf.atan2(x, y), e.fout()*9f); + Draw.reset(); }); - Draw.reset(); - }), + lancerLaserChargeBegin = new Effect(71f, e -> { + Draw.color(Palette.lancerLaser); + Fill.circle(e.x, e.y, e.fin() * 3f); - lancerLaserCharge = new Effect(38f, e -> { - Draw.color(Palette.lancerLaser); - - Angles.randLenVectors(e.id, 2, 1f + 20f * e.fout(), e.rotation, 120f, (x, y) -> { - Lines.lineAngle(e.x + x, e.y + y, Mathf.atan2(x, y), e.fslope()*3f + 1f); + Draw.color(); + Fill.circle(e.x, e.y, e.fin() * 2f); }); - Draw.reset(); - }), + lightningCharge = new Effect(38f, e -> { + Draw.color(Palette.lancerLaser); - lancerLaserChargeBegin = new Effect(71f, e -> { - Draw.color(Palette.lancerLaser); - Fill.circle(e.x, e.y, e.fin() * 3f); + Angles.randLenVectors(e.id, 2, 1f + 20f * e.fout(), e.rotation, 120f, (x, y) -> { + Shapes.tri(e.x + x, e.y + y, e.fslope() * 3f + 1, e.fslope() * 3f + 1, Mathf.atan2(x, y)); + }); - Draw.color(); - Fill.circle(e.x, e.y, e.fin() * 2f); - }), - - lightningCharge = new Effect(38f, e -> { - Draw.color(Palette.lancerLaser); - - Angles.randLenVectors(e.id, 2, 1f + 20f * e.fout(), e.rotation, 120f, (x, y) -> { - Shapes.tri(e.x + x, e.y + y, e.fslope()*3f + 1, e.fslope()*3f + 1, Mathf.atan2(x, y)); + Draw.reset(); }); - Draw.reset(); - }), + lightningShoot = new Effect(12f, e -> { + Draw.color(Color.WHITE, Palette.lancerLaser, e.fin()); + Lines.stroke(e.fout() * 1.2f + 0.5f); - lightningShoot= new Effect(12f, e -> { - Draw.color(Color.WHITE, Palette.lancerLaser, e.fin()); - Lines.stroke(e.fout() * 1.2f + 0.5f); + Angles.randLenVectors(e.id, 7, 25f * e.finpow(), e.rotation, 50f, (x, y) -> { + Lines.lineAngle(e.x + x, e.y + y, Mathf.atan2(x, y), e.fin() * 5f + 2f); + }); - Angles.randLenVectors(e.id, 7, 25f * e.finpow(), e.rotation, 50f, (x, y) -> { - Lines.lineAngle(e.x + x, e.y + y, Mathf.atan2(x, y), e.fin()*5f + 2f); + Draw.reset(); }); - - Draw.reset(); - }); + } } diff --git a/core/src/io/anuke/mindustry/content/fx/UnitFx.java b/core/src/io/anuke/mindustry/content/fx/UnitFx.java index ca1459bc63..7f26881064 100644 --- a/core/src/io/anuke/mindustry/content/fx/UnitFx.java +++ b/core/src/io/anuke/mindustry/content/fx/UnitFx.java @@ -1,20 +1,25 @@ package io.anuke.mindustry.content.fx; import io.anuke.mindustry.graphics.Palette; +import io.anuke.mindustry.type.ContentList; import io.anuke.ucore.core.Effects.Effect; import io.anuke.ucore.graphics.Draw; import io.anuke.ucore.graphics.Fill; import io.anuke.ucore.util.Angles; import io.anuke.ucore.util.Mathf; -public class UnitFx { - public static final Effect +public class UnitFx implements ContentList { + public static Effect vtolHover; - vtolHover = new Effect(40f, e -> { - float len = e.finpow()*10f; - float ang = e.rotation + Mathf.randomSeedRange(e.id, 30f); - Draw.color(Palette.lightFlame, Palette.lightOrange, e.fin()); - Fill.circle(e.x + Angles.trnsx(ang, len), e.y + Angles.trnsy(ang, len), 2f * e.fout()); - Draw.reset(); - }); + @Override + public void load() { + + vtolHover = new Effect(40f, e -> { + float len = e.finpow() * 10f; + float ang = e.rotation + Mathf.randomSeedRange(e.id, 30f); + Draw.color(Palette.lightFlame, Palette.lightOrange, e.fin()); + Fill.circle(e.x + Angles.trnsx(ang, len), e.y + Angles.trnsy(ang, len), 2f * e.fout()); + Draw.reset(); + }); + } } diff --git a/core/src/io/anuke/mindustry/core/ContentLoader.java b/core/src/io/anuke/mindustry/core/ContentLoader.java index f1aa778275..f5cd495f8f 100644 --- a/core/src/io/anuke/mindustry/core/ContentLoader.java +++ b/core/src/io/anuke/mindustry/core/ContentLoader.java @@ -3,20 +3,60 @@ package io.anuke.mindustry.core; import io.anuke.mindustry.content.*; import io.anuke.mindustry.content.blocks.*; import io.anuke.mindustry.content.bullets.*; +import io.anuke.mindustry.content.fx.*; import io.anuke.mindustry.entities.StatusEffect; import io.anuke.mindustry.entities.bullet.BulletType; import io.anuke.mindustry.entities.units.UnitType; +import io.anuke.mindustry.type.ContentList; import io.anuke.mindustry.type.Liquid; import io.anuke.mindustry.world.Block; import io.anuke.ucore.util.Log; -/**Loads all game content by creating class instances. +/**Loads all game content. * Call load() before doing anything with content.*/ public class ContentLoader { public static void load(){ - Object[] content = { + ContentList[] content = { + //items + new Items(), + + //liquids + new Liquids(), + + //ammotypes + new AmmoTypes(), + + //mechs + new Mechs(), + + //bullets + new ArtilleryBullets(), + new FlakBullets(), + new MissileBullets(), + new ShellBullets(), + new StandardBullets(), + new TurretBullets(), + + //units + new UnitTypes(), + + //weapons + new Weapons(), + + //status effects + new StatusEffects(), + + //effects + new BlockFx(), + new BulletFx(), + new EnvironmentFx(), + new ExplosionFx(), + new Fx(), + new ShootFx(), + new UnitFx(), + //blocks new Blocks(), new DefenseBlocks(), @@ -30,40 +70,14 @@ public class ContentLoader { new PowerBlocks(), new CraftingBlocks(), - //items - new Items(), - - //liquids - new Liquids(), - - //mechs - new Mechs(), - - //weapons - new Weapons(), - - //units - new UnitTypes(), - - - //bullets - new ArtilleryBullets(), - new FlakBullets(), - new MissileBullets(), - new ShellBullets(), - new StandardBullets(), - new TurretBullets(), - - //ammotypes - new AmmoTypes(), - - //status effects - new StatusEffects(), - //recipes new Recipes(), }; + for (ContentList list : content){ + list.load(); + } + for(Block block : Block.getAllBlocks()){ block.init(); } diff --git a/core/src/io/anuke/mindustry/core/NetClient.java b/core/src/io/anuke/mindustry/core/NetClient.java index 288adbda79..111edab356 100644 --- a/core/src/io/anuke/mindustry/core/NetClient.java +++ b/core/src/io/anuke/mindustry/core/NetClient.java @@ -139,10 +139,6 @@ public class NetClient extends Module { entity.read(data, time); } } - - if(debugNet){ - clientDebug.setSyncDebug(players, enemies); - } }); Net.handleClient(InvokePacket.class, packet -> { diff --git a/core/src/io/anuke/mindustry/core/Renderer.java b/core/src/io/anuke/mindustry/core/Renderer.java index 31069946d0..26dae2481e 100644 --- a/core/src/io/anuke/mindustry/core/Renderer.java +++ b/core/src/io/anuke/mindustry/core/Renderer.java @@ -57,6 +57,8 @@ public class Renderer extends RendererModule{ public Renderer() { Lines.setCircleVertices(14); + Shaders.init(); + Core.cameraScale = baseCameraScale; Effects.setEffectProvider((effect, color, x, y, rotation, data) -> { if(effect == Fx.none) return; diff --git a/core/src/io/anuke/mindustry/core/UI.java b/core/src/io/anuke/mindustry/core/UI.java index 5bbd123d08..b8e0498cfb 100644 --- a/core/src/io/anuke/mindustry/core/UI.java +++ b/core/src/io/anuke/mindustry/core/UI.java @@ -120,7 +120,7 @@ public class UI extends SceneModule{ skin = new Skin(Gdx.files.internal("ui/uiskin.json"), Core.atlas); Mathf.each(font -> { font.setUseIntegerPositions(false); - font.getData().setScale(Vars.fontscale); + font.getData().setScale(Vars.fontScale); font.getData().down += Unit.dp.scl(4f); font.getData().lineHeight -= Unit.dp.scl(2f); }, skin.font(), skin.getFont("default-font-chat"), skin.getFont("korean")); diff --git a/core/src/io/anuke/mindustry/entities/Player.java b/core/src/io/anuke/mindustry/entities/Player.java index 98a4eb0bc0..36454470e1 100644 --- a/core/src/io/anuke/mindustry/entities/Player.java +++ b/core/src/io/anuke/mindustry/entities/Player.java @@ -242,7 +242,7 @@ public class Player extends Unit implements BlockBuilder { Draw.reset(); Pools.free(layout); - Draw.tscl(fontscale); + Draw.tscl(fontScale); } public void drawBuildRequests(){ diff --git a/core/src/io/anuke/mindustry/graphics/OverlayRenderer.java b/core/src/io/anuke/mindustry/graphics/OverlayRenderer.java index 6590d35f91..430b57a59c 100644 --- a/core/src/io/anuke/mindustry/graphics/OverlayRenderer.java +++ b/core/src/io/anuke/mindustry/graphics/OverlayRenderer.java @@ -70,7 +70,7 @@ public class OverlayRenderer { Draw.color(0f, 0f, 0f, 0.5f); Fill.rect(target.drawx(), target.drawy(), v.x, v.y); Draw.textc(result.toString(), target.drawx(), target.drawy(), v); - Draw.tscl(fontscale); + Draw.tscl(fontScale); Draw.reset(); } diff --git a/core/src/io/anuke/mindustry/graphics/Shaders.java b/core/src/io/anuke/mindustry/graphics/Shaders.java index a2e822af9f..c71c64b1c9 100644 --- a/core/src/io/anuke/mindustry/graphics/Shaders.java +++ b/core/src/io/anuke/mindustry/graphics/Shaders.java @@ -3,7 +3,6 @@ package io.anuke.mindustry.graphics; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.g2d.TextureRegion; -import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.utils.FloatArray; import io.anuke.ucore.core.Core; import io.anuke.ucore.core.Timers; @@ -14,18 +13,29 @@ import static io.anuke.mindustry.Vars.tilesize; import static io.anuke.mindustry.Vars.world; public class Shaders{ - public static final Outline outline = new Outline(); - public static final BlockBuild blockbuild = new BlockBuild(); - public static final BlockPreview blockpreview = new BlockPreview(); - public static final Shield shield = new Shield(); - public static final SurfaceShader water = new SurfaceShader("water"); - public static final SurfaceShader lava = new SurfaceShader("lava"); - public static final SurfaceShader oil = new SurfaceShader("oil"); - public static final Space space = new Space(); - public static final UnitBuild build = new UnitBuild(); - public static final Shader hit = new Shader("hit", "default"); + public static Outline outline; + public static BlockBuild blockbuild; + public static BlockPreview blockpreview; + public static Shield shield; + public static SurfaceShader water; + public static SurfaceShader lava; + public static SurfaceShader oil; + public static Space space; + public static UnitBuild build; + public static Shader hit; - private static final Vector2 vec = new Vector2(); + public static void init(){ + outline = new Outline(); + blockbuild = new BlockBuild(); + blockpreview = new BlockPreview(); + shield = new Shield(); + water = new SurfaceShader("water"); + lava = new SurfaceShader("lava"); + oil = new SurfaceShader("oil"); + space = new Space(); + build = new UnitBuild(); + hit = new Shader("hit", "default"); + } public static class Space extends SurfaceShader{ @@ -70,7 +80,7 @@ public class Shaders{ @Override public void apply(){ shader.setUniformf("u_color", color); - shader.setUniformf("u_texsize", vec.set(region.getTexture().getWidth(), region.getTexture().getHeight())); + shader.setUniformf("u_texsize", region.getTexture().getWidth(), region.getTexture().getHeight()); } } diff --git a/core/src/io/anuke/mindustry/input/AndroidInput.java b/core/src/io/anuke/mindustry/input/AndroidInput.java index d8c9f65003..7ee9e674a0 100644 --- a/core/src/io/anuke/mindustry/input/AndroidInput.java +++ b/core/src/io/anuke/mindustry/input/AndroidInput.java @@ -2,12 +2,14 @@ package io.anuke.mindustry.input; import com.badlogic.gdx.input.GestureDetector; import com.badlogic.gdx.input.GestureDetector.GestureListener; +import com.badlogic.gdx.math.Rectangle; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.utils.Array; import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.entities.Player; import io.anuke.mindustry.graphics.Palette; import io.anuke.mindustry.type.Recipe; +import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Tile; import io.anuke.ucore.core.Core; import io.anuke.ucore.core.Graphics; @@ -23,6 +25,8 @@ import io.anuke.ucore.util.Mathf; import static io.anuke.mindustry.Vars.*; public class AndroidInput extends InputHandler implements GestureListener{ + private static Rectangle r1 = new Rectangle(), r2 = new Rectangle(); + //gesture data private Vector2 pinch1 = new Vector2(-1, -1), pinch2 = pinch1.cpy(); private Vector2 vector = new Vector2(); @@ -39,13 +43,51 @@ public class AndroidInput extends InputHandler implements GestureListener{ Inputs.addProcessor(new GestureDetector(20, 0.5f, 2, 0.15f, this)); } + /**Returns whether this tile is in the list of requests, or at least colliding with one.*/ boolean hasRequest(Tile tile){ + return getRequest(tile) != null; + } + + /**Returns whether this block overlaps any placement requests.*/ + boolean checkOverlapPlacement(int x, int y, Block block){ + r2.setSize(block.size * tilesize); + r2.setCenter(x * tilesize + block.offset(), y * tilesize + block.offset()); + for(PlaceRequest req : placement){ - if(req.tile() == tile) return true; + Tile other = req.tile(); + + if(other == null) continue; + + r1.setSize(req.recipe.result.size * tilesize); + r1.setCenter(other.worldx() + req.recipe.result.offset(), other.worldy() + req.recipe.result.offset()); + + if(r2.overlaps(r1)){ + return true; + } } return false; } + /**Returns the placement request that overlaps this tile, or null.*/ + PlaceRequest getRequest(Tile tile){ + r2.setSize(tilesize); + r2.setCenter(tile.worldx(), tile.worldy()); + + for(PlaceRequest req : placement){ + Tile other = req.tile(); + + if(other == null) continue; + + r1.setSize(req.recipe.result.size * tilesize); + r1.setCenter(other.worldx() + req.recipe.result.offset(), other.worldy() + req.recipe.result.offset()); + + if(r2.overlaps(r1)){ + return req; + } + } + return null; + } + @Override public void buildUI(Group group) { @@ -122,6 +164,24 @@ public class AndroidInput extends InputHandler implements GestureListener{ return false; } + @Override + public boolean longPress(float x, float y) { + if(state.is(State.menu)) return false; + + //get tile on cursor + Tile cursor = world.tile(Mathf.scl2(Graphics.mouseWorld().x, tilesize), Mathf.scl2(Graphics.mouseWorld().y, tilesize)); + + //ignore off-screen taps + if(cursor == null || ui.hasMouse(x, y)) return false; + + //remove request if it's there + if(hasRequest(cursor)){ + placement.removeValue(getRequest(cursor), true); + } + + return false; + } + @Override public boolean tap(float x, float y, int count, int button) { if(state.is(State.menu)) return false; @@ -133,7 +193,7 @@ public class AndroidInput extends InputHandler implements GestureListener{ if(cursor == null || ui.hasMouse(x, y)) return false; //add to placement queue if it's a valid place position - if(isPlacing() && validPlace(cursor.x, cursor.y, recipe.result)){ + if(isPlacing() && validPlace(cursor.x, cursor.y, recipe.result) && !checkOverlapPlacement(cursor.x, cursor.y, recipe.result)){ placement.add(new PlaceRequest(cursor.worldx(), cursor.worldy(), recipe, rotation)); } @@ -215,7 +275,6 @@ public class AndroidInput extends InputHandler implements GestureListener{ } @Override public boolean touchDown(float x, float y, int pointer, int button) { return false; } - @Override public boolean longPress(float x, float y) { return false; } @Override public boolean fling(float velocityX, float velocityY, int button) { return false; } class PlaceRequest{ diff --git a/core/src/io/anuke/mindustry/input/InputHandler.java b/core/src/io/anuke/mindustry/input/InputHandler.java index 5a6c01a91f..c346d12b4b 100644 --- a/core/src/io/anuke/mindustry/input/InputHandler.java +++ b/core/src/io/anuke/mindustry/input/InputHandler.java @@ -25,8 +25,8 @@ import io.anuke.ucore.util.Translator; import static io.anuke.mindustry.Vars.*; public abstract class InputHandler extends InputAdapter{ - public final static float playerSelectRange = Unit.dp.scl(60f); - private final static Translator stackTrns = new Translator(); + float playerSelectRange = Unit.dp.scl(60f); + Translator stackTrns = new Translator(); private float mx, my; diff --git a/core/src/io/anuke/mindustry/io/Version.java b/core/src/io/anuke/mindustry/io/Version.java index 6328d20ba6..473d266b0d 100644 --- a/core/src/io/anuke/mindustry/io/Version.java +++ b/core/src/io/anuke/mindustry/io/Version.java @@ -9,13 +9,13 @@ import io.anuke.ucore.util.Strings; import java.io.IOException; public class Version { - public static final String name; - public static final String type; - public static final String code; - public static final int build; - public static final String buildName; + public static String name; + public static String type; + public static String code; + public static int build; + public static String buildName; - static{ + public static void init(){ try { FileHandle file = Gdx.files.internal("version.properties"); diff --git a/core/src/io/anuke/mindustry/net/ClientDebug.java b/core/src/io/anuke/mindustry/net/ClientDebug.java deleted file mode 100644 index 60b0eb0bdf..0000000000 --- a/core/src/io/anuke/mindustry/net/ClientDebug.java +++ /dev/null @@ -1,51 +0,0 @@ -package io.anuke.mindustry.net; - -import com.badlogic.gdx.utils.OrderedMap; -import com.badlogic.gdx.utils.TimeUtils; -import com.badlogic.gdx.utils.reflect.ClassReflection; - -public class ClientDebug { - private OrderedMap, Long> last = new OrderedMap<>(); - private int syncPlayers = 0; - private int syncEnemies = 0; - - public void handle(Object packet){ - last.put(packet.getClass(), TimeUtils.millis()); - } - - public void setSyncDebug(int players, int enemies){ - this.syncEnemies = enemies; - this.syncPlayers = players; - } - - public String getOut(){ - StringBuilder build = new StringBuilder(); - for(Class type : last.orderedKeys()){ - build.append(elapsed(type)); - build.append("\n"); - } - build.append("sync.players: "); - build.append(syncPlayers); - build.append("\n"); - build.append("sync.enemies: "); - build.append(syncEnemies); - build.append("\n"); - return build.toString(); - } - - private String elapsed(Class type){ - long t = last.get(type, -1L); - if(t == -1){ - return ClassReflection.getSimpleName(type) + ": "; - }else{ - float el = TimeUtils.timeSinceMillis(t) / 1000f; - String tu; - if(el > 1f){ - tu = (int)el + "s"; - }else{ - tu = (int)(el * 60) + "f"; - } - return ClassReflection.getSimpleName(type) + ": " + tu; - } - } -} diff --git a/core/src/io/anuke/mindustry/net/Net.java b/core/src/io/anuke/mindustry/net/Net.java index 65cd539956..f01f82d140 100644 --- a/core/src/io/anuke/mindustry/net/Net.java +++ b/core/src/io/anuke/mindustry/net/Net.java @@ -163,7 +163,6 @@ public class Net{ /**Call to handle a packet being recieved for the client.*/ public static void handleClientReceived(Object object){ - if(debugNet) clientDebug.handle(object); if(object instanceof StreamBegin) { StreamBegin b = (StreamBegin) object; @@ -198,7 +197,6 @@ public class Net{ /**Call to handle a packet being recieved for the server.*/ public static void handleServerReceived(int connection, Object object){ - if(debugNet) serverDebug.handle(connection, object); if(serverListeners.get(object.getClass()) != null || listeners.get(object.getClass()) != null){ if(serverListeners.get(object.getClass()) != null) serverListeners.get(object.getClass()).accept(connection, object); diff --git a/core/src/io/anuke/mindustry/net/ServerDebug.java b/core/src/io/anuke/mindustry/net/ServerDebug.java deleted file mode 100644 index 6623d602fc..0000000000 --- a/core/src/io/anuke/mindustry/net/ServerDebug.java +++ /dev/null @@ -1,65 +0,0 @@ -package io.anuke.mindustry.net; - -import com.badlogic.gdx.utils.IntMap; -import com.badlogic.gdx.utils.OrderedMap; -import com.badlogic.gdx.utils.TimeUtils; -import com.badlogic.gdx.utils.reflect.ClassReflection; -import io.anuke.mindustry.entities.Player; -import io.anuke.mindustry.net.Packets.Disconnect; -import io.anuke.ucore.util.Log; - -import static io.anuke.mindustry.Vars.playerGroup; - -public class ServerDebug { - private IntMap, Long>> last = new IntMap<>(); - - public void handle(int connection, Object packet){ - try { - if (!last.containsKey(connection)) - last.put(connection, new OrderedMap<>()); - if (packet instanceof Disconnect) - last.remove(connection); - else - last.get(connection).put(packet.getClass(), TimeUtils.millis()); - }catch (Exception e){ - Log.err(""); - } - } - - public String getOut(){ - StringBuilder build = new StringBuilder(); - for(Player player : playerGroup.all()){ - OrderedMap, Long> map = last.get(player.clientid, new OrderedMap<>()); - build.append("connection "); - build.append(player.clientid); - build.append(" / player '"); - build.append(player.name); - build.append(" mech: "); - build.append(player.mech); - build.append("'\n"); - - for(Class type : map.orderedKeys()){ - build.append(" "); - build.append(elapsed(type, map)); - build.append("\n"); - } - } - return build.toString(); - } - - private String elapsed(Class type, OrderedMap, Long> last) { - long t = last.get(type, -1L); - if (t == -1) { - return ClassReflection.getSimpleName(type) + ": "; - } else { - float el = TimeUtils.timeSinceMillis(t) / 1000f; - String tu; - if (el > 1f) { - tu = (int) el + "s"; - } else { - tu = (int) (el * 60) + "f"; - } - return ClassReflection.getSimpleName(type) + ": " + tu; - } - } -} diff --git a/core/src/io/anuke/mindustry/type/ContentList.java b/core/src/io/anuke/mindustry/type/ContentList.java new file mode 100644 index 0000000000..8c00817a83 --- /dev/null +++ b/core/src/io/anuke/mindustry/type/ContentList.java @@ -0,0 +1,5 @@ +package io.anuke.mindustry.type; + +public interface ContentList { + void load(); +} diff --git a/core/src/io/anuke/mindustry/ui/Links.java b/core/src/io/anuke/mindustry/ui/Links.java index facbcf45e7..517083b91f 100644 --- a/core/src/io/anuke/mindustry/ui/Links.java +++ b/core/src/io/anuke/mindustry/ui/Links.java @@ -4,17 +4,25 @@ import com.badlogic.gdx.graphics.Color; import io.anuke.ucore.util.Bundles; public class Links { - private static final LinkEntry[] links = { - new LinkEntry("discord", "https://discord.gg/BKADYds", 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://github.com/Anuken/Mindustry/wiki", Color.valueOf("fafbfc")), - }; + private static LinkEntry[] links; + + private static void createLinks(){ + links = new LinkEntry[]{ + new LinkEntry("discord", "https://discord.gg/BKADYds", 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://github.com/Anuken/Mindustry/wiki", Color.valueOf("fafbfc")) + }; + } public static LinkEntry[] getLinks(){ + if(links == null){ + createLinks(); + } + return links; } diff --git a/core/src/io/anuke/mindustry/ui/fragments/DebugFragment.java b/core/src/io/anuke/mindustry/ui/fragments/DebugFragment.java index 587edb3eb7..75f0d1fb72 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/DebugFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/DebugFragment.java @@ -141,8 +141,7 @@ public class DebugFragment implements Fragment { "tiles.sleeping: " + TileEntity.sleepingEntities, "time: " + Timers.time(), "state.gameover: " + state.gameOver, - "state: " + state.getState(), - !Net.server() ? clientDebug.getOut() : serverDebug.getOut() + "state: " + state.getState() ); result.append("players: "); diff --git a/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java b/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java index 927078b5ee..5855ff5057 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java @@ -213,7 +213,7 @@ public class HudFragment implements Fragment{ new table(){{ aleft(); - new label(() -> Bundles.format("text.wave", state.wave)).scale(fontscale*1.5f).left().padLeft(-6); + new label(() -> Bundles.format("text.wave", state.wave)).scale(fontScale *1.5f).left().padLeft(-6); row(); diff --git a/core/src/io/anuke/mindustry/ui/fragments/MenuFragment.java b/core/src/io/anuke/mindustry/ui/fragments/MenuFragment.java index 81ab6a12d8..e38c2b4bd8 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/MenuFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/MenuFragment.java @@ -58,7 +58,7 @@ public class MenuFragment implements Fragment{ new imagebutton("icon-play-2", isize, ui.levels::show).text("$text.play").padTop(4f); - new imagebutton("icon-tutorial", isize, () -> control.playMap(world.maps().getByName("tutorial"))).text("$text.tutorial").padTop(4f); + new imagebutton("icon-tutorial", isize, () -> {}).text("$text.tutorial").padTop(4f); new imagebutton("icon-load", isize, ui.load::show).text("$text.load").padTop(4f); @@ -123,10 +123,7 @@ public class MenuFragment implements Fragment{ ui.showInfo("$text.multiplayer.web"); } })); - dialog.content().add(new MenuButton("icon-tutorial", "$text.tutorial", ()-> { - control.playMap(world.maps().getByName("tutorial")); - dialog.hide(); - })); + dialog.content().add(new MenuButton("icon-tutorial", "$text.tutorial", ()-> {})); dialog.content().row(); diff --git a/core/src/io/anuke/mindustry/world/ColorMapper.java b/core/src/io/anuke/mindustry/world/ColorMapper.java index cffa220765..bdb3a09401 100644 --- a/core/src/io/anuke/mindustry/world/ColorMapper.java +++ b/core/src/io/anuke/mindustry/world/ColorMapper.java @@ -16,51 +16,48 @@ public class ColorMapper{ private static ObjectIntMap reverseColors = new ObjectIntMap<>(); private static Array pairs = new Array<>(); - private static IntMap colors = map( - "323232", pair(Blocks.stone), - "646464", pair(Blocks.stone, Blocks.stoneblock), - "50965a", pair(Blocks.grass), - "5ab464", pair(Blocks.grass, Blocks.grassblock), - "506eb4", pair(Blocks.water), - "465a96", pair(Blocks.deepwater), - "252525", pair(Blocks.blackstone), - "575757", pair(Blocks.blackstone, Blocks.blackstoneblock), - "988a67", pair(Blocks.sand), - "e5d8bb", pair(Blocks.sand, Blocks.sandblock), - "c2d1d2", pair(Blocks.snow), - "c4e3e7", pair(Blocks.ice), - "f7feff", pair(Blocks.snow, Blocks.snowblock), - "6e501e", pair(Blocks.dirt), - "ed5334", pair(Blocks.lava), - "292929", pair(Blocks.oil), - "c3a490", pair(Blocks.iron), - "161616", pair(Blocks.coal), - "6277bc", pair(Blocks.titanium), - "83bc58", pair(Blocks.thorium), - "000000", pair(Blocks.space) - ); + private static IntMap colors; + + private static void init(){ + if(colors != null) return; + + colors = map( + "323232", pair(Blocks.stone), + "646464", pair(Blocks.stone, Blocks.stoneblock), + "50965a", pair(Blocks.grass), + "5ab464", pair(Blocks.grass, Blocks.grassblock), + "506eb4", pair(Blocks.water), + "465a96", pair(Blocks.deepwater), + "252525", pair(Blocks.blackstone), + "575757", pair(Blocks.blackstone, Blocks.blackstoneblock), + "988a67", pair(Blocks.sand), + "e5d8bb", pair(Blocks.sand, Blocks.sandblock), + "c2d1d2", pair(Blocks.snow), + "c4e3e7", pair(Blocks.ice), + "f7feff", pair(Blocks.snow, Blocks.snowblock), + "6e501e", pair(Blocks.dirt), + "ed5334", pair(Blocks.lava), + "292929", pair(Blocks.oil), + "c3a490", pair(Blocks.iron), + "161616", pair(Blocks.coal), + "6277bc", pair(Blocks.titanium), + "83bc58", pair(Blocks.thorium), + "000000", pair(Blocks.space) + ); + } public static BlockPair get(int color){ + init(); return colors.get(color); } - - public static int getColorByID(byte id){ - return colorIDS[id]; - } - - public static byte getColorID(int color){ - return (byte)reverseIDs.get(color, -1); - } - - public static IntMap getColors(){ - return colors; - } public static Array getPairs(){ + init(); return pairs; } public static int getColor(Block block){ + init(); return reverseColors.get(block, 0); } diff --git a/core/src/io/anuke/mindustry/world/WorldGenerator.java b/core/src/io/anuke/mindustry/world/WorldGenerator.java index 61c3dee83a..3006329b0f 100644 --- a/core/src/io/anuke/mindustry/world/WorldGenerator.java +++ b/core/src/io/anuke/mindustry/world/WorldGenerator.java @@ -1,7 +1,6 @@ package io.anuke.mindustry.world; import com.badlogic.gdx.utils.IntArray; -import com.badlogic.gdx.utils.ObjectMap; import io.anuke.mindustry.content.blocks.Blocks; import io.anuke.mindustry.content.blocks.StorageBlocks; import io.anuke.mindustry.game.Team; @@ -14,12 +13,6 @@ import static io.anuke.mindustry.Vars.world; public class WorldGenerator { - public static final ObjectMap rocks = new ObjectMap(){{ - put(Blocks.stone, Blocks.rock); - put(Blocks.snow, Blocks.icerock); - put(Blocks.grass, Blocks.shrub); - put(Blocks.blackstone, Blocks.blackrock); - }}; /**Should fill spawns with the correct spawnpoints.*/ public static void generate(Tile[][] tiles, MapTileData data){ diff --git a/desktop/src/io/anuke/mindustry/desktop/CrashHandler.java b/desktop/src/io/anuke/mindustry/desktop/CrashHandler.java index ed1d06582f..9728956bdf 100644 --- a/desktop/src/io/anuke/mindustry/desktop/CrashHandler.java +++ b/desktop/src/io/anuke/mindustry/desktop/CrashHandler.java @@ -3,8 +3,6 @@ package io.anuke.mindustry.desktop; import io.anuke.mindustry.net.Net; import io.anuke.ucore.util.Strings; -import javax.swing.*; -import java.io.File; import java.nio.file.Files; import java.nio.file.Paths; import java.text.SimpleDateFormat; @@ -42,9 +40,9 @@ public class CrashHandler { } try{ - JOptionPane.showMessageDialog(null, "An error has occured: \n" + result + "\n\n" + - (!failed ? "A crash report has been written to " + new File(filename).getAbsolutePath() + ".\nPlease send this file to the developer!" - : "Failed to generate crash report.\nPlease send an image of this crash log to the developer!")); + //JOptionPane.showMessageDialog(null, "An error has occured: \n" + result + "\n\n" + + // (!failed ? "A crash report has been written to " + new File(filename).getAbsolutePath() + ".\nPlease send this file to the developer!" + // : "Failed to generate crash report.\nPlease send an image of this crash log to the developer!")); }catch (Throwable i){ i.printStackTrace(); //what now? diff --git a/desktop/src/io/anuke/mindustry/desktop/DesktopPlatform.java b/desktop/src/io/anuke/mindustry/desktop/DesktopPlatform.java index 1242c38e67..3571c8bceb 100644 --- a/desktop/src/io/anuke/mindustry/desktop/DesktopPlatform.java +++ b/desktop/src/io/anuke/mindustry/desktop/DesktopPlatform.java @@ -6,14 +6,12 @@ import club.minnced.discord.rpc.DiscordRichPresence; import com.badlogic.gdx.utils.Base64Coder; import io.anuke.kryonet.DefaultThreadImpl; import io.anuke.mindustry.core.GameState.State; -import io.anuke.mindustry.core.ThreadHandler.ThreadProvider; import io.anuke.mindustry.core.Platform; +import io.anuke.mindustry.core.ThreadHandler.ThreadProvider; import io.anuke.mindustry.net.Net; import io.anuke.ucore.core.Settings; -import io.anuke.ucore.util.OS; import io.anuke.ucore.util.Strings; -import javax.swing.*; import java.net.NetworkInterface; import java.text.DateFormat; import java.text.NumberFormat; @@ -26,7 +24,7 @@ import java.util.Random; import static io.anuke.mindustry.Vars.*; public class DesktopPlatform extends Platform { - final static boolean useDiscord = OS.getPropertyNotNull("sun.arch.data.model").equals("64"); + final static boolean useDiscord = false;//OS.getPropertyNotNull("sun.arch.data.model").equals("64"); final static String applicationId = "398246104468291591"; final static DateFormat format = SimpleDateFormat.getDateTimeInstance(); String[] args; @@ -52,7 +50,7 @@ public class DesktopPlatform extends Platform { @Override public void showError(String text){ - JOptionPane.showMessageDialog(null, text); + //JOptionPane.showMessageDialog(null, text); } @Override diff --git a/kryonet/src/io/anuke/kryonet/KryoServer.java b/kryonet/src/io/anuke/kryonet/KryoServer.java index 99ca100f44..f9cdbb81fb 100644 --- a/kryonet/src/io/anuke/kryonet/KryoServer.java +++ b/kryonet/src/io/anuke/kryonet/KryoServer.java @@ -157,7 +157,6 @@ public class KryoServer implements ServerProvider { @Override public void close() { - UCore.setPrivate(server, "shutdown", true); connections.clear(); lastconnection = 0; diff --git a/server/src/io/anuke/mindustry/server/MindustryServer.java b/server/src/io/anuke/mindustry/server/MindustryServer.java index 7f1635ed3e..e6858fd124 100644 --- a/server/src/io/anuke/mindustry/server/MindustryServer.java +++ b/server/src/io/anuke/mindustry/server/MindustryServer.java @@ -1,10 +1,7 @@ package io.anuke.mindustry.server; -import io.anuke.mindustry.core.Logic; -import io.anuke.mindustry.core.NetCommon; -import io.anuke.mindustry.core.NetServer; -import io.anuke.mindustry.core.World; -import io.anuke.mindustry.core.ContentLoader; +import io.anuke.mindustry.Vars; +import io.anuke.mindustry.core.*; import io.anuke.mindustry.io.BundleLoader; import io.anuke.ucore.modules.ModuleCore; @@ -19,6 +16,8 @@ public class MindustryServer extends ModuleCore { @Override public void init(){ + Vars.init(); + headless = true; BundleLoader.load();