From 36b9451e01afc75dacfd280160ec8624f8d055b2 Mon Sep 17 00:00:00 2001 From: Anuken Date: Tue, 4 Feb 2020 12:14:09 -0500 Subject: [PATCH] Read-only component fields / Removed get/set prefix --- .../mindustry/annotations/Annotations.java | 6 + .../annotations/impl/EntityProcess.java | 26 +- .../mindustry/annotations/util/Selement.java | 5 + .../mindustry/annotations/util/Smethod.java | 4 + core/src/mindustry/ai/BlockIndexer.java | 16 +- core/src/mindustry/ai/WaveSpawner.java | 3 +- core/src/mindustry/content/Blocks.java | 6 +- core/src/mindustry/content/Bullets.java | 4 +- core/src/mindustry/content/Mechs.java | 6 +- core/src/mindustry/content/StatusEffects.java | 3 +- core/src/mindustry/core/Control.java | 29 +- core/src/mindustry/core/Logic.java | 11 +- core/src/mindustry/core/NetClient.java | 5 +- core/src/mindustry/core/NetServer.java | 15 +- core/src/mindustry/core/Renderer.java | 9 +- core/src/mindustry/editor/EditorTile.java | 6 +- .../src/mindustry/editor/MapEditorDialog.java | 2 +- core/src/mindustry/entities/Damage.java | 3 +- .../mindustry/entities/EntityCollisions.java | 28 +- core/src/mindustry/entities/Units.java | 8 +- .../mindustry/entities/bullet/BulletType.java | 19 +- .../entities/bullet/FlakBulletType.java | 2 +- .../entities/bullet/HealBulletType.java | 4 +- .../entities/bullet/LaserBulletType.java | 2 +- .../entities/bullet/LightningBulletType.java | 2 +- .../mindustry/entities/def/EntityComps.java | 248 +++++++++++------- .../entities/effect/ItemTransfer.java | 5 +- core/src/mindustry/entities/type/Player.java | 36 +-- .../entities/type/base/BuilderDrone.java | 6 +- .../entities/type/base/MinerDrone.java | 2 +- core/src/mindustry/game/MusicControl.java | 2 +- core/src/mindustry/game/Teams.java | 5 +- .../src/mindustry/graphics/BlockRenderer.java | 6 +- .../mindustry/graphics/OverlayRenderer.java | 22 +- core/src/mindustry/input/DesktopInput.java | 6 +- core/src/mindustry/input/InputHandler.java | 22 +- core/src/mindustry/input/MobileInput.java | 12 +- .../maps/generators/MapGenerator.java | 2 +- core/src/mindustry/type/StatusEffect.java | 2 +- core/src/mindustry/type/UnitDef.java | 3 +- core/src/mindustry/ui/ItemsDisplay.java | 4 +- .../mindustry/ui/dialogs/GameOverDialog.java | 2 +- .../ui/fragments/BlockInventoryFragment.java | 18 +- .../mindustry/ui/fragments/HudFragment.java | 9 +- .../ui/fragments/PlacementFragment.java | 11 +- .../ui/fragments/PlayerListFragment.java | 4 +- core/src/mindustry/world/Block.java | 66 ++--- core/src/mindustry/world/BlockStorage.java | 59 ++--- core/src/mindustry/world/Tile.java | 12 +- .../mindustry/world/blocks/BuildBlock.java | 8 +- .../mindustry/world/blocks/LiquidBlock.java | 2 +- .../world/blocks/defense/SurgeWall.java | 2 +- .../blocks/defense/turrets/CooledTurret.java | 9 +- .../blocks/defense/turrets/LaserTurret.java | 8 +- .../blocks/defense/turrets/LiquidTurret.java | 25 +- .../blocks/defense/turrets/PowerTurret.java | 2 +- .../world/blocks/defense/turrets/Turret.java | 6 +- .../world/blocks/distribution/Conveyor.java | 3 +- .../world/blocks/distribution/ItemBridge.java | 6 +- .../world/blocks/distribution/MassDriver.java | 6 +- .../blocks/distribution/OverflowGate.java | 10 +- .../world/blocks/distribution/Router.java | 10 +- .../world/blocks/liquid/Conduit.java | 9 +- .../world/blocks/liquid/LiquidRouter.java | 6 +- .../world/blocks/power/ImpactReactor.java | 2 +- .../blocks/power/ItemLiquidGenerator.java | 19 +- .../world/blocks/power/NuclearReactor.java | 12 +- .../world/blocks/power/PowerDiode.java | 6 +- .../world/blocks/power/PowerGraph.java | 28 +- .../world/blocks/power/PowerNode.java | 42 +-- .../world/blocks/production/Drill.java | 11 +- .../world/blocks/production/Fracker.java | 6 +- .../blocks/production/GenericCrafter.java | 7 +- .../blocks/production/LiquidConverter.java | 8 +- .../world/blocks/production/Pump.java | 16 +- .../world/blocks/production/Separator.java | 8 +- .../world/blocks/production/SolidPump.java | 10 +- .../world/blocks/sandbox/LiquidSource.java | 5 +- .../world/blocks/storage/CoreBlock.java | 25 +- .../world/blocks/storage/LaunchPad.java | 12 +- .../world/blocks/storage/StorageBlock.java | 12 +- .../world/blocks/storage/Unloader.java | 6 +- .../mindustry/world/blocks/units/MechPad.java | 5 +- .../world/blocks/units/RepairPoint.java | 2 +- .../world/consumers/ConsumeItemFilter.java | 3 +- .../world/consumers/ConsumeItems.java | 3 +- .../world/consumers/ConsumeLiquidFilter.java | 6 +- .../world/consumers/ConsumePower.java | 8 +- .../src/mindustry/desktop/steam/SStats.java | 17 +- .../src/mindustry/server/ServerControl.java | 4 +- tests/src/test/java/ApplicationTests.java | 19 +- .../java/power/ItemLiquidGeneratorTests.java | 10 +- .../src/test/java/power/PowerTestFixture.java | 12 +- 93 files changed, 637 insertions(+), 587 deletions(-) diff --git a/annotations/src/main/java/mindustry/annotations/Annotations.java b/annotations/src/main/java/mindustry/annotations/Annotations.java index d78d05aa5e..4cb52fe87a 100644 --- a/annotations/src/main/java/mindustry/annotations/Annotations.java +++ b/annotations/src/main/java/mindustry/annotations/Annotations.java @@ -5,6 +5,12 @@ import java.lang.annotation.*; public class Annotations{ //region entity interfaces + /** Indicates that a component field is read-only. */ + @Target(ElementType.FIELD) + @Retention(RetentionPolicy.SOURCE) + public @interface ReadOnly{ + } + /** Indicates multiple inheritance on a component type. */ @Target(ElementType.TYPE) @Retention(RetentionPolicy.SOURCE) diff --git a/annotations/src/main/java/mindustry/annotations/impl/EntityProcess.java b/annotations/src/main/java/mindustry/annotations/impl/EntityProcess.java index 6a63b40d1b..05eefc1645 100644 --- a/annotations/src/main/java/mindustry/annotations/impl/EntityProcess.java +++ b/annotations/src/main/java/mindustry/annotations/impl/EntityProcess.java @@ -76,11 +76,14 @@ public class EntityProcess extends BaseProcessor{ } for(Svar field : component.fields().select(e -> !e.is(Modifier.STATIC) && !e.is(Modifier.PRIVATE) && !e.is(Modifier.TRANSIENT))){ - String cname = Strings.capitalize(field.name()); + String cname = field.name(); //getter - inter.addMethod(MethodSpec.methodBuilder((field.mirror().toString().equals("boolean") ? "is" : "get") + cname).addModifiers(Modifier.ABSTRACT, Modifier.PUBLIC).returns(field.tname()).build()); + inter.addMethod(MethodSpec.methodBuilder(cname).addModifiers(Modifier.ABSTRACT, Modifier.PUBLIC).returns(field.tname()).build()); + //setter - if(!field.is(Modifier.FINAL)) inter.addMethod(MethodSpec.methodBuilder("set" + cname).addModifiers(Modifier.ABSTRACT, Modifier.PUBLIC).addParameter(field.tname(), field.name()).build()); + if(!field.is(Modifier.FINAL) && !field.annotations().contains(f -> f.toString().equals("@mindustry.annotations.Annotations.ReadOnly"))){ + inter.addMethod(MethodSpec.methodBuilder(cname).addModifiers(Modifier.ABSTRACT, Modifier.PUBLIC).addParameter(field.tname(), field.name()).build()); + } } //add utility methods to interface @@ -128,6 +131,8 @@ public class EntityProcess extends BaseProcessor{ if(tree.getInitializer() != null){ fbuilder.initializer(tree.getInitializer().toString()); } + + builder.addAnnotations(f.annotations().map(AnnotationSpec::get)); builder.addField(fbuilder.build()); } @@ -245,15 +250,18 @@ public class EntityProcess extends BaseProcessor{ //generate getter/setter for each method for(Smethod method : inter.methods()){ - if(method.name().length() <= 3) continue; - - String var = Strings.camelize(method.name().substring(method.name().startsWith("is") ? 2 : 3)); + String var = method.name(); + FieldSpec field = Array.with(def.builder.fieldSpecs).find(f -> f.name.equals(var)); //make sure it's a real variable AND that the component doesn't already implement it with custom logic - if(!Array.with(def.builder.fieldSpecs).contains(f -> f.name.equals(var)) || comp.methods().contains(m -> m.name().equals(method.name()))) continue; + if(field == null || comp.methods().contains(m -> m.name().equals(method.name()))) continue; - if(method.name().startsWith("get") || method.name().startsWith("is")){ + //getter + if(!method.isVoid()){ def.builder.addMethod(MethodSpec.overriding(method.e).addStatement("return " + var).build()); - }else if(method.name().startsWith("set")){ + } + + //setter + if(method.isVoid() && !Array.with(field.annotations).contains(f -> f.type.toString().equals("@mindustry.annotations.Annotations.ReadOnly"))){ def.builder.addMethod(MethodSpec.overriding(method.e).addStatement("this." + var + " = " + var).build()); } } diff --git a/annotations/src/main/java/mindustry/annotations/util/Selement.java b/annotations/src/main/java/mindustry/annotations/util/Selement.java index 1e7278188a..f4ec31a39b 100644 --- a/annotations/src/main/java/mindustry/annotations/util/Selement.java +++ b/annotations/src/main/java/mindustry/annotations/util/Selement.java @@ -1,5 +1,6 @@ package mindustry.annotations.util; +import arc.struct.*; import com.squareup.javapoet.*; import mindustry.annotations.*; @@ -14,6 +15,10 @@ public class Selement{ this.e = e; } + public Array annotations(){ + return Array.with(e.getAnnotationMirrors()); + } + public A annotation(Class annotation){ return e.getAnnotation(annotation); } diff --git a/annotations/src/main/java/mindustry/annotations/util/Smethod.java b/annotations/src/main/java/mindustry/annotations/util/Smethod.java index b9687dd728..9077e3157c 100644 --- a/annotations/src/main/java/mindustry/annotations/util/Smethod.java +++ b/annotations/src/main/java/mindustry/annotations/util/Smethod.java @@ -34,6 +34,10 @@ public class Smethod extends Selement{ return Array.with(e.getParameters()).map(Svar::new); } + public boolean isVoid(){ + return ret().toString().equals("void"); + } + public TypeMirror ret(){ return e.getReturnType(); } diff --git a/core/src/mindustry/ai/BlockIndexer.java b/core/src/mindustry/ai/BlockIndexer.java index b3a414c15c..efca527531 100644 --- a/core/src/mindustry/ai/BlockIndexer.java +++ b/core/src/mindustry/ai/BlockIndexer.java @@ -146,7 +146,7 @@ public class BlockIndexer{ ObjectSet set = damagedTiles[team.id]; for(Tile tile : set){ - if((tile.entity == null || tile.entity.getTeam() != team || !tile.entity.damaged()) || tile.block() instanceof BuildBlock){ + if((tile.entity == null || tile.entity.team() != team || !tile.entity.damaged()) || tile.block() instanceof BuildBlock){ returnArray.add(tile); } } @@ -164,7 +164,7 @@ public class BlockIndexer{ } public boolean eachBlock(Teamc team, float range, Boolf pred, Cons cons){ - return eachBlock(team.getTeam(), team.getX(), team.getY(), range, pred, cons); + return eachBlock(team.team(), team.getX(), team.getY(), range, pred, cons); } public boolean eachBlock(Team team, float wx, float wy, float range, Boolf pred, Cons cons){ @@ -213,12 +213,12 @@ public class BlockIndexer{ } public void notifyTileDamaged(Tilec entity){ - if(damagedTiles[(int)entity.getTeam().id] == null){ - damagedTiles[(int)entity.getTeam().id] = new ObjectSet<>(); + if(damagedTiles[(int)entity.team().id] == null){ + damagedTiles[(int)entity.team().id] = new ObjectSet<>(); } - ObjectSet set = damagedTiles[(int)entity.getTeam().id]; - set.add(entity.getTile()); + ObjectSet set = damagedTiles[(int)entity.team().id]; + set.add(entity.tile()); } public Tilec findEnemyTile(Team team, float x, float y, float range, Boolf pred){ @@ -262,9 +262,9 @@ public class BlockIndexer{ float ndst = e.dst2(x, y); if(ndst < range2 && (closest == null || //this one is closer, and it is at least of equal priority - (ndst < dst && (!usePriority || closest.getBlock().priority.ordinal() <= e.getBlock().priority.ordinal())) || + (ndst < dst && (!usePriority || closest.block().priority.ordinal() <= e.block().priority.ordinal())) || //priority is used, and new block has higher priority regardless of range - (usePriority && closest.getBlock().priority.ordinal() < e.getBlock().priority.ordinal()))){ + (usePriority && closest.block().priority.ordinal() < e.block().priority.ordinal()))){ dst = ndst; closest = e; } diff --git a/core/src/mindustry/ai/WaveSpawner.java b/core/src/mindustry/ai/WaveSpawner.java index 3a0de5c0f3..fe25fa96f4 100644 --- a/core/src/mindustry/ai/WaveSpawner.java +++ b/core/src/mindustry/ai/WaveSpawner.java @@ -7,7 +7,6 @@ import arc.struct.*; import arc.util.*; import mindustry.content.*; import mindustry.entities.*; -import mindustry.entities.type.*; import mindustry.game.EventType.*; import mindustry.game.*; import mindustry.world.*; @@ -35,7 +34,7 @@ public class WaveSpawner{ /** @return true if the player is near a ground spawn point. */ public boolean playerNear(){ - return groundSpawns.contains(g -> Mathf.dst(g.x * tilesize, g.y * tilesize, player.x, player.y) < state.rules.dropZoneRadius && player.getTeam() != state.rules.waveTeam); + return groundSpawns.contains(g -> Mathf.dst(g.x * tilesize, g.y * tilesize, player.x, player.y) < state.rules.dropZoneRadius && player.team() != state.rules.waveTeam); } public void spawnEnemies(){ diff --git a/core/src/mindustry/content/Blocks.java b/core/src/mindustry/content/Blocks.java index 9ffcd10858..1c33a1a1fc 100644 --- a/core/src/mindustry/content/Blocks.java +++ b/core/src/mindustry/content/Blocks.java @@ -584,7 +584,7 @@ public class Blocks implements ContentList{ drawIcons = () -> new TextureRegion[]{Core.atlas.find(name + "-bottom"), Core.atlas.find(name + "-top")}; drawer = tile -> { - LiquidModule mod = tile.entity.getLiquids(); + LiquidModule mod = tile.entity.liquids(); int rotation = rotate ? tile.rotation() * 90 : 0; @@ -680,7 +680,7 @@ public class Blocks implements ContentList{ Draw.rect(region, tile.drawx(), tile.drawy()); Draw.rect(reg(frameRegions[(int)Mathf.absin(entity.totalProgress, 5f, 2.999f)]), tile.drawx(), tile.drawy()); - Draw.color(Color.clear, tile.entity.getLiquids().current().color, tile.entity.getLiquids().total() / liquidCapacity); + Draw.color(Color.clear, tile.entity.liquids().current().color, tile.entity.liquids().total() / liquidCapacity); Draw.rect(reg(liquidRegion), tile.drawx(), tile.drawy()); Draw.color(); Draw.rect(reg(topRegion), tile.drawx(), tile.drawy()); @@ -1537,7 +1537,7 @@ public class Blocks implements ContentList{ @Override public void init(Bulletc b){ for(int i = 0; i < rays; i++){ - Damage.collideLine(b, b.getTeam(), hitEffect, b.x, b.y, b.rot(), rayLength - Math.abs(i - (rays / 2)) * 20f); + Damage.collideLine(b, b.team(), hitEffect, b.x, b.y, b.rot(), rayLength - Math.abs(i - (rays / 2)) * 20f); } } diff --git a/core/src/mindustry/content/Bullets.java b/core/src/mindustry/content/Bullets.java index 0462133eda..23bdfe4646 100644 --- a/core/src/mindustry/content/Bullets.java +++ b/core/src/mindustry/content/Bullets.java @@ -513,7 +513,7 @@ public class Bullets implements ContentList{ @Override public void update(Bulletc b){ if(b.timer.get(1, 5f)){ - Damage.collideLine(b, b.getTeam(), hitEffect, b.x, b.y, b.rot(), length, true); + Damage.collideLine(b, b.team(), hitEffect, b.x, b.y, b.rot(), length, true); } Effects.shake(1f, 1f, b.x, b.y); } @@ -587,7 +587,7 @@ public class Bullets implements ContentList{ @Override public void init(Bulletc b){ - Lightning.create(b.getTeam(), Pal.lancerLaser, damage * (b.getOwner() instanceof Player ? state.rules.playerDamageMultiplier : 1f), b.x, b.y, b.rot(), 30); + Lightning.create(b.team(), Pal.lancerLaser, damage * (b.getOwner() instanceof Player ? state.rules.playerDamageMultiplier : 1f), b.x, b.y, b.rot(), 30); } }; diff --git a/core/src/mindustry/content/Mechs.java b/core/src/mindustry/content/Mechs.java index d1be045362..0e3e9f211e 100644 --- a/core/src/mindustry/content/Mechs.java +++ b/core/src/mindustry/content/Mechs.java @@ -191,7 +191,7 @@ public class Mechs implements ContentList{ if(player.timer.get(Player.timerAbility, healReload)){ wasHealed = false; - Units.nearby(player.getTeam(), player.x, player.y, healRange, unit -> { + Units.nearby(player.team(), player.x, player.y, healRange, unit -> { if(unit.health < unit.maxHealth()){ Fx.heal.at(unit); wasHealed = true; @@ -310,7 +310,7 @@ public class Mechs implements ContentList{ if(player.timer.get(Player.timerAbility, effectReload)){ - Units.nearby(player.getTeam(), player.x, player.y, effectRange, unit -> { + Units.nearby(player.team(), player.x, player.y, effectRange, unit -> { //unit.applyEffect(StatusEffects.overdrive, effectDuration); }); @@ -368,7 +368,7 @@ public class Mechs implements ContentList{ float scl = scld(player); if(Mathf.chance(Time.delta() * (0.15 * scl))){ Fx.hitLancer.at(Pal.lancerLaser, player.x, player.y); - Lightning.create(player.getTeam(), Pal.lancerLaser, 10f * Vars.state.rules.playerDamageMultiplier, + Lightning.create(player.team(), Pal.lancerLaser, 10f * Vars.state.rules.playerDamageMultiplier, player.x + player.velocity().x, player.y + player.velocity().y, player.rotation, 14); } } diff --git a/core/src/mindustry/content/StatusEffects.java b/core/src/mindustry/content/StatusEffects.java index 4daec60b0d..7f60d54979 100644 --- a/core/src/mindustry/content/StatusEffects.java +++ b/core/src/mindustry/content/StatusEffects.java @@ -2,7 +2,6 @@ package mindustry.content; import arc.*; import arc.math.Mathf; -import mindustry.entities.Effects; import mindustry.ctype.ContentList; import mindustry.game.EventType.*; import mindustry.type.StatusEffect; @@ -47,7 +46,7 @@ public class StatusEffects implements ContentList{ init(() -> { trans(shocked, ((unit, time, newTime, result) -> { unit.damage(20f); - if(unit.getTeam() == state.rules.waveTeam){ + if(unit.team() == state.rules.waveTeam){ Events.fire(Trigger.shock); } result.set(this, time); diff --git a/core/src/mindustry/core/Control.java b/core/src/mindustry/core/Control.java index c5016e09be..45aea7a816 100644 --- a/core/src/mindustry/core/Control.java +++ b/core/src/mindustry/core/Control.java @@ -17,7 +17,6 @@ import mindustry.entities.type.*; import mindustry.gen.*; import mindustry.game.EventType.*; import mindustry.game.*; -import mindustry.gen.*; import mindustry.input.*; import mindustry.maps.Map; import mindustry.type.*; @@ -64,8 +63,8 @@ public class Control implements ApplicationListener, Loadable{ }); Events.on(PlayEvent.class, event -> { - player.setTeam(netServer.assignTeam(player, playerGroup.all())); - player.setDead(true); + player.team(netServer.assignTeam(player, playerGroup.all())); + player.dead(true); player.add(); state.set(State.playing); @@ -73,9 +72,9 @@ public class Control implements ApplicationListener, Loadable{ Events.on(WorldLoadEvent.class, event -> { Core.app.post(() -> Core.app.post(() -> { - if(net.active() && player.getClosestCore() != null){ + if(net.active() && player.closestCore() != null){ //set to closest core since that's where the player will probably respawn; prevents camera jumps - Core.camera.position.set(player.isDead() ? player.getClosestCore() : player); + Core.camera.position.set(player.dead() ? player.closestCore() : player); }else{ //locally, set to player position since respawning occurs immediately Core.camera.position.set(player); @@ -130,7 +129,7 @@ public class Control implements ApplicationListener, Loadable{ Events.on(UnlockEvent.class, e -> ui.hudfrag.showUnlock(e.content)); Events.on(BlockBuildEndEvent.class, e -> { - if(e.team == player.getTeam()){ + if(e.team == player.team()){ if(e.breaking){ state.stats.buildingsDeconstructed++; }else{ @@ -140,13 +139,13 @@ public class Control implements ApplicationListener, Loadable{ }); Events.on(BlockDestroyEvent.class, e -> { - if(e.tile.getTeam() == player.getTeam()){ + if(e.tile.getTeam() == player.team()){ state.stats.buildingsDestroyed++; } }); Events.on(UnitDestroyEvent.class, e -> { - if(e.unit.getTeam() != player.getTeam()){ + if(e.unit.team() != player.team()){ state.stats.enemyUnitsDestroyed++; } }); @@ -164,13 +163,13 @@ public class Control implements ApplicationListener, Loadable{ }); Events.on(Trigger.newGame, () -> { - Tilec core = player.getClosestCore(); + Tilec core = player.closestCore(); if(core == null) return; app.post(() -> ui.hudfrag.showLand()); renderer.zoomIn(Fx.coreLand.lifetime); - app.post(() -> Fx.coreLand.at(core.getX(), core.getY(), 0, core.getBlock())); + app.post(() -> Fx.coreLand.at(core.getX(), core.getY(), 0, core.block())); Time.run(Fx.coreLand.lifetime, () -> { Fx.launch.at(core); Effects.shake(5f, 5f, core); @@ -259,7 +258,7 @@ public class Control implements ApplicationListener, Loadable{ state.rules.zone = zone; for(Tilec core : state.teams.playerCores()){ for(ItemStack stack : zone.getStartingItems()){ - core.getItems().add(stack.item, stack.amount); + core.items().add(stack.item, stack.amount); } } state.set(State.playing); @@ -308,11 +307,11 @@ public class Control implements ApplicationListener, Loadable{ state.rules.zone = zone; for(Tilec core : state.teams.playerCores()){ for(ItemStack stack : zone.getStartingItems()){ - core.getItems().add(stack.item, stack.amount); + core.items().add(stack.item, stack.amount); } } Tilec core = state.teams.playerCores().first(); - core.getItems().clear(); + core.items().clear(); logic.play(); state.rules.waveTimer = false; @@ -435,9 +434,9 @@ public class Control implements ApplicationListener, Loadable{ input.update(); if(world.isZone()){ - for(Tilec tile : state.teams.cores(player.getTeam())){ + for(Tilec tile : state.teams.cores(player.team())){ for(Item item : content.items()){ - if(tile.getItems().has(item)){ + if(tile.items().has(item)){ data.unlockContent(item); } } diff --git a/core/src/mindustry/core/Logic.java b/core/src/mindustry/core/Logic.java index b14ffe6f6a..e5dd201c59 100644 --- a/core/src/mindustry/core/Logic.java +++ b/core/src/mindustry/core/Logic.java @@ -11,7 +11,6 @@ import mindustry.gen.*; import mindustry.game.EventType.*; import mindustry.game.*; import mindustry.game.Teams.*; -import mindustry.gen.*; import mindustry.type.*; import mindustry.world.*; import mindustry.world.blocks.*; @@ -109,9 +108,9 @@ public class Logic implements ApplicationListener{ for(TeamData team : state.teams.getActive()){ if(team.hasCore()){ Tilec entity = team.core(); - entity.getItems().clear(); + entity.items().clear(); for(ItemStack stack : state.rules.loadout){ - entity.getItems().add(stack.item, stack.amount); + entity.items().add(stack.item, stack.amount); } } } @@ -184,10 +183,10 @@ public class Logic implements ApplicationListener{ Time.runTask(30f, () -> { for(Tilec entity : state.teams.playerCores()){ for(Item item : content.items()){ - data.addItem(item, entity.getItems().get(item)); - Events.fire(new LaunchItemEvent(item, entity.getItems().get(item))); + data.addItem(item, entity.items().get(item)); + Events.fire(new LaunchItemEvent(item, entity.items().get(item))); } - entity.getTile().remove(); + entity.tile().remove(); } state.launched = true; state.gameOver = true; diff --git a/core/src/mindustry/core/NetClient.java b/core/src/mindustry/core/NetClient.java index 14b9fc28eb..5e3f257877 100644 --- a/core/src/mindustry/core/NetClient.java +++ b/core/src/mindustry/core/NetClient.java @@ -318,8 +318,7 @@ public class NetClient implements ApplicationListener{ @Remote(variants = Variant.one) public static void onPositionSet(float x, float y){ - player.x = x; - player.y = y; + player.set(x, y); } @Remote @@ -420,7 +419,7 @@ public class NetClient implements ApplicationListener{ Tile tile = world.tile(pos); if(tile != null && tile.entity != null){ - tile.entity.getItems().read(input); + tile.entity.items().read(input); }else{ new ItemModule().read(input); } diff --git a/core/src/mindustry/core/NetServer.java b/core/src/mindustry/core/NetServer.java index 6cf798e2dd..b5b2b00f9b 100644 --- a/core/src/mindustry/core/NetServer.java +++ b/core/src/mindustry/core/NetServer.java @@ -20,7 +20,6 @@ import mindustry.net.Administration; import mindustry.game.EventType.*; import mindustry.game.*; import mindustry.game.Teams.*; -import mindustry.gen.*; import mindustry.net.*; import mindustry.net.Administration.*; import mindustry.net.Packets.*; @@ -51,7 +50,7 @@ public class NetServer implements ApplicationListener{ TeamData re = state.teams.getActive().min(data -> { int count = 0; for(Player other : players){ - if(other.getTeam() == data.team && other != player){ + if(other.team() == data.team && other != player){ count++; } } @@ -220,7 +219,7 @@ public class NetServer implements ApplicationListener{ con.player = player; //playing in pvp mode automatically assigns players to teams - player.setTeam(assignTeam(player, playerGroup.all())); + player.team(assignTeam(player, playerGroup.all())); sendWorldData(player); @@ -281,7 +280,7 @@ public class NetServer implements ApplicationListener{ }); clientCommands.register("t", "", "Send a message only to your teammates.", (args, player) -> { - playerGroup.all().each(p -> p.getTeam() == player.getTeam(), o -> o.sendMessage(args[0], player, "[#" + player.getTeam().color.toString() + "]" + NetClient.colorizeName(player.id, player.name))); + playerGroup.all().each(p -> p.getTeam() == player.team(), o -> o.sendMessage(args[0], player, "[#" + player.team().color.toString() + "]" + NetClient.colorizeName(player.id, player.name))); }); //duration of a a kick in seconds @@ -374,7 +373,7 @@ public class NetServer implements ApplicationListener{ player.sendMessage("[scarlet]Did you really expect to be able to kick an admin?"); }else if(found.isLocal){ player.sendMessage("[scarlet]Local players cannot be kicked."); - }else if(found.getTeam() != player.getTeam()){ + }else if(found.team() != player.team()){ player.sendMessage("[scarlet]Only players on your team can be kicked."); }else{ if(!vtime.get()){ @@ -496,7 +495,7 @@ public class NetServer implements ApplicationListener{ NetConnection connection = player.con; if(connection == null || snapshotID < connection.lastRecievedClientSnapshot) return; - boolean verifyPosition = !player.isDead() && netServer.admins.getStrict() && headless; + boolean verifyPosition = !player.dead() && netServer.admins.getStrict() && headless; if(connection.lastRecievedClientTime == 0) connection.lastRecievedClientTime = Time.millis() - 16; @@ -714,13 +713,13 @@ public class NetServer implements ApplicationListener{ public void writeEntitySnapshot(Player player) throws IOException{ syncStream.reset(); - Array cores = state.teams.cores(player.getTeam()); + Array cores = state.teams.cores(player.team()); dataStream.writeByte(cores.size); for(CoreEntity entity : cores){ dataStream.writeInt(entity.tile.pos()); - entity.getItems().write(dataStream); + entity.items().write(dataStream); } dataStream.close(); diff --git a/core/src/mindustry/core/Renderer.java b/core/src/mindustry/core/Renderer.java index f728f2ef31..aefd832988 100644 --- a/core/src/mindustry/core/Renderer.java +++ b/core/src/mindustry/core/Renderer.java @@ -14,6 +14,7 @@ import mindustry.content.*; import mindustry.core.GameState.*; import mindustry.entities.type.*; import mindustry.game.EventType.*; +import mindustry.gen.*; import mindustry.graphics.*; import mindustry.input.*; import mindustry.ui.*; @@ -79,8 +80,8 @@ public class Renderer implements ApplicationListener{ }else{ Vec2 position = Tmp.v3.set(player); - if(player.isDead()){ - Tilec core = player.getClosestCore(); + if(player.dead()){ + Tilec core = player.closestCore(); if(core != null){ if(player.spawner == null){ camera.position.lerpDelta(core.x, core.y, 0.08f); @@ -277,9 +278,9 @@ public class Renderer implements ApplicationListener{ } private void drawLanding(){ - if(landTime > 0 && player.getClosestCore() != null){ + if(landTime > 0 && player.closestCore() != null){ float fract = landTime / Fx.coreLand.lifetime; - Tilec entity = player.getClosestCore(); + Tilec entity = player.closestCore(); TextureRegion reg = entity.block.icon(Cicon.full); float scl = Scl.scl(4f) / camerascale; diff --git a/core/src/mindustry/editor/EditorTile.java b/core/src/mindustry/editor/EditorTile.java index d9a48d625e..cc064873c3 100644 --- a/core/src/mindustry/editor/EditorTile.java +++ b/core/src/mindustry/editor/EditorTile.java @@ -141,9 +141,9 @@ public class EditorTile extends Tile{ if(block.hasEntity()){ entity = block.newEntity().init(this, false); entity.cons = new ConsumeModule(entity); - if(block.hasItems) entity.getItems() = new ItemModule(); - if(block.hasLiquids) entity.getLiquids() = new LiquidModule(); - if(block.hasPower) entity.getPower() = new PowerModule(); + if(block.hasItems) entity.items() = new ItemModule(); + if(block.hasLiquids) entity.liquids() = new LiquidModule(); + if(block.hasPower) entity.power() = new PowerModule(); } } diff --git a/core/src/mindustry/editor/MapEditorDialog.java b/core/src/mindustry/editor/MapEditorDialog.java index 577157ff19..fd50dc57f4 100644 --- a/core/src/mindustry/editor/MapEditorDialog.java +++ b/core/src/mindustry/editor/MapEditorDialog.java @@ -283,7 +283,7 @@ public class MapEditorDialog extends Dialog implements Disposable{ } } player.set(world.width() * tilesize/2f, world.height() * tilesize/2f); - player.setDead(false); + player.dead(false); logic.play(); }); } diff --git a/core/src/mindustry/entities/Damage.java b/core/src/mindustry/entities/Damage.java index b3d4d78d89..78a5859cf5 100644 --- a/core/src/mindustry/entities/Damage.java +++ b/core/src/mindustry/entities/Damage.java @@ -10,7 +10,6 @@ import arc.math.geom.*; import arc.util.*; import mindustry.content.*; import mindustry.entities.effect.*; -import mindustry.entities.type.*; import mindustry.game.EventType.*; import mindustry.game.*; import mindustry.gen.*; @@ -178,7 +177,7 @@ public class Damage{ /** Damages all entities and blocks in a radius that are enemies of the team. */ public static void damage(Team team, float x, float y, float radius, float damage, boolean complete){ Cons cons = entity -> { - if(entity.getTeam() == team || entity.dst(x, y) > radius){ + if(entity.team() == team || entity.dst(x, y) > radius){ return; } float amount = calculateDamage(x, y, entity.getX(), entity.getY(), radius, damage); diff --git a/core/src/mindustry/entities/EntityCollisions.java b/core/src/mindustry/entities/EntityCollisions.java index b5d776c78e..f2a0d270b3 100644 --- a/core/src/mindustry/entities/EntityCollisions.java +++ b/core/src/mindustry/entities/EntityCollisions.java @@ -78,8 +78,8 @@ public class EntityCollisions{ } } - entity.setX(entity.getX() + rect.x - r2.x); - entity.setY(entity.getY() + rect.y - r2.y); + entity.x(entity.getX() + rect.x - r2.x); + entity.y(entity.getY() + rect.y - r2.y); } public boolean overlapsTile(Rect rect){ @@ -112,8 +112,8 @@ public class EntityCollisions{ tree.clear(); group.each(s -> { - s.setLastX(s.getX()); - s.setLastY(s.getY()); + s.lastX(s.getX()); + s.lastY(s.getY()); tree.insert(s); }); } @@ -128,15 +128,15 @@ public class EntityCollisions{ a.hitbox(this.r1); b.hitbox(this.r2); - r1.x += (a.getLastX() - a.getX()); - r1.y += (a.getLastY() - a.getY()); - r2.x += (b.getLastX() - b.getX()); - r2.y += (b.getLastY() - b.getY()); + r1.x += (a.lastX() - a.getX()); + r1.y += (a.lastY() - a.getY()); + r2.x += (b.lastX() - b.getX()); + r2.y += (b.lastY() - b.getY()); - float vax = a.getX() - a.getLastX(); - float vay = a.getY() - a.getLastY(); - float vbx = b.getX() - b.getLastX(); - float vby = b.getY() - b.getLastY(); + float vax = a.getX() - a.lastX(); + float vay = a.getY() - a.lastY(); + float vbx = b.getX() - b.lastX(); + float vby = b.getY() - b.lastY(); if(a != b && a.collides(b)){ l1.set(a.getX(), a.getY()); @@ -204,8 +204,8 @@ public class EntityCollisions{ groupa.each(solid -> { solid.hitbox(r1); - r1.x += (solid.getLastX() - solid.getX()); - r1.y += (solid.getLastY() - solid.getY()); + r1.x += (solid.lastX() - solid.getX()); + r1.y += (solid.lastY() - solid.getY()); solid.hitbox(r2); r2.merge(r1); diff --git a/core/src/mindustry/entities/Units.java b/core/src/mindustry/entities/Units.java index 9c8b0989b5..98f068a87e 100644 --- a/core/src/mindustry/entities/Units.java +++ b/core/src/mindustry/entities/Units.java @@ -19,7 +19,7 @@ public class Units{ /** @return whether this player can interact with a specific tile. if either of these are null, returns true.*/ public static boolean canInteract(Player player, Tile tile){ - return player == null || tile == null || tile.interactable(player.getTeam()); + return player == null || tile == null || tile.interactable(player.team()); } /** @@ -32,7 +32,7 @@ public class Units{ * @return whether the target is invalid */ public static boolean invalidateTarget(Teamc target, Team team, float x, float y, float range){ - return target == null || (range != Float.MAX_VALUE && !target.withinDst(x, y, range)) || target.getTeam() == team || !target.isValid(); + return target == null || (range != Float.MAX_VALUE && !target.withinDst(x, y, range)) || target.team() == team || !target.isValid(); } /** See {@link #invalidateTarget(Teamc, Team, float, float, float)} */ @@ -42,7 +42,7 @@ public class Units{ /** See {@link #invalidateTarget(Teamc, Team, float, float, float)} */ public static boolean invalidateTarget(Teamc target, Unitc targeter){ - return invalidateTarget(target, targeter.getTeam(), targeter.x, targeter.y, targeter.getWeapon().bullet.range()); + return invalidateTarget(target, targeter.team(), targeter.x, targeter.y, targeter.getWeapon().bullet.range()); } /** Returns whether there are any entities on this tile. */ @@ -116,7 +116,7 @@ public class Units{ cdist = 0f; nearbyEnemies(team, x - range, y - range, range*2f, range*2f, e -> { - if(e.isDead() || !predicate.get(e)) return; + if(e.dead() || !predicate.get(e)) return; float dst2 = Mathf.dst2(e.x, e.y, x, y); if(dst2 < range*range && (result == null || dst2 < cdist)){ diff --git a/core/src/mindustry/entities/bullet/BulletType.java b/core/src/mindustry/entities/bullet/BulletType.java index a4328bd40b..2a363ce18c 100644 --- a/core/src/mindustry/entities/bullet/BulletType.java +++ b/core/src/mindustry/entities/bullet/BulletType.java @@ -2,16 +2,11 @@ package mindustry.entities.bullet; import arc.audio.*; import arc.math.*; -import arc.math.geom.*; -import arc.struct.*; -import arc.util.*; -import arc.util.pooling.*; import mindustry.annotations.Annotations.*; import mindustry.content.*; import mindustry.ctype.*; import mindustry.entities.*; import mindustry.entities.effect.*; -import mindustry.entities.type.*; import mindustry.game.*; import mindustry.gen.*; import mindustry.graphics.*; @@ -132,7 +127,7 @@ public abstract class BulletType extends Content{ } if(splashDamageRadius > 0){ - Damage.damage(b.getTeam(), x, y, splashDamageRadius, splashDamage * b.damageMultiplier()); + Damage.damage(b.team(), x, y, splashDamageRadius, splashDamage * b.damageMultiplier()); } } @@ -145,7 +140,7 @@ public abstract class BulletType extends Content{ } for(int i = 0; i < lightining; i++){ - Lightning.createLighting(Lightning.nextSeed(), b.getTeam(), Pal.surge, damage, b.getX(), b.getY(), Mathf.random(360f), lightningLength); + Lightning.createLighting(Lightning.nextSeed(), b.team(), Pal.surge, damage, b.getX(), b.getY(), Mathf.random(360f), lightningLength); } } @@ -164,9 +159,9 @@ public abstract class BulletType extends Content{ public void update(Bulletc b){ if(homingPower > 0.0001f){ - Teamc target = Units.closestTarget(b.getTeam(), b.getX(), b.getY(), homingRange, e -> !e.isFlying() || collidesAir); + Teamc target = Units.closestTarget(b.team(), b.getX(), b.getY(), homingRange, e -> !e.isFlying() || collidesAir); if(target != null){ - b.getVel().setAngle(Mathf.slerpDelta(b.getRotation(), b.angleTo(target), 0.08f)); + b.vel().setAngle(Mathf.slerpDelta(b.getRotation(), b.angleTo(target), 0.08f)); } } } @@ -179,7 +174,7 @@ public abstract class BulletType extends Content{ //TODO change 'create' to 'at' public Bulletc create(Teamc owner, float x, float y, float angle){ - return create(owner, owner.getTeam(), x, y, angle); + return create(owner, owner.team(), x, y, angle); } public Bulletc create(Entityc owner, Team team, float x, float y, float angle){ @@ -195,11 +190,11 @@ public abstract class BulletType extends Content{ } public Bulletc create(Bulletc parent, float x, float y, float angle){ - return create(parent.getOwner(), parent.getTeam(), x, y, angle); + return create(parent.getOwner(), parent.team(), x, y, angle); } public Bulletc create(Bulletc parent, float x, float y, float angle, float velocityScl){ - return create(parent.getOwner(), parent.getTeam(), x, y, angle, velocityScl); + return create(parent.getOwner(), parent.team(), x, y, angle, velocityScl); } public Bulletc create(Entityc owner, Team team, float x, float y, float angle, float velocityScl, float lifetimeScl, Object data){ diff --git a/core/src/mindustry/entities/bullet/FlakBulletType.java b/core/src/mindustry/entities/bullet/FlakBulletType.java index 4eb4c4bac1..8b7217f7f8 100644 --- a/core/src/mindustry/entities/bullet/FlakBulletType.java +++ b/core/src/mindustry/entities/bullet/FlakBulletType.java @@ -29,7 +29,7 @@ public class FlakBulletType extends BasicBulletType{ if(b.getData() instanceof Integer) return; if(b.timer.get(2, 6)){ - Units.nearbyEnemies(b.getTeam(), rect.setSize(explodeRange * 2f).setCenter(b.x, b.y), unit -> { + Units.nearbyEnemies(b.team(), rect.setSize(explodeRange * 2f).setCenter(b.x, b.y), unit -> { if(b.getData() instanceof Float) return; if(unit.dst(b) < explodeRange){ diff --git a/core/src/mindustry/entities/bullet/HealBulletType.java b/core/src/mindustry/entities/bullet/HealBulletType.java index da5171ec89..71a3febf63 100644 --- a/core/src/mindustry/entities/bullet/HealBulletType.java +++ b/core/src/mindustry/entities/bullet/HealBulletType.java @@ -29,7 +29,7 @@ public class HealBulletType extends BulletType{ @Override public boolean collides(Bulletc b, Tile tile){ - return tile.getTeam() != b.getTeam() || tile.entity.healthf() < 1f; + return tile.getTeam() != b.team() || tile.entity.healthf() < 1f; } @Override @@ -47,7 +47,7 @@ public class HealBulletType extends BulletType{ super.hit(b); tile = tile.link(); - if(tile.entity != null && tile.getTeam() == b.getTeam() && !(tile.block() instanceof BuildBlock)){ + if(tile.entity != null && tile.getTeam() == b.team() && !(tile.block() instanceof BuildBlock)){ Fx.healBlockFull.at(tile.drawx(), tile.drawy(), tile.block().size, Pal.heal); tile.entity.healBy(healPercent / 100f * tile.entity.maxHealth()); } diff --git a/core/src/mindustry/entities/bullet/LaserBulletType.java b/core/src/mindustry/entities/bullet/LaserBulletType.java index 3b902cafe6..31058d0481 100644 --- a/core/src/mindustry/entities/bullet/LaserBulletType.java +++ b/core/src/mindustry/entities/bullet/LaserBulletType.java @@ -41,7 +41,7 @@ public class LaserBulletType extends BulletType{ @Override public void init(Bulletc b){ - Damage.collideLine(b, b.getTeam(), hitEffect, b.x, b.y, b.rot(), length); + Damage.collideLine(b, b.team(), hitEffect, b.x, b.y, b.rot(), length); } @Override diff --git a/core/src/mindustry/entities/bullet/LightningBulletType.java b/core/src/mindustry/entities/bullet/LightningBulletType.java index d5bcaafa57..dcf34101a4 100644 --- a/core/src/mindustry/entities/bullet/LightningBulletType.java +++ b/core/src/mindustry/entities/bullet/LightningBulletType.java @@ -25,6 +25,6 @@ public class LightningBulletType extends BulletType{ @Override public void init(Bulletc b){ - Lightning.create(b.getTeam(), lightningColor, damage, b.x, b.y, b.rot(), lightningLength); + Lightning.create(b.team(), lightningColor, damage, b.x, b.y, b.rot(), lightningLength); } } diff --git a/core/src/mindustry/entities/def/EntityComps.java b/core/src/mindustry/entities/def/EntityComps.java index 3d10ded583..88483beabc 100644 --- a/core/src/mindustry/entities/def/EntityComps.java +++ b/core/src/mindustry/entities/def/EntityComps.java @@ -39,7 +39,7 @@ import java.util.*; import static mindustry.Vars.*; -@SuppressWarnings("unused") +@SuppressWarnings({"unused", "unused"}) public class EntityComps{ @Component @@ -47,41 +47,48 @@ public class EntityComps{ private UnitController controller; private UnitDef type; - public float getBounds(){ - return getHitSize() * 2f; + @Override + public float bounds(){ + return hitSize() * 2f; } - public void setController(UnitController controller){ + @Override + public void controller(UnitController controller){ this.controller = controller; controller.set(this); } - public UnitController getController(){ + @Override + public UnitController controller(){ return controller; } + @Override public void set(UnitDef def, UnitController controller){ - setType(type); - setController(controller); + type(type); + controller(controller); } - public void setType(UnitDef type){ + @Override + public void type(UnitDef type){ this.type = type; setupWeapons(type); } - public UnitDef getType(){ + @Override + public UnitDef type(){ return type; } + @Override public void update(){ //apply knockback based on spawns //TODO move elsewhere - if(getTeam() != state.rules.waveTeam){ - float relativeSize = state.rules.dropZoneRadius + getBounds()/2f + 1f; + if(team() != state.rules.waveTeam){ + float relativeSize = state.rules.dropZoneRadius + bounds()/2f + 1f; for(Tile spawn : spawner.getGroundSpawns()){ if(withinDst(spawn.worldx(), spawn.worldy(), relativeSize)){ - getVel().add(Tmp.v1.set(this).sub(spawn.worldx(), spawn.worldy()).setLength(0.1f + 1f - dst(spawn) / relativeSize).scl(0.45f * Time.delta())); + vel().add(Tmp.v1.set(this).sub(spawn.worldx(), spawn.worldy()).setLength(0.1f + 1f - dst(spawn) / relativeSize).scl(0.45f * Time.delta())); } } } @@ -91,7 +98,7 @@ public class EntityComps{ if(tile != null){ //unit block update - tile.block().unitOn(tile, (mindustry.gen.Unitc)this); + tile.block().unitOn(tile, this); //apply damage if(floor.damageTaken > 0f){ @@ -100,6 +107,7 @@ public class EntityComps{ } } + @Override public void drawLight(){ //TODO move if(type.lightRadius > 0){ @@ -107,17 +115,19 @@ public class EntityComps{ } } + @Override public void draw(){ //draw power cell - TODO move - Draw.color(Color.black, getTeam().color, healthf() + Mathf.absin(Time.time(), Math.max(healthf() * 5f, 1f), 1f - healthf())); - Draw.rect(type.cellRegion, getX(), getY(), getRotation() - 90); + Draw.color(Color.black, team().color, healthf() + Mathf.absin(Time.time(), Math.max(healthf() * 5f, 1f), 1f - healthf())); + Draw.rect(type.cellRegion, getX(), getY(), rotation() - 90); Draw.color(); } + @Override public void killed(){ - float explosiveness = 2f + item().explosiveness * getStack().amount; - float flammability = item().flammability * getStack().amount; - Damage.dynamicExplosion(getX(), getY(), flammability, explosiveness, 0f, getBounds() / 2f, Pal.darkFlame); + float explosiveness = 2f + item().explosiveness * stack().amount; + float flammability = item().flammability * stack().amount; + Damage.dynamicExplosion(getX(), getY(), flammability, explosiveness, 0f, bounds() / 2f, Pal.darkFlame); //TODO cleanup //ScorchDecal.create(getX(), getY()); @@ -125,7 +135,7 @@ public class EntityComps{ Effects.shake(2f, 2f, this); Sounds.bang.at(this); - Events.fire(new UnitDestroyEvent((mindustry.gen.Unitc)this)); + Events.fire(new UnitDestroyEvent(this)); //TODO implement suicide bomb trigger //if(explosiveness > 7f && this == player){ @@ -146,6 +156,7 @@ public class EntityComps{ private @Nullable Posc parent; private float offsetX, offsetY; + @Override public void add(){ if(parent != null){ offsetX = x - parent.getX(); @@ -153,6 +164,7 @@ public class EntityComps{ } } + @Override public void update(){ if(parent != null){ x = parent.getX() + offsetX; @@ -168,68 +180,78 @@ public class EntityComps{ Object data; BulletType type; + @Override public float getDamage(){ return type.damage; } + @Override public void add(){ type.init(this); - setDrag(type.drag); - setHitSize(type.hitSize); - setLifetime(lifeScl * type.lifetime); + drag(type.drag); + hitSize(type.hitSize); + lifetime(lifeScl * type.lifetime); } + @Override public void remove(){ type.despawned(this); } + @Override public float getLifetime(){ return type.lifetime; } + @Override public float damageMultiplier(){ - if(getOwner() instanceof Unitc){ - return ((Unitc)getOwner()).getDamageMultiplier(); + if(owner() instanceof Unitc){ + return ((Unitc)owner()).damageMultiplier(); } return 1f; } + @Override public void absorb(){ //TODO remove(); } + @Override public float clipSize(){ return type.drawSize; } + @Override public float damage(){ return type.damage * damageMultiplier(); } + @Override public void collision(Hitboxc other, float x, float y){ if(!type.pierce) remove(); type.hit(this, x, y); if(other instanceof Unitc){ Unitc unit = (Unitc)other; - unit.getVel().add(Tmp.v3.set(other.getX(), other.getY()).sub(x, y).setLength(type.knockback / unit.getMass())); + unit.vel().add(Tmp.v3.set(other.x(), other.y()).sub(x, y).setLength(type.knockback / unit.mass())); unit.apply(type.status, type.statusDuration); } } + @Override public void update(){ type.update(this); if(type.hitTiles){ - world.raycastEach(world.toTile(getLastX()), world.toTile(getLastY()), tileX(), tileY(), (x, y) -> { + world.raycastEach(world.toTile(lastX()), world.toTile(lastY()), tileX(), tileY(), (x, y) -> { Tile tile = world.ltile(x, y); if(tile == null) return false; - if(tile.entity != null && tile.entity.collide(this) && type.collides(this, tile) && !tile.entity.isDead() && (type.collidesTeam || tile.getTeam() != getTeam())){ - if(tile.getTeam() != getTeam()){ + if(tile.entity != null && tile.entity.collide(this) && type.collides(this, tile) && !tile.entity.dead() && (type.collidesTeam || tile.getTeam() != team())){ + if(tile.getTeam() != team()){ tile.entity.collision(this); } @@ -243,20 +265,23 @@ public class EntityComps{ } } + @Override public void draw(){ type.draw(this); //TODO refactor - renderer.lights.add(getX(), getY(), 16f, Pal.powerLight, 0.3f); + renderer.lights.add(x(), y(), 16f, Pal.powerLight, 0.3f); } /** Sets the bullet's rotation in degrees. */ - public void setRotation(float angle){ - getVel().setAngle(angle); + @Override + public void rotation(float angle){ + vel().setAngle(angle); } /** @return the bullet's rotation. */ - public float getRotation(){ - float angle = Mathf.atan2(getVel().x, getVel().y) * Mathf.radiansToDegrees; + @Override + public float rotation(){ + float angle = Mathf.atan2(vel().x, vel().y) * Mathf.radiansToDegrees; if(angle < 0) angle += 360; return angle; } @@ -264,13 +289,14 @@ public class EntityComps{ @Component abstract class DamageComp{ - abstract float getDamage(); + abstract float damage(); } @Component abstract class TimedComp implements Entityc, Scaled{ float time, lifetime; + @Override public void update(){ time = Math.min(time + Time.delta(), lifetime); @@ -300,6 +326,7 @@ public class EntityComps{ return health / maxHealth; } + @Override public void update(){ hitTime -= Time.delta() / hitDuration; } @@ -366,6 +393,7 @@ public class EntityComps{ return elevation < 0.001f; } + @Override public void update(){ Floor floor = floorOn(); @@ -377,7 +405,7 @@ public class EntityComps{ drownTime += Time.delta() * 1f / floor.drownTime; drownTime = Mathf.clamp(drownTime); if(Mathf.chance(Time.delta() * 0.05f)){ - floor.drownUpdateEffect.at(getX(), getY(), 0f, floor.color); + floor.drownUpdateEffect.at(x, y, 0f, floor.color); } //TODO is the netClient check necessary? @@ -403,8 +431,8 @@ public class EntityComps{ void interpolate(){ Syncc sync = (Syncc)this; - if(sync.getInterpolator().values.length > 0){ - rotation = sync.getInterpolator().values[0]; + if(sync.interpolator().values.length > 0){ + rotation = sync.interpolator().values[0]; } } } @@ -433,6 +461,7 @@ public class EntityComps{ private float sleepTime; /** Sets this tile entity data to this tile, and adds it if necessary. */ + @Override public Tilec init(Tile tile, boolean shouldAdd){ this.tile = tile; this.block = tile.block(); @@ -442,8 +471,8 @@ public class EntityComps{ sound = new SoundLoop(block.activeSound, block.activeSoundVolume); } - setHealth(block.health); - setMaxHealth(block.health); + health(block.health); + maxHealth(block.health); timer = new Interval(block.timers); if(shouldAdd){ @@ -453,33 +482,40 @@ public class EntityComps{ return this; } - public float getTimeScale(){ + @Override + public float timeScale(){ return timeScale; } + @Override public boolean consValid(){ return cons.valid(); } + @Override public void consume(){ cons.trigger(); } + @Override public boolean timer(int id, float time){ return timer.get(id, time); } /** Scaled delta. */ + @Override public float delta(){ return Time.delta() * timeScale; } /** Base efficiency. If this entity has non-buffered power, returns the power %, otherwise returns 1. */ + @Override public float efficiency(){ return power != null && (block.consumes.has(ConsumeType.power) && !block.consumes.getPower().buffered) ? power.status : 1f; } /** Call when nothing is happening to the entity. This increments the internal sleep timer. */ + @Override public void sleep(){ sleepTime += Time.delta(); if(!sleeping && sleepTime >= timeToSleep){ @@ -490,6 +526,7 @@ public class EntityComps{ } /** Call when this entity is updating. This wakes it up. */ + @Override public void noSleep(){ sleepTime = 0f; if(sleeping){ @@ -500,20 +537,24 @@ public class EntityComps{ } /** Returns the version of this TileEntity IO code.*/ + @Override public byte version(){ return 0; } + @Override public boolean collide(Bulletc other){ return true; } + @Override public void collision(Bulletc other){ block.handleBulletHit(this, other); } //TODO Implement damage! + @Override public void removeFromProximity(){ block.onProximityRemoved(tile); @@ -525,12 +566,13 @@ public class EntityComps{ other.block().onProximityUpdate(other); if(other.entity != null){ - other.entity.getProximity().remove(tile, true); + other.entity.proximity().remove(tile, true); } } } } + @Override public void updateProximity(){ tmpTiles.clear(); proximity.clear(); @@ -543,8 +585,8 @@ public class EntityComps{ if(other.entity == null || !(other.interactable(tile.getTeam()))) continue; //add this tile to proximity of nearby tiles - if(!other.entity.getProximity().contains(tile, true)){ - other.entity.getProximity().add(tile); + if(!other.entity.proximity().contains(tile, true)){ + other.entity.proximity().add(tile); } tmpTiles.add(other); @@ -563,21 +605,25 @@ public class EntityComps{ } } + @Override public Array proximity(){ return proximity; } /** Tile configuration. Defaults to 0. Used for block rebuilding. */ + @Override public int config(){ return 0; } + @Override public void remove(){ if(sound != null){ sound.stop(); } } + @Override public void killed(){ Events.fire(new BlockDestroyEvent(tile)); block.breakSound.at(tile); @@ -585,6 +631,7 @@ public class EntityComps{ tile.remove(); } + @Override public void update(){ timeScaleDuration -= Time.delta(); if(timeScaleDuration <= 0f || !block.canOverdrive){ @@ -592,7 +639,7 @@ public class EntityComps{ } if(sound != null){ - sound.update(getX(), getY(), block.shouldActiveSound(tile)); + sound.update(x(), y(), block.shouldActiveSound(tile)); } if(block.idleSound != Sounds.none && block.shouldIdleSound(tile)){ @@ -621,7 +668,7 @@ public class EntityComps{ Team team = Team.sharded; - public @Nullable Tilec getClosestCore(){ + public @Nullable Tilec closestCore(){ return state.teams.closestCore(x, y, team); } } @@ -638,7 +685,7 @@ public class EntityComps{ static int sequenceNum = 0; /** weapon mount array, never null */ - WeaponMount[] mounts = {}; + @ReadOnly WeaponMount[] mounts = {}; void setupWeapons(UnitDef def){ mounts = new WeaponMount[def.weapons.size]; @@ -662,6 +709,7 @@ public class EntityComps{ } /** Update shooting and rotation for this unit. */ + @Override public void update(){ for(WeaponMount mount : mounts){ Weapon weapon = mount.weapon; @@ -744,7 +792,7 @@ public class EntityComps{ if(this instanceof Velc){ //TODO apply force? - ((Velc)this).getVel().add(Tmp.v1); + ((Velc)this).vel().add(Tmp.v1); } Tmp.v1.trns(rotation, 3f); @@ -774,7 +822,7 @@ public class EntityComps{ void drawShadow(){ if(!isGrounded()){ Draw.color(shadowColor); - Draw.rect(getShadowRegion(), x + shadowTX * getElevation(), y + shadowTY * getElevation(), rotation - 90); + Draw.rect(getShadowRegion(), x + shadowTX * elevation(), y + shadowTY * elevation(), rotation - 90); Draw.color(); } } @@ -787,6 +835,7 @@ public class EntityComps{ float itemTime; //drawn after base + @Override @MethodPriority(3) public void draw(){ boolean number = isLocal(); @@ -812,7 +861,7 @@ public class EntityComps{ (3f + Mathf.absin(Time.time(), 5f, 1f)) * itemTime); if(isLocal()){ - Fonts.outline.draw(getStack().amount + "", + Fonts.outline.draw(stack().amount + "", x + Angles.trnsx(rotation + 180f, backTrns), y + Angles.trnsy(rotation + 180f, backTrns) - 3, Pal.accent, 0.25f * itemTime / Scl.scl(1f), false, Align.center @@ -829,12 +878,14 @@ public class EntityComps{ Color color = new Color(1, 1, 1, 1); TextureRegion region; + @Override public void draw(){ Draw.color(color); - Draw.rect(region, getX(), getY(), getRotation()); + Draw.rect(region, x(), y(), rotation()); Draw.color(); } + @Override public float clipSize(){ return region.getWidth()*2; } @@ -883,6 +934,7 @@ public class EntityComps{ interpolator.lastUpdated = 0; } + @Override public void update(){ if(Vars.net.client() && !isLocal()){ interpolate(); @@ -938,11 +990,11 @@ public class EntityComps{ } int tileX(){ - return Vars.world.toTile(getX()); + return Vars.world.toTile(x); } int tileY(){ - return Vars.world.toTile(getY()); + return Vars.world.toTile(y); } /** Returns air if this unit is on a non-air top block. */ @@ -954,6 +1006,16 @@ public class EntityComps{ public @Nullable Tile tileOn(){ return world.tileWorld(x, y); } + + @Override + public float getX(){ + return x; + } + + @Override + public float getY(){ + return y; + } } @Component @@ -966,23 +1028,23 @@ public class EntityComps{ abstract boolean canMine(Item item); - abstract float getMiningSpeed(); + abstract float miningSpeed(); abstract boolean offloadImmediately(); - boolean isMining(){ + boolean mining(){ return mineTile != null; } void updateMining(){ - Tilec core = getClosestCore(); + Tilec core = closestCore(); if(core != null && mineTile != null && mineTile.drop() != null && !acceptsItem(mineTile.drop()) && dst(core) < mineTransferRange){ - int accepted = core.getTile().block().acceptStack(item(), getStack().amount, core.getTile(), this); + int accepted = core.tile().block().acceptStack(item(), stack().amount, core.tile(), this); if(accepted > 0){ Call.transferItemTo(item(), accepted, mineTile.worldx() + Mathf.range(tilesize / 2f), - mineTile.worldy() + Mathf.range(tilesize / 2f), core.getTile()); + mineTile.worldy() + Mathf.range(tilesize / 2f), core.tile()); clearItem(); } } @@ -992,14 +1054,14 @@ public class EntityComps{ mineTile = null; }else{ Item item = mineTile.drop(); - setRotation(Mathf.slerpDelta(getRotation(), angleTo(mineTile.worldx(), mineTile.worldy()), 0.4f)); + rotation(Mathf.slerpDelta(rotation(), angleTo(mineTile.worldx(), mineTile.worldy()), 0.4f)); - if(Mathf.chance(Time.delta() * (0.06 - item.hardness * 0.01) * getMiningSpeed())){ + if(Mathf.chance(Time.delta() * (0.06 - item.hardness * 0.01) * miningSpeed())){ - if(dst(core) < mineTransferRange && core.getTile().block().acceptStack(item, 1, core.getTile(), this) == 1 && offloadImmediately()){ + if(dst(core) < mineTransferRange && core.tile().block().acceptStack(item, 1, core.tile(), this) == 1 && offloadImmediately()){ Call.transferItemTo(item, 1, mineTile.worldx() + Mathf.range(tilesize / 2f), - mineTile.worldy() + Mathf.range(tilesize / 2f), core.getTile()); + mineTile.worldy() + Mathf.range(tilesize / 2f), core.tile()); }else if(acceptsItem(item)){ //this is clientside, since items are synced anyway ItemTransfer.transferItemToUnit(item, @@ -1016,7 +1078,7 @@ public class EntityComps{ } void drawOver(){ - if(!isMining()) return; + if(!mining()) return; float focusLen = 4f + Mathf.absin(Time.time(), 1.1f, 0.5f); float swingScl = 12f, swingMag = tilesize / 8f; float flashScl = 0.3f; @@ -1042,13 +1104,13 @@ public class EntityComps{ } @Component - abstract static class BuilderComp implements mindustry.gen.Unitc{ + abstract static class BuilderComp implements Unitc{ static final float placeDistance = 220f; static final Vec2[] tmptr = new Vec2[]{new Vec2(), new Vec2(), new Vec2(), new Vec2()}; transient float x, y, rotation; - - Queue requests = new Queue<>(); + + @ReadOnly Queue requests = new Queue<>(); float buildSpeed = 1f; //boolean building; @@ -1064,7 +1126,7 @@ public class EntityComps{ } } - Tilec core = getClosestCore(); + Tilec core = closestCore(); //nothing to build. if(buildRequest() == null) return; @@ -1087,10 +1149,10 @@ public class EntityComps{ Tile tile = world.tile(current.x, current.y); if(!(tile.block() instanceof BuildBlock)){ - if(!current.initialized && !current.breaking && Build.validPlace(getTeam(), current.x, current.y, current.block, current.rotation)){ - Build.beginPlace(getTeam(), current.x, current.y, current.block, current.rotation); - }else if(!current.initialized && current.breaking && Build.validBreak(getTeam(), current.x, current.y)){ - Build.beginBreak(getTeam(), current.x, current.y); + if(!current.initialized && !current.breaking && Build.validPlace(team(), current.x, current.y, current.block, current.rotation)){ + Build.beginPlace(team(), current.x, current.y, current.block, current.rotation); + }else if(!current.initialized && current.breaking && Build.validBreak(team(), current.x, current.y)){ + Build.beginBreak(team(), current.x, current.y); }else{ requests.removeFirst(); return; @@ -1098,7 +1160,7 @@ public class EntityComps{ } if(tile.entity instanceof BuildEntity && !current.initialized){ - Core.app.post(() -> Events.fire(new BuildSelectEvent(tile, getTeam(), (Builderc)this, current.breaking))); + Core.app.post(() -> Events.fire(new BuildSelectEvent(tile, team(), (Builderc)this, current.breaking))); current.initialized = true; } @@ -1136,7 +1198,7 @@ public class EntityComps{ boolean shouldSkip(BuildRequest request, @Nullable Tilec core){ //requests that you have at least *started* are considered if(state.rules.infiniteResources || request.breaking || !request.initialized || core == null) return false; - return request.stuck && !core.getItems().has(request.block.requirements); + return request.stuck && !core.items().has(request.block.requirements); } void removeBuild(int x, int y, boolean breaking){ @@ -1238,12 +1300,12 @@ public class EntityComps{ @Component abstract class ItemsComp{ - ItemStack stack = new ItemStack(); + @ReadOnly ItemStack stack = new ItemStack(); - abstract int getItemCapacity(); + abstract int itemCapacity(); void update(){ - stack.amount = Mathf.clamp(stack.amount, 0, getItemCapacity()); + stack.amount = Mathf.clamp(stack.amount, 0, itemCapacity()); } Item item(){ @@ -1255,7 +1317,7 @@ public class EntityComps{ } boolean acceptsItem(Item item){ - return !hasItem() || item == stack.item && stack.amount + 1 <= getItemCapacity(); + return !hasItem() || item == stack.item && stack.amount + 1 <= itemCapacity(); } boolean hasItem(){ @@ -1275,14 +1337,17 @@ public class EntityComps{ Object data; float rotation = 0f; + @Override public void draw(){ } + @Override public void update(){ //TODO fix effects, make everything poolable } + @Override public float clipSize(){ return effect.size; } @@ -1295,6 +1360,7 @@ public class EntityComps{ final Vec2 vel = new Vec2(); float drag = 0f; + @Override public void update(){ //TODO handle solidity x += vel.x; @@ -1310,6 +1376,7 @@ public class EntityComps{ float hitSize; float lastX, lastY; + @Override public void update(){ } @@ -1323,19 +1390,20 @@ public class EntityComps{ } - float getDeltaX(){ + float deltaX(){ return x - lastX; } - float getDeltaY(){ + float deltaY(){ return y - lastY; } boolean collides(Hitboxc other){ return Intersector.overlapsRect(x - hitSize/2f, y - hitSize/2f, hitSize, hitSize, - other.getX() - other.getHitSize()/2f, other.getY() - other.getHitSize()/2f, other.getHitSize(), other.getHitSize()); + other.x() - other.hitSize()/2f, other.y() - other.hitSize()/2f, other.hitSize(), other.hitSize()); } + @Override public void hitbox(Rect rect){ rect.setCentered(x, y, hitSize, hitSize); } @@ -1347,16 +1415,16 @@ public class EntityComps{ } @Component - abstract class StatusComp implements Posc{ + abstract class StatusComp implements Posc, Flyingc{ private Array statuses = new Array<>(); private Bits applied = new Bits(content.getBy(ContentType.status).size); - float speedMultiplier; - float damageMultiplier; - float armorMultiplier; + @ReadOnly float speedMultiplier; + @ReadOnly float damageMultiplier; + @ReadOnly float armorMultiplier; /** @return damage taken based on status armor multipliers */ - float getDamage(float amount){ + float getShieldDamage(float amount){ return amount * Mathf.clamp(1f - armorMultiplier / 100f); } @@ -1396,7 +1464,7 @@ public class EntityComps{ return false; } - Color getStatusColor(){ + Color statusColor(){ if(statuses.size == 0){ return Tmp.c1.set(Color.white); } @@ -1410,16 +1478,12 @@ public class EntityComps{ return Tmp.c1.set(r / statuses.size, g / statuses.size, b / statuses.size, 1f); } + @Override public void update(){ Floor floor = floorOn(); - Tile tile = tileOn(); - boolean flying = false; - //TODO conditionally apply status effects on floor, if not flying - if(!flying && tile != null){ + if(isGrounded() && floor.status != null){ //apply effect - if(floor.status != null){ - apply(floor.status, floor.statusDuration); - } + apply(floor.status, floor.statusDuration); } applied.clear(); diff --git a/core/src/mindustry/entities/effect/ItemTransfer.java b/core/src/mindustry/entities/effect/ItemTransfer.java index f40f3267b1..6f9161af8f 100644 --- a/core/src/mindustry/entities/effect/ItemTransfer.java +++ b/core/src/mindustry/entities/effect/ItemTransfer.java @@ -7,7 +7,6 @@ import arc.util.*; import arc.util.pooling.*; import mindustry.annotations.Annotations.*; import mindustry.entities.*; -import mindustry.entities.type.*; import mindustry.gen.*; import mindustry.graphics.*; import mindustry.type.*; @@ -42,11 +41,11 @@ public class ItemTransfer extends TimedEntity implements DrawTrait{ @Remote(called = Loc.server, unreliable = true) public static void transferItemTo(Item item, int amount, float x, float y, Tile tile){ - if(tile == null || tile.entity == null || tile.entity.getItems() == null) return; + if(tile == null || tile.entity == null || tile.entity.items() == null) return; for(int i = 0; i < Mathf.clamp(amount / 3, 1, 8); i++){ Time.run(i * 3, () -> create(item, x, y, tile, () -> {})); } - tile.entity.getItems().add(item, amount); + tile.entity.items().add(item, amount); } public static void create(Item item, float fromx, float fromy, Position to, Runnable done){ diff --git a/core/src/mindustry/entities/type/Player.java b/core/src/mindustry/entities/type/Player.java index 7acedffef0..b7a6bc847b 100644 --- a/core/src/mindustry/entities/type/Player.java +++ b/core/src/mindustry/entities/type/Player.java @@ -236,7 +236,7 @@ public class Player extends Unitc implements BuilderMinerTrait, ShooterTrait{ return playerGroup; } - public void setTeam(Team team){ + public void team(Team team){ this.team = team; } @@ -406,7 +406,7 @@ public class Player extends Unitc implements BuilderMinerTrait, ShooterTrait{ control.input.drawBreaking(request); }else{ request.block.drawRequest(request, control.input.allRequests(), - Build.validPlace(getTeam(), request.x, request.y, request.block, request.rotation) || control.input.requestMatches(request)); + Build.validPlace(team(), request.x, request.y, request.block, request.rotation) || control.input.requestMatches(request)); } } @@ -439,14 +439,14 @@ public class Player extends Unitc implements BuilderMinerTrait, ShooterTrait{ velocity.set(0f, 0f); x = 0; y = 0; - setDead(true); + dead(true); } if(netServer.isWaitingForPlayers()){ - setDead(true); + dead(true); } - if(!isDead() && isOutOfBounds()){ + if(!dead() && isOutOfBounds()){ destructTime += Time.delta(); if(destructTime >= boundsCountdown){ @@ -456,7 +456,7 @@ public class Player extends Unitc implements BuilderMinerTrait, ShooterTrait{ destructTime = 0f; } - if(!isDead() && isFlying()){ + if(!dead() && isFlying()){ loops.play(Sounds.thruster, this, Mathf.clamp(velocity.len() * 2f) * 0.3f); } @@ -465,7 +465,7 @@ public class Player extends Unitc implements BuilderMinerTrait, ShooterTrait{ loops.play(Sounds.build, request.tile(), 0.75f); } - if(isDead()){ + if(dead()){ isBoosting = false; boostHeat = 0f; if(respawns > 0 || !state.rules.limitedRespawns){ @@ -604,7 +604,7 @@ public class Player extends Unitc implements BuilderMinerTrait, ShooterTrait{ protected void updateTouch(){ if(Units.invalidateTarget(target, this) && - !(target instanceof Tilec && ((Tilec)target).damaged() && target.isValid() && target.getTeam() == team && mech.canHeal && dst(target) < mech.range && !(((Tilec)target).block instanceof BuildBlock))){ + !(target instanceof Tilec && ((Tilec)target).damaged() && target.isValid() && target.team() == team && mech.canHeal && dst(target) < mech.range && !(((Tilec)target).block instanceof BuildBlock))){ target = null; } @@ -616,10 +616,10 @@ public class Player extends Unitc implements BuilderMinerTrait, ShooterTrait{ float attractDst = 15f; float speed = isBoosting && !mech.flying ? mech.boostSpeed : mech.speed; - if(moveTarget != null && !moveTarget.isDead()){ + if(moveTarget != null && !moveTarget.dead()){ targetX = moveTarget.getX(); targetY = moveTarget.getY(); - boolean tapping = moveTarget instanceof Tilec && moveTarget.getTeam() == team; + boolean tapping = moveTarget instanceof Tilec && moveTarget.team() == team; attractDst = 0f; if(tapping){ @@ -627,7 +627,7 @@ public class Player extends Unitc implements BuilderMinerTrait, ShooterTrait{ } if(dst(moveTarget) <= 2f * Time.delta()){ - if(tapping && !isDead()){ + if(tapping && !dead()){ Tile tile = ((Tilec)moveTarget).tile; tile.block().tapped(tile, this); } @@ -680,7 +680,7 @@ public class Player extends Unitc implements BuilderMinerTrait, ShooterTrait{ if(target == null){ isShooting = false; if(Core.settings.getBool("autotarget")){ - target = Units.closestTarget(team, x, y, mech.range, u -> u.getTeam() != Team.derelict, u -> u.getTeam() != Team.derelict); + target = Units.closestTarget(team, x, y, mech.range, u -> u.team() != Team.derelict, u -> u.getTeam() != Team.derelict); if(mech.canHeal && target == null){ target = Geometry.findClosest(x, y, indexer.getDamaged(Team.sharded)); @@ -695,7 +695,7 @@ public class Player extends Unitc implements BuilderMinerTrait, ShooterTrait{ setMineTile(null); } } - }else if(target.isValid() || (target instanceof Tilec && ((Tilec)target).damaged() && target.getTeam() == team && mech.canHeal && dst(target) < mech.range)){ + }else if(target.isValid() || (target instanceof Tilec && ((Tilec)target).damaged() && target.team() == team && mech.canHeal && dst(target) < mech.range)){ //rotate toward and shoot the target if(mech.faceTarget){ rotation = Mathf.slerpDelta(rotation, angleTo(target), 0.2f); @@ -786,19 +786,19 @@ public class Player extends Unitc implements BuilderMinerTrait, ShooterTrait{ if(state.isEditor()){ //instant respawn at center of map. set(world.width() * tilesize/2f, world.height() * tilesize/2f); - setDead(false); + dead(false); }else if(spawner != null && spawner.isValid()){ spawner.updateSpawning(this); }else if(!netServer.isWaitingForPlayers()){ if(!net.client()){ if(lastSpawner != null && lastSpawner.isValid()){ this.spawner = lastSpawner; - }else if(getClosestCore() != null){ - this.spawner = (SpawnerTrait)getClosestCore(); + }else if(closestCore() != null){ + this.spawner = (SpawnerTrait)closestCore(); } } - }else if(getClosestCore() != null){ - set(getClosestCore().getX(), getClosestCore().getY()); + }else if(closestCore() != null){ + set(closestCore().getX(), closestCore().getY()); } } diff --git a/core/src/mindustry/entities/type/base/BuilderDrone.java b/core/src/mindustry/entities/type/base/BuilderDrone.java index f1da6f3bff..4a35328797 100644 --- a/core/src/mindustry/entities/type/base/BuilderDrone.java +++ b/core/src/mindustry/entities/type/base/BuilderDrone.java @@ -68,7 +68,7 @@ public class BuilderDrone extends BaseDrone implements BuilderTrait{ }else{ //else, building isn't valid, follow a player target = null; - if(playerTarget == null || playerTarget.getTeam() != team || !playerTarget.isValid()){ + if(playerTarget == null || playerTarget.team() != team || !playerTarget.isValid()){ playerTarget = null; if(retarget()){ @@ -77,7 +77,7 @@ public class BuilderDrone extends BaseDrone implements BuilderTrait{ //find player with min amount of drones for(Player player : playerGroup.all()){ - if(player.getTeam() == team){ + if(player.team() == team){ int drones = getDrones(player); float dst = dst2(player); @@ -168,7 +168,7 @@ public class BuilderDrone extends BaseDrone implements BuilderTrait{ if(!isBuilding() && timer.get(timerTarget2, 15)){ for(Player player : playerGroup.all()){ - if(player.getTeam() == team && player.buildRequest() != null){ + if(player.team() == team && player.buildRequest() != null){ BuildRequest req = player.buildRequest(); Tile tile = world.tile(req.x, req.y); if(tile != null && tile.entity instanceof BuildEntity){ diff --git a/core/src/mindustry/entities/type/base/MinerDrone.java b/core/src/mindustry/entities/type/base/MinerDrone.java index 033bacff5f..79325adda7 100644 --- a/core/src/mindustry/entities/type/base/MinerDrone.java +++ b/core/src/mindustry/entities/type/base/MinerDrone.java @@ -173,6 +173,6 @@ public class MinerDrone extends BaseDrone implements MinerTrait{ if(entity == null){ return; } - targetItem = Structs.findMin(type.toMine, indexer::hasOre, (a, b) -> -Integer.compare(entity.getItems().get(a), entity.getItems().get(b))); + targetItem = Structs.findMin(type.toMine, indexer::hasOre, (a, b) -> -Integer.compare(entity.items().get(a), entity.items().get(b))); } } diff --git a/core/src/mindustry/game/MusicControl.java b/core/src/mindustry/game/MusicControl.java index 26a44876ac..2d506a2c85 100644 --- a/core/src/mindustry/game/MusicControl.java +++ b/core/src/mindustry/game/MusicControl.java @@ -83,7 +83,7 @@ public class MusicControl{ /** Whether to play dark music.*/ private boolean isDark(){ - if(state.teams.get(player.getTeam()).hasCore() && state.teams.get(player.getTeam()).core().healthf() < 0.85f){ + if(state.teams.get(player.team()).hasCore() && state.teams.get(player.team()).core().healthf() < 0.85f){ //core damaged -> dark return true; } diff --git a/core/src/mindustry/game/Teams.java b/core/src/mindustry/game/Teams.java index 81bd679824..012ec04c53 100644 --- a/core/src/mindustry/game/Teams.java +++ b/core/src/mindustry/game/Teams.java @@ -5,7 +5,6 @@ import arc.math.geom.*; import arc.struct.*; import arc.util.ArcAnnotate.*; import arc.util.*; -import mindustry.entities.type.*; import mindustry.world.blocks.storage.CoreBlock.*; import static mindustry.Vars.*; @@ -102,7 +101,7 @@ public class Teams{ } public void registerCore(CoreEntity core){ - TeamData data = get(core.getTeam()); + TeamData data = get(core.team()); //add core if not present if(!data.cores.contains(core)){ data.cores.add(core); @@ -117,7 +116,7 @@ public class Teams{ } public void unregisterCore(CoreEntity entity){ - TeamData data = get(entity.getTeam()); + TeamData data = get(entity.team()); //remove core data.cores.remove(entity); //unregister in active list diff --git a/core/src/mindustry/graphics/BlockRenderer.java b/core/src/mindustry/graphics/BlockRenderer.java index a828e745cc..b0eb1a59f1 100644 --- a/core/src/mindustry/graphics/BlockRenderer.java +++ b/core/src/mindustry/graphics/BlockRenderer.java @@ -134,7 +134,7 @@ public class BlockRenderer implements Disposable{ } if(brokenFade > 0.001f){ - for(BrokenBlock block : state.teams.get(player.getTeam()).brokenBlocks){ + for(BrokenBlock block : state.teams.get(player.team()).brokenBlocks){ Block b = content.block(block.block); if(!camera.bounds(Tmp.r1).grow(tilesize * 2f).overlaps(Tmp.r2.setSize(b.size * tilesize).setCenter(block.x * tilesize + b.offset(), block.y * tilesize + b.offset()))) continue; @@ -233,7 +233,7 @@ public class BlockRenderer implements Disposable{ addRequest(tile, block.layer2); } - if(tile.entity != null && tile.entity.getPower() != null && tile.entity.getPower().links.size > 0){ + if(tile.entity != null && tile.entity.power() != null && tile.entity.power().links.size > 0){ for(Tile other : block.getPowerConnections(tile, outArray)){ if(other.block().layer == Layer.power){ addRequest(other, Layer.power); @@ -275,7 +275,7 @@ public class BlockRenderer implements Disposable{ if(request.tile.entity != null && request.tile.entity.damaged()){ block.drawCracks(request.tile); } - if(block.synthetic() && request.tile.getTeam() != player.getTeam()){ + if(block.synthetic() && request.tile.getTeam() != player.team()){ block.drawTeam(request.tile); } diff --git a/core/src/mindustry/graphics/OverlayRenderer.java b/core/src/mindustry/graphics/OverlayRenderer.java index a1d01b1fc1..b320ab9b75 100644 --- a/core/src/mindustry/graphics/OverlayRenderer.java +++ b/core/src/mindustry/graphics/OverlayRenderer.java @@ -28,7 +28,7 @@ public class OverlayRenderer{ public void drawBottom(){ InputHandler input = control.input; - if(player.isDead()) return; + if(player.dead()) return; input.drawBottom(); } @@ -37,13 +37,13 @@ public class OverlayRenderer{ if(Core.settings.getBool("indicators")){ for(Player player : playerGroup.all()){ - if(Vars.player != player && Vars.player.getTeam() == player.getTeam()){ + if(Vars.player != player && Vars.player.team() == player.team()){ if(!rect.setSize(Core.camera.width * 0.9f, Core.camera.height * 0.9f) .setCenter(Core.camera.position.x, Core.camera.position.y).contains(player.x, player.y)){ Tmp.v1.set(player.x, player.y).sub(Core.camera.position.x, Core.camera.position.y).setLength(indicatorLength); - Lines.stroke(2f, player.getTeam().color); + Lines.stroke(2f, player.team().color); Lines.lineAngle(Core.camera.position.x + Tmp.v1.x, Core.camera.position.y + Tmp.v1.y, Tmp.v1.angle(), 4f); Draw.reset(); } @@ -51,17 +51,17 @@ public class OverlayRenderer{ } Units.all(unit -> { - if(unit != player && unit.getTeam() != player.getTeam() && !rect.setSize(Core.camera.width * 0.9f, Core.camera.height * 0.9f).setCenter(Core.camera.position.x, Core.camera.position.y).contains(unit.x, unit.y)){ + if(unit != player && unit.team() != player.team() && !rect.setSize(Core.camera.width * 0.9f, Core.camera.height * 0.9f).setCenter(Core.camera.position.x, Core.camera.position.y).contains(unit.x, unit.y)){ Tmp.v1.set(unit.x, unit.y).sub(Core.camera.position.x, Core.camera.position.y).setLength(indicatorLength); - Lines.stroke(1f, unit.getTeam().color); + Lines.stroke(1f, unit.team().color); Lines.lineAngle(Core.camera.position.x + Tmp.v1.x, Core.camera.position.y + Tmp.v1.y, Tmp.v1.angle(), 3f); Draw.reset(); } }); if(ui.hudfrag.blockfrag.currentCategory == Category.upgrade){ - for(Tile mechpad : indexer.getAllied(player.getTeam(), BlockFlag.mechPad)){ + for(Tile mechpad : indexer.getAllied(player.team(), BlockFlag.mechPad)){ if(!(mechpad.block() instanceof MechPad)) continue; if(!rect.setSize(Core.camera.width * 0.9f, Core.camera.height * 0.9f) .setCenter(Core.camera.position.x, Core.camera.position.y).contains(mechpad.drawx(), mechpad.drawy())){ @@ -76,7 +76,7 @@ public class OverlayRenderer{ } } - if(player.isDead()) return; //dead players don't draw + if(player.dead()) return; //dead players don't draw InputHandler input = control.input; @@ -94,7 +94,7 @@ public class OverlayRenderer{ Lines.stroke(buildFadeTime * 2f); if(buildFadeTime > 0.005f){ - state.teams.eachEnemyCore(player.getTeam(), core -> { + state.teams.eachEnemyCore(player.team(), core -> { float dst = core.dst(player); if(dst < state.rules.enemyCoreBuildRadius * 2.2f){ Draw.color(Color.darkGray); @@ -122,10 +122,10 @@ public class OverlayRenderer{ Vec2 vec = Core.input.mouseWorld(input.getMouseX(), input.getMouseY()); Tile tile = world.ltileWorld(vec.x, vec.y); - if(tile != null && tile.block() != Blocks.air && tile.getTeam() == player.getTeam()){ + if(tile != null && tile.block() != Blocks.air && tile.getTeam() == player.team()){ tile.block().drawSelect(tile); - if(Core.input.keyDown(Binding.rotateplaced) && tile.block().rotate && tile.interactable(player.getTeam())){ + if(Core.input.keyDown(Binding.rotateplaced) && tile.block().rotate && tile.interactable(player.team())){ control.input.drawArrow(tile.block(), tile.x, tile.y, tile.rotation(), true); Draw.color(Pal.accent, 0.3f + Mathf.absin(4f, 0.2f)); Fill.square(tile.drawx(), tile.drawy(), tile.block().size * tilesize/2f); @@ -144,7 +144,7 @@ public class OverlayRenderer{ Draw.reset(); Tile tile = world.ltileWorld(v.x, v.y); - if(tile != null && tile.interactable(player.getTeam()) && tile.block().acceptStack(player.item().item, player.item().amount, tile, player) > 0){ + if(tile != null && tile.interactable(player.team()) && tile.block().acceptStack(player.item().item, player.item().amount, tile, player) > 0){ Lines.stroke(3f, Pal.gray); Lines.square(tile.drawx(), tile.drawy(), tile.block().size * tilesize / 2f + 3 + Mathf.absin(Time.time(), 5f, 1f)); Lines.stroke(1f, Pal.place); diff --git a/core/src/mindustry/input/DesktopInput.java b/core/src/mindustry/input/DesktopInput.java index 24aaaba3b2..e8575ecf24 100644 --- a/core/src/mindustry/input/DesktopInput.java +++ b/core/src/mindustry/input/DesktopInput.java @@ -136,7 +136,7 @@ public class DesktopInput extends InputHandler{ ui.listfrag.toggle(); } - if(((player.getClosestCore() == null && player.isDead()) || state.isPaused()) && !ui.chatfrag.shown()){ + if(((player.closestCore() == null && player.dead()) || state.isPaused()) && !ui.chatfrag.shown()){ //move camera around float camSpeed = !Core.input.keyDown(Binding.dash) ? 3f : 8f; Core.camera.position.add(Tmp.v1.setZero().add(Core.input.axis(Binding.move_x), Core.input.axis(Binding.move_y)).nor().scl(Time.delta() * camSpeed)); @@ -162,7 +162,7 @@ public class DesktopInput extends InputHandler{ renderer.scaleCamera(Core.input.axisTap(Binding.zoom)); } - if(player.isDead()){ + if(player.dead()){ cursorType = SystemCursor.arrow; return; } @@ -222,7 +222,7 @@ public class DesktopInput extends InputHandler{ cursorType = ui.unloadCursor; } - if(cursor.interactable(player.getTeam()) && !isPlacing() && Math.abs(Core.input.axisTap(Binding.rotate)) > 0 && Core.input.keyDown(Binding.rotateplaced) && cursor.block().rotate){ + if(cursor.interactable(player.team()) && !isPlacing() && Math.abs(Core.input.axisTap(Binding.rotate)) > 0 && Core.input.keyDown(Binding.rotateplaced) && cursor.block().rotate){ Call.rotateBlock(player, cursor, Core.input.axisTap(Binding.rotate) > 0); } } diff --git a/core/src/mindustry/input/InputHandler.java b/core/src/mindustry/input/InputHandler.java index b55f1c6ec1..8522b7c865 100644 --- a/core/src/mindustry/input/InputHandler.java +++ b/core/src/mindustry/input/InputHandler.java @@ -132,7 +132,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ ItemTransfer.create(item, player.x + Angles.trnsx(player.rotation + 180f, backTrns), player.y + Angles.trnsy(player.rotation + 180f, backTrns), new Vec2(tile.drawx() + stackTrns.x, tile.drawy() + stackTrns.y), () -> { - if(tile.block() != block || tile.entity == null || tile.entity.getItems() == null) return; + if(tile.block() != block || tile.entity == null || tile.entity.items() == null) return; tile.block().handleStack(item, removed, tile, player); remaining[1] -= removed; @@ -417,7 +417,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ } } - for(BrokenBlock req : player.getTeam().data().brokenBlocks){ + for(BrokenBlock req : player.team().data().brokenBlocks){ Block block = content.block(req.block); if(block.bounds(req.x, req.y, Tmp.r2).overlaps(Tmp.r1)){ drawSelected(req.x, req.y, content.block(req.block), Pal.remove); @@ -525,7 +525,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ } //remove blocks to rebuild - Iterator broken = state.teams.get(player.getTeam()).brokenBlocks.iterator(); + Iterator broken = state.teams.get(player.team()).brokenBlocks.iterator(); while(broken.hasNext()){ BrokenBlock req = broken.next(); Block block = content.block(req.block); @@ -565,7 +565,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ boolean consumed = false, showedInventory = false; //check if tapped block is configurable - if(tile.block().configurable && tile.interactable(player.getTeam())){ + if(tile.block().configurable && tile.interactable(player.team())){ consumed = true; if(((!frag.config.isShown() && tile.block().shouldShowConfigure(tile, player)) //if the config fragment is hidden, show //alternatively, the current selected block can 'agree' to switch config tiles @@ -587,15 +587,15 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ } //call tapped event - if(!consumed && tile.interactable(player.getTeam())){ + if(!consumed && tile.interactable(player.team())){ Call.onTileTapped(player, tile); } //consume tap event if necessary - if(tile.interactable(player.getTeam()) && tile.block().consumesTap){ + if(tile.interactable(player.team()) && tile.block().consumesTap){ consumed = true; - }else if(tile.interactable(player.getTeam()) && tile.block().synthetic() && !consumed){ - if(tile.block().hasItems && tile.entity.getItems().total() > 0){ + }else if(tile.interactable(player.team()) && tile.block().synthetic() && !consumed){ + if(tile.block().hasItems && tile.entity.items().total() > 0){ frag.inv.showFor(tile); consumed = true; showedInventory = true; @@ -750,7 +750,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ ItemStack stack = player.item(); - if(tile.block().acceptStack(stack.item, stack.amount, tile, player) > 0 && tile.interactable(player.getTeam()) && tile.block().hasItems && player.item().amount > 0 && !player.isTransferring && tile.interactable(player.getTeam())){ + if(tile.block().acceptStack(stack.item, stack.amount, tile, player) > 0 && tile.interactable(player.team()) && tile.block().hasItems && player.item().amount > 0 && !player.isTransferring && tile.interactable(player.team())){ Call.transferInventory(player, tile); }else{ Call.dropItem(player.angleTo(x, y)); @@ -782,11 +782,11 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ return false; } } - return Build.validPlace(player.getTeam(), x, y, type, rotation); + return Build.validPlace(player.team(), x, y, type, rotation); } public boolean validBreak(int x, int y){ - return Build.validBreak(player.getTeam(), x, y); + return Build.validBreak(player.team(), x, y); } public void placeBlock(int x, int y, Block block, int rotation){ diff --git a/core/src/mindustry/input/MobileInput.java b/core/src/mindustry/input/MobileInput.java index d3bfa4c3d5..f95f42acf9 100644 --- a/core/src/mindustry/input/MobileInput.java +++ b/core/src/mindustry/input/MobileInput.java @@ -67,7 +67,7 @@ public class MobileInput extends InputHandler implements GestureListener{ /** Check and assign targets for a specific position. */ void checkTargets(float x, float y){ - Unitc unit = Units.closestEnemy(player.getTeam(), x, y, 20f, u -> !u.isDead()); + Unitc unit = Units.closestEnemy(player.team(), x, y, 20f, u -> !u.dead()); if(unit != null){ player.setMineTile(null); @@ -75,11 +75,11 @@ public class MobileInput extends InputHandler implements GestureListener{ }else{ Tile tile = world.ltileWorld(x, y); - if(tile != null && tile.synthetic() && player.getTeam().isEnemy(tile.getTeam())){ + if(tile != null && tile.synthetic() && player.team().isEnemy(tile.getTeam())){ Tilec entity = tile.entity; player.setMineTile(null); player.target = entity; - }else if(tile != null && player.mech.canHeal && tile.entity != null && tile.getTeam() == player.getTeam() && tile.entity.damaged()){ + }else if(tile != null && player.mech.canHeal && tile.entity != null && tile.getTeam() == player.team() && tile.entity.damaged()){ player.setMineTile(null); player.target = tile.entity; } @@ -441,7 +441,7 @@ public class MobileInput extends InputHandler implements GestureListener{ down = true; - if(player.isDead()) return false; + if(player.dead()) return false; //get tile on cursor Tile cursor = tileAt(screenX, screenY); @@ -518,7 +518,7 @@ public class MobileInput extends InputHandler implements GestureListener{ @Override public boolean longPress(float x, float y){ - if(state.is(State.menu) || mode == none || player.isDead()) return false; + if(state.is(State.menu) || mode == none || player.dead()) return false; //get tile on cursor Tile cursor = tileAt(x, y); @@ -583,7 +583,7 @@ public class MobileInput extends InputHandler implements GestureListener{ mode = none; } - if(player.isDead()){ + if(player.dead()){ mode = none; } diff --git a/core/src/mindustry/maps/generators/MapGenerator.java b/core/src/mindustry/maps/generators/MapGenerator.java index b64b03f2a7..a55222d758 100644 --- a/core/src/mindustry/maps/generators/MapGenerator.java +++ b/core/src/mindustry/maps/generators/MapGenerator.java @@ -111,7 +111,7 @@ public class MapGenerator extends Generator{ if(tile.block() instanceof StorageBlock && !(tile.block() instanceof CoreBlock) && world.getZone() != null){ for(Item item : world.getZone().resources){ if(Mathf.chance(0.3)){ - tile.entity.getItems().add(item, Math.min(Mathf.random(500), tile.block().itemCapacity)); + tile.entity.items().add(item, Math.min(Mathf.random(500), tile.block().itemCapacity)); } } } diff --git a/core/src/mindustry/type/StatusEffect.java b/core/src/mindustry/type/StatusEffect.java index 99eb17afdf..e7aacc1c41 100644 --- a/core/src/mindustry/type/StatusEffect.java +++ b/core/src/mindustry/type/StatusEffect.java @@ -50,7 +50,7 @@ public class StatusEffect extends MappableContent{ } if(effect != Fx.none && Mathf.chance(Time.delta() * 0.15f)){ - effect.at(unit.getX() + Mathf.range(unit.getBounds() / 2f), unit.getY() + Mathf.range(unit.getBounds() / 2f)); + effect.at(unit.getX() + Mathf.range(unit.bounds() / 2f), unit.getY() + Mathf.range(unit.bounds() / 2f)); } } diff --git a/core/src/mindustry/type/UnitDef.java b/core/src/mindustry/type/UnitDef.java index 31543fe1aa..2984a026e1 100644 --- a/core/src/mindustry/type/UnitDef.java +++ b/core/src/mindustry/type/UnitDef.java @@ -12,7 +12,6 @@ import arc.util.ArcAnnotate.*; import arc.util.*; import mindustry.annotations.Annotations.*; import mindustry.ctype.*; -import mindustry.entities.type.*; import mindustry.entities.type.base.*; import mindustry.game.*; import mindustry.gen.*; @@ -106,7 +105,7 @@ public class UnitDef extends UnlockableContent{ public void drawStats(Unitc player){ if(drawCell){ float health = player.healthf(); - Draw.color(Color.black, player.getTeam().color, health + Mathf.absin(Time.time(), health * 5f, 1f - health)); + Draw.color(Color.black, player.team().color, health + Mathf.absin(Time.time(), health * 5f, 1f - health)); Draw.rect(player.getPowerCellRegion(), player.x + Angles.trnsx(player.rotation, cellOffsetY, cellOffsetX), player.y + Angles.trnsy(player.rotation, cellOffsetY, cellOffsetX), diff --git a/core/src/mindustry/ui/ItemsDisplay.java b/core/src/mindustry/ui/ItemsDisplay.java index 995918895f..6472c5ee5b 100644 --- a/core/src/mindustry/ui/ItemsDisplay.java +++ b/core/src/mindustry/ui/ItemsDisplay.java @@ -53,9 +53,9 @@ public class ItemsDisplay extends Table{ private String format(Item item){ builder.setLength(0); builder.append(ui.formatAmount(data.items().get(item, 0))); - if(!state.is(State.menu) && player.getTeam().data().hasCore() && player.getTeam().core().items.get(item) > 0){ + if(!state.is(State.menu) && player.team().data().hasCore() && player.team().core().items.get(item) > 0){ builder.append(" [unlaunched]+ "); - builder.append(ui.formatAmount(state.teams.get(player.getTeam()).core().items.get(item))); + builder.append(ui.formatAmount(state.teams.get(player.team()).core().items.get(item))); } return builder.toString(); } diff --git a/core/src/mindustry/ui/dialogs/GameOverDialog.java b/core/src/mindustry/ui/dialogs/GameOverDialog.java index f5a9605a82..580f2a474a 100644 --- a/core/src/mindustry/ui/dialogs/GameOverDialog.java +++ b/core/src/mindustry/ui/dialogs/GameOverDialog.java @@ -22,7 +22,7 @@ public class GameOverDialog extends FloatingDialog{ public void show(Team winner){ this.winner = winner; show(); - if(winner == player.getTeam()){ + if(winner == player.team()){ Events.fire(new WinEvent()); }else{ Events.fire(new LoseEvent()); diff --git a/core/src/mindustry/ui/fragments/BlockInventoryFragment.java b/core/src/mindustry/ui/fragments/BlockInventoryFragment.java index 948834d923..a8e3a219aa 100644 --- a/core/src/mindustry/ui/fragments/BlockInventoryFragment.java +++ b/core/src/mindustry/ui/fragments/BlockInventoryFragment.java @@ -38,8 +38,8 @@ public class BlockInventoryFragment extends Fragment{ @Remote(called = Loc.server, targets = Loc.both, forward = true) public static void requestItem(Player player, Tile tile, Item item, int amount){ - if(player == null || tile == null || !tile.interactable(player.getTeam())) return; - amount = Mathf.clamp(amount, 0, player.getItemCapacity()); + if(player == null || tile == null || !tile.interactable(player.team())) return; + amount = Mathf.clamp(amount, 0, player.ttemCapacity()); int fa = amount; if(net.server() && (!Units.canInteract(player, tile) || @@ -71,7 +71,7 @@ public class BlockInventoryFragment extends Fragment{ return; } this.tile = t; - if(tile == null || tile.entity == null || !tile.block().isAccessible() || tile.entity.getItems().total() == 0) + if(tile == null || tile.entity == null || !tile.block().isAccessible() || tile.entity.items().total() == 0) return; rebuild(true); } @@ -98,14 +98,14 @@ public class BlockInventoryFragment extends Fragment{ table.touchable(Touchable.enabled); table.update(() -> { - if(state.is(State.menu) || tile == null || tile.entity == null || !tile.block().isAccessible() || tile.entity.getItems().total() == 0){ + if(state.is(State.menu) || tile == null || tile.entity == null || !tile.block().isAccessible() || tile.entity.items().total() == 0){ hide(); }else{ if(holding && lastItem != null){ holdTime += Time.delta(); if(holdTime >= holdWithdraw){ - int amount = Math.min(tile.entity.getItems().get(lastItem), player.maxAccepted(lastItem)); + int amount = Math.min(tile.entity.items().get(lastItem), player.maxAccepted(lastItem)); Call.requestItem(player, tile, lastItem, amount); holding = false; holdTime = 0f; @@ -117,7 +117,7 @@ public class BlockInventoryFragment extends Fragment{ updateTablePosition(); if(tile.block().hasItems){ for(int i = 0; i < content.items().size; i++){ - boolean has = tile.entity.getItems().has(content.item(i)); + boolean has = tile.entity.items().has(content.item(i)); if(has != container.contains(i)){ rebuild(false); } @@ -136,7 +136,7 @@ public class BlockInventoryFragment extends Fragment{ for(int i = 0; i < content.items().size; i++){ Item item = content.item(i); - if(!tile.entity.getItems().has(item)) continue; + if(!tile.entity.items().has(item)) continue; container.add(i); @@ -149,14 +149,14 @@ public class BlockInventoryFragment extends Fragment{ if(tile == null || tile.entity == null){ return ""; } - return round(tile.entity.getItems().get(item)); + return round(tile.entity.items().get(item)); }); image.addListener(l); image.addListener(new InputListener(){ @Override public boolean touchDown(InputEvent event, float x, float y, int pointer, KeyCode button){ - if(!canPick.get() || tile == null || tile.entity == null || tile.entity.getItems() == null || !tile.entity.getItems().has(item)) return false; + if(!canPick.get() || tile == null || tile.entity == null || tile.entity.items() == null || !tile.entity.items().has(item)) return false; int amount = Math.min(1, player.maxAccepted(item)); if(amount > 0){ Call.requestItem(player, tile, item, amount); diff --git a/core/src/mindustry/ui/fragments/HudFragment.java b/core/src/mindustry/ui/fragments/HudFragment.java index 3109179e1b..0f854b14c2 100644 --- a/core/src/mindustry/ui/fragments/HudFragment.java +++ b/core/src/mindustry/ui/fragments/HudFragment.java @@ -27,7 +27,6 @@ import mindustry.gen.*; import mindustry.graphics.*; import mindustry.input.*; import mindustry.net.Packets.*; -import mindustry.type.*; import mindustry.ui.*; import mindustry.ui.Cicon; import mindustry.ui.dialogs.*; @@ -173,7 +172,7 @@ public class HudFragment extends Fragment{ .size(50f).margin(6f).get(); button.getImageCell().grow(); button.getStyle().imageUpColor = team.color; - button.update(() -> button.setChecked(player.getTeam() == team)); + button.update(() -> button.setChecked(player.team() == team)); if(++i % 3 == 0){ teams.row(); @@ -287,7 +286,7 @@ public class HudFragment extends Fragment{ }); t.top().visible(() -> { - if(state.is(State.menu) || !state.teams.get(player.getTeam()).hasCore()){ + if(state.is(State.menu) || !state.teams.get(player.team()).hasCore()){ coreAttackTime[0] = 0f; return false; } @@ -347,14 +346,14 @@ public class HudFragment extends Fragment{ @Remote(targets = Loc.both, forward = true, called = Loc.both) public static void setPlayerTeamEditor(Player player, Team team){ if(state.isEditor() && player != null){ - player.setTeam(team); + player.team(team); } } @Remote(targets = Loc.both, called = Loc.server) public static void spawnUnitEditor(Player player, UnitType type){ if(state.isEditor()){ - BaseUnit unit = type.create(player.getTeam()); + BaseUnit unit = type.create(player.team()); unit.set(player.x, player.y); unit.rotation = player.rotation; unit.add(); diff --git a/core/src/mindustry/ui/fragments/PlacementFragment.java b/core/src/mindustry/ui/fragments/PlacementFragment.java index ac03e5e727..2eb3be05c2 100644 --- a/core/src/mindustry/ui/fragments/PlacementFragment.java +++ b/core/src/mindustry/ui/fragments/PlacementFragment.java @@ -15,7 +15,6 @@ import mindustry.content.*; import mindustry.gen.*; import mindustry.entities.units.*; import mindustry.game.EventType.*; -import mindustry.gen.*; import mindustry.graphics.*; import mindustry.input.*; import mindustry.type.*; @@ -220,8 +219,8 @@ public class PlacementFragment extends Fragment{ button.resizeImage(Cicon.medium.size); button.update(() -> { //color unplacable things gray - Tilec core = player.getClosestCore(); - Color color = state.rules.infiniteResources || (core != null && (core.getItems().has(block.requirements, state.rules.buildCostMultiplier) || state.rules.infiniteResources)) ? Color.white : Color.gray; + Tilec core = player.closestCore(); + Color color = state.rules.infiniteResources || (core != null && (core.items().has(block.requirements, state.rules.buildCostMultiplier) || state.rules.infiniteResources)) ? Color.white : Color.gray; button.forEach(elem -> elem.setColor(color)); button.setChecked(control.input.block == block); @@ -308,10 +307,10 @@ public class PlacementFragment extends Fragment{ line.addImage(stack.item.icon(Cicon.small)).size(8 * 2); line.add(stack.item.localizedName).maxWidth(140f).fillX().color(Color.lightGray).padLeft(2).left().get().setEllipsis(true); line.labelWrap(() -> { - Tilec core = player.getClosestCore(); + Tilec core = player.closestCore(); if(core == null || state.rules.infiniteResources) return "*/*"; - int amount = core.getItems().get(stack.item); + int amount = core.items().get(stack.item); int stackamount = Math.round(stack.amount * state.rules.buildCostMultiplier); String color = (amount < stackamount / 2f ? "[red]" : amount < stackamount ? "[accent]" : "[white]"); @@ -338,7 +337,7 @@ public class PlacementFragment extends Fragment{ t.add(new Image(lastDisplay.getDisplayIcon(hoverTile))).size(8 * 4); t.labelWrap(lastDisplay.getDisplayName(hoverTile)).left().width(190f).padLeft(5); }).growX().left(); - if(hoverTile.getTeam() == player.getTeam()){ + if(hoverTile.getTeam() == player.team()){ topTable.row(); topTable.table(t -> { t.left().defaults().left(); diff --git a/core/src/mindustry/ui/fragments/PlayerListFragment.java b/core/src/mindustry/ui/fragments/PlayerListFragment.java index 1b71d710c7..9f9740d0f9 100644 --- a/core/src/mindustry/ui/fragments/PlayerListFragment.java +++ b/core/src/mindustry/ui/fragments/PlayerListFragment.java @@ -65,7 +65,7 @@ public class PlayerListFragment extends Fragment{ float h = 74f; - playerGroup.all().sort(Structs.comparing(Unitc::getTeam)); + playerGroup.all().sort(Structs.comparing(Unitc::team)); playerGroup.all().each(user -> { NetConnection connection = user.con; @@ -129,7 +129,7 @@ public class PlayerListFragment extends Fragment{ t.addImageButton(Icon.zoom, Styles.clearPartiali, () -> Call.onAdminRequest(user, AdminAction.trace)); }).padRight(12).size(bs + 10f, bs); - }else if(!user.isLocal && !user.isAdmin && net.client() && playerGroup.size() >= 3 && player.getTeam() == user.getTeam()){ //votekick + }else if(!user.isLocal && !user.isAdmin && net.client() && playerGroup.size() >= 3 && player.team() == user.getTeam()){ //votekick button.add().growY(); button.addImageButton(Icon.hammer, Styles.clearPartiali, diff --git a/core/src/mindustry/world/Block.java b/core/src/mindustry/world/Block.java index 386b6e7e76..2a41af4c3b 100644 --- a/core/src/mindustry/world/Block.java +++ b/core/src/mindustry/world/Block.java @@ -176,7 +176,7 @@ public class Block extends BlockStorage{ } public void onProximityRemoved(Tile tile){ - if(tile.entity.getPower() != null){ + if(tile.entity.power() != null){ tile.block().powerGraphRemoved(tile); } } @@ -189,41 +189,41 @@ public class Block extends BlockStorage{ Tilec entity = tile.ent(); for(Tile other : getPowerConnections(tile, tempTiles)){ - if(other.entity.getPower() != null){ - other.entity.getPower().graph.add(entity.getPower().graph); + if(other.entity.power() != null){ + other.entity.power().graph.add(entity.power().graph); } } } protected void powerGraphRemoved(Tile tile){ - if(tile.entity == null || tile.entity.getPower() == null){ + if(tile.entity == null || tile.entity.power() == null){ return; } - tile.entity.getPower().graph.remove(tile); - for(int i = 0; i < tile.entity.getPower().links.size; i++){ - Tile other = world.tile(tile.entity.getPower().links.get(i)); - if(other != null && other.entity != null && other.entity.getPower() != null){ - other.entity.getPower().links.removeValue(tile.pos()); + tile.entity.power().graph.remove(tile); + for(int i = 0; i < tile.entity.power().links.size; i++){ + Tile other = world.tile(tile.entity.power().links.get(i)); + if(other != null && other.entity != null && other.entity.power() != null){ + other.entity.power().links.removeValue(tile.pos()); } } } public Array getPowerConnections(Tile tile, Array out){ out.clear(); - if(tile == null || tile.entity == null || tile.entity.getPower() == null) return out; + if(tile == null || tile.entity == null || tile.entity.power() == null) return out; for(Tile other : tile.entity.proximity()){ - if(other != null && other.entity != null && other.entity.getPower() != null + if(other != null && other.entity != null && other.entity.power() != null && !(consumesPower && other.block().consumesPower && !outputsPower && !other.block().outputsPower) - && !tile.entity.getPower().links.contains(other.pos())){ + && !tile.entity.power().links.contains(other.pos())){ out.add(other); } } - for(int i = 0; i < tile.entity.getPower().links.size; i++){ - Tile link = world.tile(tile.entity.getPower().links.get(i)); - if(link != null && link.entity != null && link.entity.getPower() != null) out.add(link); + for(int i = 0; i < tile.entity.power().links.size; i++){ + Tile link = world.tile(tile.entity.power().links.get(i)); + if(link != null && link.entity != null && link.entity.power() != null) out.add(link); } return out; } @@ -300,8 +300,8 @@ public class Block extends BlockStorage{ } public void drawLight(Tile tile){ - if(tile.entity != null && hasLiquids && drawLiquidLight && tile.entity.getLiquids().current().lightColor.a > 0.001f){ - drawLiquidLight(tile, tile.entity.getLiquids().current(), tile.entity.getLiquids().smoothAmount()); + if(tile.entity != null && hasLiquids && drawLiquidLight && tile.entity.liquids().current().lightColor.a > 0.001f){ + drawLiquidLight(tile, tile.entity.liquids().current(), tile.entity.liquids().smoothAmount()); } } @@ -339,14 +339,14 @@ public class Block extends BlockStorage{ Geometry.circle(tile.x, tile.y, range, (x, y) -> { Tile other = world.ltile(x, y); if(other != null && other.block instanceof PowerNode && ((PowerNode)other.block).linkValid(other, tile) && !PowerNode.insulated(other, tile) && !other.entity.proximity().contains(tile) && - !(outputsPower && tile.entity.proximity().contains(p -> p.entity != null && p.entity.getPower() != null && p.entity.getPower().graph == other.entity.getPower().graph))){ + !(outputsPower && tile.entity.proximity().contains(p -> p.entity != null && p.entity.power() != null && p.entity.power().graph == other.entity.power().graph))){ tempTiles.add(other); } }); tempTiles.sort(Structs.comparingFloat(t -> t.dst2(tile))); if(!tempTiles.isEmpty()){ Tile toLink = tempTiles.first(); - if(!toLink.entity.getPower().links.contains(tile.pos())){ + if(!toLink.entity.power().links.contains(tile.pos())){ toLink.configureAny(tile.pos()); } } @@ -372,7 +372,7 @@ public class Block extends BlockStorage{ /** Call when some content is produced. This unlocks the content if it is applicable. */ public void useContent(Tile tile, UnlockableContent content){ //only unlocks content in zones - if(!headless && tile.getTeam() == player.getTeam() && world.isZone()){ + if(!headless && tile.getTeam() == player.team() && world.isZone()){ logic.handleContent(content); } } @@ -547,10 +547,10 @@ public class Block extends BlockStorage{ Liquid liquid = consumes.get(ConsumeType.liquid).liquid; current = entity -> liquid; }else{ - current = entity -> entity.getLiquids().current(); + current = entity -> entity.liquids().current(); } - bars.add("liquid", entity -> new Bar(() -> entity.getLiquids().get(current.get(entity)) <= 0.001f ? Core.bundle.get("bar.liquid") : current.get(entity).localizedName, - () -> current.get(entity).barColor(), () -> entity.getLiquids().get(current.get(entity)) / liquidCapacity)); + bars.add("liquid", entity -> new Bar(() -> entity.liquids().get(current.get(entity)) <= 0.001f ? Core.bundle.get("bar.liquid") : current.get(entity).localizedName, + () -> current.get(entity).barColor(), () -> entity.liquids().get(current.get(entity)) / liquidCapacity)); } if(hasPower && consumes.hasPower()){ @@ -558,12 +558,12 @@ public class Block extends BlockStorage{ boolean buffered = cons.buffered; float capacity = cons.capacity; - bars.add("power", entity -> new Bar(() -> buffered ? Core.bundle.format("bar.poweramount", Float.isNaN(entity.getPower().status * capacity) ? "" : (int)(entity.getPower().status * capacity)) : - Core.bundle.get("bar.power"), () -> Pal.powerBar, () -> Mathf.zero(cons.requestedPower(entity)) && entity.getPower().graph.getPowerProduced() + entity.getPower().graph.getBatteryStored() > 0f ? 1f : entity.getPower().status)); + bars.add("power", entity -> new Bar(() -> buffered ? Core.bundle.format("bar.poweramount", Float.isNaN(entity.power().status * capacity) ? "" : (int)(entity.power().status * capacity)) : + Core.bundle.get("bar.power"), () -> Pal.powerBar, () -> Mathf.zero(cons.requestedPower(entity)) && entity.power().graph.getPowerProduced() + entity.power().graph.getBatteryStored() > 0f ? 1f : entity.power().status)); } if(hasItems && configurable){ - bars.add("items", entity -> new Bar(() -> Core.bundle.format("bar.items", entity.getItems().total()), () -> Pal.items, () -> (float)entity.getItems().total() / itemCapacity)); + bars.add("items", entity -> new Bar(() -> Core.bundle.format("bar.items", entity.items().total()), () -> Pal.items, () -> (float)entity.items().total() / itemCapacity)); } } @@ -608,24 +608,24 @@ public class Block extends BlockStorage{ if(hasItems){ for(Item item : content.items()){ - int amount = tile.entity.getItems().get(item); + int amount = tile.entity.items().get(item); explosiveness += item.explosiveness * amount; flammability += item.flammability * amount; } } if(hasLiquids){ - flammability += tile.entity.getLiquids().sum((liquid, amount) -> liquid.explosiveness * amount / 2f); - explosiveness += tile.entity.getLiquids().sum((liquid, amount) -> liquid.flammability * amount / 2f); + flammability += tile.entity.liquids().sum((liquid, amount) -> liquid.explosiveness * amount / 2f); + explosiveness += tile.entity.liquids().sum((liquid, amount) -> liquid.flammability * amount / 2f); } if(consumes.hasPower() && consumes.getPower().buffered){ - power += tile.entity.getPower().status * consumes.getPower().capacity; + power += tile.entity.power().status * consumes.getPower().capacity; } if(hasLiquids){ - tile.entity.getLiquids().each((liquid, amount) -> { + tile.entity.liquids().each((liquid, amount) -> { float splash = Mathf.clamp(amount / 4f, 0f, 10f); for(int i = 0; i < Mathf.clamp(amount / 5, 0, 30); i++){ @@ -656,10 +656,10 @@ public class Block extends BlockStorage{ } return 0; }else{ - float result = tile.entity.getItems().sum((item, amount) -> item.flammability * amount); + float result = tile.entity.items().sum((item, amount) -> item.flammability * amount); if(hasLiquids){ - result += tile.entity.getLiquids().sum((liquid, amount) -> liquid.flammability * amount / 3f); + result += tile.entity.liquids().sum((liquid, amount) -> liquid.flammability * amount / 3f); } return result; diff --git a/core/src/mindustry/world/BlockStorage.java b/core/src/mindustry/world/BlockStorage.java index 8e15231015..53844dce65 100644 --- a/core/src/mindustry/world/BlockStorage.java +++ b/core/src/mindustry/world/BlockStorage.java @@ -9,7 +9,6 @@ import mindustry.content.*; import mindustry.ctype.*; import mindustry.entities.effect.*; import mindustry.gen.*; -import mindustry.gen.*; import mindustry.type.*; import mindustry.world.consumers.*; import mindustry.world.meta.*; @@ -49,8 +48,8 @@ public abstract class BlockStorage extends UnlockableContent{ /** Returns the amount of items this block can accept. */ public int acceptStack(Item item, int amount, Tile tile, Teamc source){ - if(acceptItem(item, tile, tile) && hasItems && (source == null || source.getTeam() == tile.getTeam())){ - return Math.min(getMaximumAccepted(tile, item) - tile.entity.getItems().get(item), amount); + if(acceptItem(item, tile, tile) && hasItems && (source == null || source.team() == tile.getTeam())){ + return Math.min(getMaximumAccepted(tile, item) - tile.entity.items().get(item), amount); }else{ return 0; } @@ -62,17 +61,17 @@ public abstract class BlockStorage extends UnlockableContent{ /** Remove a stack from this inventory, and return the amount removed. */ public int removeStack(Tile tile, Item item, int amount){ - if(tile.entity == null || tile.entity.getItems() == null) return 0; - amount = Math.min(amount, tile.entity.getItems().get(item)); + if(tile.entity == null || tile.entity.items() == null) return 0; + amount = Math.min(amount, tile.entity.items().get(item)); tile.entity.noSleep(); - tile.entity.getItems().remove(item, amount); + tile.entity.items().remove(item, amount); return amount; } /** Handle a stack input. */ public void handleStack(Item item, int amount, Tile tile, Teamc source){ tile.entity.noSleep(); - tile.entity.getItems().add(item, amount); + tile.entity.items().add(item, amount); } public boolean outputsItems(){ @@ -89,19 +88,19 @@ public abstract class BlockStorage extends UnlockableContent{ } public void handleItem(Item item, Tile tile, Tile source){ - tile.entity.getItems().add(item, 1); + tile.entity.items().add(item, 1); } public boolean acceptItem(Item item, Tile tile, Tile source){ - return consumes.itemFilters.get(item.id) && tile.entity.getItems().get(item) < getMaximumAccepted(tile, item); + return consumes.itemFilters.get(item.id) && tile.entity.items().get(item) < getMaximumAccepted(tile, item); } public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount){ - return hasLiquids && tile.entity.getLiquids().get(liquid) + amount < liquidCapacity && consumes.liquidfilters.get(liquid.id); + return hasLiquids && tile.entity.liquids().get(liquid) + amount < liquidCapacity && consumes.liquidfilters.get(liquid.id); } public void handleLiquid(Tile tile, Tile source, Liquid liquid, float amount){ - tile.entity.getLiquids().add(liquid, amount); + tile.entity.liquids().add(liquid, amount); } public void tryDumpLiquid(Tile tile, Liquid liquid){ @@ -115,9 +114,9 @@ public abstract class BlockStorage extends UnlockableContent{ other = other.block().getLiquidDestination(other, in, liquid); - if(other != null && other.getTeam() == tile.getTeam() && other.block().hasLiquids && canDumpLiquid(tile, other, liquid) && other.entity.getLiquids() != null){ - float ofract = other.entity.getLiquids().get(liquid) / other.block().liquidCapacity; - float fract = tile.entity.getLiquids().get(liquid) / liquidCapacity; + if(other != null && other.getTeam() == tile.getTeam() && other.block().hasLiquids && canDumpLiquid(tile, other, liquid) && other.entity.liquids() != null){ + float ofract = other.entity.liquids().get(liquid) / other.block().liquidCapacity; + float fract = tile.entity.liquids().get(liquid) / liquidCapacity; if(ofract < fract) tryMoveLiquid(tile, in, other, (fract - ofract) * liquidCapacity / 2f, liquid); } @@ -130,11 +129,11 @@ public abstract class BlockStorage extends UnlockableContent{ } public void tryMoveLiquid(Tile tile, Tile tileSource, Tile next, float amount, Liquid liquid){ - float flow = Math.min(next.block().liquidCapacity - next.entity.getLiquids().get(liquid) - 0.001f, amount); + float flow = Math.min(next.block().liquidCapacity - next.entity.liquids().get(liquid) - 0.001f, amount); if(next.block().acceptLiquid(next, tileSource, liquid, flow)){ next.block().handleLiquid(next, tileSource, liquid, flow); - tile.entity.getLiquids().remove(liquid, flow); + tile.entity.liquids().remove(liquid, flow); } } @@ -148,20 +147,20 @@ public abstract class BlockStorage extends UnlockableContent{ next = next.link(); next = next.block().getLiquidDestination(next, tile, liquid); - if(next.getTeam() == tile.getTeam() && next.block().hasLiquids && tile.entity.getLiquids().get(liquid) > 0f){ + if(next.getTeam() == tile.getTeam() && next.block().hasLiquids && tile.entity.liquids().get(liquid) > 0f){ if(next.block().acceptLiquid(next, tile, liquid, 0f)){ - float ofract = next.entity.getLiquids().get(liquid) / next.block().liquidCapacity; - float fract = tile.entity.getLiquids().get(liquid) / liquidCapacity * liquidPressure; - float flow = Math.min(Mathf.clamp((fract - ofract) * (1f)) * (liquidCapacity), tile.entity.getLiquids().get(liquid)); - flow = Math.min(flow, next.block().liquidCapacity - next.entity.getLiquids().get(liquid) - 0.001f); + float ofract = next.entity.liquids().get(liquid) / next.block().liquidCapacity; + float fract = tile.entity.liquids().get(liquid) / liquidCapacity * liquidPressure; + float flow = Math.min(Mathf.clamp((fract - ofract) * (1f)) * (liquidCapacity), tile.entity.liquids().get(liquid)); + flow = Math.min(flow, next.block().liquidCapacity - next.entity.liquids().get(liquid) - 0.001f); if(flow > 0f && ofract <= fract && next.block().acceptLiquid(next, tile, liquid, flow)){ next.block().handleLiquid(next, tile, liquid, flow); - tile.entity.getLiquids().remove(liquid, flow); + tile.entity.liquids().remove(liquid, flow); return flow; }else if(ofract > 0.1f && fract > 0.1f){ - Liquid other = next.entity.getLiquids().current(); + Liquid other = next.entity.liquids().current(); if((other.flammability > 0.3f && liquid.temperature > 0.7f) || (liquid.flammability > 0.3f && other.temperature > 0.7f)){ tile.entity.damage(1 * Time.delta()); next.entity.damage(1 * Time.delta()); @@ -169,7 +168,7 @@ public abstract class BlockStorage extends UnlockableContent{ Fx.fire.at((tile.worldx() + next.worldx()) / 2f, (tile.worldy() + next.worldy()) / 2f); } }else if((liquid.temperature > 0.7f && other.temperature < 0.55f) || (other.temperature > 0.7f && liquid.temperature < 0.55f)){ - tile.entity.getLiquids().remove(liquid, Math.min(tile.entity.getLiquids().get(liquid), 0.7f * Time.delta())); + tile.entity.liquids().remove(liquid, Math.min(tile.entity.liquids().get(liquid), 0.7f * Time.delta())); if(Mathf.chance(0.2f * Time.delta())){ Fx.steam.at((tile.worldx() + next.worldx()) / 2f, (tile.worldy() + next.worldy()) / 2f); } @@ -177,9 +176,9 @@ public abstract class BlockStorage extends UnlockableContent{ } } }else if(leakResistance != 100f && !next.block().solid && !next.block().hasLiquids){ - float leakAmount = tile.entity.getLiquids().get(liquid) / leakResistance; + float leakAmount = tile.entity.liquids().get(liquid) / leakResistance; Puddle.deposit(next, tile, liquid, leakAmount); - tile.entity.getLiquids().remove(liquid, leakAmount); + tile.entity.liquids().remove(liquid, leakAmount); } return 0; } @@ -220,7 +219,7 @@ public abstract class BlockStorage extends UnlockableContent{ */ public boolean tryDump(Tile tile, Item todump){ Tilec entity = tile.entity; - if(entity == null || !hasItems || tile.entity.getItems().total() == 0 || (todump != null && !entity.getItems().has(todump))) + if(entity == null || !hasItems || tile.entity.items().total() == 0 || (todump != null && !entity.items().has(todump))) return false; Array proximity = entity.proximity(); @@ -237,9 +236,9 @@ public abstract class BlockStorage extends UnlockableContent{ for(int ii = 0; ii < Vars.content.items().size; ii++){ Item item = Vars.content.item(ii); - if(other.getTeam() == tile.getTeam() && entity.getItems().has(item) && other.block().acceptItem(item, other, in) && canDump(tile, other, item)){ + if(other.getTeam() == tile.getTeam() && entity.items().has(item) && other.block().acceptItem(item, other, in) && canDump(tile, other, item)){ other.block().handleItem(item, other, in); - tile.entity.getItems().remove(item, 1); + tile.entity.items().remove(item, 1); incrementDump(tile, proximity.size); return true; } @@ -248,7 +247,7 @@ public abstract class BlockStorage extends UnlockableContent{ if(other.getTeam() == tile.getTeam() && other.block().acceptItem(todump, other, in) && canDump(tile, other, todump)){ other.block().handleItem(todump, other, in); - tile.entity.getItems().remove(todump, 1); + tile.entity.items().remove(todump, 1); incrementDump(tile, proximity.size); return true; } diff --git a/core/src/mindustry/world/Tile.java b/core/src/mindustry/world/Tile.java index 528e7d7972..aa1626c3e9 100644 --- a/core/src/mindustry/world/Tile.java +++ b/core/src/mindustry/world/Tile.java @@ -455,12 +455,12 @@ public class Tile implements Position{ if(block.hasEntity()){ //TODO assign data and don't use new entity entity = block.newEntity().init(this, block.update); - entity.setCons(new ConsumeModule(entity)); - if(block.hasItems) entity.setItems(new ItemModule()); - if(block.hasLiquids) entity.setLiquids(new LiquidModule()); + entity.cons(new ConsumeModule(entity)); + if(block.hasItems) entity.items(new ItemModule()); + if(block.hasLiquids) entity.liquids(new LiquidModule()); if(block.hasPower){ - entity.setPower(new PowerModule()); - entity.getPower().graph.add(this); + entity.power(new PowerModule()); + entity.power().graph.add(this); } if(!world.isGenerating()){ @@ -511,7 +511,7 @@ public class Tile implements Position{ @Remote(called = Loc.server, unreliable = true) public static void onTileDamage(Tile tile, float health){ if(tile.entity != null){ - tile.entity.setHealth(health); + tile.entity.health(health); if(tile.entity.damaged()){ indexer.notifyTileDamaged(tile.entity); diff --git a/core/src/mindustry/world/blocks/BuildBlock.java b/core/src/mindustry/world/blocks/BuildBlock.java index 4dc61ec3ae..0b097ec8b6 100644 --- a/core/src/mindustry/world/blocks/BuildBlock.java +++ b/core/src/mindustry/world/blocks/BuildBlock.java @@ -9,13 +9,11 @@ import arc.math.*; import arc.util.ArcAnnotate.*; import arc.util.*; import mindustry.content.*; -import mindustry.entities.effect.*; import mindustry.entities.type.*; import mindustry.gen.*; import mindustry.entities.units.*; import mindustry.game.EventType.*; import mindustry.game.*; -import mindustry.gen.*; import mindustry.graphics.*; import mindustry.type.*; import mindustry.ui.*; @@ -228,7 +226,7 @@ public class BuildBlock extends Block{ setConstruct(previous, cblock); } - float maxProgress = core == null ? amount : checkRequired(core.getItems(), amount, false); + float maxProgress = core == null ? amount : checkRequired(core.items(), amount, false); for(int i = 0; i < cblock.requirements.length; i++){ int reqamount = Math.round(state.rules.buildCostMultiplier * cblock.requirements[i].amount); @@ -236,13 +234,13 @@ public class BuildBlock extends Block{ totalAccumulator[i] = Math.min(totalAccumulator[i] + reqamount * maxProgress, reqamount); } - maxProgress = core == null ? maxProgress : checkRequired(core.getItems(), maxProgress, true); + maxProgress = core == null ? maxProgress : checkRequired(core.items(), maxProgress, true); progress = Mathf.clamp(progress + maxProgress); builderID = builder.getId(); if(progress >= 1f || state.rules.infiniteResources){ - constructed(tile, cblock, builderID, tile.rotation(), builder.getTeam(), configured); + constructed(tile, cblock, builderID, tile.rotation(), builder.team(), configured); return true; } return false; diff --git a/core/src/mindustry/world/blocks/LiquidBlock.java b/core/src/mindustry/world/blocks/LiquidBlock.java index 3aa52549d8..9b8c45842f 100644 --- a/core/src/mindustry/world/blocks/LiquidBlock.java +++ b/core/src/mindustry/world/blocks/LiquidBlock.java @@ -36,7 +36,7 @@ public class LiquidBlock extends Block{ @Override public void draw(Tile tile){ - LiquidModule mod = tile.entity.getLiquids(); + LiquidModule mod = tile.entity.liquids(); int rotation = rotate ? tile.rotation() * 90 : 0; diff --git a/core/src/mindustry/world/blocks/defense/SurgeWall.java b/core/src/mindustry/world/blocks/defense/SurgeWall.java index eba0613183..f495beb94b 100644 --- a/core/src/mindustry/world/blocks/defense/SurgeWall.java +++ b/core/src/mindustry/world/blocks/defense/SurgeWall.java @@ -18,7 +18,7 @@ public class SurgeWall extends Wall{ public void handleBulletHit(Tilec entity, Bullet bullet){ super.handleBulletHit(entity, bullet); if(Mathf.chance(lightningChance)){ - Lightning.create(entity.getTeam(), Pal.surge, lightningDamage, bullet.x, bullet.y, bullet.rot() + 180f, lightningLength); + Lightning.create(entity.team(), Pal.surge, lightningDamage, bullet.x, bullet.y, bullet.rot() + 180f, lightningLength); } } } diff --git a/core/src/mindustry/world/blocks/defense/turrets/CooledTurret.java b/core/src/mindustry/world/blocks/defense/turrets/CooledTurret.java index 270bd6b45a..1ec02cc07b 100644 --- a/core/src/mindustry/world/blocks/defense/turrets/CooledTurret.java +++ b/core/src/mindustry/world/blocks/defense/turrets/CooledTurret.java @@ -5,7 +5,6 @@ import arc.math.*; import arc.util.*; import mindustry.content.*; import mindustry.entities.*; -import mindustry.entities.Effects.*; import mindustry.game.EventType.*; import mindustry.type.*; import mindustry.world.*; @@ -37,7 +36,7 @@ public class CooledTurret extends Turret{ @Override public void handleLiquid(Tile tile, Tile source, Liquid liquid, float amount){ - if(tile.entity.getLiquids().currentAmount() <= 0.001f){ + if(tile.entity.liquids().currentAmount() <= 0.001f){ Events.fire(Trigger.turretCool); } @@ -51,11 +50,11 @@ public class CooledTurret extends Turret{ float maxUsed = consumes.get(ConsumeType.liquid).amount; TurretEntity entity = tile.ent(); - Liquid liquid = entity.getLiquids().current(); + Liquid liquid = entity.liquids().current(); - float used = Math.min(Math.min(entity.getLiquids().get(liquid), maxUsed * Time.delta()), Math.max(0, ((reload - entity.reload) / coolantMultiplier) / liquid.heatCapacity)) * baseReloadSpeed(tile); + float used = Math.min(Math.min(entity.liquids().get(liquid), maxUsed * Time.delta()), Math.max(0, ((reload - entity.reload) / coolantMultiplier) / liquid.heatCapacity)) * baseReloadSpeed(tile); entity.reload += used * liquid.heatCapacity * coolantMultiplier; - entity.getLiquids().remove(liquid, used); + entity.liquids().remove(liquid, used); if(Mathf.chance(0.06 * used)){ coolEffect.at(tile.drawx() + Mathf.range(size * tilesize / 2f), tile.drawy() + Mathf.range(size * tilesize / 2f)); diff --git a/core/src/mindustry/world/blocks/defense/turrets/LaserTurret.java b/core/src/mindustry/world/blocks/defense/turrets/LaserTurret.java index 459c85294d..2a2404e56e 100644 --- a/core/src/mindustry/world/blocks/defense/turrets/LaserTurret.java +++ b/core/src/mindustry/world/blocks/defense/turrets/LaserTurret.java @@ -2,9 +2,7 @@ package mindustry.world.blocks.defense.turrets; import arc.math.*; import arc.util.*; -import mindustry.entities.*; import mindustry.entities.bullet.*; -import mindustry.entities.type.*; import mindustry.type.*; import mindustry.world.*; import mindustry.world.consumers.*; @@ -72,12 +70,12 @@ public class LaserTurret extends PowerTurret{ entity.reload = 0f; }else{ - Liquid liquid = entity.getLiquids().current(); + Liquid liquid = entity.liquids().current(); float maxUsed = consumes.get(ConsumeType.liquid).amount; - float used = baseReloadSpeed(tile) * (tile.isEnemyCheat() ? maxUsed : Math.min(entity.getLiquids().get(liquid), maxUsed * Time.delta())) * liquid.heatCapacity * coolantMultiplier; + float used = baseReloadSpeed(tile) * (tile.isEnemyCheat() ? maxUsed : Math.min(entity.liquids().get(liquid), maxUsed * Time.delta())) * liquid.heatCapacity * coolantMultiplier; entity.reload += used; - entity.getLiquids().remove(liquid, used); + entity.liquids().remove(liquid, used); if(Mathf.chance(0.06 * used)){ coolEffect.at(tile.drawx() + Mathf.range(size * tilesize / 2f), tile.drawy() + Mathf.range(size * tilesize / 2f)); diff --git a/core/src/mindustry/world/blocks/defense/turrets/LiquidTurret.java b/core/src/mindustry/world/blocks/defense/turrets/LiquidTurret.java index 8525a2206d..df5137bb4d 100644 --- a/core/src/mindustry/world/blocks/defense/turrets/LiquidTurret.java +++ b/core/src/mindustry/world/blocks/defense/turrets/LiquidTurret.java @@ -7,7 +7,6 @@ import mindustry.entities.*; import mindustry.entities.bullet.*; import mindustry.entities.effect.*; import mindustry.gen.*; -import mindustry.gen.*; import mindustry.type.*; import mindustry.world.*; import mindustry.world.consumers.*; @@ -38,8 +37,8 @@ public class LiquidTurret extends Turret{ TurretEntity entity = tile.ent(); if(Core.atlas.isFound(reg(liquidRegion))){ - Draw.color(entity.getLiquids().current().color); - Draw.alpha(entity.getLiquids().total() / liquidCapacity); + Draw.color(entity.liquids().current().color); + Draw.alpha(entity.liquids().total() / liquidCapacity); Draw.rect(reg(liquidRegion), tile.drawx() + tr2.x, tile.drawy() + tr2.y, entity.rotation - 90); Draw.color(); } @@ -72,7 +71,7 @@ public class LiquidTurret extends Turret{ @Override protected boolean validateTarget(Tile tile){ TurretEntity entity = tile.ent(); - if(entity.getLiquids().current().canExtinguish() && entity.target instanceof Tile){ + if(entity.liquids().current().canExtinguish() && entity.target instanceof Tile){ return Fire.has(((Tile)entity.target).x, ((Tile)entity.target).y); } return super.validateTarget(tile); @@ -81,7 +80,7 @@ public class LiquidTurret extends Turret{ @Override protected void findTarget(Tile tile){ TurretEntity entity = tile.ent(); - if(entity.getLiquids().current().canExtinguish()){ + if(entity.liquids().current().canExtinguish()){ int tr = (int)(range / tilesize); for(int x = -tr; x <= tr; x++){ for(int y = -tr; y <= tr; y++){ @@ -102,8 +101,8 @@ public class LiquidTurret extends Turret{ TurretEntity entity = tile.ent(); - type.shootEffect.at(tile.drawx() + tr.x, tile.drawy() + tr.y, entity.rotation, entity.getLiquids().current().color); - type.smokeEffect.at(tile.drawx() + tr.x, tile.drawy() + tr.y, entity.rotation, entity.getLiquids().current().color); + type.shootEffect.at(tile.drawx() + tr.x, tile.drawy() + tr.y, entity.rotation, entity.liquids().current().color); + type.smokeEffect.at(tile.drawx() + tr.x, tile.drawy() + tr.y, entity.rotation, entity.liquids().current().color); //shootSound.at(tile); if(shootShake > 0){ @@ -116,21 +115,21 @@ public class LiquidTurret extends Turret{ @Override public BulletType useAmmo(Tile tile){ TurretEntity entity = tile.ent(); - if(tile.isEnemyCheat()) return ammo.get(entity.getLiquids().current()); - BulletType type = ammo.get(entity.getLiquids().current()); - entity.getLiquids().remove(entity.getLiquids().current(), type.ammoMultiplier); + if(tile.isEnemyCheat()) return ammo.get(entity.liquids().current()); + BulletType type = ammo.get(entity.liquids().current()); + entity.liquids().remove(entity.liquids().current(), type.ammoMultiplier); return type; } @Override public BulletType peekAmmo(Tile tile){ - return ammo.get(tile.entity.getLiquids().current()); + return ammo.get(tile.entity.liquids().current()); } @Override public boolean hasAmmo(Tile tile){ TurretEntity entity = tile.ent(); - return ammo.get(entity.getLiquids().current()) != null && entity.getLiquids().total() >= ammo.get(entity.getLiquids().current()).ammoMultiplier; + return ammo.get(entity.liquids().current()) != null && entity.liquids().total() >= ammo.get(entity.liquids().current()).ammoMultiplier; } @Override @@ -141,7 +140,7 @@ public class LiquidTurret extends Turret{ @Override public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount){ return ammo.get(liquid) != null - && (tile.entity.getLiquids().current() == liquid || (ammo.containsKey(tile.entity.getLiquids().current()) && tile.entity.getLiquids().get(tile.entity.getLiquids().current()) <= ammo.get(tile.entity.getLiquids().current()).ammoMultiplier + 0.001f)); + && (tile.entity.liquids().current() == liquid || (ammo.containsKey(tile.entity.liquids().current()) && tile.entity.liquids().get(tile.entity.liquids().current()) <= ammo.get(tile.entity.liquids().current()).ammoMultiplier + 0.001f)); } } diff --git a/core/src/mindustry/world/blocks/defense/turrets/PowerTurret.java b/core/src/mindustry/world/blocks/defense/turrets/PowerTurret.java index d009fe7a18..c9f6c93bd6 100644 --- a/core/src/mindustry/world/blocks/defense/turrets/PowerTurret.java +++ b/core/src/mindustry/world/blocks/defense/turrets/PowerTurret.java @@ -47,6 +47,6 @@ public class PowerTurret extends CooledTurret{ @Override protected float baseReloadSpeed(Tile tile){ - return tile.isEnemyCheat() ? 1f : tile.entity.getPower().status; + return tile.isEnemyCheat() ? 1f : tile.entity.power().status; } } diff --git a/core/src/mindustry/world/blocks/defense/turrets/Turret.java b/core/src/mindustry/world/blocks/defense/turrets/Turret.java index c39f1fabab..0845eedfd6 100644 --- a/core/src/mindustry/world/blocks/defense/turrets/Turret.java +++ b/core/src/mindustry/world/blocks/defense/turrets/Turret.java @@ -14,10 +14,8 @@ import arc.math.geom.Vec2; import arc.util.Time; import mindustry.content.Fx; import mindustry.entities.*; -import mindustry.entities.*; import mindustry.entities.bullet.BulletType; import mindustry.gen.*; -import mindustry.gen.*; import mindustry.graphics.*; import mindustry.world.Block; import mindustry.world.Tile; @@ -193,9 +191,9 @@ public abstract class Turret extends Block{ TurretEntity entity = tile.ent(); if(targetAir && !targetGround){ - entity.target = Units.closestEnemy(tile.getTeam(), tile.drawx(), tile.drawy(), range, e -> !e.isDead() && e.isFlying()); + entity.target = Units.closestEnemy(tile.getTeam(), tile.drawx(), tile.drawy(), range, e -> !e.dead() && e.isFlying()); }else{ - entity.target = Units.closestTarget(tile.getTeam(), tile.drawx(), tile.drawy(), range, e -> !e.isDead() && (!e.isFlying() || targetAir) && (e.isFlying() || targetGround)); + entity.target = Units.closestTarget(tile.getTeam(), tile.drawx(), tile.drawy(), range, e -> !e.dead() && (!e.isFlying() || targetAir) && (e.isFlying() || targetGround)); } } diff --git a/core/src/mindustry/world/blocks/distribution/Conveyor.java b/core/src/mindustry/world/blocks/distribution/Conveyor.java index 6c3b32b3d5..bcfc492a93 100644 --- a/core/src/mindustry/world/blocks/distribution/Conveyor.java +++ b/core/src/mindustry/world/blocks/distribution/Conveyor.java @@ -11,7 +11,6 @@ import arc.util.*; import mindustry.content.*; import mindustry.gen.*; import mindustry.entities.units.*; -import mindustry.gen.*; import mindustry.graphics.*; import mindustry.type.*; import mindustry.ui.*; @@ -96,7 +95,7 @@ public class Conveyor extends Block implements Autotiler{ if(tile.front() != null && tile.front().entity != null){ entity.next = tile.front().entity; - entity.nextc = entity.next instanceof ConveyorEntity && entity.next.getTeam() == tile.getTeam() ? (ConveyorEntity)entity.next : null; + entity.nextc = entity.next instanceof ConveyorEntity && entity.next.team() == tile.getTeam() ? (ConveyorEntity)entity.next : null; entity.aligned = entity.nextc != null && tile.rotation() == entity.next.tile.rotation(); } } diff --git a/core/src/mindustry/world/blocks/distribution/ItemBridge.java b/core/src/mindustry/world/blocks/distribution/ItemBridge.java index bf31643446..dab5bf0189 100644 --- a/core/src/mindustry/world/blocks/distribution/ItemBridge.java +++ b/core/src/mindustry/world/blocks/distribution/ItemBridge.java @@ -266,10 +266,10 @@ public class ItemBridge extends Block{ if(rel == rel2) return false; }else{ - return source.block() instanceof ItemBridge && source.ent().link == tile.pos() && tile.entity.getItems().total() < itemCapacity; + return source.block() instanceof ItemBridge && source.ent().link == tile.pos() && tile.entity.items().total() < itemCapacity; } - return tile.entity.getItems().total() < itemCapacity; + return tile.entity.items().total() < itemCapacity; } @@ -315,7 +315,7 @@ public class ItemBridge extends Block{ return false; } - return tile.entity.getLiquids().get(liquid) + amount < liquidCapacity && (tile.entity.getLiquids().current() == liquid || tile.entity.getLiquids().get(tile.entity.getLiquids().current()) < 0.2f); + return tile.entity.liquids().get(liquid) + amount < liquidCapacity && (tile.entity.liquids().current() == liquid || tile.entity.liquids().get(tile.entity.liquids().current()) < 0.2f); } @Override diff --git a/core/src/mindustry/world/blocks/distribution/MassDriver.java b/core/src/mindustry/world/blocks/distribution/MassDriver.java index 55483d6def..5ae1ecc88c 100644 --- a/core/src/mindustry/world/blocks/distribution/MassDriver.java +++ b/core/src/mindustry/world/blocks/distribution/MassDriver.java @@ -116,8 +116,8 @@ public class MassDriver extends Block{ float targetRotation = tile.angleTo(link); if( - tile.entity.getItems().total() >= minDistribute && //must shoot minimum amount of items - link.block().itemCapacity - link.entity.getItems().total() >= minDistribute //must have minimum amount of space + tile.entity.items().total() >= minDistribute && //must shoot minimum amount of items + link.block().itemCapacity - link.entity.items().total() >= minDistribute //must have minimum amount of space ){ MassDriverEntity other = link.ent(); other.waitingShooters.add(tile); @@ -225,7 +225,7 @@ public class MassDriver extends Block{ @Override public boolean acceptItem(Item item, Tile tile, Tile source){ //mass drivers that ouput only cannot accept items - return tile.entity.getItems().total() < itemCapacity && linkValid(tile); + return tile.entity.items().total() < itemCapacity && linkValid(tile); } protected void fire(Tile tile, Tile target){ diff --git a/core/src/mindustry/world/blocks/distribution/OverflowGate.java b/core/src/mindustry/world/blocks/distribution/OverflowGate.java index dcf744d642..73fdcd079b 100644 --- a/core/src/mindustry/world/blocks/distribution/OverflowGate.java +++ b/core/src/mindustry/world/blocks/distribution/OverflowGate.java @@ -42,8 +42,8 @@ public class OverflowGate extends Block{ public void update(Tile tile){ OverflowGateEntity entity = tile.ent(); - if(entity.lastItem == null && entity.getItems().total() > 0){ - entity.getItems().clear(); + if(entity.lastItem == null && entity.items().total() > 0){ + entity.items().clear(); } if(entity.lastItem != null){ @@ -53,7 +53,7 @@ public class OverflowGate extends Block{ if(target != null && (entity.time >= 1f)){ getTileTarget(tile, entity.lastItem, entity.lastInput, true); target.block().handleItem(entity.lastItem, target, Edges.getFacingEdge(tile, target)); - entity.getItems().remove(entity.lastItem, 1); + entity.items().remove(entity.lastItem, 1); entity.lastItem = null; } } @@ -63,13 +63,13 @@ public class OverflowGate extends Block{ public boolean acceptItem(Item item, Tile tile, Tile source){ OverflowGateEntity entity = tile.ent(); - return tile.getTeam() == source.getTeam() && entity.lastItem == null && entity.getItems().total() == 0; + return tile.getTeam() == source.getTeam() && entity.lastItem == null && entity.items().total() == 0; } @Override public void handleItem(Item item, Tile tile, Tile source){ OverflowGateEntity entity = tile.ent(); - entity.getItems().add(item, 1); + entity.items().add(item, 1); entity.lastItem = item; entity.time = 0f; entity.lastInput = source; diff --git a/core/src/mindustry/world/blocks/distribution/Router.java b/core/src/mindustry/world/blocks/distribution/Router.java index 2718ddb30b..fe8349f5bd 100644 --- a/core/src/mindustry/world/blocks/distribution/Router.java +++ b/core/src/mindustry/world/blocks/distribution/Router.java @@ -26,8 +26,8 @@ public class Router extends Block{ public void update(Tile tile){ RouterEntity entity = tile.ent(); - if(entity.lastItem == null && entity.getItems().total() > 0){ - entity.getItems().clear(); + if(entity.lastItem == null && entity.items().total() > 0){ + entity.items().clear(); } if(entity.lastItem != null){ @@ -37,7 +37,7 @@ public class Router extends Block{ if(target != null && (entity.time >= 1f || !(target.block() instanceof Router))){ getTileTarget(tile, entity.lastItem, entity.lastInput, true); target.block().handleItem(entity.lastItem, target, Edges.getFacingEdge(tile, target)); - entity.getItems().remove(entity.lastItem, 1); + entity.items().remove(entity.lastItem, 1); entity.lastItem = null; } } @@ -47,13 +47,13 @@ public class Router extends Block{ public boolean acceptItem(Item item, Tile tile, Tile source){ RouterEntity entity = tile.ent(); - return tile.getTeam() == source.getTeam() && entity.lastItem == null && entity.getItems().total() == 0; + return tile.getTeam() == source.getTeam() && entity.lastItem == null && entity.items().total() == 0; } @Override public void handleItem(Item item, Tile tile, Tile source){ RouterEntity entity = tile.ent(); - entity.getItems().add(item, 1); + entity.items().add(item, 1); entity.lastItem = item; entity.time = 0f; entity.lastInput = source; diff --git a/core/src/mindustry/world/blocks/liquid/Conduit.java b/core/src/mindustry/world/blocks/liquid/Conduit.java index 3d6a6bfc00..ea7f701979 100644 --- a/core/src/mindustry/world/blocks/liquid/Conduit.java +++ b/core/src/mindustry/world/blocks/liquid/Conduit.java @@ -8,7 +8,6 @@ import arc.math.geom.*; import arc.struct.*; import arc.util.*; import mindustry.content.*; -import mindustry.entities.type.*; import mindustry.entities.units.*; import mindustry.type.*; import mindustry.world.*; @@ -96,7 +95,7 @@ public class Conduit extends LiquidBlock implements Autotiler{ Draw.colorl(0.34f); Draw.rect(botRegions[entity.blendbits], tile.drawx(), tile.drawy(), rotation); - Draw.color(tile.entity.getLiquids().current().color); + Draw.color(tile.entity.liquids().current().color); Draw.alpha(entity.smoothLiquid); Draw.rect(botRegions[entity.blendbits], tile.drawx(), tile.drawy(), rotation); Draw.color(); @@ -109,8 +108,8 @@ public class Conduit extends LiquidBlock implements Autotiler{ ConduitEntity entity = tile.ent(); entity.smoothLiquid = Mathf.lerpDelta(entity.smoothLiquid, entity.getLiquids().currentAmount() / liquidCapacity, 0.05f); - if(tile.entity.getLiquids().total() > 0.001f && tile.entity.timer(timerFlow, 1)){ - tryMoveLiquid(tile, tile.getNearby(tile.rotation()), leakResistance, tile.entity.getLiquids().current()); + if(tile.entity.liquids().total() > 0.001f && tile.entity.timer(timerFlow, 1)){ + tryMoveLiquid(tile, tile.getNearby(tile.rotation()), leakResistance, tile.entity.liquids().current()); entity.noSleep(); }else{ entity.sleep(); @@ -125,7 +124,7 @@ public class Conduit extends LiquidBlock implements Autotiler{ @Override public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount){ tile.entity.noSleep(); - return tile.entity.getLiquids().get(liquid) + amount < liquidCapacity && (tile.entity.getLiquids().current() == liquid || tile.entity.getLiquids().get(tile.entity.getLiquids().current()) < 0.2f) + return tile.entity.liquids().get(liquid) + amount < liquidCapacity && (tile.entity.liquids().current() == liquid || tile.entity.liquids().get(tile.entity.liquids().current()) < 0.2f) && ((source.absoluteRelativeTo(tile.x, tile.y) + 2) % 4 != tile.rotation()); } diff --git a/core/src/mindustry/world/blocks/liquid/LiquidRouter.java b/core/src/mindustry/world/blocks/liquid/LiquidRouter.java index b912227d41..3f787d1ef2 100644 --- a/core/src/mindustry/world/blocks/liquid/LiquidRouter.java +++ b/core/src/mindustry/world/blocks/liquid/LiquidRouter.java @@ -13,13 +13,13 @@ public class LiquidRouter extends LiquidBlock{ @Override public void update(Tile tile){ - if(tile.entity.getLiquids().total() > 0.01f){ - tryDumpLiquid(tile, tile.entity.getLiquids().current()); + if(tile.entity.liquids().total() > 0.01f){ + tryDumpLiquid(tile, tile.entity.liquids().current()); } } @Override public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount){ - return tile.entity.getLiquids().get(liquid) + amount < liquidCapacity && (tile.entity.getLiquids().current() == liquid || tile.entity.getLiquids().get(tile.entity.getLiquids().current()) < 0.2f); + return tile.entity.liquids().get(liquid) + amount < liquidCapacity && (tile.entity.liquids().current() == liquid || tile.entity.liquids().get(tile.entity.liquids().current()) < 0.2f); } } diff --git a/core/src/mindustry/world/blocks/power/ImpactReactor.java b/core/src/mindustry/world/blocks/power/ImpactReactor.java index 041c99727f..2bee3473d3 100644 --- a/core/src/mindustry/world/blocks/power/ImpactReactor.java +++ b/core/src/mindustry/world/blocks/power/ImpactReactor.java @@ -71,7 +71,7 @@ public class ImpactReactor extends PowerGenerator{ public void update(Tile tile){ FusionReactorEntity entity = tile.ent(); - if(entity.consValid() && entity.getPower().status >= 0.99f){ + if(entity.consValid() && entity.power().status >= 0.99f){ boolean prevOut = getPowerProduction(tile) <= consumes.getPower().requestedPower(entity); entity.warmup = Mathf.lerpDelta(entity.warmup, 1f, warmupSpeed); diff --git a/core/src/mindustry/world/blocks/power/ItemLiquidGenerator.java b/core/src/mindustry/world/blocks/power/ItemLiquidGenerator.java index c324b203be..32dbab21c7 100644 --- a/core/src/mindustry/world/blocks/power/ItemLiquidGenerator.java +++ b/core/src/mindustry/world/blocks/power/ItemLiquidGenerator.java @@ -7,7 +7,6 @@ import arc.math.*; import arc.util.*; import mindustry.content.*; import mindustry.entities.*; -import mindustry.entities.Effects.*; import mindustry.type.*; import mindustry.world.*; import mindustry.world.consumers.*; @@ -106,7 +105,7 @@ public class ItemLiquidGenerator extends PowerGenerator{ Liquid liquid = null; for(Liquid other : content.liquids()){ - if(hasLiquids && entity.getLiquids().get(other) >= 0.001f && getLiquidEfficiency(other) >= minLiquidEfficiency){ + if(hasLiquids && entity.liquids().get(other) >= 0.001f && getLiquidEfficiency(other) >= minLiquidEfficiency){ liquid = other; break; } @@ -115,12 +114,12 @@ public class ItemLiquidGenerator extends PowerGenerator{ entity.heat = Mathf.lerpDelta(entity.heat, entity.generateTime >= 0.001f ? 1f : 0f, 0.05f); //liquid takes priority over solids - if(hasLiquids && liquid != null && entity.getLiquids().get(liquid) >= 0.001f){ + if(hasLiquids && liquid != null && entity.liquids().get(liquid) >= 0.001f){ float baseLiquidEfficiency = getLiquidEfficiency(liquid); float maximumPossible = maxLiquidGenerate * calculationDelta; - float used = Math.min(entity.getLiquids().get(liquid) * calculationDelta, maximumPossible); + float used = Math.min(entity.liquids().get(liquid) * calculationDelta, maximumPossible); - entity.getLiquids().remove(liquid, used * entity.getPower().graph.getUsageFraction()); + entity.liquids().remove(liquid, used * entity.power().graph.getUsageFraction()); entity.productionEfficiency = baseLiquidEfficiency * used / maximumPossible; if(used > 0.001f && Mathf.chance(0.05 * entity.delta())){ @@ -128,16 +127,16 @@ public class ItemLiquidGenerator extends PowerGenerator{ } }else if(hasItems){ // No liquids accepted or none supplied, try using items if accepted - if(entity.generateTime <= 0f && entity.getItems().total() > 0){ + if(entity.generateTime <= 0f && entity.items().total() > 0){ generateEffect.at(tile.worldx() + Mathf.range(3f), tile.worldy() + Mathf.range(3f)); - Item item = entity.getItems().take(); + Item item = entity.items().take(); entity.productionEfficiency = getItemEfficiency(item); entity.explosiveness = item.explosiveness; entity.generateTime = 1f; } if(entity.generateTime > 0f){ - entity.generateTime -= Math.min(1f / itemDuration * entity.delta() * entity.getPower().graph.getUsageFraction(), entity.generateTime); + entity.generateTime -= Math.min(1f / itemDuration * entity.delta() * entity.power().graph.getUsageFraction(), entity.generateTime); if(randomlyExplode && state.rules.reactorExplosions && Mathf.chance(entity.delta() * 0.06 * Mathf.clamp(entity.explosiveness - 0.5f))){ //this block is run last so that in the event of a block destruction, no code relies on the block type @@ -166,8 +165,8 @@ public class ItemLiquidGenerator extends PowerGenerator{ } if(hasLiquids){ - Draw.color(entity.getLiquids().current().color); - Draw.alpha(entity.getLiquids().currentAmount() / liquidCapacity); + Draw.color(entity.liquids().current().color); + Draw.alpha(entity.liquids().currentAmount() / liquidCapacity); Draw.rect(liquidRegion, tile.drawx(), tile.drawy()); Draw.color(); } diff --git a/core/src/mindustry/world/blocks/power/NuclearReactor.java b/core/src/mindustry/world/blocks/power/NuclearReactor.java index e18e568c2a..35488349d0 100644 --- a/core/src/mindustry/world/blocks/power/NuclearReactor.java +++ b/core/src/mindustry/world/blocks/power/NuclearReactor.java @@ -79,7 +79,7 @@ public class NuclearReactor extends PowerGenerator{ ConsumeLiquid cliquid = consumes.get(ConsumeType.liquid); Item item = consumes.get(ConsumeType.item).items[0].item; - int fuel = entity.getItems().get(item); + int fuel = entity.items().get(item); float fullness = (float)fuel / itemCapacity; entity.productionEfficiency = fullness; @@ -94,9 +94,9 @@ public class NuclearReactor extends PowerGenerator{ Liquid liquid = cliquid.liquid; if(entity.heat > 0){ - float maxUsed = Math.min(entity.getLiquids().get(liquid), entity.heat / coolantPower); + float maxUsed = Math.min(entity.liquids().get(liquid), entity.heat / coolantPower); entity.heat -= maxUsed * coolantPower; - entity.getLiquids().remove(liquid, maxUsed); + entity.liquids().remove(liquid, maxUsed); } if(entity.heat > smokeThreshold){ @@ -123,7 +123,7 @@ public class NuclearReactor extends PowerGenerator{ NuclearReactorEntity entity = tile.ent(); - int fuel = entity.getItems().get(consumes.get(ConsumeType.item).items[0].item); + int fuel = entity.items().get(consumes.get(ConsumeType.item).items[0].item); if((fuel < 5 && entity.heat < 0.5f) || !state.rules.reactorExplosions) return; @@ -166,8 +166,8 @@ public class NuclearReactor extends PowerGenerator{ Draw.color(coolColor, hotColor, entity.heat); Fill.rect(tile.drawx(), tile.drawy(), size * tilesize, size * tilesize); - Draw.color(entity.getLiquids().current().color); - Draw.alpha(entity.getLiquids().currentAmount() / liquidCapacity); + Draw.color(entity.liquids().current().color); + Draw.alpha(entity.liquids().currentAmount() / liquidCapacity); Draw.rect(topRegion, tile.drawx(), tile.drawy()); if(entity.heat > flashThreshold){ diff --git a/core/src/mindustry/world/blocks/power/PowerDiode.java b/core/src/mindustry/world/blocks/power/PowerDiode.java index 20204c48ac..21e2d9b34e 100644 --- a/core/src/mindustry/world/blocks/power/PowerDiode.java +++ b/core/src/mindustry/world/blocks/power/PowerDiode.java @@ -29,8 +29,8 @@ public class PowerDiode extends Block{ if(tile.front() == null || tile.back() == null || !tile.back().block().hasPower || !tile.front().block().hasPower || tile.back().getTeam() != tile.front().getTeam()) return; - PowerGraph backGraph = tile.back().entity.getPower().graph; - PowerGraph frontGraph = tile.front().entity.getPower().graph; + PowerGraph backGraph = tile.back().entity.power().graph; + PowerGraph frontGraph = tile.front().entity.power().graph; if(backGraph == frontGraph) return; // 0f - 1f of battery capacity in use @@ -51,7 +51,7 @@ public class PowerDiode extends Block{ // battery % of the graph on either side, defaults to zero public float bar(Tile tile){ - return (tile != null && tile.block().hasPower) ? tile.entity.getPower().graph.getBatteryStored() / tile.entity.getPower().graph.getTotalBatteryCapacity() : 0f; + return (tile != null && tile.block().hasPower) ? tile.entity.power().graph.getBatteryStored() / tile.entity.power().graph.getTotalBatteryCapacity() : 0f; } @Override diff --git a/core/src/mindustry/world/blocks/power/PowerGraph.java b/core/src/mindustry/world/blocks/power/PowerGraph.java index 06f43330af..c3ea54ad9e 100644 --- a/core/src/mindustry/world/blocks/power/PowerGraph.java +++ b/core/src/mindustry/world/blocks/power/PowerGraph.java @@ -88,7 +88,7 @@ public class PowerGraph{ for(Tile battery : batteries){ Consumers consumes = battery.block().consumes; if(consumes.hasPower()){ - totalAccumulator += battery.entity.getPower().status * consumes.getPower().capacity; + totalAccumulator += battery.entity.power().status * consumes.getPower().capacity; } } return totalAccumulator; @@ -99,7 +99,7 @@ public class PowerGraph{ for(Tile battery : batteries){ if(battery.block().consumes.hasPower()){ ConsumePower power = battery.block().consumes.getPower(); - totalCapacity += (1f - battery.entity.getPower().status) * power.capacity; + totalCapacity += (1f - battery.entity.power().status) * power.capacity; } } return totalCapacity; @@ -124,7 +124,7 @@ public class PowerGraph{ for(Tile battery : batteries){ Consumers consumes = battery.block().consumes; if(consumes.hasPower()){ - battery.entity.getPower().status *= (1f-consumedPowerPercentage); + battery.entity.power().status *= (1f-consumedPowerPercentage); } } return used; @@ -141,7 +141,7 @@ public class PowerGraph{ if(consumes.hasPower()){ ConsumePower consumePower = consumes.getPower(); if(consumePower.capacity > 0f){ - battery.entity.getPower().status += (1f-battery.entity.getPower().status) * chargedPercent; + battery.entity.power().status += (1f-battery.entity.power().status) * chargedPercent; } } } @@ -159,17 +159,17 @@ public class PowerGraph{ if(!Mathf.zero(consumePower.capacity)){ // Add an equal percentage of power to all buffers, based on the global power coverage in this graph float maximumRate = consumePower.requestedPower(consumer.entity) * coverage * consumer.entity.delta(); - consumer.entity.getPower().status = Mathf.clamp(consumer.entity.getPower().status + maximumRate / consumePower.capacity); + consumer.entity.power().status = Mathf.clamp(consumer.entity.power().status + maximumRate / consumePower.capacity); } }else{ //valid consumers get power as usual if(otherConsumersAreValid(consumer, consumePower)){ - consumer.entity.getPower().status = coverage; + consumer.entity.power().status = coverage; }else{ //invalid consumers get an estimate, if they were to activate - consumer.entity.getPower().status = Math.min(1, produced / (needed + consumePower.usage * consumer.entity.delta())); + consumer.entity.power().status = Math.min(1, produced / (needed + consumePower.usage * consumer.entity.delta())); //just in case - if(Float.isNaN(consumer.entity.getPower().status)){ - consumer.entity.getPower().status = 0f; + if(Float.isNaN(consumer.entity.power().status)){ + consumer.entity.power().status = 0f; } } } @@ -183,7 +183,7 @@ public class PowerGraph{ }else if(!consumers.isEmpty() && consumers.first().isEnemyCheat()){ //when cheating, just set status to 1 for(Tile tile : consumers){ - tile.entity.getPower().status = 1f; + tile.entity.power().status = 1f; } lastPowerNeeded = lastPowerProduced = lastUsageFraction = 1f; @@ -230,8 +230,8 @@ public class PowerGraph{ } public void add(Tile tile){ - if(tile.entity == null || tile.entity.getPower() == null) return; - tile.entity.getPower().graph = this; + if(tile.entity == null || tile.entity.power() == null) return; + tile.entity.power().graph = this; all.add(tile); if(tile.block().outputsPower && tile.block().consumesPower && !tile.block().consumes.getPower().buffered){ @@ -277,7 +277,7 @@ public class PowerGraph{ //go through all the connections of this tile for(Tile other : tile.block().getPowerConnections(tile, outArray1)){ //a graph has already been assigned to this tile from a previous call, skip it - if(other.entity.getPower().graph != this) continue; + if(other.entity.power().graph != this) continue; //create graph for this branch PowerGraph graph = new PowerGraph(); @@ -296,7 +296,7 @@ public class PowerGraph{ for(Tile next : child.block().getPowerConnections(child, outArray2)){ //make sure it hasn't looped back, and that the new graph being assigned hasn't already been assigned //also skip closed tiles - if(next != tile && next.entity.getPower().graph != graph && !closedSet.contains(next.pos())){ + if(next != tile && next.entity.power().graph != graph && !closedSet.contains(next.pos())){ queue.addLast(next); closedSet.add(next.pos()); } diff --git a/core/src/mindustry/world/blocks/power/PowerNode.java b/core/src/mindustry/world/blocks/power/PowerNode.java index 0650626f3a..4b61227ab9 100644 --- a/core/src/mindustry/world/blocks/power/PowerNode.java +++ b/core/src/mindustry/world/blocks/power/PowerNode.java @@ -41,19 +41,19 @@ public class PowerNode extends PowerBlock{ public void configured(Tile tile, Player player, int value){ Tilec entity = tile.entity; Tile other = world.tile(value); - boolean contains = entity.getPower().links.contains(value), valid = other != null && other.entity != null && other.entity.getPower() != null; + boolean contains = entity.getPower().links.contains(value), valid = other != null && other.entity != null && other.entity.power() != null; if(contains){ //unlink entity.getPower().links.removeValue(value); - if(valid) other.entity.getPower().links.removeValue(tile.pos()); + if(valid) other.entity.power().links.removeValue(tile.pos()); PowerGraph newgraph = new PowerGraph(); //reflow from this point, covering all tiles on this side newgraph.reflow(tile); - if(valid && other.entity.getPower().graph != newgraph){ + if(valid && other.entity.power().graph != newgraph){ //create new graph for other end PowerGraph og = new PowerGraph(); //reflow from other end @@ -67,12 +67,12 @@ public class PowerNode extends PowerBlock{ if(other.getTeamID() == tile.getTeamID()){ - if(!other.entity.getPower().links.contains(tile.pos())){ - other.entity.getPower().links.add(tile.pos()); + if(!other.entity.power().links.contains(tile.pos())){ + other.entity.power().links.add(tile.pos()); } } - entity.getPower().graph.add(other.entity.getPower().graph); + entity.getPower().graph.add(other.entity.power().graph); } } @@ -89,15 +89,15 @@ public class PowerNode extends PowerBlock{ super.setBars(); bars.add("power", entity -> new Bar(() -> Core.bundle.format("bar.powerbalance", - ((entity.getPower().graph.getPowerBalance() >= 0 ? "+" : "") + Strings.fixed(entity.getPower().graph.getPowerBalance() * 60, 1))), + ((entity.power().graph.getPowerBalance() >= 0 ? "+" : "") + Strings.fixed(entity.power().graph.getPowerBalance() * 60, 1))), () -> Pal.powerBar, - () -> Mathf.clamp(entity.getPower().graph.getLastPowerProduced() / entity.getPower().graph.getLastPowerNeeded()))); + () -> Mathf.clamp(entity.power().graph.getLastPowerProduced() / entity.power().graph.getLastPowerNeeded()))); bars.add("batteries", entity -> new Bar(() -> Core.bundle.format("bar.powerstored", - (ui.formatAmount((int)entity.getPower().graph.getBatteryStored())), ui.formatAmount((int)entity.getPower().graph.getTotalBatteryCapacity())), + (ui.formatAmount((int)entity.power().graph.getBatteryStored())), ui.formatAmount((int)entity.power().graph.getTotalBatteryCapacity())), () -> Pal.powerBar, - () -> Mathf.clamp(entity.getPower().graph.getBatteryStored() / entity.getPower().graph.getTotalBatteryCapacity()))); + () -> Mathf.clamp(entity.power().graph.getBatteryStored() / entity.power().graph.getTotalBatteryCapacity()))); } @Override @@ -105,7 +105,7 @@ public class PowerNode extends PowerBlock{ if(net.client()) return; Boolf valid = other -> other != null && other != tile && ((!other.block().outputsPower && other.block().consumesPower) || (other.block().outputsPower && !other.block().consumesPower) || other.block() instanceof PowerNode) && linkValid(tile, other) - && !other.entity.proximity().contains(tile) && other.entity.getPower().graph != tile.entity.getPower().graph; + && !other.entity.proximity().contains(tile) && other.entity.power().graph != tile.entity.power().graph; tempTiles.clear(); Geometry.circle(tile.x, tile.y, (int)(laserRange + 2), (x, y) -> { @@ -123,7 +123,7 @@ public class PowerNode extends PowerBlock{ return Float.compare(a.dst2(tile), b.dst2(tile)); }); tempTiles.each(valid, other -> { - if(!tile.entity.getPower().links.contains(other.pos())){ + if(!tile.entity.power().links.contains(other.pos())){ tile.configureAny(other.pos()); } }); @@ -132,10 +132,10 @@ public class PowerNode extends PowerBlock{ } private void getPotentialLinks(Tile tile, Cons others){ - Boolf valid = other -> other != null && other != tile && other.entity != null && other.entity.getPower() != null && + Boolf valid = other -> other != null && other != tile && other.entity != null && other.entity.power() != null && ((!other.block().outputsPower && other.block().consumesPower) || (other.block().outputsPower && !other.block().consumesPower) || other.block() instanceof PowerNode) && - overlaps(tile.x * tilesize + offset(), tile.y * tilesize + offset(), other, laserRange * tilesize) && other.getTeam() == player.getTeam() - && !other.entity.proximity().contains(tile) && !graphs.contains(other.entity.getPower().graph); + overlaps(tile.x * tilesize + offset(), tile.y * tilesize + offset(), other, laserRange * tilesize) && other.getTeam() == player.team() + && !other.entity.proximity().contains(tile) && !graphs.contains(other.entity.power().graph); tempTiles.clear(); graphs.clear(); @@ -152,7 +152,7 @@ public class PowerNode extends PowerBlock{ return Float.compare(a.dst2(tile), b.dst2(tile)); }); tempTiles.each(valid, t -> { - graphs.add(t.entity.getPower().graph); + graphs.add(t.entity.power().graph); others.get(t); }); } @@ -167,7 +167,7 @@ public class PowerNode extends PowerBlock{ @Override public void update(Tile tile){ - tile.entity.getPower().graph.update(); + tile.entity.power().graph.update(); } @Override @@ -181,7 +181,7 @@ public class PowerNode extends PowerBlock{ } if(tile == other){ - if(other.entity.getPower().links.size == 0){ + if(other.entity.power().links.size == 0){ int[] total = {0}; getPotentialLinks(tile, link -> { if(!insulated(tile, link) && total[0]++ < maxNodes){ @@ -281,7 +281,7 @@ public class PowerNode extends PowerBlock{ } protected boolean linked(Tile tile, Tile other){ - return tile.entity.getPower().links.contains(other.pos()); + return tile.entity.power().links.contains(other.pos()); } public boolean linkValid(Tile tile, Tile link){ @@ -293,7 +293,7 @@ public class PowerNode extends PowerBlock{ if(overlaps(tile, link, laserRange * tilesize) || (link.block() instanceof PowerNode && overlaps(link, tile, link.cblock().laserRange * tilesize))){ if(checkMaxNodes && link.block() instanceof PowerNode){ - return link.entity.getPower().links.size < link.cblock().maxNodes || link.entity.getPower().links.contains(tile.pos()); + return link.entity.power().links.size < link.cblock().maxNodes || link.entity.power().links.contains(tile.pos()); } return true; } @@ -331,7 +331,7 @@ public class PowerNode extends PowerBlock{ x2 += t2.x; y2 += t2.y; - float fract = 1f - tile.entity.getPower().graph.getSatisfaction(); + float fract = 1f - tile.entity.power().graph.getSatisfaction(); Draw.color(Color.white, Pal.powerLight, fract * 0.86f + Mathf.absin(3f, 0.1f)); Draw.alpha(opacity); diff --git a/core/src/mindustry/world/blocks/production/Drill.java b/core/src/mindustry/world/blocks/production/Drill.java index 4d5b73385c..6286bc106e 100644 --- a/core/src/mindustry/world/blocks/production/Drill.java +++ b/core/src/mindustry/world/blocks/production/Drill.java @@ -9,7 +9,6 @@ import arc.util.*; import mindustry.content.*; import mindustry.entities.*; import mindustry.gen.*; -import mindustry.gen.*; import mindustry.graphics.*; import mindustry.type.*; import mindustry.ui.*; @@ -76,7 +75,7 @@ public class Drill extends Block{ bars.add("drillspeed", e -> { DrillEntity entity = (DrillEntity)e; - return new Bar(() -> Core.bundle.format("bar.drillspeed", Strings.fixed(entity.lastDrillSpeed * 60 * entity.getTimeScale(), 2)), () -> Pal.ammo, () -> entity.warmup); + return new Bar(() -> Core.bundle.format("bar.drillspeed", Strings.fixed(entity.lastDrillSpeed * 60 * entity.timeScale(), 2)), () -> Pal.ammo, () -> entity.warmup); }); } @@ -128,7 +127,7 @@ public class Drill extends Block{ @Override public boolean shouldConsume(Tile tile){ - return tile.entity.getItems().total() < itemCapacity; + return tile.entity.items().total() < itemCapacity; } @Override @@ -252,11 +251,11 @@ public class Drill extends Block{ entity.drillTime += entity.warmup * entity.delta(); - if(entity.getItems().total() < itemCapacity && entity.dominantItems > 0 && entity.consValid()){ + if(entity.items().total() < itemCapacity && entity.dominantItems > 0 && entity.consValid()){ float speed = 1f; - if(entity.getCons().optionalValid()){ + if(entity.cons().optionalValid()){ speed = liquidBoostIntensity; } @@ -275,7 +274,7 @@ public class Drill extends Block{ return; } - if(entity.dominantItems > 0 && entity.progress >= drillTime + hardnessDrillMultiplier * entity.dominantItem.hardness && tile.entity.getItems().total() < itemCapacity){ + if(entity.dominantItems > 0 && entity.progress >= drillTime + hardnessDrillMultiplier * entity.dominantItem.hardness && tile.entity.items().total() < itemCapacity){ offloadNear(tile, entity.dominantItem); diff --git a/core/src/mindustry/world/blocks/production/Fracker.java b/core/src/mindustry/world/blocks/production/Fracker.java index b908aeaf96..e8ce36dff8 100644 --- a/core/src/mindustry/world/blocks/production/Fracker.java +++ b/core/src/mindustry/world/blocks/production/Fracker.java @@ -44,7 +44,7 @@ public class Fracker extends SolidPump{ @Override public boolean shouldConsume(Tile tile){ - return tile.entity.getLiquids().get(result) < liquidCapacity - 0.01f; + return tile.entity.liquids().get(result) < liquidCapacity - 0.01f; } @Override @@ -55,7 +55,7 @@ public class Fracker extends SolidPump{ super.drawCracks(tile); Draw.color(result.color); - Draw.alpha(tile.entity.getLiquids().get(result) / liquidCapacity); + Draw.alpha(tile.entity.liquids().get(result) / liquidCapacity); Draw.rect(liquidRegion, tile.drawx(), tile.drawy()); Draw.color(); @@ -87,7 +87,7 @@ public class Fracker extends SolidPump{ @Override public float typeLiquid(Tile tile){ - return tile.entity.getLiquids().get(result); + return tile.entity.liquids().get(result); } public static class FrackerEntity extends SolidPumpEntity{ diff --git a/core/src/mindustry/world/blocks/production/GenericCrafter.java b/core/src/mindustry/world/blocks/production/GenericCrafter.java index f6e5b6fd91..a9e7239a06 100644 --- a/core/src/mindustry/world/blocks/production/GenericCrafter.java +++ b/core/src/mindustry/world/blocks/production/GenericCrafter.java @@ -7,7 +7,6 @@ import arc.util.*; import mindustry.content.*; import mindustry.entities.*; import mindustry.gen.*; -import mindustry.gen.*; import mindustry.type.*; import mindustry.world.*; import mindustry.world.consumers.*; @@ -60,7 +59,7 @@ public class GenericCrafter extends Block{ @Override public boolean shouldIdleSound(Tile tile){ - return tile.entity.getCons().valid(); + return tile.entity.cons().valid(); } @Override @@ -135,10 +134,10 @@ public class GenericCrafter extends Block{ @Override public boolean shouldConsume(Tile tile){ - if(outputItem != null && tile.entity.getItems().get(outputItem.item) >= itemCapacity){ + if(outputItem != null && tile.entity.items().get(outputItem.item) >= itemCapacity){ return false; } - return outputLiquid == null || !(tile.entity.getLiquids().get(outputLiquid.liquid) >= liquidCapacity); + return outputLiquid == null || !(tile.entity.liquids().get(outputLiquid.liquid) >= liquidCapacity); } @Override diff --git a/core/src/mindustry/world/blocks/production/LiquidConverter.java b/core/src/mindustry/world/blocks/production/LiquidConverter.java index e2a36132e6..0704e6a08f 100644 --- a/core/src/mindustry/world/blocks/production/LiquidConverter.java +++ b/core/src/mindustry/world/blocks/production/LiquidConverter.java @@ -35,7 +35,7 @@ public class LiquidConverter extends GenericCrafter{ @Override public void drawLight(Tile tile){ if(hasLiquids && drawLiquidLight && outputLiquid.liquid.lightColor.a > 0.001f){ - drawLiquidLight(tile, outputLiquid.liquid, tile.entity.getLiquids().get(outputLiquid.liquid)); + drawLiquidLight(tile, outputLiquid.liquid, tile.entity.liquids().get(outputLiquid.liquid)); } } @@ -44,12 +44,12 @@ public class LiquidConverter extends GenericCrafter{ GenericCrafterEntity entity = tile.ent(); ConsumeLiquidBase cl = consumes.get(ConsumeType.liquid); - if(tile.entity.getCons().valid()){ - float use = Math.min(cl.amount * entity.delta(), liquidCapacity - entity.getLiquids().get(outputLiquid.liquid)) * entity.efficiency(); + if(tile.entity.cons().valid()){ + float use = Math.min(cl.amount * entity.delta(), liquidCapacity - entity.liquids().get(outputLiquid.liquid)) * entity.efficiency(); useContent(tile, outputLiquid.liquid); entity.progress += use / cl.amount / craftTime; - entity.getLiquids().add(outputLiquid.liquid, use); + entity.liquids().add(outputLiquid.liquid, use); if(entity.progress >= 1f){ entity.consume(); entity.progress = 0f; diff --git a/core/src/mindustry/world/blocks/production/Pump.java b/core/src/mindustry/world/blocks/production/Pump.java index d78a8928a8..7eabecdb41 100644 --- a/core/src/mindustry/world/blocks/production/Pump.java +++ b/core/src/mindustry/world/blocks/production/Pump.java @@ -48,8 +48,8 @@ public class Pump extends LiquidBlock{ public void draw(Tile tile){ Draw.rect(name, tile.drawx(), tile.drawy()); - Draw.color(tile.entity.getLiquids().current().color); - Draw.alpha(tile.entity.getLiquids().total() / liquidCapacity); + Draw.color(tile.entity.liquids().current().color); + Draw.alpha(tile.entity.liquids().total() / liquidCapacity); Draw.rect(liquidRegion, tile.drawx(), tile.drawy()); Draw.color(); } @@ -118,16 +118,16 @@ public class Pump extends LiquidBlock{ liquidDrop = tile.floor().liquidDrop; } - if(tile.entity.getCons().valid() && liquidDrop != null){ - float maxPump = Math.min(liquidCapacity - tile.entity.getLiquids().total(), tiles * pumpAmount * tile.entity.delta() / size / size) * tile.entity.efficiency(); - tile.entity.getLiquids().add(liquidDrop, maxPump); + if(tile.entity.cons().valid() && liquidDrop != null){ + float maxPump = Math.min(liquidCapacity - tile.entity.liquids().total(), tiles * pumpAmount * tile.entity.delta() / size / size) * tile.entity.efficiency(); + tile.entity.liquids().add(liquidDrop, maxPump); } - if(tile.entity.getLiquids().currentAmount() > 0f && tile.entity.timer(timerContentCheck, 10)){ - useContent(tile, tile.entity.getLiquids().current()); + if(tile.entity.liquids().currentAmount() > 0f && tile.entity.timer(timerContentCheck, 10)){ + useContent(tile, tile.entity.liquids().current()); } - tryDumpLiquid(tile, tile.entity.getLiquids().current()); + tryDumpLiquid(tile, tile.entity.liquids().current()); } protected boolean isValid(Tile tile){ diff --git a/core/src/mindustry/world/blocks/production/Separator.java b/core/src/mindustry/world/blocks/production/Separator.java index 25a46379a1..c6f750595a 100644 --- a/core/src/mindustry/world/blocks/production/Separator.java +++ b/core/src/mindustry/world/blocks/production/Separator.java @@ -54,7 +54,7 @@ public class Separator extends Block{ @Override public boolean shouldConsume(Tile tile){ - return tile.entity.getItems().total() < itemCapacity; + return tile.entity.items().total() < itemCapacity; } @Override @@ -63,8 +63,8 @@ public class Separator extends Block{ GenericCrafterEntity entity = tile.ent(); - Draw.color(tile.entity.getLiquids().current().color); - Draw.alpha(tile.entity.getLiquids().total() / liquidCapacity); + Draw.color(tile.entity.liquids().current().color); + Draw.alpha(tile.entity.liquids().total() / liquidCapacity); Draw.rect(reg(liquidRegion), tile.drawx(), tile.drawy()); Draw.reset(); @@ -106,7 +106,7 @@ public class Separator extends Block{ entity.consume(); - if(item != null && entity.getItems().get(item) < itemCapacity){ + if(item != null && entity.items().get(item) < itemCapacity){ offloadNear(tile, item); } } diff --git a/core/src/mindustry/world/blocks/production/SolidPump.java b/core/src/mindustry/world/blocks/production/SolidPump.java index 2ad802dac5..9eae5cbf1d 100644 --- a/core/src/mindustry/world/blocks/production/SolidPump.java +++ b/core/src/mindustry/world/blocks/production/SolidPump.java @@ -74,8 +74,8 @@ public class SolidPump extends Pump{ SolidPumpEntity entity = tile.ent(); Draw.rect(region, tile.drawx(), tile.drawy()); - Draw.color(tile.entity.getLiquids().current().color); - Draw.alpha(tile.entity.getLiquids().total() / liquidCapacity); + Draw.color(tile.entity.liquids().current().color); + Draw.alpha(tile.entity.liquids().total() / liquidCapacity); Draw.rect(liquidRegion, tile.drawx(), tile.drawy()); Draw.color(); Draw.rect(name + "-rotator", tile.drawx(), tile.drawy(), entity.pumpTime * rotateSpeed); @@ -105,9 +105,9 @@ public class SolidPump extends Pump{ fraction += entity.boost; - if(tile.entity.getCons().valid() && typeLiquid(tile) < liquidCapacity - 0.001f){ + if(tile.entity.cons().valid() && typeLiquid(tile) < liquidCapacity - 0.001f){ float maxPump = Math.min(liquidCapacity - typeLiquid(tile), pumpAmount * entity.delta() * fraction * entity.efficiency()); - tile.entity.getLiquids().add(result, maxPump); + tile.entity.liquids().add(result, maxPump); entity.lastPump = maxPump; entity.warmup = Mathf.lerpDelta(entity.warmup, 1f, 0.02f); if(Mathf.chance(entity.delta() * updateEffectChance)) @@ -152,7 +152,7 @@ public class SolidPump extends Pump{ } public float typeLiquid(Tile tile){ - return tile.entity.getLiquids().total(); + return tile.entity.liquids().total(); } public static class SolidPumpEntity extends Tilec{ diff --git a/core/src/mindustry/world/blocks/sandbox/LiquidSource.java b/core/src/mindustry/world/blocks/sandbox/LiquidSource.java index d2d05161d5..98019ffd27 100644 --- a/core/src/mindustry/world/blocks/sandbox/LiquidSource.java +++ b/core/src/mindustry/world/blocks/sandbox/LiquidSource.java @@ -11,7 +11,6 @@ import arc.util.ArcAnnotate.*; import mindustry.entities.type.*; import mindustry.gen.*; import mindustry.entities.units.*; -import mindustry.gen.*; import mindustry.type.*; import mindustry.ui.*; import mindustry.ui.Cicon; @@ -54,9 +53,9 @@ public class LiquidSource extends Block{ LiquidSourceEntity entity = tile.ent(); if(entity.source == null){ - tile.entity.getLiquids().clear(); + tile.entity.liquids().clear(); }else{ - tile.entity.getLiquids().add(entity.source, liquidCapacity); + tile.entity.liquids().add(entity.source, liquidCapacity); tryDumpLiquid(tile, entity.source); } } diff --git a/core/src/mindustry/world/blocks/storage/CoreBlock.java b/core/src/mindustry/world/blocks/storage/CoreBlock.java index 55293099ae..59454a4b78 100644 --- a/core/src/mindustry/world/blocks/storage/CoreBlock.java +++ b/core/src/mindustry/world/blocks/storage/CoreBlock.java @@ -12,7 +12,6 @@ import mindustry.entities.traits.*; import mindustry.entities.type.*; import mindustry.gen.*; import mindustry.game.EventType.*; -import mindustry.gen.*; import mindustry.graphics.*; import mindustry.type.*; import mindustry.ui.*; @@ -71,7 +70,7 @@ public class CoreBlock extends StorageBlock{ @Override public boolean acceptItem(Item item, Tile tile, Tile source){ - return tile.entity.getItems().get(item) < getMaximumAccepted(tile, item); + return tile.entity.items().get(item) < getMaximumAccepted(tile, item); } @Override @@ -86,14 +85,14 @@ public class CoreBlock extends StorageBlock{ for(Tilec other : state.teams.cores(tile.getTeam())){ if(other.tile != tile){ - entity.getItems() = other.items; + entity.items() = other.items; } } state.teams.registerCore(entity); entity.storageCapacity = itemCapacity + entity.proximity().sum(e -> isContainer(e) ? e.block().itemCapacity : 0); entity.proximity().each(this::isContainer, t -> { - t.entity.getItems() = entity.getItems(); + t.entity.items() = entity.items(); t.ent().linkedCore = tile; }); @@ -104,7 +103,7 @@ public class CoreBlock extends StorageBlock{ if(!world.isGenerating()){ for(Item item : content.items()){ - entity.getItems().set(item, Math.min(entity.getItems().get(item), entity.storageCapacity)); + entity.items().set(item, Math.min(entity.items().get(item), entity.storageCapacity)); } } @@ -123,10 +122,10 @@ public class CoreBlock extends StorageBlock{ Draw.rect("block-select", t.drawx() + offset * p.x, t.drawy() + offset * p.y, i * 90); } }; - if(tile.entity.proximity().contains(e -> isContainer(e) && e.entity.getItems() == tile.entity.getItems())){ + if(tile.entity.proximity().contains(e -> isContainer(e) && e.entity.items() == tile.entity.items())){ outline.get(tile); } - tile.entity.proximity().each(e -> isContainer(e) && e.entity.getItems() == tile.entity.getItems(), outline); + tile.entity.proximity().each(e -> isContainer(e) && e.entity.items() == tile.entity.items(), outline); Draw.reset(); } @@ -137,7 +136,7 @@ public class CoreBlock extends StorageBlock{ @Override public float handleDamage(Tile tile, float amount){ - if(player != null && tile.getTeam() == player.getTeam()){ + if(player != null && tile.getTeam() == player.team()){ Events.fire(Trigger.teamCoreDamage); } return amount; @@ -151,15 +150,15 @@ public class CoreBlock extends StorageBlock{ @Override public void removed(Tile tile){ CoreEntity entity = tile.ent(); - int total = tile.entity.proximity().count(e -> e.entity != null && e.entity.getItems() != null && e.entity.getItems() == tile.entity.getItems()); + int total = tile.entity.proximity().count(e -> e.entity != null && e.entity.items() != null && e.entity.items() == tile.entity.items()); float fract = 1f / total / state.teams.cores(tile.getTeam()).size; - tile.entity.proximity().each(e -> isContainer(e) && e.entity.getItems() == tile.entity.getItems(), t -> { + tile.entity.proximity().each(e -> isContainer(e) && e.entity.items() == tile.entity.items(), t -> { StorageBlockEntity ent = (StorageBlockEntity)t.entity; ent.linkedCore = null; ent.items = new ItemModule(); for(Item item : content.items()){ - ent.items.set(item, (int)(fract * tile.entity.getItems().get(item))); + ent.items.set(item, (int)(fract * tile.entity.items().get(item))); } }); @@ -167,7 +166,7 @@ public class CoreBlock extends StorageBlock{ int max = itemCapacity * state.teams.cores(tile.getTeam()).size; for(Item item : content.items()){ - tile.entity.getItems().set(item, Math.min(tile.entity.getItems().get(item), max)); + tile.entity.items().set(item, Math.min(tile.entity.items().get(item), max)); } for(CoreEntity other : state.teams.cores(tile.getTeam())){ @@ -206,7 +205,7 @@ public class CoreBlock extends StorageBlock{ CoreEntity entity = tile.ent(); if(entity.spawnPlayer != null){ - if(!entity.spawnPlayer.isDead() || !entity.spawnPlayer.isAdded()){ + if(!entity.spawnPlayer.dead() || !entity.spawnPlayer.isAdded()){ entity.spawnPlayer = null; return; } diff --git a/core/src/mindustry/world/blocks/storage/LaunchPad.java b/core/src/mindustry/world/blocks/storage/LaunchPad.java index 1aa5a4c85c..d22d6b0bd3 100644 --- a/core/src/mindustry/world/blocks/storage/LaunchPad.java +++ b/core/src/mindustry/world/blocks/storage/LaunchPad.java @@ -40,14 +40,14 @@ public class LaunchPad extends StorageBlock{ @Override public boolean acceptItem(Item item, Tile tile, Tile source){ - return item.type == ItemType.material && tile.entity.getItems().total() < itemCapacity; + return item.type == ItemType.material && tile.entity.items().total() < itemCapacity; } @Override public void draw(Tile tile){ super.draw(tile); - float progress = Mathf.clamp(Mathf.clamp((tile.entity.getItems().total() / (float)itemCapacity)) * ((tile.entity.timerTime(timerLaunch) / (launchTime / tile.entity.timeScale)))); + float progress = Mathf.clamp(Mathf.clamp((tile.entity.items().total() / (float)itemCapacity)) * ((tile.entity.timerTime(timerLaunch) / (launchTime / tile.entity.timeScale)))); float scale = size / 3f; Lines.stroke(2f); @@ -56,7 +56,7 @@ public class LaunchPad extends StorageBlock{ Draw.color(Pal.accent); - if(tile.entity.getCons().valid()){ + if(tile.entity.cons().valid()){ for(int i = 0; i < 3; i++){ float f = (Time.time() / 200f + i * 0.5f) % 1f; @@ -72,13 +72,13 @@ public class LaunchPad extends StorageBlock{ public void update(Tile tile){ Tilec entity = tile.entity; - if(world.isZone() && entity.consValid() && entity.getItems().total() >= itemCapacity && entity.timer(timerLaunch, launchTime / entity.timeScale)){ + if(world.isZone() && entity.consValid() && entity.items().total() >= itemCapacity && entity.timer(timerLaunch, launchTime / entity.timeScale)){ for(Item item : Vars.content.items()){ Events.fire(Trigger.itemLaunch); Fx.padlaunch.at(tile); - int used = Math.min(entity.getItems().get(item), itemCapacity); + int used = Math.min(entity.items().get(item), itemCapacity); data.addItem(item, used); - entity.getItems().remove(item, used); + entity.items().remove(item, used); Events.fire(new LaunchItemEvent(item, used)); } } diff --git a/core/src/mindustry/world/blocks/storage/StorageBlock.java b/core/src/mindustry/world/blocks/storage/StorageBlock.java index 171c7ff022..b4b678acb5 100644 --- a/core/src/mindustry/world/blocks/storage/StorageBlock.java +++ b/core/src/mindustry/world/blocks/storage/StorageBlock.java @@ -17,7 +17,7 @@ public abstract class StorageBlock extends Block{ @Override public boolean acceptItem(Item item, Tile tile, Tile source){ StorageBlockEntity entity = tile.ent(); - return entity.linkedCore != null ? entity.linkedCore.block().acceptItem(item, entity.linkedCore, source) : tile.entity.getItems().get(item) < getMaximumAccepted(tile, item); + return entity.linkedCore != null ? entity.linkedCore.block().acceptItem(item, entity.linkedCore, source) : tile.entity.items().get(item) < getMaximumAccepted(tile, item); } @Override @@ -46,10 +46,10 @@ public abstract class StorageBlock extends Block{ Tilec entity = tile.entity; if(item == null){ - return entity.getItems().take(); + return entity.items().take(); }else{ - if(entity.getItems().has(item)){ - entity.getItems().remove(item, 1); + if(entity.items().has(item)){ + entity.items().remove(item, 1); return item; } @@ -64,9 +64,9 @@ public abstract class StorageBlock extends Block{ public boolean hasItem(Tile tile, Item item){ Tilec entity = tile.entity; if(item == null){ - return entity.getItems().total() > 0; + return entity.items().total() > 0; }else{ - return entity.getItems().has(item); + return entity.items().has(item); } } diff --git a/core/src/mindustry/world/blocks/storage/Unloader.java b/core/src/mindustry/world/blocks/storage/Unloader.java index 21373c2cbb..5de19bc053 100644 --- a/core/src/mindustry/world/blocks/storage/Unloader.java +++ b/core/src/mindustry/world/blocks/storage/Unloader.java @@ -55,7 +55,7 @@ public class Unloader extends Block{ @Override public void configured(Tile tile, Player player, int value){ - tile.entity.getItems().clear(); + tile.entity.items().clear(); tile.ent().sortItem = content.item(value); } @@ -63,10 +63,10 @@ public class Unloader extends Block{ public void update(Tile tile){ UnloaderEntity entity = tile.ent(); - if(tile.entity.timer(timerUnload, speed / entity.timeScale) && tile.entity.getItems().total() == 0){ + if(tile.entity.timer(timerUnload, speed / entity.timeScale) && tile.entity.items().total() == 0){ for(Tile other : tile.entity.proximity()){ if(other.interactable(tile.getTeam()) && other.block().unloadable && other.block().hasItems && entity.getItems().total() == 0 && - ((entity.sortItem == null && other.entity.getItems().total() > 0) || hasItem(other, entity.sortItem))){ + ((entity.sortItem == null && other.entity.items().total() > 0) || hasItem(other, entity.sortItem))){ offloadNear(tile, removeItem(other, entity.sortItem)); } } diff --git a/core/src/mindustry/world/blocks/units/MechPad.java b/core/src/mindustry/world/blocks/units/MechPad.java index fb97c21319..871d3b6c65 100644 --- a/core/src/mindustry/world/blocks/units/MechPad.java +++ b/core/src/mindustry/world/blocks/units/MechPad.java @@ -13,7 +13,6 @@ import mindustry.entities.traits.*; import mindustry.entities.type.*; import mindustry.gen.*; import mindustry.game.EventType.*; -import mindustry.gen.*; import mindustry.graphics.*; import mindustry.world.*; import mindustry.world.blocks.*; @@ -80,7 +79,7 @@ public class MechPad extends Block{ protected static boolean checkValidTap(Tile tile, Player player){ MechFactoryEntity entity = tile.ent(); - return !player.isDead() && tile.interactable(player.getTeam()) && Math.abs(player.x - tile.drawx()) <= tile.block().size * tilesize && + return !player.dead() && tile.interactable(player.team()) && Math.abs(player.x - tile.drawx()) <= tile.block().size * tilesize && Math.abs(player.y - tile.drawy()) <= tile.block().size * tilesize && entity.consValid() && entity.player == null; } @@ -100,7 +99,7 @@ public class MechPad extends Block{ if(checkValidTap(tile, player)){ Call.onMechFactoryTap(player, tile); - }else if(player.isLocal && mobile && !player.isDead() && entity.consValid() && entity.player == null){ + }else if(player.isLocal && mobile && !player.dead() && entity.consValid() && entity.player == null){ //deselect on double taps player.moveTarget = player.moveTarget == tile.entity ? null : tile.entity; } diff --git a/core/src/mindustry/world/blocks/units/RepairPoint.java b/core/src/mindustry/world/blocks/units/RepairPoint.java index fdb0aa4f43..797f28b609 100644 --- a/core/src/mindustry/world/blocks/units/RepairPoint.java +++ b/core/src/mindustry/world/blocks/units/RepairPoint.java @@ -110,7 +110,7 @@ public class RepairPoint extends Block{ RepairPointEntity entity = tile.ent(); boolean targetIsBeingRepaired = false; - if(entity.target != null && (entity.target.isDead() || entity.target.dst(tile) > repairRadius || entity.target.health >= entity.target.maxHealth())){ + if(entity.target != null && (entity.target.dead() || entity.target.dst(tile) > repairRadius || entity.target.health >= entity.target.maxHealth())){ entity.target = null; }else if(entity.target != null && entity.consValid()){ entity.target.health += repairSpeed * Time.delta() * entity.strength * entity.efficiency(); diff --git a/core/src/mindustry/world/consumers/ConsumeItemFilter.java b/core/src/mindustry/world/consumers/ConsumeItemFilter.java index f9d4229dc7..592866ba24 100644 --- a/core/src/mindustry/world/consumers/ConsumeItemFilter.java +++ b/core/src/mindustry/world/consumers/ConsumeItemFilter.java @@ -4,7 +4,6 @@ import arc.struct.*; import arc.func.*; import arc.scene.ui.layout.*; import arc.util.ArcAnnotate.*; -import mindustry.entities.type.*; import mindustry.type.*; import mindustry.ui.*; import mindustry.ui.Cicon; @@ -35,7 +34,7 @@ public class ConsumeItemFilter extends Consume{ @Override public void build(Tile tile, Table table){ MultiReqImage image = new MultiReqImage(); - content.items().each(i -> filter.get(i) && (!world.isZone() || data.isUnlocked(i)), item -> image.add(new ReqImage(new ItemImage(item.icon(Cicon.medium), 1), () -> tile.entity != null && tile.entity.getItems() != null && tile.entity.getItems().has(item)))); + content.items().each(i -> filter.get(i) && (!world.isZone() || data.isUnlocked(i)), item -> image.add(new ReqImage(new ItemImage(item.icon(Cicon.medium), 1), () -> tile.entity != null && tile.entity.items() != null && tile.entity.items().has(item)))); table.add(image).size(8 * 4); } diff --git a/core/src/mindustry/world/consumers/ConsumeItems.java b/core/src/mindustry/world/consumers/ConsumeItems.java index b71c95fc51..9d11f13106 100644 --- a/core/src/mindustry/world/consumers/ConsumeItems.java +++ b/core/src/mindustry/world/consumers/ConsumeItems.java @@ -3,7 +3,6 @@ package mindustry.world.consumers; import arc.struct.*; import arc.scene.ui.layout.*; import arc.util.ArcAnnotate.*; -import mindustry.entities.type.*; import mindustry.type.*; import mindustry.ui.*; import mindustry.ui.Cicon; @@ -38,7 +37,7 @@ public class ConsumeItems extends Consume{ @Override public void build(Tile tile, Table table){ for(ItemStack stack : items){ - table.add(new ReqImage(new ItemImage(stack.item.icon(Cicon.medium), stack.amount), () -> tile.entity != null && tile.entity.getItems() != null && tile.entity.getItems().has(stack.item, stack.amount))).size(8 * 4).padRight(5); + table.add(new ReqImage(new ItemImage(stack.item.icon(Cicon.medium), stack.amount), () -> tile.entity != null && tile.entity.items() != null && tile.entity.items().has(stack.item, stack.amount))).size(8 * 4).padRight(5); } } diff --git a/core/src/mindustry/world/consumers/ConsumeLiquidFilter.java b/core/src/mindustry/world/consumers/ConsumeLiquidFilter.java index 577d0a5a38..2fb844a827 100644 --- a/core/src/mindustry/world/consumers/ConsumeLiquidFilter.java +++ b/core/src/mindustry/world/consumers/ConsumeLiquidFilter.java @@ -32,7 +32,7 @@ public class ConsumeLiquidFilter extends ConsumeLiquidBase{ public void build(Tile tile, Table table){ Array list = content.liquids().select(l -> !l.isHidden() && filter.get(l)); MultiReqImage image = new MultiReqImage(); - list.each(liquid -> image.add(new ReqImage(liquid.icon(Cicon.medium), () -> tile.entity != null && tile.entity.getLiquids() != null && tile.entity.getLiquids().get(liquid) >= use(tile.entity)))); + list.each(liquid -> image.add(new ReqImage(liquid.icon(Cicon.medium), () -> tile.entity != null && tile.entity.liquids() != null && tile.entity.liquids().get(liquid) >= use(tile.entity)))); table.add(image).size(8 * 4); } @@ -44,12 +44,12 @@ public class ConsumeLiquidFilter extends ConsumeLiquidBase{ @Override public void update(Tilec entity){ - entity.getLiquids().remove(entity.getLiquids().current(), use(entity)); + entity.liquids().remove(entity.liquids().current(), use(entity)); } @Override public boolean valid(Tilec entity){ - return entity != null && entity.getLiquids() != null && filter.get(entity.getLiquids().current()) && entity.getLiquids().currentAmount() >= use(entity); + return entity != null && entity.liquids() != null && filter.get(entity.liquids().current()) && entity.liquids().currentAmount() >= use(entity); } @Override diff --git a/core/src/mindustry/world/consumers/ConsumePower.java b/core/src/mindustry/world/consumers/ConsumePower.java index 340e630400..3e73898972 100644 --- a/core/src/mindustry/world/consumers/ConsumePower.java +++ b/core/src/mindustry/world/consumers/ConsumePower.java @@ -50,7 +50,7 @@ public class ConsumePower extends Consume{ if(buffered){ return true; }else{ - return entity.getPower().status > 0f; + return entity.power().status > 0f; } } @@ -69,12 +69,12 @@ public class ConsumePower extends Consume{ * @return The amount of power which is requested per tick. */ public float requestedPower(Tilec entity){ - if(entity.getTile().entity == null) return 0f; + if(entity.tile().entity == null) return 0f; if(buffered){ - return (1f-entity.getPower().status)*capacity; + return (1f-entity.power().status)*capacity; }else{ try{ - return usage * Mathf.num(entity.getBlock().shouldConsume(entity.getTile())); + return usage * Mathf.num(entity.block().shouldConsume(entity.tile())); }catch(Exception e){ //HACK an error will only happen with a bar that is checking its requested power, and the entity is null/a different class return 0; diff --git a/desktop/src/mindustry/desktop/steam/SStats.java b/desktop/src/mindustry/desktop/steam/SStats.java index cdc6288ebe..02fe0b1c1f 100644 --- a/desktop/src/mindustry/desktop/steam/SStats.java +++ b/desktop/src/mindustry/desktop/steam/SStats.java @@ -6,7 +6,6 @@ import arc.util.*; import com.codedisaster.steamworks.*; import mindustry.*; import mindustry.content.*; -import mindustry.entities.type.*; import mindustry.entities.units.*; import mindustry.game.EventType.*; import mindustry.game.Stats.*; @@ -54,17 +53,17 @@ public class SStats implements SteamUserStatsCallback{ private void checkUpdate(){ if(campaign()){ - SStat.maxUnitActive.max(unitGroup.count(t -> t.getTeam() == player.getTeam())); + SStat.maxUnitActive.max(unitGroup.count(t -> t.getTeam() == player.team())); - if(unitGroup.count(u -> u.getType() == UnitTypes.phantom && u.getTeam() == player.getTeam()) >= 10){ + if(unitGroup.count(u -> u.getType() == UnitTypes.phantom && u.getTeam() == player.team()) >= 10){ active10Phantoms.complete(); } - if(unitGroup.count(u -> u.getType() == UnitTypes.crawler && u.getTeam() == player.getTeam()) >= 50){ + if(unitGroup.count(u -> u.getType() == UnitTypes.crawler && u.getTeam() == player.team()) >= 50){ active50Crawlers.complete(); } - for(Tilec entity : player.getTeam().cores()){ + for(Tilec entity : player.team().cores()){ if(!content.items().contains(i -> i.type == ItemType.material && entity.getItems().get(i) < entity.block.itemCapacity)){ fillCoreAllCampaign.complete(); break; @@ -76,7 +75,7 @@ public class SStats implements SteamUserStatsCallback{ private void registerEvents(){ Events.on(UnitDestroyEvent.class, e -> { if(ncustom()){ - if(e.unit.getTeam() != Vars.player.getTeam()){ + if(e.unit.team() != Vars.player.team()){ SStat.unitsDestroyed.add(); if(e.unit instanceof BaseUnit && ((BaseUnit)e.unit).isBoss()){ @@ -93,7 +92,7 @@ public class SStats implements SteamUserStatsCallback{ }); Events.on(Trigger.newGame, () -> Core.app.post(() -> { - if(campaign() && player.getClosestCore() != null && player.getClosestCore().items.total() >= 10 * 1000){ + if(campaign() && player.closestCore() != null && player.closestCore().items.total() >= 10 * 1000){ drop10kitems.complete(); } })); @@ -133,7 +132,7 @@ public class SStats implements SteamUserStatsCallback{ }); Events.on(BlockDestroyEvent.class, e -> { - if(campaign() && e.tile.getTeam() != player.getTeam()){ + if(campaign() && e.tile.getTeam() != player.team()){ SStat.blocksDestroyed.add(); } }); @@ -180,7 +179,7 @@ public class SStats implements SteamUserStatsCallback{ trigger(Trigger.itemLaunch, launchItemPad); Events.on(UnitCreateEvent.class, e -> { - if(campaign() && e.unit.getTeam() == player.getTeam()){ + if(campaign() && e.unit.team() == player.team()){ SStat.unitsBuilt.add(); } }); diff --git a/server/src/mindustry/server/ServerControl.java b/server/src/mindustry/server/ServerControl.java index 631b561b42..645a1287a5 100644 --- a/server/src/mindustry/server/ServerControl.java +++ b/server/src/mindustry/server/ServerControl.java @@ -866,7 +866,7 @@ public class ServerControl implements ApplicationListener{ Array players = new Array<>(); for(Player p : playerGroup.all()){ players.add(p); - p.setDead(true); + p.dead(true); } logic.reset(); @@ -881,7 +881,7 @@ public class ServerControl implements ApplicationListener{ p.reset(); if(state.rules.pvp){ - p.setTeam(netServer.assignTeam(p, new ArrayIterable<>(players))); + p.team(netServer.assignTeam(p, new ArrayIterable<>(players))); } netServer.sendWorldData(p); } diff --git a/tests/src/test/java/ApplicationTests.java b/tests/src/test/java/ApplicationTests.java index 1cbbb4636c..be672cf72b 100644 --- a/tests/src/test/java/ApplicationTests.java +++ b/tests/src/test/java/ApplicationTests.java @@ -8,7 +8,6 @@ import mindustry.content.*; import mindustry.core.*; import mindustry.core.GameState.*; import mindustry.ctype.*; -import mindustry.entities.type.*; import mindustry.entities.type.base.*; import mindustry.entities.units.*; import mindustry.game.*; @@ -143,12 +142,12 @@ public class ApplicationTests{ void blockInventories(){ multiblock(); Tile tile = world.tile(4, 4); - tile.entity.getItems().add(Items.coal, 5); - tile.entity.getItems().add(Items.titanium, 50); - assertEquals(tile.entity.getItems().total(), 55); - tile.entity.getItems().remove(Items.phasefabric, 10); - tile.entity.getItems().remove(Items.titanium, 10); - assertEquals(tile.entity.getItems().total(), 45); + tile.entity.items().add(Items.coal, 5); + tile.entity.items().add(Items.titanium, 50); + assertEquals(tile.entity.items().total(), 55); + tile.entity.items().remove(Items.phasefabric, 10); + tile.entity.items().remove(Items.titanium, 10); + assertEquals(tile.entity.items().total(), 45); } @Test @@ -422,7 +421,7 @@ public class ApplicationTests{ Tile core = world.tile(5, 5); core.set(Blocks.coreShard, Team.sharded); for(Item item : content.items()){ - core.entity.getItems().set(item, 3000); + core.entity.items().set(item, 3000); } assertEquals(core.entity, state.teams.get(Team.sharded).core()); @@ -439,12 +438,12 @@ public class ApplicationTests{ assertEquals(capacity - 1, deposited); tile.block().handleStack(item, capacity - 1, tile, unit); - assertEquals(tile.entity.getItems().get(item), capacity - 1); + assertEquals(tile.entity.items().get(item), capacity - 1); int overflow = tile.block().acceptStack(item, 10, tile, unit); assertEquals(1, overflow); tile.block().handleStack(item, 1, tile, unit); - assertEquals(capacity, tile.entity.getItems().get(item)); + assertEquals(capacity, tile.entity.items().get(item)); } } \ No newline at end of file diff --git a/tests/src/test/java/power/ItemLiquidGeneratorTests.java b/tests/src/test/java/power/ItemLiquidGeneratorTests.java index 894421b67e..138aaa5f9a 100644 --- a/tests/src/test/java/power/ItemLiquidGeneratorTests.java +++ b/tests/src/test/java/power/ItemLiquidGeneratorTests.java @@ -87,13 +87,13 @@ public class ItemLiquidGeneratorTests extends PowerTestFixture{ createGenerator(inputType); assertTrue(generator.acceptLiquid(tile, null, liquid, availableLiquidAmount), inputType + " | " + parameterDescription + ": Liquids which will be declined by the generator don't need to be tested - The code won't be called for those cases."); - entity.getLiquids().add(liquid, availableLiquidAmount); + entity.liquids().add(liquid, availableLiquidAmount); entity.cons.update(); // Perform an update on the generator once - This should use up any resource up to the maximum liquid usage generator.update(tile); - assertEquals(expectedRemainingLiquidAmount, entity.getLiquids().get(liquid), inputType + " | " + parameterDescription + ": Remaining liquid amount mismatch."); + assertEquals(expectedRemainingLiquidAmount, entity.liquids().get(liquid), inputType + " | " + parameterDescription + ": Remaining liquid amount mismatch."); assertEquals(expectedEfficiency, entity.productionEfficiency, inputType + " | " + parameterDescription + ": Efficiency mismatch."); } @@ -130,7 +130,7 @@ public class ItemLiquidGeneratorTests extends PowerTestFixture{ assertTrue(generator.acceptItem(item, tile, null), inputType + " | " + parameterDescription + ": Items which will be declined by the generator don't need to be tested - The code won't be called for those cases."); if(amount > 0){ - entity.getItems().add(item, amount); + entity.items().add(item, amount); } entity.cons.update(); @@ -138,7 +138,7 @@ public class ItemLiquidGeneratorTests extends PowerTestFixture{ try{ generator.update(tile); - assertEquals(expectedRemainingItemAmount, entity.getItems().get(item), inputType + " | " + parameterDescription + ": Remaining item amount mismatch."); + assertEquals(expectedRemainingItemAmount, entity.items().get(item), inputType + " | " + parameterDescription + ": Remaining item amount mismatch."); assertEquals(expectedEfficiency, entity.productionEfficiency, inputType + " | " + parameterDescription + ": Efficiency mismatch."); }catch(NullPointerException e){ e.printStackTrace(); @@ -162,7 +162,7 @@ public class ItemLiquidGeneratorTests extends PowerTestFixture{ createGenerator(inputType); // Burn a single coal and test for the duration - entity.getItems().add(Items.coal, 1); + entity.items().add(Items.coal, 1); entity.cons.update(); generator.update(tile); diff --git a/tests/src/test/java/power/PowerTestFixture.java b/tests/src/test/java/power/PowerTestFixture.java index d0ceb3ac77..459d26aa9a 100644 --- a/tests/src/test/java/power/PowerTestFixture.java +++ b/tests/src/test/java/power/PowerTestFixture.java @@ -87,19 +87,19 @@ public class PowerTestFixture{ // Simulate the "changed" method. Calling it through reflections would require half the game to be initialized. tile.entity = block.newEntity().init(tile, false); - tile.entity.getCons() = new ConsumeModule(tile.entity); - if(block.hasItems) tile.entity.getItems() = new ItemModule(); - if(block.hasLiquids) tile.entity.getLiquids() = new LiquidModule(); + tile.entity.cons() = new ConsumeModule(tile.entity); + if(block.hasItems) tile.entity.items() = new ItemModule(); + if(block.hasLiquids) tile.entity.liquids() = new LiquidModule(); if(block.hasPower){ - tile.entity.getPower() = new PowerModule(); - tile.entity.getPower().graph = new PowerGraph(){ + tile.entity.power() = new PowerModule(); + tile.entity.power().graph = new PowerGraph(){ //assume there's always something consuming power @Override public float getUsageFraction(){ return 1f; } }; - tile.entity.getPower().graph.add(tile); + tile.entity.power().graph.add(tile); } // Assign incredibly high health so the block does not get destroyed on e.g. burning Blast Compound