From 659bfea8cf1097a1ab06062af973f87c2b3efbbe Mon Sep 17 00:00:00 2001 From: Anuken Date: Fri, 7 Feb 2020 23:12:39 -0500 Subject: [PATCH] Cleanup --- core/src/mindustry/entities/Effects.java | 23 ++++----- .../mindustry/entities/def/AllEntities.java | 2 +- .../src/mindustry/entities/def/ChildComp.java | 4 +- .../mindustry/entities/def/PlayerComp.java | 5 -- core/src/mindustry/game/SpawnGroup.java | 7 +-- core/src/mindustry/io/MapIO.java | 1 - core/src/mindustry/type/Sector.java | 1 - core/src/mindustry/ui/ContentDisplay.java | 50 ------------------- 8 files changed, 15 insertions(+), 78 deletions(-) diff --git a/core/src/mindustry/entities/Effects.java b/core/src/mindustry/entities/Effects.java index 02c41452a6..9b4c281eea 100644 --- a/core/src/mindustry/entities/Effects.java +++ b/core/src/mindustry/entities/Effects.java @@ -6,6 +6,7 @@ import arc.math.*; import arc.math.geom.*; import arc.util.*; import mindustry.content.*; +import mindustry.gen.*; import static mindustry.Vars.*; @@ -38,19 +39,15 @@ public class Effects{ Rect pos = Tmp.r2.setSize(effect.size).setCenter(x, y); if(view.overlaps(pos)){ - //TODO implement create() method here. - //EffectEntity entity = Pools.obtain(EffectEntity.class, EffectEntity::new); - //entity.effect = effect; - //entity.color.set(color); - //entity.rotation = rotation; - //entity.data = data; - //entity.id++; - //entity.set(x, y); - //if(data instanceof Entity){ - // entity.setParent((Entity)data); - //} - //TODO ground effect - //effectGroup.add(entity); + EffectEntity entity = EffectEntity.create(); + entity.effect(effect); + entity.rotation(rotation); + entity.data(data); + entity.id(EntityGroup.nextId()); + entity.set(x, y); + entity.color().set(color); + if(data instanceof Posc) entity.parent((Posc)data); + entity.add(); } } } diff --git a/core/src/mindustry/entities/def/AllEntities.java b/core/src/mindustry/entities/def/AllEntities.java index 2b452f0c5d..8f7d99ab25 100644 --- a/core/src/mindustry/entities/def/AllEntities.java +++ b/core/src/mindustry/entities/def/AllEntities.java @@ -11,7 +11,7 @@ class AllEntities{ @EntityDef(value = {Tilec.class}, isFinal = false) class TileDef{} - @EntityDef(value = {Effectc.class}, pooled = true) + @EntityDef(value = {Effectc.class, Childc.class}, pooled = true) class EffectDef{} @EntityDef({Decalc.class}) diff --git a/core/src/mindustry/entities/def/ChildComp.java b/core/src/mindustry/entities/def/ChildComp.java index c1d8f0d955..e64efe6eac 100644 --- a/core/src/mindustry/entities/def/ChildComp.java +++ b/core/src/mindustry/entities/def/ChildComp.java @@ -8,8 +8,8 @@ import mindustry.gen.*; abstract class ChildComp implements Posc{ transient float x, y; - private @Nullable Posc parent; - private float offsetX, offsetY; + @Nullable Posc parent; + float offsetX, offsetY; @Override public void add(){ diff --git a/core/src/mindustry/entities/def/PlayerComp.java b/core/src/mindustry/entities/def/PlayerComp.java index d32eb50c8e..207248273b 100644 --- a/core/src/mindustry/entities/def/PlayerComp.java +++ b/core/src/mindustry/entities/def/PlayerComp.java @@ -78,11 +78,6 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc{ } public Unitc unit(){ - if(dead()){ - //TODO remove - Log.err("WARNING: DEAD PLAYER UNIT ACCESSED"); - new RuntimeException().printStackTrace(); - } return unit; } diff --git a/core/src/mindustry/game/SpawnGroup.java b/core/src/mindustry/game/SpawnGroup.java index 92945d543d..5a9dba9a24 100644 --- a/core/src/mindustry/game/SpawnGroup.java +++ b/core/src/mindustry/game/SpawnGroup.java @@ -58,20 +58,17 @@ public class SpawnGroup implements Serializable{ * This method does not add() the unit. */ public Unitc createUnit(Team team){ - //TODO - throw new IllegalArgumentException("TODO"); - /* Unitc unit = type.create(team); if(effect != null){ - unit.applyEffect(effect, 999999f); + unit.apply(effect, 999999f); } if(items != null){ unit.addItem(items.item, items.amount); } - return unit;*/ + return unit; } @Override diff --git a/core/src/mindustry/io/MapIO.java b/core/src/mindustry/io/MapIO.java index 2519cd0f77..3187b791b6 100644 --- a/core/src/mindustry/io/MapIO.java +++ b/core/src/mindustry/io/MapIO.java @@ -19,7 +19,6 @@ import java.util.zip.*; import static mindustry.Vars.*; /** Reads and writes map files. */ -//TODO does this class even need to exist??? move to Maps? public class MapIO{ private static final int[] pngHeader = {0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A}; diff --git a/core/src/mindustry/type/Sector.java b/core/src/mindustry/type/Sector.java index 3ebe6af7eb..d1fbff354a 100644 --- a/core/src/mindustry/type/Sector.java +++ b/core/src/mindustry/type/Sector.java @@ -5,7 +5,6 @@ import arc.util.*; import mindustry.graphics.PlanetGrid.*; /** A small section of a planet. */ -//TODO should this be content? public class Sector{ public final SectorRect rect; public final Planet planet; diff --git a/core/src/mindustry/ui/ContentDisplay.java b/core/src/mindustry/ui/ContentDisplay.java index 771dccbb08..c2ab37ba1f 100644 --- a/core/src/mindustry/ui/ContentDisplay.java +++ b/core/src/mindustry/ui/ContentDisplay.java @@ -131,56 +131,6 @@ public class ContentDisplay{ table.row(); } - //TODO implement later - /* - public static void displayMech(Table table, Mech mech){ - table.table(title -> { - title.addImage(mech.icon(Cicon.xlarge)).size(8 * 6); - title.add("[accent]" + mech.localizedName).padLeft(5); - }); - table.left().defaults().left(); - - table.row(); - - table.addImage().height(3).color(Color.lightGray).pad(15).padLeft(0).padRight(0).fillX(); - - table.row(); - - if(mech.description != null){ - table.add(mech.displayDescription()).padLeft(5).padRight(5).width(400f).wrap().fillX(); - table.row(); - - table.addImage().height(3).color(Color.lightGray).pad(15).padLeft(0).padRight(0).fillX(); - table.row(); - } - - table.left().defaults().fillX(); - - if(Core.bundle.has("mech." + mech.name + ".weapon")){ - table.add(Core.bundle.format("mech.weapon", Core.bundle.get("mech." + mech.name + ".weapon"))); - table.row(); - } - if(Core.bundle.has("mech." + mech.name + ".ability")){ - table.add(Core.bundle.format("mech.ability", Core.bundle.get("mech." + mech.name + ".ability"))); - table.row(); - } - - table.add(Core.bundle.format("mech.buildspeed", (int)(mech.buildPower * 100f))); - table.row(); - - table.add(Core.bundle.format("mech.health", (int)mech.health)); - table.row(); - table.add(Core.bundle.format("mech.itemcapacity", mech.itemCapacity)); - table.row(); - - if(mech.drillPower > 0){ - table.add(Core.bundle.format("mech.minespeed", (int)(mech.mineSpeed * 100f))); - table.row(); - table.add(Core.bundle.format("mech.minepower", mech.drillPower)); - table.row(); - } - }*/ - public static void displayUnit(Table table, UnitDef unit){ table.table(title -> { title.addImage(unit.icon(Cicon.xlarge)).size(8 * 6);