From 35348f115011a0ee31cc62c6137cf3929731dec2 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sat, 29 Dec 2018 09:12:37 -0500 Subject: [PATCH] Re-implemented block shadows / Removed alpha drones --- .../src/io/anuke/mindustry/content/Mechs.java | 30 ------------------- .../io/anuke/mindustry/content/UnitTypes.java | 22 -------------- .../mindustry/graphics/BlockRenderer.java | 30 +++++++++++++++---- 3 files changed, 24 insertions(+), 58 deletions(-) diff --git a/core/src/io/anuke/mindustry/content/Mechs.java b/core/src/io/anuke/mindustry/content/Mechs.java index a93cf876aa..bb3f266f65 100644 --- a/core/src/io/anuke/mindustry/content/Mechs.java +++ b/core/src/io/anuke/mindustry/content/Mechs.java @@ -14,18 +14,12 @@ import io.anuke.mindustry.content.fx.UnitFx; import io.anuke.mindustry.entities.Player; import io.anuke.mindustry.entities.Units; import io.anuke.mindustry.entities.effect.Lightning; -import io.anuke.mindustry.entities.units.BaseUnit; -import io.anuke.mindustry.entities.units.types.AlphaDrone; import io.anuke.mindustry.game.ContentList; import io.anuke.mindustry.graphics.Palette; import io.anuke.mindustry.graphics.Shaders; -import io.anuke.mindustry.maps.TutorialSector; -import io.anuke.mindustry.net.Net; import io.anuke.mindustry.type.ContentType; import io.anuke.mindustry.type.Mech; -import static io.anuke.mindustry.Vars.unitGroups; - public class Mechs implements ContentList{ public static Mech alpha, delta, tau, omega, dart, javelin, trident, glaive; @@ -36,8 +30,6 @@ public class Mechs implements ContentList{ public void load(){ alpha = new Mech("alpha-mech", false){ - int maxDrones = 3; - float buildTime = 20f; { drillPower = 1; @@ -53,28 +45,6 @@ public class Mechs implements ContentList{ @Override public void updateAlt(Player player){ - if(player.isShooting && getDrones(player) < maxDrones && !TutorialSector.supressDrone()){ - player.timer.get(Player.timerAbility, buildTime); - - if(player.timer.getTime(Player.timerAbility) > buildTime/2f){ - if(!Net.client()){ - AlphaDrone drone = (AlphaDrone) UnitTypes.alphaDrone.create(player.getTeam()); - drone.leader = player; - drone.set(player.x, player.y); - drone.add(); - - Effects.effect(UnitFx.unitLand, player); - } - } - } - } - - int getDrones(Player player){ - int sum = 0; - for(BaseUnit unit : unitGroups[player.getTeam().ordinal()].all()){ - if(unit instanceof AlphaDrone && ((AlphaDrone) unit).leader == player) sum ++; - } - return sum; } }; diff --git a/core/src/io/anuke/mindustry/content/UnitTypes.java b/core/src/io/anuke/mindustry/content/UnitTypes.java index 5433e0c79d..9fcee1977e 100644 --- a/core/src/io/anuke/mindustry/content/UnitTypes.java +++ b/core/src/io/anuke/mindustry/content/UnitTypes.java @@ -1,6 +1,5 @@ package io.anuke.mindustry.content; -import io.anuke.arc.graphics.Color; import io.anuke.arc.collection.ObjectSet; import io.anuke.mindustry.entities.units.UnitType; import io.anuke.mindustry.entities.units.types.*; @@ -10,32 +9,11 @@ import io.anuke.mindustry.type.ContentType; public class UnitTypes implements ContentList{ public static UnitType spirit, phantom, - alphaDrone, wraith, ghoul, revenant, dagger, titan, fortress; @Override public void load(){ - alphaDrone = new UnitType("alpha-drone", AlphaDrone.class, AlphaDrone::new){ - { - isFlying = true; - drag = 0.005f; - speed = 0.6f; - maxVelocity = 1.7f; - range = 40f; - health = 45; - hitsize = 4f; - mass = 0.1f; - weapon = Weapons.droneBlaster; - trailColor = Color.valueOf("ffd37f"); - } - - @Override - public boolean isHidden() { - return true; - } - }; - spirit = new UnitType("spirit", Spirit.class, Spirit::new){{ weapon = Weapons.healBlasterDrone; isFlying = true; diff --git a/core/src/io/anuke/mindustry/graphics/BlockRenderer.java b/core/src/io/anuke/mindustry/graphics/BlockRenderer.java index bad18d37b4..15450f4431 100644 --- a/core/src/io/anuke/mindustry/graphics/BlockRenderer.java +++ b/core/src/io/anuke/mindustry/graphics/BlockRenderer.java @@ -9,6 +9,7 @@ import io.anuke.arc.graphics.Color; import io.anuke.arc.graphics.g2d.Draw; import io.anuke.arc.graphics.glutils.FrameBuffer; import io.anuke.arc.math.Mathf; +import io.anuke.arc.util.Tmp; import io.anuke.mindustry.content.blocks.Blocks; import io.anuke.mindustry.game.EventType.TileChangeEvent; import io.anuke.mindustry.game.EventType.WorldLoadEvent; @@ -32,6 +33,7 @@ public class BlockRenderer{ private int requestidx = 0; private int iterateidx = 0; private FrameBuffer shadows = new FrameBuffer(1, 1); + private FrameBuffer shadowWrite = new FrameBuffer(1, 1); public BlockRenderer(){ @@ -57,10 +59,10 @@ public class BlockRenderer{ public void drawShadows(){ Draw.color(0, 0, 0, 0.15f); - Draw.rect(Draw.wrap(shadows.getTexture()), + Draw.rect(Draw.wrap(shadowWrite.getTexture()), camera.position.x - camera.position.x % tilesize, camera.position.y - camera.position.y % tilesize, - shadows.getWidth(), -shadows.getHeight()); + shadowWrite.getWidth()*Draw.scl, -shadowWrite.getHeight()*Draw.scl); Draw.color(); } @@ -87,13 +89,15 @@ public class BlockRenderer{ teamChecks.clear(); requestidx = 0; - //TODO fix shadows Draw.flush(); - Draw.proj().setOrtho(Mathf.round(camera.position.x, tilesize)-shadowW/2f, Mathf.round(camera.position.y, tilesize)-shadowH/2f, - shadowW, shadowH); + Draw.proj().setOrtho( + Mathf.round(Core.camera.position.x, tilesize)-shadowW/2f*Draw.scl, + Mathf.round(Core.camera.position.y, tilesize)-shadowH/2f*Draw.scl, + shadowW*Draw.scl, shadowH*Draw.scl); if(shadows.getWidth() != shadowW || shadows.getHeight() != shadowH){ shadows.resize(shadowW, shadowH); + shadowWrite.resize(shadowW, shadowH); } shadows.begin(); @@ -137,10 +141,24 @@ public class BlockRenderer{ } } - //TODO proper shadows Draw.flush(); shadows.end(); + Tmp.tr1.set(shadows.getTexture()); + Shaders.outline.color.set(Color.BLACK); + Shaders.outline.region = Tmp.tr1; + + Draw.shader(Shaders.outline); + shadowWrite.begin(); + Core.graphics.clear(Color.CLEAR); + Draw.rect(Draw.wrap(shadows.getTexture()), + Mathf.round(Core.camera.position.x, tilesize), + Mathf.round(Core.camera.position.y, tilesize), + shadows.getTexture().getWidth() * Draw.scl, + -shadows.getTexture().getHeight() * Draw.scl); + Draw.shader(); + shadowWrite.end(); + Draw.proj(camera.projection()); Sort.instance().sort(requests.items, 0, requestidx);