mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-01-21 09:47:14 +07:00
Added LiquidExplodeAbility
This commit is contained in:
parent
096826a36f
commit
d13c7a959f
@ -48,8 +48,9 @@ public class Liquids implements ContentList{
|
|||||||
neoplasm = new CellLiquid("neoplasm", Color.valueOf("e05438")){{
|
neoplasm = new CellLiquid("neoplasm", Color.valueOf("e05438")){{
|
||||||
heatCapacity = 0.4f;
|
heatCapacity = 0.4f;
|
||||||
temperature = 0.54f;
|
temperature = 0.54f;
|
||||||
viscosity = 0.65f;
|
viscosity = 0.85f;
|
||||||
flammability = 0.1f;
|
flammability = 0.1f;
|
||||||
|
capPuddles = false;
|
||||||
|
|
||||||
colorFrom = Color.valueOf("f98f4a");
|
colorFrom = Color.valueOf("f98f4a");
|
||||||
colorTo = Color.valueOf("9e172c");
|
colorTo = Color.valueOf("9e172c");
|
||||||
|
@ -0,0 +1,37 @@
|
|||||||
|
package mindustry.entities.abilities;
|
||||||
|
|
||||||
|
import arc.math.*;
|
||||||
|
import arc.util.noise.*;
|
||||||
|
import mindustry.content.*;
|
||||||
|
import mindustry.entities.*;
|
||||||
|
import mindustry.gen.*;
|
||||||
|
import mindustry.type.*;
|
||||||
|
import mindustry.world.*;
|
||||||
|
|
||||||
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
|
public class LiquidExplodeAbility extends Ability{
|
||||||
|
public Liquid liquid = Liquids.water;
|
||||||
|
public float amount = 120f;
|
||||||
|
public float radAmountScale = 5f, radScale = 1f;
|
||||||
|
public float noiseMag = 6.5f, noiseScl = 5f;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void death(Unit unit){
|
||||||
|
int tx = unit.tileX(), ty = unit.tileY();
|
||||||
|
int rad = (int)(unit.hitSize / tilesize * radScale);
|
||||||
|
float realNoise = unit.hitSize / noiseMag;
|
||||||
|
for(int x = -rad; x <= rad; x++){
|
||||||
|
for(int y = -rad; y <= rad; y++){
|
||||||
|
if(x*x + y*y <= rad*rad - Simplex.noise2d(0, 2, 0.5f, 1f / noiseScl, x + tx, y + ty) * realNoise * realNoise){
|
||||||
|
float scaling = (1f - Mathf.dst(x, y) / rad) * radAmountScale;
|
||||||
|
|
||||||
|
Tile tile = world.tile(tx + x, ty + y);
|
||||||
|
if(tile != null){
|
||||||
|
Puddles.deposit(tile, liquid, amount * scaling);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -20,7 +20,6 @@ import static mindustry.entities.Puddles.*;
|
|||||||
@Component(base = true)
|
@Component(base = true)
|
||||||
abstract class PuddleComp implements Posc, Puddlec, Drawc{
|
abstract class PuddleComp implements Posc, Puddlec, Drawc{
|
||||||
private static final Rect rect = new Rect(), rect2 = new Rect();
|
private static final Rect rect = new Rect(), rect2 = new Rect();
|
||||||
private static int seeds;
|
|
||||||
|
|
||||||
private static Puddle paramPuddle;
|
private static Puddle paramPuddle;
|
||||||
private static Cons<Unit> unitCons = unit -> {
|
private static Cons<Unit> unitCons = unit -> {
|
||||||
@ -70,7 +69,9 @@ abstract class PuddleComp implements Posc, Puddlec, Drawc{
|
|||||||
amount -= deposited * targets;
|
amount -= deposited * targets;
|
||||||
}
|
}
|
||||||
|
|
||||||
amount = Mathf.clamp(amount, 0, maxLiquid);
|
if(liquid.capPuddles){
|
||||||
|
amount = Mathf.clamp(amount, 0, maxLiquid);
|
||||||
|
}
|
||||||
|
|
||||||
if(amount <= 0f){
|
if(amount <= 0f){
|
||||||
remove();
|
remove();
|
||||||
@ -108,6 +109,8 @@ abstract class PuddleComp implements Posc, Puddlec, Drawc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateTime -= Time.delta;
|
updateTime -= Time.delta;
|
||||||
|
|
||||||
|
liquid.update(self());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -35,6 +35,7 @@ public class CellLiquid extends Liquid{
|
|||||||
|
|
||||||
rand.setSeed(id);
|
rand.setSeed(id);
|
||||||
for(int i = 0; i < cells; i++){
|
for(int i = 0; i < cells; i++){
|
||||||
|
Draw.z(Layer.debris - 0.5f + i/1000f + (id % 100) / 10000f);
|
||||||
Tmp.v1.trns(rand.random(360f), rand.random(length));
|
Tmp.v1.trns(rand.random(360f), rand.random(length));
|
||||||
float vx = x + Tmp.v1.x, vy = y + Tmp.v1.y;
|
float vx = x + Tmp.v1.x, vy = y + Tmp.v1.y;
|
||||||
|
|
||||||
|
@ -43,6 +43,8 @@ public class Liquid extends UnlockableContent{
|
|||||||
public float particleSpacing = 60f;
|
public float particleSpacing = 60f;
|
||||||
/** Temperature at which this liquid vaporizes. This isn't just boiling. */
|
/** Temperature at which this liquid vaporizes. This isn't just boiling. */
|
||||||
public float boilPoint = 2f;
|
public float boilPoint = 2f;
|
||||||
|
/** If true, puddle size is capped. */
|
||||||
|
public boolean capPuddles = true;
|
||||||
/** Effect when this liquid vaporizes. */
|
/** Effect when this liquid vaporizes. */
|
||||||
public Effect vaporEffect = Fx.vapor;
|
public Effect vaporEffect = Fx.vapor;
|
||||||
|
|
||||||
@ -97,6 +99,11 @@ public class Liquid extends UnlockableContent{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Runs when puddles update. */
|
||||||
|
public void update(Puddle puddle){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setStats(){
|
public void setStats(){
|
||||||
stats.addPercent(Stat.explosiveness, explosiveness);
|
stats.addPercent(Stat.explosiveness, explosiveness);
|
||||||
|
@ -18,11 +18,14 @@ public class NeoplasmUnitType extends UnitType{
|
|||||||
percentAmount = 1f / (30f * 60f) * 100f;
|
percentAmount = 1f / (30f * 60f) * 100f;
|
||||||
}});
|
}});
|
||||||
|
|
||||||
|
abilities.add(new LiquidExplodeAbility(){{
|
||||||
|
liquid = Liquids.neoplasm;
|
||||||
|
}});
|
||||||
|
|
||||||
//green flashing is unnecessary since they always regen
|
//green flashing is unnecessary since they always regen
|
||||||
showHeal = false;
|
showHeal = false;
|
||||||
|
|
||||||
//TODO
|
//TODO
|
||||||
//- liquid regen ability
|
//- liquid regen ability
|
||||||
//- liquid/neoplasm explode ability
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user