From 42c323365aef7a0aef10dfee671ef041e160a058 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sun, 21 Jun 2020 20:22:20 -0400 Subject: [PATCH] Removed CoreLauncher --- .../src/main/resources/classids.properties | 1 + core/src/mindustry/content/Blocks.java | 12 +- core/src/mindustry/core/Control.java | 10 ++ .../entities/comp/LaunchCoreComp.java | 76 +++++++++++ .../mindustry/ui/dialogs/PlanetDialog.java | 7 +- .../mindustry/ui/fragments/HudFragment.java | 16 ++- .../world/blocks/campaign/CoreLauncher.java | 127 ------------------ .../world/blocks/storage/CoreBlock.java | 2 + 8 files changed, 106 insertions(+), 145 deletions(-) create mode 100644 core/src/mindustry/entities/comp/LaunchCoreComp.java delete mode 100644 core/src/mindustry/world/blocks/campaign/CoreLauncher.java diff --git a/annotations/src/main/resources/classids.properties b/annotations/src/main/resources/classids.properties index f49a36e31f..85e912ce07 100644 --- a/annotations/src/main/resources/classids.properties +++ b/annotations/src/main/resources/classids.properties @@ -9,6 +9,7 @@ mindustry.entities.comp.BulletComp=5 mindustry.entities.comp.DecalComp=6 mindustry.entities.comp.EffectComp=7 mindustry.entities.comp.FireComp=8 +mindustry.entities.comp.LaunchCoreComp=21 mindustry.entities.comp.PlayerComp=9 mindustry.entities.comp.PuddleComp=10 mindustry.entities.comp.TileComp=11 diff --git a/core/src/mindustry/content/Blocks.java b/core/src/mindustry/content/Blocks.java index ffb1478b6f..32b8e448c1 100644 --- a/core/src/mindustry/content/Blocks.java +++ b/core/src/mindustry/content/Blocks.java @@ -82,7 +82,7 @@ public class Blocks implements ContentList{ repairPoint, resupplyPoint, //campaign - launchPad, launchPadLarge, coreSilo, dataProcessor, + launchPad, launchPadLarge, dataProcessor, //misc experimental blockForge, blockLoader, blockUnloader; @@ -1836,16 +1836,6 @@ public class Blocks implements ContentList{ consumes.power(6f); }}; - //TODO remove later - /* - coreSilo = new CoreLauncher("core-silo"){{ - requirements(Category.effect, BuildVisibility.campaignOnly, ItemStack.with(Items.copper, 350, Items.silicon, 140, Items.lead, 200, Items.titanium, 150)); - size = 5; - itemCapacity = 500; - - consumes.items(ItemStack.with(Items.copper, 500)); - }};*/ - dataProcessor = new ResearchBlock("data-processor"){{ requirements(Category.effect, BuildVisibility.campaignOnly, ItemStack.with(Items.copper, 200, Items.lead, 100)); diff --git a/core/src/mindustry/core/Control.java b/core/src/mindustry/core/Control.java index 58ade85b5f..e704148ae5 100644 --- a/core/src/mindustry/core/Control.java +++ b/core/src/mindustry/core/Control.java @@ -9,6 +9,7 @@ import arc.math.*; import arc.scene.ui.*; import arc.struct.*; import arc.util.*; +import mindustry.*; import mindustry.audio.*; import mindustry.content.*; import mindustry.core.GameState.*; @@ -239,6 +240,15 @@ public class Control implements ApplicationListener, Loadable{ }); } + //TODO move + public void handleLaunch(Tilec tile){ + LaunchCorec ent = LaunchCoreEntity.create(); + ent.set(tile); + ent.block(Blocks.coreShard); + ent.lifetime(Vars.launchDuration); + ent.add(); + } + public void playSector(Sector sector){ ui.loadAnd(() -> { ui.planet.hide(); diff --git a/core/src/mindustry/entities/comp/LaunchCoreComp.java b/core/src/mindustry/entities/comp/LaunchCoreComp.java new file mode 100644 index 0000000000..186cff2b2e --- /dev/null +++ b/core/src/mindustry/entities/comp/LaunchCoreComp.java @@ -0,0 +1,76 @@ +package mindustry.entities.comp; + +import arc.graphics.g2d.*; +import arc.math.*; +import arc.util.*; +import mindustry.annotations.Annotations.*; +import mindustry.content.*; +import mindustry.gen.*; +import mindustry.graphics.*; +import mindustry.ui.*; +import mindustry.world.*; + +@EntityDef(value = LaunchCorec.class, serialize = false) +@Component +abstract class LaunchCoreComp implements Drawc, Timedc{ + @Import float x, y; + + transient Interval in = new Interval(); + Block block; + + @Override + public void draw(){ + float alpha = fout(Interp.pow5Out); + float scale = (1f - alpha) * 1.4f + 1f; + float cx = cx(), cy = cy(); + float rotation = fin() * (140f + Mathf.randomSeedRange(id(), 50f)); + + Draw.z(Layer.effect + 0.001f); + + Draw.color(Pal.engine); + + float rad = 0.2f + fslope(); + float rscl = (block.size - 1) * 0.85f; + + Fill.light(cx, cy, 10, 25f * (rad + scale-1f) * rscl, Tmp.c2.set(Pal.engine).a(alpha), Tmp.c1.set(Pal.engine).a(0f)); + + Draw.alpha(alpha); + for(int i = 0; i < 4; i++){ + Drawf.tri(cx, cy, 6f * rscl, 40f * (rad + scale-1f) * rscl, i * 90f + rotation); + } + + Draw.color(); + + Draw.z(Layer.weather - 1); + + TextureRegion region = block.icon(Cicon.full); + float rw = region.getWidth() * Draw.scl * scale, rh = region.getHeight() * Draw.scl * scale; + + Draw.alpha(alpha); + Draw.rect(region, cx, cy, rw, rh, rotation - 45); + + Tmp.v1.trns(225f, fin(Interp.pow3In) * 250f); + + Draw.z(Layer.flyingUnit + 1); + Draw.color(0, 0, 0, 0.22f * alpha); + Draw.rect(region, cx + Tmp.v1.x, cy + Tmp.v1.y, rw, rh, rotation - 45); + + Draw.reset(); + } + + float cx(){ + return x + fin(Interp.pow2In) * (12f + Mathf.randomSeedRange(id() + 3, 4f)); + } + + float cy(){ + return y + fin(Interp.pow5In) * (100f + Mathf.randomSeedRange(id() + 2, 30f)); + } + + @Override + public void update(){ + float r = 4f; + if(in.get(3f - fin()*2f)){ + Fx.rocketSmokeLarge.at(cx() + Mathf.range(r), cy() + Mathf.range(r), fin()); + } + } +} \ No newline at end of file diff --git a/core/src/mindustry/ui/dialogs/PlanetDialog.java b/core/src/mindustry/ui/dialogs/PlanetDialog.java index eb1b5ac323..2749c6234d 100644 --- a/core/src/mindustry/ui/dialogs/PlanetDialog.java +++ b/core/src/mindustry/ui/dialogs/PlanetDialog.java @@ -22,7 +22,6 @@ import mindustry.graphics.g3d.PlanetRenderer.*; import mindustry.type.*; import mindustry.type.Sector.*; import mindustry.ui.*; -import mindustry.world.blocks.campaign.CoreLauncher.*; import static mindustry.Vars.*; import static mindustry.graphics.g3d.PlanetRenderer.*; @@ -36,7 +35,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{ private int launchRange; private float zoom = 1f, selectAlpha = 1f; private @Nullable Sector selected, hovered, launchSector; - private CoreLauncherEntity launcher; + private Tilec launcher; private Mode mode = look; public PlanetDialog(){ @@ -98,7 +97,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{ return super.show(); } - public void show(Sector sector, int range, CoreLauncherEntity launcher){ + public void show(Sector sector, int range, Tilec launcher){ this.launcher = launcher; selected = null; hovered = null; @@ -343,7 +342,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{ } if(mode == launch){ - launcher.launch(); + control.handleLaunch(launcher); zoom = 0.5f; ui.hudfrag.showLaunchDirect(); diff --git a/core/src/mindustry/ui/fragments/HudFragment.java b/core/src/mindustry/ui/fragments/HudFragment.java index 97348fa191..b03f525f22 100644 --- a/core/src/mindustry/ui/fragments/HudFragment.java +++ b/core/src/mindustry/ui/fragments/HudFragment.java @@ -24,6 +24,7 @@ import mindustry.net.Packets.*; import mindustry.type.*; import mindustry.ui.*; import mindustry.ui.dialogs.*; +import mindustry.world.blocks.storage.*; import static mindustry.Vars.*; @@ -56,6 +57,7 @@ public class HudFragment extends Fragment{ showToast("Sector[accent] captured[]!"); }); + //TODO full implementation Events.on(ResetEvent.class, e -> { coreItems.resetUsed(); }); @@ -145,7 +147,7 @@ public class HudFragment extends Fragment{ cont.row(); } - //TODO BUTTONS FOR VIEWING EXPORTS/IMPORTS/RESEARCH + //TODO BUTTONS FOR VIEWING EXPORTS/IMPORTS/RESEARCH/MAP/ETC /* cont.table(t -> { @@ -324,7 +326,7 @@ public class HudFragment extends Fragment{ p.touchable(Touchable.disabled); }); - //DEBUG: rate table + //TODO DEBUG: rate table parent.fill(t -> { t.bottom().left(); t.table(Styles.black6, c -> { @@ -355,8 +357,16 @@ public class HudFragment extends Fragment{ rebuild.run(); } }); - }); + }).visible(() -> state.isCampaign() && content.items().contains(i -> state.secinfo.getExport(i) > 0)); + }); + //TODO move, select loadout, consume resources + parent.fill(t -> { + t.bottom().visible(() -> state.isCampaign() && player.team().core() != null); + + t.button("test launch", Icon.warning, () -> { + ui.planet.show(state.getSector(), ((CoreBlock)player.team().core().block).launchRange, player.team().core()); + }).width(150f); }); blockfrag.build(parent); diff --git a/core/src/mindustry/world/blocks/campaign/CoreLauncher.java b/core/src/mindustry/world/blocks/campaign/CoreLauncher.java deleted file mode 100644 index e61624d757..0000000000 --- a/core/src/mindustry/world/blocks/campaign/CoreLauncher.java +++ /dev/null @@ -1,127 +0,0 @@ -package mindustry.world.blocks.campaign; - -import arc.Graphics.*; -import arc.Graphics.Cursor.*; -import arc.graphics.g2d.*; -import arc.math.*; -import arc.util.*; -import mindustry.*; -import mindustry.annotations.Annotations.*; -import mindustry.content.*; -import mindustry.gen.*; -import mindustry.graphics.*; -import mindustry.ui.*; -import mindustry.world.*; - -import static mindustry.Vars.*; - -public class CoreLauncher extends Block{ - public int range = 1; - - public CoreLauncher(String name){ - super(name); - - hasItems = true; - configurable = true; - update = true; - //will be enabled when needed (if at all) - //buildPlaceability = BuildPlaceability.sectorCaptured; - } - - public class CoreLauncherEntity extends TileEntity{ - - @Override - public void updateTile(){ - super.updateTile(); - } - - @Override - public boolean configTapped(){ - - if(state.isCampaign() && consValid()){ - Vars.ui.planet.show(state.rules.sector, range, this); - } - return false; - } - - @Override - public Cursor getCursor(){ - return consValid() ? SystemCursor.hand : SystemCursor.arrow; - } - - public void launch(){ - LaunchCorec ent = LaunchCoreEntity.create(); - ent.set(this); - ent.block(Blocks.coreShard); - ent.lifetime(Vars.launchDuration); - ent.add(); - - cons.trigger(); - } - } - - @EntityDef(value = LaunchCorec.class, serialize = false) - @Component - static abstract class LaunchCoreComp implements Drawc, Timedc{ - @Import float x, y; - - transient Interval in = new Interval(); - Block block; - - @Override - public void draw(){ - float alpha = fout(Interp.pow5Out); - float scale = (1f - alpha) * 1.4f + 1f; - float cx = cx(), cy = cy(); - float rotation = fin() * (140f + Mathf.randomSeedRange(id(), 50f)); - - Draw.z(Layer.effect + 0.001f); - - Draw.color(Pal.engine); - - float rad = 0.2f + fslope(); - float rscl = (block.size - 1) * 0.85f; - - Fill.light(cx, cy, 10, 25f * (rad + scale-1f) * rscl, Tmp.c2.set(Pal.engine).a(alpha), Tmp.c1.set(Pal.engine).a(0f)); - - Draw.alpha(alpha); - for(int i = 0; i < 4; i++){ - Drawf.tri(cx, cy, 6f * rscl, 40f * (rad + scale-1f) * rscl, i * 90f + rotation); - } - - Draw.color(); - - Draw.z(Layer.weather - 1); - - TextureRegion region = block.icon(Cicon.full); - float rw = region.getWidth() * Draw.scl * scale, rh = region.getHeight() * Draw.scl * scale; - - Draw.alpha(alpha); - Draw.rect(region, cx, cy, rw, rh, rotation - 45); - - Tmp.v1.trns(225f, fin(Interp.pow3In) * 250f); - - Draw.z(Layer.flyingUnit + 1); - Draw.color(0, 0, 0, 0.22f * alpha); - Draw.rect(region, cx + Tmp.v1.x, cy + Tmp.v1.y, rw, rh, rotation - 45); - - Draw.reset(); - } - - float cx(){ - return x + fin(Interp.pow2In) * (12f + Mathf.randomSeedRange(id() + 3, 4f)); - } - - float cy(){ - return y + fin(Interp.pow5In) * (100f + Mathf.randomSeedRange(id() + 2, 30f)); - } - - @Override - public void update(){ - float r = 4f; - if(in.get(3f - fin()*2f)){ - Fx.rocketSmokeLarge.at(cx() + Mathf.range(r), cy() + Mathf.range(r), fin()); - } - } - } -} diff --git a/core/src/mindustry/world/blocks/storage/CoreBlock.java b/core/src/mindustry/world/blocks/storage/CoreBlock.java index 1e0e660a24..571a09b8b2 100644 --- a/core/src/mindustry/world/blocks/storage/CoreBlock.java +++ b/core/src/mindustry/world/blocks/storage/CoreBlock.java @@ -28,6 +28,8 @@ public class CoreBlock extends StorageBlock{ public final int timerResupply = timers++; + public int launchRange = 1; + public int ammoAmount = 5; public float resupplyRate = 10f; public float resupplyRange = 60f;