From 43bff5c34d51ee9698d28d066c31f4f2f2b28f06 Mon Sep 17 00:00:00 2001 From: Anuken Date: Wed, 30 Jan 2019 19:48:41 -0500 Subject: [PATCH] Removed camera clamp / Self-destruct timer / More blend tweaks --- core/assets/bundles/bundle.properties | 1 + core/src/io/anuke/mindustry/Vars.java | 4 ++++ .../io/anuke/mindustry/content/Blocks.java | 4 ++-- .../src/io/anuke/mindustry/core/Renderer.java | 3 --- .../io/anuke/mindustry/entities/Player.java | 24 +++++++++++++++---- .../src/io/anuke/mindustry/entities/Unit.java | 18 ++++++++++++-- .../mindustry/entities/units/BaseUnit.java | 5 ++-- .../mindustry/ui/dialogs/DeployDialog.java | 6 ++--- .../mindustry/ui/fragments/HudFragment.java | 22 +++++++++++++---- .../mindustry/ui/fragments/MenuFragment.java | 2 +- .../anuke/mindustry/world/blocks/Floor.java | 8 +++---- .../mindustry/world/blocks/OreBlock.java | 1 + 12 files changed, 71 insertions(+), 27 deletions(-) diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index 515ad4d797..aa3d1478fd 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -34,6 +34,7 @@ deconstruction = You've just selected [accent]block deconstruction mode[].\n\nTo showagain = Don't show again next session coreattack = < Core is under attack! > nearpoint = [[ [scarlet]LEAVE DROP POINT IMMEDIATELY[] ]\nannihilation imminent +outofbounds = [[ OUT OF BOUNDS ]\n[]self-destruct in {0} database = Core Database savegame = Save Game loadgame = Load Game diff --git a/core/src/io/anuke/mindustry/Vars.java b/core/src/io/anuke/mindustry/Vars.java index 5164fd56ae..e21d3d414a 100644 --- a/core/src/io/anuke/mindustry/Vars.java +++ b/core/src/io/anuke/mindustry/Vars.java @@ -51,6 +51,10 @@ public class Vars{ public static final int maxNameLength = 40; /**displayed item size when ingame, TODO remove.*/ public static final float itemSize = 5f; + /**extra padding around the world; units outside this bound will begin to self-destruct.*/ + public static final float worldBounds = 100f; + /**ticks spent out of bound until self destruct.*/ + public static final float boundsCountdown = 60*7; /**size of tiles in units*/ public static final int tilesize = 8; /**all choosable player colors in join/host dialog*/ diff --git a/core/src/io/anuke/mindustry/content/Blocks.java b/core/src/io/anuke/mindustry/content/Blocks.java index e10a21e9c4..b0ee620bb0 100644 --- a/core/src/io/anuke/mindustry/content/Blocks.java +++ b/core/src/io/anuke/mindustry/content/Blocks.java @@ -153,12 +153,12 @@ public class Blocks implements ContentList{ craters = new Floor("craters"){{ minimapColor = Color.valueOf("323232"); variants = 6; - hasEdges = false; + blendGroup = stone; }}; charr = new Floor("char"){{ minimapColor = Color.valueOf("323232"); - hasEdges = false; + blendGroup = stone; }}; sandWater = new Floor("sand-water"){{ diff --git a/core/src/io/anuke/mindustry/core/Renderer.java b/core/src/io/anuke/mindustry/core/Renderer.java index 3abb7f34d6..30d6829c0a 100644 --- a/core/src/io/anuke/mindustry/core/Renderer.java +++ b/core/src/io/anuke/mindustry/core/Renderer.java @@ -126,9 +126,6 @@ public class Renderer implements ApplicationListener{ camera.position.lerpDelta(position, 0.08f); } - camera.position.x = Mathf.clamp(camera.position.x, -tilesize / 2f, world.width() * tilesize - tilesize / 2f); - camera.position.y = Mathf.clamp(camera.position.y, -tilesize / 2f, world.height() * tilesize - tilesize / 2f); - updateShake(0.75f); draw(); diff --git a/core/src/io/anuke/mindustry/entities/Player.java b/core/src/io/anuke/mindustry/entities/Player.java index 05db15938a..91ae30c9be 100644 --- a/core/src/io/anuke/mindustry/entities/Player.java +++ b/core/src/io/anuke/mindustry/entities/Player.java @@ -19,10 +19,13 @@ import io.anuke.arc.util.Interval; import io.anuke.arc.util.Pack; import io.anuke.arc.util.Time; import io.anuke.arc.util.pooling.Pools; -import io.anuke.mindustry.content.Mechs; import io.anuke.mindustry.content.Fx; +import io.anuke.mindustry.content.Mechs; import io.anuke.mindustry.entities.effect.ScorchDecal; -import io.anuke.mindustry.entities.traits.*; +import io.anuke.mindustry.entities.traits.BuilderTrait; +import io.anuke.mindustry.entities.traits.ShooterTrait; +import io.anuke.mindustry.entities.traits.SpawnerTrait; +import io.anuke.mindustry.entities.traits.TargetTrait; import io.anuke.mindustry.game.Team; import io.anuke.mindustry.gen.Call; import io.anuke.mindustry.graphics.Palette; @@ -60,7 +63,7 @@ public class Player extends Unit implements BuilderTrait, ShooterTrait{ public String name = "name"; public String uuid, usid; public boolean isAdmin, isTransferring, isShooting, isBoosting, isMobile; - public float boostHeat, shootHeat; + public float boostHeat, shootHeat, destructTime; public boolean achievedFlight; public Color color = new Color(); public Mech mech; @@ -490,6 +493,16 @@ public class Player extends Unit implements BuilderTrait, ShooterTrait{ setDead(true); } + if(!isDead() && isOutOfBounds()){ + destructTime += Time.delta(); + + if(destructTime >= boundsCountdown){ + kill(); + } + }else{ + destructTime = 0f; + } + if(isDead()){ isBoosting = false; boostHeat = 0f; @@ -545,8 +558,9 @@ public class Player extends Unit implements BuilderTrait, ShooterTrait{ updateBuilding(this); - x = Mathf.clamp(x, 0, world.width() * tilesize - tilesize); - y = Mathf.clamp(y, 0, world.height() * tilesize - tilesize); + if(!mech.flying){ + clampPosition(); + } } protected void updateMech(){ diff --git a/core/src/io/anuke/mindustry/entities/Unit.java b/core/src/io/anuke/mindustry/entities/Unit.java index 46e77684c6..782a127fa7 100644 --- a/core/src/io/anuke/mindustry/entities/Unit.java +++ b/core/src/io/anuke/mindustry/entities/Unit.java @@ -33,8 +33,8 @@ import java.io.DataInput; import java.io.DataOutput; import java.io.IOException; -import static io.anuke.mindustry.Vars.state; -import static io.anuke.mindustry.Vars.world; +import static io.anuke.mindustry.Vars.*; +import static io.anuke.mindustry.Vars.tilesize; public abstract class Unit extends DestructibleEntity implements SaveTrait, TargetTrait, SyncTrait, DrawTrait, TeamTrait, InventoryTrait{ /**Total duration of hit flash effect*/ @@ -174,6 +174,20 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ inventory.writeSave(stream); } + protected void clampPosition(){ + x = Mathf.clamp(x, tilesize, world.width() * tilesize - tilesize); + y = Mathf.clamp(y, tilesize, world.height() * tilesize - tilesize); + } + + public void kill(){ + health = -1; + damage(1); + } + + public boolean isOutOfBounds(){ + return x < worldBounds || y < worldBounds || x > world.width() * tilesize + worldBounds || y > world.height() * tilesize + worldBounds; + } + public float calculateDamage(float amount){ return amount * Mathf.clamp(1f - getArmor() / 100f * status.getArmorMultiplier()); } diff --git a/core/src/io/anuke/mindustry/entities/units/BaseUnit.java b/core/src/io/anuke/mindustry/entities/units/BaseUnit.java index 3894e22ea5..43fe065847 100644 --- a/core/src/io/anuke/mindustry/entities/units/BaseUnit.java +++ b/core/src/io/anuke/mindustry/entities/units/BaseUnit.java @@ -301,8 +301,9 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{ if(target != null) behavior(); - x = Mathf.clamp(x, tilesize, world.width() * tilesize - tilesize); - y = Mathf.clamp(y, tilesize, world.height() * tilesize - tilesize); + if(!isFlying()){ + clampPosition(); + } } @Override diff --git a/core/src/io/anuke/mindustry/ui/dialogs/DeployDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/DeployDialog.java index e16e55b705..a06768c83a 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/DeployDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/DeployDialog.java @@ -48,11 +48,9 @@ public class DeployDialog extends FloatingDialog{ } public void setup(){ - try{ - Class.forName("io.anuke.arc.recorder.GifRecorder"); - }catch(Throwable t){ + if(!System.getProperty("mindustry.debug", "false").equals("true")){ ui.showInfo("This is not ready for testing. Play custom games instead."); - hide(); + Core.app.post(this::hide); return; } diff --git a/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java b/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java index 32a4969f75..b84c8b35e5 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java @@ -17,10 +17,7 @@ import io.anuke.arc.scene.ui.layout.Stack; import io.anuke.arc.scene.ui.layout.Table; import io.anuke.arc.scene.ui.layout.Unit; import io.anuke.arc.scene.utils.Elements; -import io.anuke.arc.util.Align; -import io.anuke.arc.util.Scaling; -import io.anuke.arc.util.Time; -import io.anuke.arc.util.Tmp; +import io.anuke.arc.util.*; import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.game.EventType.StateChangeEvent; import io.anuke.mindustry.game.Team; @@ -33,6 +30,8 @@ import io.anuke.mindustry.net.Packets.AdminAction; import io.anuke.mindustry.ui.IntFormat; import io.anuke.mindustry.ui.dialogs.FloatingDialog; +import java.lang.StringBuilder; + import static io.anuke.mindustry.Vars.*; public class HudFragment extends Fragment{ @@ -154,6 +153,7 @@ public class HudFragment extends Fragment{ t.table("button", top -> top.add("$paused").pad(6f)); }); + //spawner warning parent.fill(t -> { t.touchable(Touchable.disabled); t.visible(() -> !state.is(State.menu)); @@ -165,6 +165,20 @@ public class HudFragment extends Fragment{ }).get().color.a = 0f; }); + //out of bounds warning + parent.fill(t -> { + t.touchable(Touchable.disabled); + t.visible(() -> !state.is(State.menu)); + t.table("flat", c -> c.add("") + .update(l ->{ + l.setColor(Tmp.c1.set(Color.WHITE).lerp(Color.SCARLET, Mathf.absin(Time.time(), 10f, 1f))); + l.setText(Core.bundle.format("outofbounds", (int)((boundsCountdown - players[0].destructTime) / 60f))); + }).get().setAlignment(Align.center, Align.center)) + .margin(6).update(u -> { + u.color.a = Mathf.lerpDelta(u.color.a, Mathf.num(players[0].isOutOfBounds()), 0.1f); + }).get().color.a = 0f; + }); + parent.fill(t -> { t.visible(() -> netServer.isWaitingForPlayers() && !state.is(State.menu)); t.table("button", c -> c.add("$waiting.players")); diff --git a/core/src/io/anuke/mindustry/ui/fragments/MenuFragment.java b/core/src/io/anuke/mindustry/ui/fragments/MenuFragment.java index c641aeafc8..58c4354f4c 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/MenuFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/MenuFragment.java @@ -59,7 +59,7 @@ public class MenuFragment extends Fragment{ MobileButton play = new MobileButton("icon-play-2", isize, "$play", ui.deploy::show), maps = new MobileButton("icon-map", isize, "$maps", ui.maps::show), - custom = new MobileButton("icon-play-custom", isize, "customgame", this::showCustomSelect), + custom = new MobileButton("icon-play-custom", isize, "$customgame", this::showCustomSelect), join = new MobileButton("icon-add", isize, "$joingame", ui.join::show), editor = new MobileButton("icon-editor", isize, "$editor", () -> ui.loadAnd(ui.editor::show)), tools = new MobileButton("icon-tools", isize, "$settings", ui.settings::show), diff --git a/core/src/io/anuke/mindustry/world/blocks/Floor.java b/core/src/io/anuke/mindustry/world/blocks/Floor.java index a4b3aea873..380e48a0e8 100644 --- a/core/src/io/anuke/mindustry/world/blocks/Floor.java +++ b/core/src/io/anuke/mindustry/world/blocks/Floor.java @@ -55,8 +55,8 @@ public class Floor extends Block{ public boolean playerUnmineable = false; /**Style of the edge stencil. Loaded by looking up "edge-stencil-{name}".*/ public String edgeStyle = "smooth"; - /**Whether edges are used at all.*/ - public boolean hasEdges = true; + /**Group of blocks that this block does not draw edges on.*/ + public Block blendGroup = this; protected TextureRegion[][] edges; protected byte eq = 0; @@ -83,7 +83,7 @@ public class Floor extends Block{ } int size = (int)(tilesize / Draw.scl); - if(hasEdges && Core.atlas.has(name + "-edge")){ + if(Core.atlas.has(name + "-edge")){ edges = Core.atlas.find(name + "-edge").split(size, size); } region = variantRegions[0]; @@ -135,7 +135,7 @@ public class Floor extends Block{ } protected boolean doEdge(Floor other){ - return (other.id > id || edges == null) && other.edgeOnto(this); + return (other.blendGroup.id > id || edges == null) && other.edgeOnto(this); } protected boolean edgeOnto(Floor other){ diff --git a/core/src/io/anuke/mindustry/world/blocks/OreBlock.java b/core/src/io/anuke/mindustry/world/blocks/OreBlock.java index d5a1b83cc5..42f2913de7 100644 --- a/core/src/io/anuke/mindustry/world/blocks/OreBlock.java +++ b/core/src/io/anuke/mindustry/world/blocks/OreBlock.java @@ -20,6 +20,7 @@ public class OreBlock extends Floor{ this.variants = 3; this.minimapColor = ore.color; this.edge = base.name; + this.blendGroup = base; oreBlockMap.getOr(ore, ObjectMap::new).put(base, this); }