mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-10 18:57:39 +07:00
Fixed projector clipping
This commit is contained in:
parent
07305aecf4
commit
ba1363895e
@ -16,6 +16,7 @@ mindustry.entities.comp.PlayerComp=12
|
||||
mindustry.entities.comp.PuddleComp=13
|
||||
mindustry.type.Weather.WeatherStateComp=14
|
||||
mindustry.world.blocks.campaign.LaunchPad.LaunchPayloadComp=15
|
||||
mindustry.world.blocks.defense.ForceProjector.ForceDrawComp=22
|
||||
mono=16
|
||||
nova=17
|
||||
poly=18
|
||||
|
@ -0,0 +1 @@
|
||||
{fields:[{name:x,type:float,size:4},{name:y,type:float,size:4}]}
|
@ -89,9 +89,6 @@ public class Rules{
|
||||
public boolean enemyLights = true;
|
||||
/** Ambient light color, used when lighting is enabled. */
|
||||
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 */
|
||||
public Team defaultTeam = Team.sharded;
|
||||
/** team of the enemy in waves/sectors */
|
||||
|
@ -163,8 +163,6 @@ public class CustomRulesDialog extends BaseDialog{
|
||||
number("@rules.enemycorebuildradius", f -> rules.enemyCoreBuildRadius = f * tilesize, () -> Math.min(rules.enemyCoreBuildRadius / tilesize, 200));
|
||||
|
||||
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);
|
||||
|
||||
main.button(b -> {
|
||||
|
@ -31,7 +31,7 @@ public class ForceProjector extends Block{
|
||||
public float basePowerDraw = 0.2f;
|
||||
public @Load("@-top") TextureRegion topRegion;
|
||||
|
||||
static ForceProjectorEntity paramEntity;
|
||||
static ForceBuild paramEntity;
|
||||
static final Cons<Shielderc> shieldConsumer = trait -> {
|
||||
if(trait.team() != paramEntity.team && Intersector.isInsideHexagon(paramEntity.x, paramEntity.y, paramEntity.realRadius() * 2f, trait.x(), trait.y())){
|
||||
trait.absorb();
|
||||
@ -48,8 +48,6 @@ public class ForceProjector extends Block{
|
||||
hasPower = true;
|
||||
hasLiquids = 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);
|
||||
}
|
||||
|
||||
@ -79,13 +77,25 @@ public class ForceProjector extends Block{
|
||||
Draw.color();
|
||||
}
|
||||
|
||||
public class ForceProjectorEntity extends Building{
|
||||
boolean broken = true;
|
||||
float buildup = 0f;
|
||||
float radscl = 0f;
|
||||
float hit;
|
||||
float warmup;
|
||||
float phaseHeat;
|
||||
public class ForceBuild extends Building{
|
||||
public boolean broken = true;
|
||||
public float buildup, radscl, hit, warmup, phaseHeat;
|
||||
public ForceDraw drawer;
|
||||
|
||||
@Override
|
||||
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
|
||||
public void updateTile(){
|
||||
@ -138,7 +148,7 @@ public class ForceProjector extends Block{
|
||||
}
|
||||
}
|
||||
|
||||
float realRadius(){
|
||||
public float realRadius(){
|
||||
return (radius + phaseHeat * phaseRadiusBoost) * radscl;
|
||||
}
|
||||
|
||||
@ -146,6 +156,8 @@ public class ForceProjector extends Block{
|
||||
public void draw(){
|
||||
super.draw();
|
||||
|
||||
drawer.set(x, y);
|
||||
|
||||
if(buildup > 0f){
|
||||
Draw.alpha(buildup / breakage * 0.75f);
|
||||
Draw.blend(Blending.additive);
|
||||
@ -153,7 +165,9 @@ public class ForceProjector extends Block{
|
||||
Draw.blend();
|
||||
Draw.reset();
|
||||
}
|
||||
}
|
||||
|
||||
public void drawShield(){
|
||||
if(!broken){
|
||||
float radius = realRadius();
|
||||
|
||||
@ -196,4 +210,21 @@ public class ForceProjector extends Block{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ public class MendProjector extends Block{
|
||||
Drawf.dashCircle(x * tilesize + offset, y * tilesize + offset, range, Pal.accent);
|
||||
}
|
||||
|
||||
public class MendEntity extends Building{
|
||||
public class MendBuild extends Building{
|
||||
float heat;
|
||||
float charge = Mathf.random(reload);
|
||||
float phaseHeat;
|
||||
|
@ -60,7 +60,7 @@ public class OverdriveProjector extends Block{
|
||||
}
|
||||
}
|
||||
|
||||
public class OverdriveEntity extends Building{
|
||||
public class OverdriveBuild extends Building{
|
||||
float heat;
|
||||
float charge = Mathf.random(reload);
|
||||
float phaseHeat;
|
||||
|
@ -26,10 +26,10 @@ public class SolarGenerator extends PowerGenerator{
|
||||
public void updateTile(){
|
||||
productionEfficiency = enabled ?
|
||||
Mathf.maxZero(Attribute.light.env() +
|
||||
(state.rules.solarPowerMultiplier < 0 ?
|
||||
(state.rules.lighting ? 1f - state.rules.ambientLight.a : 1f) :
|
||||
state.rules.solarPowerMultiplier
|
||||
)) : 0f;
|
||||
(state.rules.lighting ?
|
||||
1f - state.rules.ambientLight.a :
|
||||
1f
|
||||
)) : 0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user