Bugfixes / Beam link for bases
This commit is contained in:
@@ -112,7 +112,7 @@ public class Blocks{
|
||||
//power - erekir
|
||||
//TODO rename chemicalCombustionChamber
|
||||
turbineCondenser, ventCondenser, chemicalCombustionChamber, pyrolysisGenerator,
|
||||
beamNode, beamTower,
|
||||
beamNode, beamTower, beamLink,
|
||||
|
||||
//production
|
||||
mechanicalDrill, pneumaticDrill, laserDrill, blastDrill, waterExtractor, oilExtractor, cultivator,
|
||||
@@ -1731,8 +1731,7 @@ public class Blocks{
|
||||
|
||||
//TODO 5x5??
|
||||
shieldProjector = new BaseShield("shield-projector"){{
|
||||
category = Category.effect;
|
||||
buildVisibility = BuildVisibility.editorOnly;
|
||||
requirements(Category.effect, BuildVisibility.editorOnly, with());
|
||||
|
||||
size = 3;
|
||||
|
||||
@@ -2125,6 +2124,16 @@ public class Blocks{
|
||||
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"){{
|
||||
requirements(Category.power, with(Items.copper, 25, Items.lead, 15));
|
||||
powerProduction = 1f;
|
||||
|
||||
48
core/src/mindustry/world/blocks/power/LongPowerNode.java
Normal file
48
core/src/mindustry/world/blocks/power/LongPowerNode.java
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,8 @@ public class PowerNode extends PowerBlock{
|
||||
public @Load("laser-end") TextureRegion laserEnd;
|
||||
public float laserRange = 6;
|
||||
public int maxNodes = 3;
|
||||
public boolean autolink = true, drawRange = true;
|
||||
public float laserScale = 0.25f;
|
||||
public Color laserColor1 = Color.white;
|
||||
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){
|
||||
Tile tile = world.tile(x, y);
|
||||
|
||||
if(tile == null) return;
|
||||
if(tile == null || !autolink) return;
|
||||
|
||||
Lines.stroke(1f);
|
||||
Draw.color(Pal.placing);
|
||||
@@ -176,7 +178,7 @@ public class PowerNode extends PowerBlock{
|
||||
vx = Mathf.cosDeg(angle1), vy = Mathf.sinDeg(angle1),
|
||||
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){
|
||||
@@ -202,6 +204,8 @@ public class PowerNode extends PowerBlock{
|
||||
}
|
||||
|
||||
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 &&
|
||||
(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 &&
|
||||
@@ -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. */
|
||||
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 &&
|
||||
node.autolink &&
|
||||
other.power.links.size < node.maxNodes &&
|
||||
node.overlaps(other.x, other.y, tile, block, node.laserRange * tilesize) && other.team == team
|
||||
&& !graphs.contains(other.power.graph) &&
|
||||
@@ -410,6 +415,8 @@ public class PowerNode extends PowerBlock{
|
||||
public void drawSelect(){
|
||||
super.drawSelect();
|
||||
|
||||
if(!drawRange) return;
|
||||
|
||||
Lines.stroke(1f);
|
||||
|
||||
Draw.color(Pal.accent);
|
||||
@@ -421,23 +428,33 @@ public class PowerNode extends PowerBlock{
|
||||
public void drawConfigure(){
|
||||
|
||||
Drawf.circles(x, y, tile.block().size * tilesize / 2f + 1f + Mathf.absin(Time.time, 4f, 1f));
|
||||
Drawf.circles(x, y, laserRange * tilesize);
|
||||
|
||||
for(int x = (int)(tile.x - laserRange - 2); x <= tile.x + laserRange + 2; x++){
|
||||
for(int y = (int)(tile.y - laserRange - 2); y <= tile.y + laserRange + 2; y++){
|
||||
Building link = world.build(x, y);
|
||||
if(drawRange){
|
||||
Drawf.circles(x, y, laserRange * tilesize);
|
||||
|
||||
if(link != this && linkValid(this, link, false)){
|
||||
boolean linked = linked(link);
|
||||
for(int x = (int)(tile.x - laserRange - 2); x <= tile.x + laserRange + 2; x++){
|
||||
for(int y = (int)(tile.y - laserRange - 2); y <= tile.y + laserRange + 2; y++){
|
||||
Building link = world.build(x, y);
|
||||
|
||||
if(linked){
|
||||
Drawf.square(link.x, link.y, link.block.size * tilesize / 2f + 1f, Pal.place);
|
||||
if(link != this && linkValid(this, link, false)){
|
||||
boolean linked = linked(link);
|
||||
|
||||
if(linked){
|
||||
Drawf.square(link.x, link.y, link.block.size * tilesize / 2f + 1f, Pal.place);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
@@ -8,7 +8,7 @@ public enum BuildVisibility{
|
||||
hidden(() -> false),
|
||||
shown(() -> true),
|
||||
debugOnly(() -> false),
|
||||
editorOnly(() -> false),
|
||||
editorOnly(() -> Vars.state.rules.editor),
|
||||
sandboxOnly(() -> Vars.state == null || Vars.state.rules.infiniteResources),
|
||||
campaignOnly(() -> Vars.state == null || Vars.state.isCampaign()),
|
||||
lightingOnly(() -> Vars.state == null || Vars.state.rules.lighting || Vars.state.isCampaign()),
|
||||
|
||||
Reference in New Issue
Block a user