From 98ec2dcf440348226f62cc8c19412d53387aab33 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sat, 7 Apr 2018 23:24:33 -0400 Subject: [PATCH] Implemented passable liquids --- core/assets/maps/trinity.mmap | Bin 198401 -> 198417 bytes core/assets/version.properties | 2 +- core/src/io/anuke/mindustry/Vars.java | 2 +- .../mindustry/content/StatusEffects.java | 6 +- .../mindustry/content/blocks/Blocks.java | 27 ++++++-- .../anuke/mindustry/content/fx/BlockFx.java | 18 +++++ .../anuke/mindustry/content/fx/ShootFx.java | 8 +-- core/src/io/anuke/mindustry/core/Control.java | 2 +- .../src/io/anuke/mindustry/core/Renderer.java | 25 ++++--- .../io/anuke/mindustry/entities/Player.java | 46 ++++++++----- .../src/io/anuke/mindustry/entities/Unit.java | 57 ++++++++++++++++ .../entities/effect/GroundEffectEntity.java | 64 ++++++++++++++++++ .../entities/effect/StaticEffectEntity.java | 45 ------------ .../entities/units/GroundUnitType.java | 15 ++++ .../mindustry/entities/units/UnitType.java | 11 +-- .../ui/dialogs/SettingsMenuDialog.java | 4 ++ .../mindustry/world/blocks/types/Floor.java | 25 +++++++ .../blocks/types/distribution/Teleporter.java | 2 + 18 files changed, 265 insertions(+), 94 deletions(-) create mode 100644 core/src/io/anuke/mindustry/entities/effect/GroundEffectEntity.java delete mode 100644 core/src/io/anuke/mindustry/entities/effect/StaticEffectEntity.java diff --git a/core/assets/maps/trinity.mmap b/core/assets/maps/trinity.mmap index de1d8eeb07a9e070681a90dd84d52b8f67f65102..42ee699faab5a71d0a169d0a0538a888e7844fd6 100644 GIT binary patch literal 198417 zcmeI52Ychj5r)UHbSF{mY^T`iae8rjuTFKE<5VY3heSvRA6N{MSJHla23T-7TwqaD zC}8>JLFC!p!D8pdyC9^K&qV3}{>T4+I*1Z_igsty;L(`gM*FAn+uPmv&9CM>}!wFra;UdJ@Gn;B)7b zaYzR=IE{m|2c~sMJ5e$j(-CKf!H|w==WG(hbV7UcXdaBC#fa|F-TD1Vl7`RF&M@M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G_<0uX=z1Rwwb z2tWV=5P$##AOHafKmY;|fB*y_009U<00Izz00bbA7=aW0x2zXOV(Vf#5NIV}^0Nh6 zSy7M}fk1w1CbmqL0|7_C4BsRG8U)fHu!-%pHEArLRU9mVTC2BB9xOc;-fIHedfrgq zYYt5Q&pe- z;MWAFTQf;wEGiiSPX6Gl+UvV*u~}VPV7>0iZ_Q*_v5@o#sHOJ&x1d&U-36w!?T8?- z0=ETt1xint#8%{tRr58lPXQO3@J@1bTZ2G*Yx*@7Cq|6rBtyUyt@Yn|ZeOj~Wz2a$ z@N4`y8DcCXB?6|Xz4-(m0aj2AeC=Iat+7l>&{#_{1kBH>|MrPsHPyi10@dCilMFN# zk_-WRZU>KjzZqz}OEVd6EF=K}!PDD50@QHxUxQtQub!I#HK+F8t&azYdzIJNRL1usx?jfAn-l6Vi#CfkWUX9D@ut#psO|m=dEdmTTneW$fN{{wWLZQkk;P< z)@9E7f%V3MREe>!^a#Wpc6ncWiXIi=tG8`|+FqAT zo(u~-Z~`&;4;%~2hX4d1009U<00Izz00bZa0SG_<0uX=z1Rwwb2tWV=5P$##AOHaf pKmY;|fB*y_009U<00Izz00bZa0SG_<0uX=z1Rwwb2<%AU{{axR_gDY` diff --git a/core/assets/version.properties b/core/assets/version.properties index 41330a4b25..4c1bea5b90 100644 --- a/core/assets/version.properties +++ b/core/assets/version.properties @@ -1,5 +1,5 @@ #Autogenerated file. Do not modify. -#Sat Apr 07 20:46:33 EDT 2018 +#Sat Apr 07 23:21:47 EDT 2018 version=release androidBuildCode=870 name=Mindustry diff --git a/core/src/io/anuke/mindustry/Vars.java b/core/src/io/anuke/mindustry/Vars.java index d5a5636cdf..b392e0acb2 100644 --- a/core/src/io/anuke/mindustry/Vars.java +++ b/core/src/io/anuke/mindustry/Vars.java @@ -144,7 +144,7 @@ public class Vars{ public static final EntityGroup bulletGroup = Entities.addGroup(Bullet.class); public static final EntityGroup shieldGroup = Entities.addGroup(Shield.class, false); public static final EntityGroup effectGroup = Entities.addGroup(EffectEntity.class, false); - public static final EntityGroup staticEffectGroup = Entities.addGroup(EffectEntity.class, false); + public static final EntityGroup groundEffectGroup = Entities.addGroup(EffectEntity.class, false); public static final EntityGroup[] unitGroups = new EntityGroup[Team.values().length]; static{ diff --git a/core/src/io/anuke/mindustry/content/StatusEffects.java b/core/src/io/anuke/mindustry/content/StatusEffects.java index 40864ec971..11c969d972 100644 --- a/core/src/io/anuke/mindustry/content/StatusEffects.java +++ b/core/src/io/anuke/mindustry/content/StatusEffects.java @@ -21,7 +21,7 @@ public class StatusEffects { @Override public TransitionResult getTransition(Unit unit, StatusEffect to, float time, float newTime, TransitionResult result){ if(to == oiled){ - unit.damage(1f, false); + unit.damage(1f); Effects.effect(EnvironmentFx.burning, unit.x + Mathf.range(unit.getSize()/2f), unit.y + Mathf.range(unit.getSize()/2f)); return result.set(this, Math.min(time + newTime, baseDuration + oiled.baseDuration)); } @@ -31,7 +31,7 @@ public class StatusEffects { @Override public void update(Unit unit, float time){ - unit.damage(0.04f * Timers.delta(), false); + unit.damagePeriodic(0.04f); if(Mathf.chance(Timers.delta() * 0.2f)){ Effects.effect(EnvironmentFx.burning, unit.x + Mathf.range(unit.getSize()/2f), unit.y + Mathf.range(unit.getSize()/2f)); @@ -87,7 +87,7 @@ public class StatusEffects { @Override public void update(Unit unit, float time){ unit.velocity.scl(0.8f); - unit.damage(0.1f * Timers.delta(), false); + unit.damagePeriodic(0.1f); if(Mathf.chance(Timers.delta() * 0.2f)){ Effects.effect(EnvironmentFx.melting, unit.x + Mathf.range(unit.getSize()/2f), unit.y + Mathf.range(unit.getSize()/2f)); diff --git a/core/src/io/anuke/mindustry/content/blocks/Blocks.java b/core/src/io/anuke/mindustry/content/blocks/Blocks.java index 395f971a4d..7217d98d08 100644 --- a/core/src/io/anuke/mindustry/content/blocks/Blocks.java +++ b/core/src/io/anuke/mindustry/content/blocks/Blocks.java @@ -1,7 +1,9 @@ package io.anuke.mindustry.content.blocks; +import com.badlogic.gdx.graphics.Color; import io.anuke.mindustry.content.Items; import io.anuke.mindustry.content.Liquids; +import io.anuke.mindustry.content.StatusEffects; import io.anuke.mindustry.graphics.DrawLayer; import io.anuke.mindustry.resource.ItemStack; import io.anuke.mindustry.world.Block; @@ -21,6 +23,9 @@ public class Blocks { blockpart = new BlockPart(), + defaultFloor = new Floor("defaultfloor") {{ + }}, + space = new Floor("space") {{ variants = 0; drawLayer = DrawLayer.space; @@ -32,32 +37,46 @@ public class Blocks { }}, deepwater = new Floor("deepwater") {{ + liquidColor = Color.valueOf("546bb3"); + speedMultiplier = 0.3f; variants = 0; - solid = true; liquidDrop = Liquids.water; liquid = true; + status = StatusEffects.wet; + statusIntensity = 1f; + drownTime = 140f; drawLayer = DrawLayer.water; }}, water = new Floor("water") {{ + liquidColor = Color.valueOf("546bb3"); + speedMultiplier = 0.5f; variants = 0; - solid = true; + status = StatusEffects.wet; + statusIntensity = 0.9f; liquidDrop = Liquids.water; liquid = true; drawLayer = DrawLayer.water; }}, lava = new Floor("lava") {{ + liquidColor = Color.valueOf("ed5334"); + speedMultiplier = 0.2f; + damageTaken = 0.1f; + status = StatusEffects.melting; + statusIntensity = 0.8f; variants = 0; - solid = true; liquidDrop = Liquids.lava; liquid = true; drawLayer = DrawLayer.lava; }}, oil = new Floor("oil") {{ + liquidColor = Color.valueOf("292929"); + status = StatusEffects.oiled; + statusIntensity = 1f; + speedMultiplier = 0.2f; variants = 0; - solid = true; liquidDrop = Liquids.oil; liquid = true; drawLayer = DrawLayer.oil; diff --git a/core/src/io/anuke/mindustry/content/fx/BlockFx.java b/core/src/io/anuke/mindustry/content/fx/BlockFx.java index 42a6e22d51..b516138ee0 100644 --- a/core/src/io/anuke/mindustry/content/fx/BlockFx.java +++ b/core/src/io/anuke/mindustry/content/fx/BlockFx.java @@ -2,13 +2,16 @@ package io.anuke.mindustry.content.fx; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Colors; +import io.anuke.mindustry.entities.effect.GroundEffectEntity.GroundEffect; import io.anuke.mindustry.graphics.Palette; import io.anuke.ucore.core.Effects.Effect; import io.anuke.ucore.graphics.Draw; import io.anuke.ucore.graphics.Fill; +import io.anuke.ucore.graphics.Hue; import io.anuke.ucore.graphics.Lines; import io.anuke.ucore.util.Angles; import io.anuke.ucore.util.Mathf; +import io.anuke.ucore.util.Tmp; import static io.anuke.mindustry.Vars.tilesize; @@ -251,6 +254,21 @@ public class BlockFx { Lines.lineAngle(e.x + x, e.y + y, Mathf.atan2(x, y), e.fslope()*4f + 1f); }); + Draw.reset(); + }), + ripple = new GroundEffect(false, 30, e -> { + Draw.color(Hue.shift(Tmp.c1.set(e.color), 2, 0.1f)); + Lines.stroke(e.fout() + 0.4f); + Lines.circle(e.x, e.y, 2f + e.fin()*4f); + Draw.reset(); + }), + + bubble = new Effect(20, e -> { + Draw.color(Hue.shift(Tmp.c1.set(e.color), 2, 0.1f)); + Lines.stroke(e.fout() + 0.2f); + Angles.randLenVectors(e.id, 3, 11f, (x, y) -> { + Lines.circle(e.x + x, e.y + y, 1f + e.fin() * 3f); + }); Draw.reset(); }); } diff --git a/core/src/io/anuke/mindustry/content/fx/ShootFx.java b/core/src/io/anuke/mindustry/content/fx/ShootFx.java index 8d8f7b3ada..cf30c3155f 100644 --- a/core/src/io/anuke/mindustry/content/fx/ShootFx.java +++ b/core/src/io/anuke/mindustry/content/fx/ShootFx.java @@ -1,7 +1,7 @@ package io.anuke.mindustry.content.fx; import com.badlogic.gdx.graphics.Color; -import io.anuke.mindustry.entities.effect.StaticEffectEntity.StaticEffect; +import io.anuke.mindustry.entities.effect.GroundEffectEntity.GroundEffect; import io.anuke.mindustry.graphics.Palette; import io.anuke.ucore.core.Effects.Effect; import io.anuke.ucore.graphics.Draw; @@ -88,7 +88,7 @@ public class ShootFx { Draw.reset(); }), - shellEjectSmall = new StaticEffect(30f, 400f, e -> { + shellEjectSmall = new GroundEffect(30f, 400f, e -> { Draw.color(Palette.lightOrange, Color.LIGHT_GRAY, Palette.lightishGray, e.fin()); float rot = e.rotation + 90f; for(int i : Mathf.signs){ @@ -103,7 +103,7 @@ public class ShootFx { Draw.color(); }), - shellEjectMedium = new StaticEffect(34f, 400f, e -> { + shellEjectMedium = new GroundEffect(34f, 400f, e -> { Draw.color(Palette.lightOrange, Color.LIGHT_GRAY, Palette.lightishGray, e.fin()); float rot = e.rotation + 90f; for(int i : Mathf.signs){ @@ -126,7 +126,7 @@ public class ShootFx { Draw.color(); }), - shellEjectBig = new StaticEffect(22f, 400f, e -> { + shellEjectBig = new GroundEffect(22f, 400f, e -> { Draw.color(Palette.lightOrange, Color.LIGHT_GRAY, Palette.lightishGray, e.fin()); float rot = e.rotation + 90f; for(int i : Mathf.signs){ diff --git a/core/src/io/anuke/mindustry/core/Control.java b/core/src/io/anuke/mindustry/core/Control.java index dfc02d5fbf..ec1fcb6ecc 100644 --- a/core/src/io/anuke/mindustry/core/Control.java +++ b/core/src/io/anuke/mindustry/core/Control.java @@ -352,7 +352,7 @@ public class Control extends Module{ if(!state.is(State.paused) || Net.active()){ Entities.update(effectGroup); - Entities.update(staticEffectGroup); + Entities.update(groundEffectGroup); if(respawntime > 0){ diff --git a/core/src/io/anuke/mindustry/core/Renderer.java b/core/src/io/anuke/mindustry/core/Renderer.java index 220bff8dab..c931547458 100644 --- a/core/src/io/anuke/mindustry/core/Renderer.java +++ b/core/src/io/anuke/mindustry/core/Renderer.java @@ -13,11 +13,12 @@ import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.FloatArray; import com.badlogic.gdx.utils.Pools; import io.anuke.mindustry.content.blocks.Blocks; +import io.anuke.mindustry.content.fx.Fx; import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.entities.Player; import io.anuke.mindustry.entities.SyncEntity; -import io.anuke.mindustry.entities.effect.StaticEffectEntity; -import io.anuke.mindustry.entities.effect.StaticEffectEntity.StaticEffect; +import io.anuke.mindustry.entities.effect.GroundEffectEntity; +import io.anuke.mindustry.entities.effect.GroundEffectEntity.GroundEffect; import io.anuke.mindustry.entities.units.BaseUnit; import io.anuke.mindustry.game.Team; import io.anuke.mindustry.graphics.BlockRenderer; @@ -60,17 +61,25 @@ public class Renderer extends RendererModule{ Lines.setCircleVertices(14); Core.cameraScale = baseCameraScale; - Effects.setEffectProvider((name, color, x, y, rotation) -> { + Effects.setEffectProvider((effect, color, x, y, rotation) -> { + if(effect == Fx.none) return; if(Settings.getBool("effects")){ Rectangle view = rect.setSize(camera.viewportWidth, camera.viewportHeight) .setCenter(camera.position.x, camera.position.y); - Rectangle pos = rect2.setSize(name.size).setCenter(x, y); + Rectangle pos = rect2.setSize(effect.size).setCenter(x, y); if(view.overlaps(pos)){ - int id = new EffectEntity(name, color, rotation).set(x, y).add(effectGroup).id; + int id = 0; - if(name instanceof StaticEffect){ - new StaticEffectEntity((StaticEffect) name, color, rotation).set(x, y).add(staticEffectGroup).id = id; + if(!(effect instanceof GroundEffect) || ((GroundEffect)effect).isStatic) { + id = new EffectEntity(effect, color, rotation).set(x, y).add(effectGroup).id; + } + + if(effect instanceof GroundEffect){ + GroundEffectEntity r = new GroundEffectEntity((GroundEffect) effect, color, rotation).set(x, y).add(groundEffectGroup); + if(((GroundEffect)effect).isStatic){ + r.id = id; + } } } } @@ -191,7 +200,7 @@ public class Renderer extends RendererModule{ blocks.drawFloor(); - Entities.draw(staticEffectGroup); + Entities.draw(groundEffectGroup); blocks.processBlocks(); blocks.drawBlocks(Layer.overlay); diff --git a/core/src/io/anuke/mindustry/entities/Player.java b/core/src/io/anuke/mindustry/entities/Player.java index 9beb6219b4..fe77f5d745 100644 --- a/core/src/io/anuke/mindustry/entities/Player.java +++ b/core/src/io/anuke/mindustry/entities/Player.java @@ -4,16 +4,16 @@ import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.math.Vector2; import io.anuke.mindustry.content.Mechs; import io.anuke.mindustry.content.Weapons; -import io.anuke.mindustry.content.blocks.Blocks; -import io.anuke.mindustry.game.Team; import io.anuke.mindustry.content.fx.ExplosionFx; import io.anuke.mindustry.content.fx.Fx; +import io.anuke.mindustry.game.Team; import io.anuke.mindustry.net.Net; import io.anuke.mindustry.net.NetEvents; import io.anuke.mindustry.resource.Mech; import io.anuke.mindustry.resource.Upgrade; import io.anuke.mindustry.resource.Weapon; import io.anuke.mindustry.world.Tile; +import io.anuke.mindustry.world.blocks.types.Floor; import io.anuke.ucore.core.Effects; import io.anuke.ucore.core.Inputs; import io.anuke.ucore.core.Settings; @@ -77,7 +77,7 @@ public class Player extends Unit{ @Override public boolean isFlying(){ - return mech.flying; + return mech.flying || noclip; } @Override @@ -87,13 +87,14 @@ public class Player extends Unit{ @Override public void damage(float amount){ - if(debug || mech.flying) return; + //if(debug || mech.flying) return; hitTime = hitDuration; - - health -= amount; - if(health <= 0 && !dead && isLocal){ //remote players don't die normally - onDeath(); - dead = true; + if(!debug) { + health -= amount; + if(health <= 0 && !dead && isLocal){ //remote players don't die normally + onDeath(); + dead = true; + } } } @@ -105,6 +106,7 @@ public class Player extends Unit{ @Override public void onDeath(){ dead = true; + drownTime = 0f; if(Net.active()){ NetEvents.handleUnitDeath(this); } @@ -148,9 +150,16 @@ public class Player extends Unit{ float ft = Mathf.sin(walktime, 6f, 2f); + Floor floor = getFloorOn(); + + Draw.color(); Draw.alpha(hitTime / hitDuration); if(!mech.flying) { + if(floor.liquid){ + Draw.tint(Color.WHITE, floor.liquidColor, 0.5f); + } + for (int i : Mathf.signs) { tr.trns(baseRotation, ft * i); Draw.rect(mname + "-leg", x + tr.x, y + tr.y, 12f * i, 12f - Mathf.clamp(ft * i, 0, 2), baseRotation - 90); @@ -159,6 +168,12 @@ public class Player extends Unit{ Draw.rect(mname + "-base", x, y,baseRotation- 90); } + if(floor.liquid) { + Draw.tint(Color.WHITE, floor.liquidColor, drownTime * 0.4f); + }else { + Draw.tint(Color.WHITE); + } + Draw.rect(mname, x, y, rotation -90); for (int i : Mathf.signs) { @@ -202,7 +217,7 @@ public class Player extends Unit{ Tile tile = world.tileWorld(x, y); //if player is in solid block - if(tile != null && ((tile.floor().liquid && tile.block() == Blocks.air) || tile.solid())){ + if(tile != null && tile.solid()){ stucktime += Timers.delta(); }else{ stucktime = 0f; @@ -248,15 +263,12 @@ public class Player extends Unit{ movement.limit(speed); - if(!noclip){ - move(movement.x*Timers.delta(), movement.y*Timers.delta()); - }else{ - x += movement.x*Timers.delta(); - y += movement.y*Timers.delta(); - } + velocity.add(movement); + + updateVelocity(0.4f, speed); if(!movement.isZero()){ - walktime += Timers.delta(); + walktime += Timers.delta() * velocity.len()*(1f/0.5f)/speed * getFloorOn().speedMultiplier; baseRotation = Mathf.slerpDelta(baseRotation, movement.angle(), 0.13f); } diff --git a/core/src/io/anuke/mindustry/entities/Unit.java b/core/src/io/anuke/mindustry/entities/Unit.java index d4805fb02b..fef9506e29 100644 --- a/core/src/io/anuke/mindustry/entities/Unit.java +++ b/core/src/io/anuke/mindustry/entities/Unit.java @@ -1,10 +1,17 @@ package io.anuke.mindustry.entities; import com.badlogic.gdx.math.Vector2; +import io.anuke.mindustry.content.blocks.Blocks; import io.anuke.mindustry.game.Team; +import io.anuke.mindustry.world.Tile; +import io.anuke.mindustry.world.blocks.types.Floor; +import io.anuke.ucore.core.Effects; +import io.anuke.ucore.core.Timers; import io.anuke.ucore.entities.SolidEntity; +import io.anuke.ucore.util.Mathf; import static io.anuke.mindustry.Vars.state; +import static io.anuke.mindustry.Vars.world; public abstract class Unit extends SyncEntity { //total duration of hit effect @@ -14,6 +21,7 @@ public abstract class Unit extends SyncEntity { public Team team = Team.blue; public Vector2 velocity = new Vector2(); public float hitTime; + public float drownTime; @Override public void damage(float amount){ @@ -26,6 +34,55 @@ public abstract class Unit extends SyncEntity { return other instanceof Bullet && state.teams.areEnemies((((Bullet) other).team), team); } + public Floor getFloorOn(){ + Tile tile = world.tileWorld(x, y); + return (Floor)(tile == null || (!(tile.floor() instanceof Floor)) ? Blocks.defaultFloor : tile.floor()); + } + + public void updateVelocity(float drag, float maxVelocity){ + Floor floor = getFloorOn(); + + velocity.limit(maxVelocity); + + if(isFlying()) { + x += velocity.x / getMass(); + y += velocity.y / getMass(); + }else{ + if(floor.liquid && velocity.len() > 0.4f && Timers.get(this, "flooreffect", 14 - (velocity.len() * floor.speedMultiplier)*2f)){ + Effects.effect(floor.walkEffect, floor.liquidColor, x, y); + } + + status.handleApply(this, floor.status, floor.statusIntensity); + + if(floor.damageTaken > 0f){ + damagePeriodic(floor.damageTaken); + } + + if(floor.drownTime > 0){ + drownTime += Timers.delta() * 1f/floor.drownTime; + if(Timers.get(this, "drowneffect", 15)){ + Effects.effect(floor.drownUpdateEffect, floor.liquidColor, x, y); + } + }else{ + drownTime = Mathf.lerpDelta(drownTime, 0f, 0.03f); + } + + drownTime = Mathf.clamp(drownTime); + + if(drownTime >= 1f){ + damage(health + 1, false); + } + + move(velocity.x / getMass() * floor.speedMultiplier, velocity.y / getMass() * floor.speedMultiplier); + } + + velocity.scl(Mathf.clamp(1f-drag* floor.dragMultiplier* Timers.delta())); + } + + public void damagePeriodic(float amount){ + damage(amount * Timers.delta(), Timers.get(this, "damageeffect", 20)); + } + public void damage(float amount, boolean withEffect){ if(withEffect){ damage(amount); diff --git a/core/src/io/anuke/mindustry/entities/effect/GroundEffectEntity.java b/core/src/io/anuke/mindustry/entities/effect/GroundEffectEntity.java new file mode 100644 index 0000000000..109bb2a2eb --- /dev/null +++ b/core/src/io/anuke/mindustry/entities/effect/GroundEffectEntity.java @@ -0,0 +1,64 @@ +package io.anuke.mindustry.entities.effect; + +import com.badlogic.gdx.graphics.Color; +import io.anuke.ucore.core.Effects; +import io.anuke.ucore.core.Effects.Effect; +import io.anuke.ucore.core.Timers; +import io.anuke.ucore.entities.EffectEntity; +import io.anuke.ucore.function.EffectRenderer; +import io.anuke.ucore.util.Mathf; + +public class GroundEffectEntity extends EffectEntity { + private boolean once; + + public GroundEffectEntity(GroundEffect effect, Color color, float rotation) { + super(effect, color, rotation); + } + + @Override + public void update(){ + GroundEffect effect = (GroundEffect)renderer; + + if(effect.isStatic) { + time += Timers.delta(); + + time = Mathf.clamp(time, 0, effect.staticLife); + + if (!once && time >= lifetime) { + once = true; + time = 0f; + } else if (once && time >= effect.staticLife) { + remove(); + } + }else{ + super.update(); + } + } + + @Override + public void drawOver(){ + GroundEffect effect = (GroundEffect)renderer; + + if(once && effect.isStatic) + Effects.renderEffect(id, renderer, color, lifetime, rotation, x, y); + else if(!effect.isStatic) + Effects.renderEffect(id, renderer, color, time, rotation, x, y); + } + + public static class GroundEffect extends Effect{ + public final float staticLife; + public final boolean isStatic; + + public GroundEffect(float life, float staticLife, EffectRenderer draw) { + super(life, draw); + this.staticLife = staticLife; + this.isStatic = false; + } + + public GroundEffect(boolean isStatic, float life, EffectRenderer draw) { + super(life, draw); + this.staticLife = 0f; + this.isStatic = isStatic; + } + } +} diff --git a/core/src/io/anuke/mindustry/entities/effect/StaticEffectEntity.java b/core/src/io/anuke/mindustry/entities/effect/StaticEffectEntity.java deleted file mode 100644 index 6539f9a59c..0000000000 --- a/core/src/io/anuke/mindustry/entities/effect/StaticEffectEntity.java +++ /dev/null @@ -1,45 +0,0 @@ -package io.anuke.mindustry.entities.effect; - -import com.badlogic.gdx.graphics.Color; -import io.anuke.ucore.core.Effects; -import io.anuke.ucore.core.Effects.Effect; -import io.anuke.ucore.core.Timers; -import io.anuke.ucore.entities.EffectEntity; -import io.anuke.ucore.function.EffectRenderer; -import io.anuke.ucore.util.Mathf; - -public class StaticEffectEntity extends EffectEntity { - private boolean once; - - public StaticEffectEntity(StaticEffect effect, Color color, float rotation) { - super(effect, color, rotation); - } - - @Override - public void update(){ - time += Timers.delta(); - - time = Mathf.clamp(time, 0, ((StaticEffect)renderer).staticLife); - - if(!once && time >= lifetime){ - once = true; - time = 0f; - }else if(once && time >= ((StaticEffect)renderer).staticLife){ - remove(); - } - } - - @Override - public void drawOver(){ - if(once) Effects.renderEffect(id, renderer, color, lifetime, rotation, x, y); - } - - public static class StaticEffect extends Effect{ - public final float staticLife; - - public StaticEffect(float life, float staticLife, EffectRenderer draw) { - super(life, draw); - this.staticLife = staticLife; - } - } -} diff --git a/core/src/io/anuke/mindustry/entities/units/GroundUnitType.java b/core/src/io/anuke/mindustry/entities/units/GroundUnitType.java index d25d03c0cc..d04160851f 100644 --- a/core/src/io/anuke/mindustry/entities/units/GroundUnitType.java +++ b/core/src/io/anuke/mindustry/entities/units/GroundUnitType.java @@ -1,13 +1,16 @@ package io.anuke.mindustry.entities.units; +import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.utils.ObjectSet; import io.anuke.mindustry.entities.Unit; import io.anuke.mindustry.entities.Units; import io.anuke.mindustry.game.TeamInfo.TeamData; import io.anuke.mindustry.world.Tile; +import io.anuke.mindustry.world.blocks.types.Floor; import io.anuke.ucore.core.Timers; import io.anuke.ucore.graphics.Draw; +import io.anuke.ucore.graphics.Hue; import io.anuke.ucore.util.Mathf; import io.anuke.ucore.util.Translator; @@ -42,11 +45,23 @@ public abstract class GroundUnitType extends UnitType{ float ft = Mathf.sin(walktime, 6f, 2f); + Floor floor = unit.getFloorOn(); + + if(floor.liquid){ + Draw.tint(Hue.mix(Color.WHITE, floor.liquidColor, 0.5f)); + } + for (int i : Mathf.signs) { tr1.trns(unit.baseRotation, ft * i); Draw.rect(name + "-leg", unit.x + tr1.x, unit.y + tr1.y, 12f * i, 12f - Mathf.clamp(ft * i, 0, 2), unit.baseRotation - 90); } + if(floor.liquid) { + Draw.tint(Color.WHITE, floor.liquidColor, unit.drownTime * 0.4f); + }else { + Draw.tint(Color.WHITE); + } + Draw.rect(name + "-base", unit.x, unit.y, unit.baseRotation- 90); Draw.rect(name, unit.x, unit.y, unit.rotation -90); diff --git a/core/src/io/anuke/mindustry/entities/units/UnitType.java b/core/src/io/anuke/mindustry/entities/units/UnitType.java index a4c355ff62..beab516389 100644 --- a/core/src/io/anuke/mindustry/entities/units/UnitType.java +++ b/core/src/io/anuke/mindustry/entities/units/UnitType.java @@ -76,16 +76,7 @@ public abstract class UnitType { unit.status.update(unit); - unit.velocity.limit(maxVelocity); - - if(isFlying) { - unit.x += unit.velocity.x / mass; - unit.y += unit.velocity.y / mass; - }else{ - unit.move(unit.velocity.x / mass, unit.velocity.y / mass); - } - - unit.velocity.scl(Mathf.clamp(1f-drag* Timers.delta())); + unit.updateVelocity(drag, maxVelocity); if(unit.target != null) behavior(unit); diff --git a/core/src/io/anuke/mindustry/ui/dialogs/SettingsMenuDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/SettingsMenuDialog.java index 9e96043e84..286e24f72e 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/SettingsMenuDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/SettingsMenuDialog.java @@ -145,9 +145,13 @@ public class SettingsMenuDialog extends SettingsDialog{ renderer.pixelSurface.setScale(Core.cameraScale); renderer.shadowSurface.setScale(Core.cameraScale); renderer.shieldSurface.setScale(Core.cameraScale); + //Graphics.getEffects1().setScale(Core.cameraScale); + //Graphics.getEffects2().setScale(Core.cameraScale); }else{ renderer.shadowSurface.setScale(1); renderer.shieldSurface.setScale(1); + //Graphics.getEffects1().setScale(1); + //Graphics.getEffects2().setScale(1); } renderer.setPixelate(b); }); diff --git a/core/src/io/anuke/mindustry/world/blocks/types/Floor.java b/core/src/io/anuke/mindustry/world/blocks/types/Floor.java index 5a75611207..4d0326f2dc 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/Floor.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/Floor.java @@ -1,9 +1,14 @@ package io.anuke.mindustry.world.blocks.types; +import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.math.MathUtils; +import io.anuke.mindustry.content.StatusEffects; +import io.anuke.mindustry.content.fx.BlockFx; +import io.anuke.mindustry.entities.StatusEffect; import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Tile; +import io.anuke.ucore.core.Effects.Effect; import io.anuke.ucore.function.Predicate; import io.anuke.ucore.graphics.Draw; import io.anuke.ucore.util.Mathf; @@ -14,12 +19,32 @@ public class Floor extends Block{ protected TextureRegion tempRegion = new TextureRegion(); protected Predicate blends = block -> block != this; protected boolean blend = true; + + public float speedMultiplier = 1f; + public float dragMultiplier = 1f; + public float damageTaken = 0f; + public float drownTime = 0f; + public Effect walkEffect = BlockFx.ripple; + public Effect drownUpdateEffect = BlockFx.bubble; + public StatusEffect status = StatusEffects.none; + public float statusIntensity = 0.6f; + public Color liquidColor; public Floor(String name) { super(name); variants = 3; } + @Override + public void init(){ + super.init(); + + if(liquid && liquidColor == null){ + throw new RuntimeException("All liquids must define a liquidColor! Problematic block: " + name); + } + } + + @Override public void drawNonLayer(Tile tile){ MathUtils.random.setSeed(tile.id()); diff --git a/core/src/io/anuke/mindustry/world/blocks/types/distribution/Teleporter.java b/core/src/io/anuke/mindustry/world/blocks/types/distribution/Teleporter.java index faac36d7ee..9194539cc3 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/distribution/Teleporter.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/distribution/Teleporter.java @@ -166,6 +166,8 @@ public class Teleporter extends PowerBlock{ catastrophicFailure(tile); } + //TODO draw warning info! + if (entity.teleporting) { entity.speedScl = Mathf.lerpDelta(entity.speedScl, 2f, 0.01f); float liquidUsed = Math.min(liquidCapacity, liquidUse * Timers.delta());