Fixed projector clipping

This commit is contained in:
Anuken
2020-09-03 19:17:49 -04:00
parent 07305aecf4
commit ba1363895e
8 changed files with 50 additions and 22 deletions

View File

@@ -16,6 +16,7 @@ mindustry.entities.comp.PlayerComp=12
mindustry.entities.comp.PuddleComp=13 mindustry.entities.comp.PuddleComp=13
mindustry.type.Weather.WeatherStateComp=14 mindustry.type.Weather.WeatherStateComp=14
mindustry.world.blocks.campaign.LaunchPad.LaunchPayloadComp=15 mindustry.world.blocks.campaign.LaunchPad.LaunchPayloadComp=15
mindustry.world.blocks.defense.ForceProjector.ForceDrawComp=22
mono=16 mono=16
nova=17 nova=17
poly=18 poly=18

View File

@@ -0,0 +1 @@
{fields:[{name:x,type:float,size:4},{name:y,type:float,size:4}]}

View File

@@ -89,9 +89,6 @@ public class Rules{
public boolean enemyLights = true; public boolean enemyLights = true;
/** Ambient light color, used when lighting is enabled. */ /** Ambient light color, used when lighting is enabled. */
public Color ambientLight = new Color(0.01f, 0.01f, 0.04f, 0.99f); public Color ambientLight = new Color(0.01f, 0.01f, 0.04f, 0.99f);
/** Multiplier for solar panel power output.
negative = use ambient light if lighting is enabled. */
public float solarPowerMultiplier = -1f;
/** team of the player by default */ /** team of the player by default */
public Team defaultTeam = Team.sharded; public Team defaultTeam = Team.sharded;
/** team of the enemy in waves/sectors */ /** team of the enemy in waves/sectors */

View File

@@ -163,8 +163,6 @@ public class CustomRulesDialog extends BaseDialog{
number("@rules.enemycorebuildradius", f -> rules.enemyCoreBuildRadius = f * tilesize, () -> Math.min(rules.enemyCoreBuildRadius / tilesize, 200)); number("@rules.enemycorebuildradius", f -> rules.enemyCoreBuildRadius = f * tilesize, () -> Math.min(rules.enemyCoreBuildRadius / tilesize, 200));
title("@rules.title.environment"); title("@rules.title.environment");
//various multipliers should be handled elsewhere
//number("@rules.solarpowermultiplier", f -> rules.solarPowerMultiplier = f, () -> rules.solarPowerMultiplier);
check("@rules.lighting", b -> rules.lighting = b, () -> rules.lighting); check("@rules.lighting", b -> rules.lighting = b, () -> rules.lighting);
main.button(b -> { main.button(b -> {

View File

@@ -31,7 +31,7 @@ public class ForceProjector extends Block{
public float basePowerDraw = 0.2f; public float basePowerDraw = 0.2f;
public @Load("@-top") TextureRegion topRegion; public @Load("@-top") TextureRegion topRegion;
static ForceProjectorEntity paramEntity; static ForceBuild paramEntity;
static final Cons<Shielderc> shieldConsumer = trait -> { static final Cons<Shielderc> shieldConsumer = trait -> {
if(trait.team() != paramEntity.team && Intersector.isInsideHexagon(paramEntity.x, paramEntity.y, paramEntity.realRadius() * 2f, trait.x(), trait.y())){ if(trait.team() != paramEntity.team && Intersector.isInsideHexagon(paramEntity.x, paramEntity.y, paramEntity.realRadius() * 2f, trait.x(), trait.y())){
trait.absorb(); trait.absorb();
@@ -48,8 +48,6 @@ public class ForceProjector extends Block{
hasPower = true; hasPower = true;
hasLiquids = true; hasLiquids = true;
hasItems = true; hasItems = true;
//TODO this isn't good enough, shields are still clipped
expanded = true;
consumes.add(new ConsumeLiquidFilter(liquid -> liquid.temperature <= 0.5f && liquid.flammability < 0.1f, 0.1f)).boost().update(false); consumes.add(new ConsumeLiquidFilter(liquid -> liquid.temperature <= 0.5f && liquid.flammability < 0.1f, 0.1f)).boost().update(false);
} }
@@ -79,13 +77,25 @@ public class ForceProjector extends Block{
Draw.color(); Draw.color();
} }
public class ForceProjectorEntity extends Building{ public class ForceBuild extends Building{
boolean broken = true; public boolean broken = true;
float buildup = 0f; public float buildup, radscl, hit, warmup, phaseHeat;
float radscl = 0f; public ForceDraw drawer;
float hit;
float warmup; @Override
float phaseHeat; public void add(){
super.add();
drawer = ForceDraw.create();
drawer.build = this;
drawer.set(x, y);
drawer.add();
}
@Override
public void remove(){
super.remove();
drawer.remove();
}
@Override @Override
public void updateTile(){ public void updateTile(){
@@ -138,7 +148,7 @@ public class ForceProjector extends Block{
} }
} }
float realRadius(){ public float realRadius(){
return (radius + phaseHeat * phaseRadiusBoost) * radscl; return (radius + phaseHeat * phaseRadiusBoost) * radscl;
} }
@@ -146,6 +156,8 @@ public class ForceProjector extends Block{
public void draw(){ public void draw(){
super.draw(); super.draw();
drawer.set(x, y);
if(buildup > 0f){ if(buildup > 0f){
Draw.alpha(buildup / breakage * 0.75f); Draw.alpha(buildup / breakage * 0.75f);
Draw.blend(Blending.additive); Draw.blend(Blending.additive);
@@ -153,7 +165,9 @@ public class ForceProjector extends Block{
Draw.blend(); Draw.blend();
Draw.reset(); Draw.reset();
} }
}
public void drawShield(){
if(!broken){ if(!broken){
float radius = realRadius(); float radius = realRadius();
@@ -196,4 +210,21 @@ public class ForceProjector extends Block{
phaseHeat = read.f(); phaseHeat = read.f();
} }
} }
@EntityDef(value = {ForceDrawc.class}, serialize = false)
@Component(base = true)
abstract class ForceDrawComp implements Drawc{
transient ForceBuild build;
@Override
public void draw(){
build.drawShield();
}
@Replace
@Override
public float clipSize(){
return build.realRadius() * 2.5f;
}
}
} }

View File

@@ -55,7 +55,7 @@ public class MendProjector extends Block{
Drawf.dashCircle(x * tilesize + offset, y * tilesize + offset, range, Pal.accent); Drawf.dashCircle(x * tilesize + offset, y * tilesize + offset, range, Pal.accent);
} }
public class MendEntity extends Building{ public class MendBuild extends Building{
float heat; float heat;
float charge = Mathf.random(reload); float charge = Mathf.random(reload);
float phaseHeat; float phaseHeat;

View File

@@ -60,7 +60,7 @@ public class OverdriveProjector extends Block{
} }
} }
public class OverdriveEntity extends Building{ public class OverdriveBuild extends Building{
float heat; float heat;
float charge = Mathf.random(reload); float charge = Mathf.random(reload);
float phaseHeat; float phaseHeat;

View File

@@ -26,9 +26,9 @@ public class SolarGenerator extends PowerGenerator{
public void updateTile(){ public void updateTile(){
productionEfficiency = enabled ? productionEfficiency = enabled ?
Mathf.maxZero(Attribute.light.env() + Mathf.maxZero(Attribute.light.env() +
(state.rules.solarPowerMultiplier < 0 ? (state.rules.lighting ?
(state.rules.lighting ? 1f - state.rules.ambientLight.a : 1f) : 1f - state.rules.ambientLight.a :
state.rules.solarPowerMultiplier 1f
)) : 0f; )) : 0f;
} }
} }