Cryofluid floor tweaks

This commit is contained in:
Anuken
2021-09-27 15:07:10 -04:00
12 changed files with 462 additions and 16 deletions

View File

@@ -35,7 +35,7 @@ public class Blocks implements ContentList{
public static Block
//environment
air, spawn, cliff, deepwater, water, taintedWater, deepTaintedWater, tar, slag, stone, craters, charr, sand, darksand, dirt, mud, ice, snow, darksandTaintedWater, space,
air, spawn, cliff, deepwater, water, taintedWater, deepTaintedWater, tar, slag, cryofluid, stone, craters, charr, sand, darksand, dirt, mud, ice, snow, darksandTaintedWater, space,
dacite,
stoneWall, dirtWall, sporeWall, iceWall, daciteWall, sporePine, snowPine, pine, shrubs, whiteTree, whiteTreeDead, sporeCluster,
iceSnow, sandWater, darksandWater, duneWall, sandWall, moss, sporeMoss, shale, shaleWall, shaleBoulder, sandBoulder, daciteBoulder, boulder, snowBoulder, basaltBoulder, grass, salt,
@@ -196,6 +196,22 @@ public class Blocks implements ContentList{
cacheLayer = CacheLayer.tar;
}};
cryofluid = new Floor("pooled-cryofluid"){{
drownTime = 150f;
status = StatusEffects.freezing;
statusDuration = 240f;
speedMultiplier = 0.5f;
variants = 0;
liquidDrop = Liquids.cryofluid;
liquidMultiplier = 0.5f;
isLiquid = true;
cacheLayer = CacheLayer.cryofluid;
emitLight = true;
lightRadius = 25f;
lightColor = Color.cyan.cpy().a(0.19f);
}};
slag = new Floor("molten-slag"){{
drownTime = 150f;
status = StatusEffects.melting;

View File

@@ -362,13 +362,13 @@ public class Fx{
Fill.circle(e.x, e.y, e.fin() * 10);
Drawf.light(e.x, e.y, e.fin() * 20f, Pal.heal, 0.7f);
}).followParent(true),
}).followParent(true).rotWithParent(true),
greenLaserChargeSmall = new Effect(40f, 100f, e -> {
color(Pal.heal);
stroke(e.fin() * 2f);
Lines.circle(e.x, e.y, e.fout() * 50f);
}).followParent(true),
}).followParent(true).rotWithParent(true),
greenCloud = new Effect(80f, e -> {
color(Pal.heal);
@@ -1943,7 +1943,7 @@ public class Fx{
}
Lines.endLine();
}).followParent(false),
}).followParent(false).rotWithParent(false),
chainEmp = new Effect(30f, 300f, e -> {
if(!(e.data instanceof Position p)) return;
@@ -1980,5 +1980,5 @@ public class Fx{
}
Lines.endLine();
}).followParent(false);
}).followParent(false).rotWithParent(false);
}

View File

@@ -30,8 +30,12 @@ public class Effect{
public float lifetime = 50f;
/** Clip size. */
public float clip;
/** Amount added to rotation */
public float baseRotation;
/** If true, parent unit is data are followed. */
public boolean followParent;
/** If this and followParent are true, the effect will offset and rotate with the parent's rotation. */
public boolean rotWithParent;
public float layer = Layer.effect;
public float layerDuration;
@@ -61,11 +65,21 @@ public class Effect{
return this;
}
public Effect rotWithParent(boolean follow){
rotWithParent = follow;
return this;
}
public Effect layer(float l){
layer = l;
return this;
}
public Effect baseRotation(float d){
baseRotation = d;
return this;
}
public Effect layer(float l, float duration){
layer = l;
this.layerDuration = duration;
@@ -156,12 +170,15 @@ public class Effect{
EffectState entity = EffectState.create();
entity.effect = effect;
entity.rotation = rotation;
entity.rotation = effect.baseRotation + rotation;
entity.data = data;
entity.lifetime = effect.lifetime;
entity.set(x, y);
entity.color.set(color);
if(effect.followParent && data instanceof Posc p) entity.parent = p;
if(effect.followParent && data instanceof Posc p){
entity.parent = p;
entity.rotWithParent = effect.rotWithParent;
}
entity.add();
}
}

View File

@@ -1,29 +1,41 @@
package mindustry.entities.comp;
import arc.math.*;
import arc.util.*;
import mindustry.annotations.Annotations.*;
import mindustry.gen.*;
@Component
abstract class ChildComp implements Posc{
@Import float x, y;
abstract class ChildComp implements Posc, Rotc{
@Import float x, y, rotation;
@Nullable Posc parent;
float offsetX, offsetY;
boolean rotWithParent;
float offsetX, offsetY, offsetPos, offsetRot;
@Override
public void add(){
if(parent != null){
offsetX = x - parent.getX();
offsetY = y - parent.getY();
if(rotWithParent && parent instanceof Rotc r){
offsetPos = -r.rotation();
offsetRot = rotation - r.rotation();
}
}
}
@Override
public void update(){
if(parent != null){
x = parent.getX() + offsetX;
y = parent.getY() + offsetY;
if(rotWithParent && parent instanceof Rotc r){
x = parent.getX() + Angles.trnsx(r.rotation() + offsetPos, offsetX, offsetY);
y = parent.getY() + Angles.trnsy(r.rotation() + offsetPos, offsetX, offsetY);
rotation = r.rotation() + offsetRot;
}else{
x = parent.getX() + offsetX;
y = parent.getY() + offsetY;
}
}
}
}

View File

@@ -10,7 +10,7 @@ import static mindustry.Vars.*;
public class CacheLayer{
public static CacheLayer
water, mud, tar, slag, space, normal, walls;
water, mud, cryofluid, tar, slag, space, normal, walls;
public static CacheLayer[] all = {};
@@ -37,6 +37,7 @@ public class CacheLayer{
mud = new ShaderLayer(Shaders.mud),
tar = new ShaderLayer(Shaders.tar),
slag = new ShaderLayer(Shaders.slag),
cryofluid = new ShaderLayer(Shaders.cryofluid),
space = new ShaderLayer(Shaders.space),
normal = new CacheLayer(),
walls = new CacheLayer()

View File

@@ -21,7 +21,7 @@ public class Shaders{
public static UnitBuildShader build;
public static DarknessShader darkness;
public static LightShader light;
public static SurfaceShader water, mud, tar, slag, space, caustics;
public static SurfaceShader water, mud, tar, slag, cryofluid, space, caustics;
public static PlanetShader planet;
public static PlanetGridShader planetGrid;
public static AtmosphereShader atmosphere;
@@ -47,6 +47,7 @@ public class Shaders{
mud = new SurfaceShader("mud");
tar = new SurfaceShader("tar");
slag = new SurfaceShader("slag");
cryofluid = new SurfaceShader("cryofluid");
space = new SpaceShader("space");
//caustics = new SurfaceShader("caustics"){
// @Override