Bugfixes / Beam link for bases

This commit is contained in:
Anuken
2022-02-07 14:24:02 -05:00
parent 0152569414
commit 271e19f63f
8 changed files with 91 additions and 16 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

@@ -527,3 +527,4 @@
63176=red-stone-vent|block-red-stone-vent-ui 63176=red-stone-vent|block-red-stone-vent-ui
63175=carbon-vent|block-carbon-vent-ui 63175=carbon-vent|block-carbon-vent-ui
63174=shield-projector|block-shield-projector-ui 63174=shield-projector|block-shield-projector-ui
63173=beam-link|block-beam-link-ui

Binary file not shown.

View File

@@ -112,7 +112,7 @@ public class Blocks{
//power - erekir //power - erekir
//TODO rename chemicalCombustionChamber //TODO rename chemicalCombustionChamber
turbineCondenser, ventCondenser, chemicalCombustionChamber, pyrolysisGenerator, turbineCondenser, ventCondenser, chemicalCombustionChamber, pyrolysisGenerator,
beamNode, beamTower, beamNode, beamTower, beamLink,
//production //production
mechanicalDrill, pneumaticDrill, laserDrill, blastDrill, waterExtractor, oilExtractor, cultivator, mechanicalDrill, pneumaticDrill, laserDrill, blastDrill, waterExtractor, oilExtractor, cultivator,
@@ -1731,8 +1731,7 @@ public class Blocks{
//TODO 5x5?? //TODO 5x5??
shieldProjector = new BaseShield("shield-projector"){{ shieldProjector = new BaseShield("shield-projector"){{
category = Category.effect; requirements(Category.effect, BuildVisibility.editorOnly, with());
buildVisibility = BuildVisibility.editorOnly;
size = 3; size = 3;
@@ -2125,6 +2124,16 @@ public class Blocks{
range = 23; range = 23;
}}; }};
beamLink = new LongPowerNode("beam-link"){{
requirements(Category.power, BuildVisibility.editorOnly, with());
size = 3;
maxNodes = 1;
laserRange = 1000f;
autolink = false;
laserColor2 = Color.valueOf("ffd9c2");
laserScale = 0.65f;
}};
combustionGenerator = new BurnerGenerator("combustion-generator"){{ combustionGenerator = new BurnerGenerator("combustion-generator"){{
requirements(Category.power, with(Items.copper, 25, Items.lead, 15)); requirements(Category.power, with(Items.copper, 25, Items.lead, 15));
powerProduction = 1f; powerProduction = 1f;

View File

@@ -0,0 +1,48 @@
package mindustry.world.blocks.power;
import arc.*;
import arc.graphics.*;
import arc.graphics.g2d.*;
import arc.math.*;
import arc.util.*;
import mindustry.annotations.Annotations.*;
import mindustry.graphics.*;
public class LongPowerNode extends PowerNode{
public @Load("@-glow") TextureRegion glow;
public Color glowColor = Color.valueOf("cbfd81").a(0.6f);
public float glowScl = 16f, glowMag = 0.6f;
public LongPowerNode(String name){
super(name);
drawRange = false;
}
@Override
public void load(){
super.load();
laser = Core.atlas.find("power-beam");
laserEnd = Core.atlas.find("power-beam-end");
}
public class LongPowerNodeBuild extends PowerNodeBuild{
public float warmup = 0f;
@Override
public void updateTile(){
super.updateTile();
warmup = Mathf.lerpDelta(warmup, power.links.size > 0 ? 1f : 0f, 0.05f);
}
@Override
public void draw(){
super.draw();
if(warmup > 0.001f){
Drawf.additive(glow, Tmp.c1.set(glowColor).mula(warmup).mula(1f - glowMag + Mathf.absin(glowScl, glowMag)), x, y);
}
}
}
}

View File

@@ -31,6 +31,8 @@ public class PowerNode extends PowerBlock{
public @Load("laser-end") TextureRegion laserEnd; public @Load("laser-end") TextureRegion laserEnd;
public float laserRange = 6; public float laserRange = 6;
public int maxNodes = 3; public int maxNodes = 3;
public boolean autolink = true, drawRange = true;
public float laserScale = 0.25f;
public Color laserColor1 = Color.white; public Color laserColor1 = Color.white;
public Color laserColor2 = Pal.powerLight; public Color laserColor2 = Pal.powerLight;
@@ -145,7 +147,7 @@ public class PowerNode extends PowerBlock{
public void drawPlace(int x, int y, int rotation, boolean valid){ public void drawPlace(int x, int y, int rotation, boolean valid){
Tile tile = world.tile(x, y); Tile tile = world.tile(x, y);
if(tile == null) return; if(tile == null || !autolink) return;
Lines.stroke(1f); Lines.stroke(1f);
Draw.color(Pal.placing); Draw.color(Pal.placing);
@@ -176,7 +178,7 @@ public class PowerNode extends PowerBlock{
vx = Mathf.cosDeg(angle1), vy = Mathf.sinDeg(angle1), vx = Mathf.cosDeg(angle1), vy = Mathf.sinDeg(angle1),
len1 = size1 * tilesize / 2f - 1.5f, len2 = size2 * tilesize / 2f - 1.5f; len1 = size1 * tilesize / 2f - 1.5f, len2 = size2 * tilesize / 2f - 1.5f;
Drawf.laser(team, laser, laserEnd, x1 + vx*len1, y1 + vy*len1, x2 - vx*len2, y2 - vy*len2, 0.25f); Drawf.laser(team, laser, laserEnd, x1 + vx*len1, y1 + vy*len1, x2 - vx*len2, y2 - vy*len2, laserScale);
} }
protected boolean overlaps(float srcx, float srcy, Tile other, Block otherBlock, float range){ protected boolean overlaps(float srcx, float srcy, Tile other, Block otherBlock, float range){
@@ -202,6 +204,8 @@ public class PowerNode extends PowerBlock{
} }
protected void getPotentialLinks(Tile tile, Team team, Cons<Building> others){ protected void getPotentialLinks(Tile tile, Team team, Cons<Building> others){
if(!autolink) return;
Boolf<Building> valid = other -> other != null && other.tile() != tile && other.power != null && Boolf<Building> valid = other -> other != null && other.tile() != tile && other.power != null &&
(other.block.outputsPower || other.block.consumesPower || other.block instanceof PowerNode) && (other.block.outputsPower || other.block.consumesPower || other.block instanceof PowerNode) &&
overlaps(tile.x * tilesize + offset, tile.y * tilesize + offset, other.tile(), laserRange * tilesize) && other.team == team && overlaps(tile.x * tilesize + offset, tile.y * tilesize + offset, other.tile(), laserRange * tilesize) && other.team == team &&
@@ -255,6 +259,7 @@ public class PowerNode extends PowerBlock{
/** Iterates through linked nodes of a block at a tile. All returned buildings are power nodes. */ /** Iterates through linked nodes of a block at a tile. All returned buildings are power nodes. */
public static void getNodeLinks(Tile tile, Block block, Team team, Cons<Building> others){ public static void getNodeLinks(Tile tile, Block block, Team team, Cons<Building> others){
Boolf<Building> valid = other -> other != null && other.tile() != tile && other.block instanceof PowerNode node && Boolf<Building> valid = other -> other != null && other.tile() != tile && other.block instanceof PowerNode node &&
node.autolink &&
other.power.links.size < node.maxNodes && other.power.links.size < node.maxNodes &&
node.overlaps(other.x, other.y, tile, block, node.laserRange * tilesize) && other.team == team node.overlaps(other.x, other.y, tile, block, node.laserRange * tilesize) && other.team == team
&& !graphs.contains(other.power.graph) && && !graphs.contains(other.power.graph) &&
@@ -410,6 +415,8 @@ public class PowerNode extends PowerBlock{
public void drawSelect(){ public void drawSelect(){
super.drawSelect(); super.drawSelect();
if(!drawRange) return;
Lines.stroke(1f); Lines.stroke(1f);
Draw.color(Pal.accent); Draw.color(Pal.accent);
@@ -421,6 +428,8 @@ public class PowerNode extends PowerBlock{
public void drawConfigure(){ public void drawConfigure(){
Drawf.circles(x, y, tile.block().size * tilesize / 2f + 1f + Mathf.absin(Time.time, 4f, 1f)); Drawf.circles(x, y, tile.block().size * tilesize / 2f + 1f + Mathf.absin(Time.time, 4f, 1f));
if(drawRange){
Drawf.circles(x, y, laserRange * tilesize); Drawf.circles(x, y, laserRange * tilesize);
for(int x = (int)(tile.x - laserRange - 2); x <= tile.x + laserRange + 2; x++){ for(int x = (int)(tile.x - laserRange - 2); x <= tile.x + laserRange + 2; x++){
@@ -438,6 +447,14 @@ public class PowerNode extends PowerBlock{
} }
Draw.reset(); Draw.reset();
}else{
power.links.each(i -> {
var link = world.build(i);
if(link != null && linkValid(this, link, false)){
Drawf.square(link.x, link.y, link.block.size * tilesize / 2f + 1f, Pal.place);
}
});
}
} }
@Override @Override

View File

@@ -8,7 +8,7 @@ public enum BuildVisibility{
hidden(() -> false), hidden(() -> false),
shown(() -> true), shown(() -> true),
debugOnly(() -> false), debugOnly(() -> false),
editorOnly(() -> false), editorOnly(() -> Vars.state.rules.editor),
sandboxOnly(() -> Vars.state == null || Vars.state.rules.infiniteResources), sandboxOnly(() -> Vars.state == null || Vars.state.rules.infiniteResources),
campaignOnly(() -> Vars.state == null || Vars.state.isCampaign()), campaignOnly(() -> Vars.state == null || Vars.state.isCampaign()),
lightingOnly(() -> Vars.state == null || Vars.state.rules.lighting || Vars.state.isCampaign()), lightingOnly(() -> Vars.state == null || Vars.state.rules.lighting || Vars.state.isCampaign()),