mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-04-27 07:50:54 -07:00
Implementation of new region system
This commit is contained in:
parent
069d572a97
commit
fd62125862
37 changed files with 168 additions and 599 deletions
|
|
@ -93,6 +93,7 @@ public class Annotations{
|
|||
String value();
|
||||
int length() default 1;
|
||||
int[] lengths() default {};
|
||||
String fallback() default "error"; //TODO
|
||||
}
|
||||
|
||||
@Target(ElementType.TYPE)
|
||||
|
|
|
|||
|
|
@ -33,65 +33,50 @@ public class LoadRegionProcessor extends BaseProcessor{
|
|||
fieldMap.getOr(field.enclosingType(), Array::new).add(field);
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
|
||||
for(Entry<Stype, Array<Svar>> entry : fieldMap){
|
||||
if(index == 0){
|
||||
method.beginControlFlow("if(content instanceof $T)", entry.key.tname());
|
||||
}else{
|
||||
method.nextControlFlow("else if(content instanceof $T)", entry.key.tname());
|
||||
}
|
||||
method.beginControlFlow("if(content instanceof $T)", entry.key.tname());
|
||||
|
||||
//go through each supertype
|
||||
for(Stype stype : entry.key.superclasses().and(entry.key)){
|
||||
if(fieldMap.containsKey(stype)){
|
||||
for(Svar field : fieldMap.get(stype)){
|
||||
LoadRegion an = field.annotation(LoadRegion.class);
|
||||
//get # of array dimensions
|
||||
int dims = count(field.mirror().toString(), "[]");
|
||||
for(Svar field : entry.value){
|
||||
LoadRegion an = field.annotation(LoadRegion.class);
|
||||
//get # of array dimensions
|
||||
int dims = count(field.mirror().toString(), "[]");
|
||||
boolean doFallback = !an.fallback().equals("error");
|
||||
String fallbackString = doFallback ? ", " + parse(an.value()).replace("content.name", '"' + an.fallback() + '"') : "";
|
||||
|
||||
//not an array
|
||||
if(dims == 0){
|
||||
method.addStatement("(($T)content).$L = $T.atlas.find($L)", entry.key.tname(), field.name(), Core.class, parse(an.value()));
|
||||
}else{
|
||||
//is an array, create length string
|
||||
int[] lengths = an.lengths();
|
||||
if(lengths.length == 0) lengths = new int[]{an.length()};
|
||||
//not an array
|
||||
if(dims == 0){
|
||||
method.addStatement("(($T)content).$L = $T.atlas.find($L$L)", entry.key.tname(), field.name(), Core.class, parse(an.value()), fallbackString);
|
||||
}else{
|
||||
//is an array, create length string
|
||||
int[] lengths = an.lengths();
|
||||
if(lengths.length == 0) lengths = new int[]{an.length()};
|
||||
|
||||
if(dims != lengths.length){
|
||||
err("Length dimensions must match array dimensions: " + dims + " != " + lengths.length, field);
|
||||
}
|
||||
if(dims != lengths.length){
|
||||
err("Length dimensions must match array dimensions: " + dims + " != " + lengths.length, field);
|
||||
}
|
||||
|
||||
StringBuilder lengthString = new StringBuilder();
|
||||
for(int value : lengths) lengthString.append("[").append(value).append("]");
|
||||
StringBuilder lengthString = new StringBuilder();
|
||||
for(int value : lengths) lengthString.append("[").append(value).append("]");
|
||||
|
||||
method.addStatement("(($T)content).$L = new $T$L", entry.key.tname(), field.name(), TextureRegion.class, lengthString.toString());
|
||||
method.addStatement("(($T)content).$L = new $T$L", entry.key.tname(), field.name(), TextureRegion.class, lengthString.toString());
|
||||
|
||||
for(int i = 0; i < dims; i++){
|
||||
int length = lengths[0];
|
||||
for(int i = 0; i < dims; i++){
|
||||
method.beginControlFlow("for(int INDEX$L = 0; INDEX$L < $L; INDEX$L ++)", i, i, lengths[i], i);
|
||||
}
|
||||
|
||||
method.beginControlFlow("for(int INDEX$L = 0; INDEX$L < $L; INDEX$L ++)", i, i, length, i);
|
||||
}
|
||||
StringBuilder indexString = new StringBuilder();
|
||||
for(int i = 0; i < dims; i++){
|
||||
indexString.append("[INDEX").append(i).append("]");
|
||||
}
|
||||
|
||||
StringBuilder indexString = new StringBuilder();
|
||||
for(int i = 0; i < dims; i++){
|
||||
indexString.append("[INDEX").append(i).append("]");
|
||||
}
|
||||
method.addStatement("(($T)content).$L$L = $T.atlas.find($L$L)", entry.key.tname(), field.name(), indexString.toString(), Core.class, parse(an.value()), fallbackString);
|
||||
|
||||
method.addStatement("(($T)content).$L$L = $T.atlas.find($L)", entry.key.tname(), field.name(), indexString.toString(), Core.class, parse(an.value()));
|
||||
|
||||
for(int i = 0; i < dims; i++){
|
||||
method.endControlFlow();
|
||||
}
|
||||
}
|
||||
for(int i = 0; i < dims; i++){
|
||||
method.endControlFlow();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
index ++;
|
||||
}
|
||||
|
||||
if(index > 0){
|
||||
method.endControlFlow();
|
||||
}
|
||||
|
||||
|
|
@ -122,6 +107,7 @@ public class LoadRegionProcessor extends BaseProcessor{
|
|||
value = value.replace("#1", "\" + INDEX0 + \"");
|
||||
value = value.replace("#2", "\" + INDEX1 + \"");
|
||||
value = value.replace("#", "\" + INDEX0 + \"");
|
||||
value = value.replace("$size", "\" + ((mindustry.world.Block)content).size + \"");
|
||||
return value;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -512,12 +512,12 @@ public class Blocks implements ContentList{
|
|||
consumes.power(3f);
|
||||
consumes.item(Items.titanium, 2);
|
||||
|
||||
int topRegion = reg("-top");
|
||||
int topRegion = re("-top");
|
||||
|
||||
drawer = entity -> {
|
||||
Draw.rect(region, entity.x(), entity.y());
|
||||
Draw.alpha(Mathf.absin(entity.totalProgress, 3f, 0.9f) * entity.warmup);
|
||||
Draw.rect(reg(topRegion), entity.x(), entity.y());
|
||||
Draw.rect(re(topRegion), entity.x(), entity.y());
|
||||
Draw.reset();
|
||||
};
|
||||
}};
|
||||
|
|
@ -534,13 +534,13 @@ public class Blocks implements ContentList{
|
|||
consumes.power(5f);
|
||||
itemCapacity = 20;
|
||||
|
||||
int bottomRegion = reg("-bottom"), weaveRegion = reg("-weave");
|
||||
int bottomRegion = re("-bottom"), weaveRegion = re("-weave");
|
||||
|
||||
drawIcons = () -> new TextureRegion[]{Core.atlas.find(name + "-bottom"), Core.atlas.find(name), Core.atlas.find(name + "-weave")};
|
||||
|
||||
drawer = entity -> {
|
||||
Draw.rect(reg(bottomRegion), entity.x(), entity.y());
|
||||
Draw.rect(reg(weaveRegion), entity.x(), entity.y(), entity.totalProgress);
|
||||
Draw.rect(re(bottomRegion), entity.x(), entity.y());
|
||||
Draw.rect(re(weaveRegion), entity.x(), entity.y(), entity.totalProgress);
|
||||
|
||||
Draw.color(Pal.accent);
|
||||
Draw.alpha(entity.warmup);
|
||||
|
|
@ -585,23 +585,23 @@ public class Blocks implements ContentList{
|
|||
consumes.item(Items.titanium);
|
||||
consumes.liquid(Liquids.water, 0.2f);
|
||||
|
||||
int liquidRegion = reg("-liquid"), topRegion = reg("-top"), bottomRegion = reg("-bottom");
|
||||
int liquidRegion = re("-liquid"), topRegion = re("-top"), bottomRegion = re("-bottom");
|
||||
|
||||
drawIcons = () -> new TextureRegion[]{Core.atlas.find(name + "-bottom"), Core.atlas.find(name + "-top")};
|
||||
|
||||
drawer = entity -> {
|
||||
int rotation = rotate ? entity.rotation() * 90 : 0;
|
||||
|
||||
Draw.rect(reg(bottomRegion), entity.x(), entity.y(), rotation);
|
||||
Draw.rect(re(bottomRegion), entity.x(), entity.y(), rotation);
|
||||
|
||||
if(entity.liquids().total() > 0.001f){
|
||||
Draw.color(outputLiquid.liquid.color);
|
||||
Draw.alpha(entity.liquids().get(outputLiquid.liquid) / liquidCapacity);
|
||||
Draw.rect(reg(liquidRegion), entity.x(), entity.y(), rotation);
|
||||
Draw.rect(re(liquidRegion), entity.x(), entity.y(), rotation);
|
||||
Draw.color();
|
||||
}
|
||||
|
||||
Draw.rect(reg(topRegion), entity.x(), entity.y(), rotation);
|
||||
Draw.rect(re(topRegion), entity.x(), entity.y(), rotation);
|
||||
};
|
||||
}};
|
||||
|
||||
|
|
@ -672,20 +672,20 @@ public class Blocks implements ContentList{
|
|||
|
||||
int[] frameRegions = new int[3];
|
||||
for(int i = 0; i < 3; i++){
|
||||
frameRegions[i] = reg("-frame" + i);
|
||||
frameRegions[i] = re("-frame" + i);
|
||||
}
|
||||
|
||||
int liquidRegion = reg("-liquid");
|
||||
int topRegion = reg("-top");
|
||||
int liquidRegion = re("-liquid");
|
||||
int topRegion = re("-top");
|
||||
|
||||
drawIcons = () -> new TextureRegion[]{Core.atlas.find(name), Core.atlas.find(name + "-top")};
|
||||
drawer = entity -> {
|
||||
Draw.rect(region, entity.x(), entity.y());
|
||||
Draw.rect(reg(frameRegions[(int)Mathf.absin(entity.totalProgress, 5f, 2.999f)]), entity.x(), entity.y());
|
||||
Draw.rect(re(frameRegions[(int)Mathf.absin(entity.totalProgress, 5f, 2.999f)]), entity.x(), entity.y());
|
||||
Draw.color(Color.clear, entity.liquids().current().color, entity.liquids().total() / liquidCapacity);
|
||||
Draw.rect(reg(liquidRegion), entity.x(), entity.y());
|
||||
Draw.rect(re(liquidRegion), entity.x(), entity.y());
|
||||
Draw.color();
|
||||
Draw.rect(reg(topRegion), entity.x(), entity.y());
|
||||
Draw.rect(re(topRegion), entity.x(), entity.y());
|
||||
};
|
||||
}};
|
||||
|
||||
|
|
@ -700,13 +700,13 @@ public class Blocks implements ContentList{
|
|||
consumes.item(Items.scrap, 1);
|
||||
consumes.power(0.50f);
|
||||
|
||||
int rotatorRegion = reg("-rotator");
|
||||
int rotatorRegion = re("-rotator");
|
||||
|
||||
drawIcons = () -> new TextureRegion[]{Core.atlas.find(name), Core.atlas.find(name + "-rotator")};
|
||||
|
||||
drawer = entity -> {
|
||||
Draw.rect(region, entity.x(), entity.y());
|
||||
Draw.rect(reg(rotatorRegion), entity.x(), entity.y(), entity.totalProgress * 2f);
|
||||
Draw.rect(re(rotatorRegion), entity.x(), entity.y(), entity.totalProgress * 2f);
|
||||
};
|
||||
}};
|
||||
|
||||
|
|
|
|||
|
|
@ -158,8 +158,6 @@ public class Block extends UnlockableContent{
|
|||
public boolean alwaysUnlocked = false;
|
||||
|
||||
protected Prov<Tilec> entityType = null; //initialized later
|
||||
protected TextureRegion[] cacheRegions = {};
|
||||
protected Array<String> cacheRegionStrings = new Array<>();
|
||||
//TODO move
|
||||
public ObjectMap<Class<?>, Cons2> configurations = new ObjectMap<>();
|
||||
|
||||
|
|
@ -168,6 +166,10 @@ public class Block extends UnlockableContent{
|
|||
protected TextureRegion[] variantRegions, editorVariantRegions;
|
||||
public TextureRegion region, editorIcon;
|
||||
|
||||
//TODO remove completely
|
||||
protected TextureRegion[] cacheRegions = {};
|
||||
protected Array<String> cacheRegionStrings = new Array<>();
|
||||
|
||||
//TODO move
|
||||
public static TextureRegion[][] cracks;
|
||||
protected static final Array<Tile> tempTiles = new Array<>();
|
||||
|
|
@ -279,17 +281,6 @@ public class Block extends UnlockableContent{
|
|||
return rotate;
|
||||
}
|
||||
|
||||
/** Adds a region by name to be loaded, with the final name "{name}-suffix". Returns an ID to looks this region up by in {@link #reg(int)}. */
|
||||
protected int reg(String suffix){
|
||||
cacheRegionStrings.add(name + suffix);
|
||||
return cacheRegionStrings.size - 1;
|
||||
}
|
||||
|
||||
/** Returns an internally cached region by ID. */
|
||||
protected TextureRegion reg(int id){
|
||||
return cacheRegions[id];
|
||||
}
|
||||
|
||||
public boolean synthetic(){
|
||||
return update || destructible;
|
||||
}
|
||||
|
|
@ -547,6 +538,19 @@ public class Block extends UnlockableContent{
|
|||
}
|
||||
}
|
||||
|
||||
/** Adds a region by name to be loaded, with the final name "{name}-suffix". Returns an ID to looks this region up by in {@link #re(int)}.
|
||||
* DO NOT USE. This will eventually be removed. */
|
||||
protected int re(String suffix){
|
||||
cacheRegionStrings.add(name + suffix);
|
||||
return cacheRegionStrings.size - 1;
|
||||
}
|
||||
|
||||
/** Returns an internally cached region by ID.
|
||||
* DO NOT USE. This will eventually be removed*/
|
||||
protected TextureRegion re(int id){
|
||||
return cacheRegions[id];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayInfo(Table table){
|
||||
ContentDisplay.displayBlock(table, this);
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
package mindustry.world.blocks.defense;
|
||||
|
||||
import arc.*;
|
||||
import arc.Graphics.*;
|
||||
import arc.Graphics.Cursor.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.util.*;
|
||||
import arc.util.io.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.units.*;
|
||||
|
|
@ -20,8 +20,7 @@ public class Door extends Wall{
|
|||
public final int timerToggle = timers++;
|
||||
public Effect openfx = Fx.dooropen;
|
||||
public Effect closefx = Fx.doorclose;
|
||||
|
||||
protected TextureRegion openRegion;
|
||||
public @LoadRegion("@-open") TextureRegion openRegion;
|
||||
|
||||
public Door(String name){
|
||||
super(name);
|
||||
|
|
@ -37,12 +36,6 @@ public class Door extends Wall{
|
|||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
super.load();
|
||||
openRegion = Core.atlas.find(name + "-open");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureRegion getRequestRegion(BuildRequest req, Eachable<BuildRequest> list){
|
||||
return req.config == Boolean.TRUE ? openRegion : region;
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import arc.math.*;
|
|||
import arc.math.geom.*;
|
||||
import arc.util.*;
|
||||
import arc.util.io.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
|
|
@ -28,7 +29,7 @@ public class ForceProjector extends Block{
|
|||
public float cooldownLiquid = 1.5f;
|
||||
public float cooldownBrokenBase = 0.35f;
|
||||
public float basePowerDraw = 0.2f;
|
||||
public TextureRegion topRegion;
|
||||
public @LoadRegion("@-top") TextureRegion topRegion;
|
||||
|
||||
private static ForceProjectorEntity paramEntity;
|
||||
private static Cons<Shielderc> shieldConsumer = trait -> {
|
||||
|
|
@ -56,12 +57,6 @@ public class ForceProjector extends Block{
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
super.load();
|
||||
topRegion = Core.atlas.find(name + "-top");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStats(){
|
||||
super.setStats();
|
||||
|
|
|
|||
|
|
@ -1,12 +1,11 @@
|
|||
package mindustry.world.blocks.defense;
|
||||
|
||||
import arc.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import arc.util.io.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
|
|
@ -16,12 +15,10 @@ import mindustry.world.meta.*;
|
|||
import static mindustry.Vars.*;
|
||||
|
||||
public class MendProjector extends Block{
|
||||
private static final IntSet healed = new IntSet();
|
||||
|
||||
public final int timerUse = timers++;
|
||||
public Color baseColor = Color.valueOf("84f491");
|
||||
public Color phaseColor = Color.valueOf("ffd59e");
|
||||
public TextureRegion topRegion;
|
||||
public @LoadRegion("@-top") TextureRegion topRegion;
|
||||
public float reload = 250f;
|
||||
public float range = 60f;
|
||||
public float healPercent = 12f;
|
||||
|
|
@ -42,12 +39,6 @@ public class MendProjector extends Block{
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
super.load();
|
||||
topRegion = Core.atlas.find(name + "-top");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStats(){
|
||||
super.setStats();
|
||||
|
|
|
|||
|
|
@ -1,12 +1,11 @@
|
|||
package mindustry.world.blocks.defense;
|
||||
|
||||
import arc.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import arc.util.io.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.world.*;
|
||||
|
|
@ -15,11 +14,9 @@ import mindustry.world.meta.*;
|
|||
import static mindustry.Vars.*;
|
||||
|
||||
public class OverdriveProjector extends Block{
|
||||
private static final IntSet healed = new IntSet();
|
||||
|
||||
public final int timerUse = timers++;
|
||||
|
||||
public TextureRegion topRegion;
|
||||
public @LoadRegion("@-top") TextureRegion topRegion;
|
||||
public float reload = 60f;
|
||||
public float range = 80f;
|
||||
public float speedBoost = 1.5f;
|
||||
|
|
@ -43,12 +40,6 @@ public class OverdriveProjector extends Block{
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
super.load();
|
||||
topRegion = Core.atlas.find(name + "-top");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPlace(int x, int y, int rotation, boolean valid){
|
||||
Drawf.dashCircle(x * tilesize + offset(), y * tilesize + offset(), range, Pal.accent);
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package mindustry.world.blocks.defense.turrets;
|
|||
import arc.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.struct.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.bullet.*;
|
||||
import mindustry.gen.*;
|
||||
|
|
@ -15,13 +16,12 @@ import static mindustry.Vars.tilesize;
|
|||
|
||||
public class LiquidTurret extends Turret{
|
||||
public ObjectMap<Liquid, BulletType> ammoTypes = new ObjectMap<>();
|
||||
public int liquidRegion;
|
||||
public @LoadRegion("@-liquid") TextureRegion liquidRegion;
|
||||
|
||||
public LiquidTurret(String name){
|
||||
super(name);
|
||||
hasLiquids = true;
|
||||
activeSound = Sounds.spray;
|
||||
liquidRegion = reg("-liquid");
|
||||
}
|
||||
|
||||
/** Initializes accepted ammo map. Format: [liquid1, bullet1, liquid2, bullet2...] */
|
||||
|
|
@ -53,10 +53,10 @@ public class LiquidTurret extends Turret{
|
|||
public void draw(){
|
||||
super.draw();
|
||||
|
||||
if(Core.atlas.isFound(reg(liquidRegion))){
|
||||
if(Core.atlas.isFound(liquidRegion)){
|
||||
Draw.color(liquids.current().color);
|
||||
Draw.alpha(liquids.total() / liquidCapacity);
|
||||
Draw.rect(reg(liquidRegion), x + tr2.x, y + tr2.y, rotation - 90);
|
||||
Draw.rect(liquidRegion, x + tr2.x, y + tr2.y, rotation - 90);
|
||||
Draw.color();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import arc.math.geom.*;
|
|||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import arc.util.io.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.bullet.*;
|
||||
|
|
@ -51,7 +52,8 @@ public abstract class Turret extends Block{
|
|||
protected Vec2 tr = new Vec2();
|
||||
protected Vec2 tr2 = new Vec2();
|
||||
|
||||
public TextureRegion baseRegion, heatRegion;
|
||||
public @LoadRegion("block-$size") TextureRegion baseRegion;
|
||||
public @LoadRegion("@-heat") TextureRegion heatRegion;
|
||||
|
||||
public Cons<TurretEntity> drawer = tile -> Draw.rect(region, tile.x() + tr2.x, tile.y() + tr2.y, tile.rotation - 90);
|
||||
public Cons<TurretEntity> heatDrawer = tile -> {
|
||||
|
|
@ -78,15 +80,6 @@ public abstract class Turret extends Block{
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
super.load();
|
||||
|
||||
region = Core.atlas.find(name);
|
||||
baseRegion = Core.atlas.find("block-" + size);
|
||||
heatRegion = Core.atlas.find(name + "-heat");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStats(){
|
||||
super.setStats();
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import arc.struct.*;
|
|||
import arc.util.ArcAnnotate.*;
|
||||
import arc.util.*;
|
||||
import arc.util.io.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.gen.*;
|
||||
|
|
@ -27,7 +28,8 @@ public class Conveyor extends Block implements Autotiler{
|
|||
|
||||
private final Vec2 tr1 = new Vec2();
|
||||
private final Vec2 tr2 = new Vec2();
|
||||
private TextureRegion[][] regions = new TextureRegion[7][4];
|
||||
|
||||
public @LoadRegion(value = "@-#1-#2", lengths = {7, 4}) TextureRegion[][] regions;
|
||||
|
||||
public float speed = 0f;
|
||||
public float displayedSpeed = 0f;
|
||||
|
|
@ -54,17 +56,6 @@ public class Conveyor extends Block implements Autotiler{
|
|||
stats.add(BlockStat.itemsMoved, displayedSpeed, StatUnit.itemsSecond);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
super.load();
|
||||
|
||||
for(int i = 0; i < regions.length; i++){
|
||||
for(int j = 0; j < 4; j++){
|
||||
regions[i][j] = Core.atlas.find(name + "-" + i + "-" + j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawRequestRegion(BuildRequest req, Eachable<BuildRequest> list){
|
||||
int[] bits = getTiling(req, list);
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import arc.struct.*;
|
|||
import arc.struct.IntSet.*;
|
||||
import arc.util.*;
|
||||
import arc.util.io.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
|
|
@ -22,7 +23,9 @@ public class ItemBridge extends Block{
|
|||
public final int timerTransport = timers++;
|
||||
public int range;
|
||||
public float transportTime = 2f;
|
||||
public TextureRegion endRegion, bridgeRegion, arrowRegion;
|
||||
public @LoadRegion("@-end") TextureRegion endRegion;
|
||||
public @LoadRegion("@-bridge") TextureRegion bridgeRegion;
|
||||
public @LoadRegion("@-arrow") TextureRegion arrowRegion;
|
||||
|
||||
private static BuildRequest otherReq;
|
||||
private static int lastPlaced = -1;
|
||||
|
|
@ -44,15 +47,6 @@ public class ItemBridge extends Block{
|
|||
config(Integer.class, (tile, i) -> ((ItemBridgeEntity)tile).link = i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
super.load();
|
||||
|
||||
endRegion = Core.atlas.find(name + "-end");
|
||||
bridgeRegion = Core.atlas.find(name + "-bridge");
|
||||
arrowRegion = Core.atlas.find(name + "-arrow");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawRequestConfigTop(BuildRequest req, Eachable<BuildRequest> list){
|
||||
otherReq = null;
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import arc.util.*;
|
|||
import arc.util.io.*;
|
||||
import arc.util.pooling.Pool.*;
|
||||
import arc.util.pooling.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.gen.*;
|
||||
|
|
@ -29,7 +30,7 @@ public class MassDriver extends Block{
|
|||
public Effect smokeEffect = Fx.shootBigSmoke2;
|
||||
public Effect recieveEffect = Fx.mineBig;
|
||||
public float shake = 3f;
|
||||
public TextureRegion baseRegion;
|
||||
public @LoadRegion("@-base") TextureRegion baseRegion;
|
||||
|
||||
public MassDriver(String name){
|
||||
super(name);
|
||||
|
|
@ -49,13 +50,6 @@ public class MassDriver extends Block{
|
|||
return new TextureRegion[]{Core.atlas.find(name + "-base"), Core.atlas.find(name)};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
super.load();
|
||||
|
||||
baseRegion = Core.atlas.find(name + "-base");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPlace(int x, int y, int rotation, boolean valid){
|
||||
Drawf.dashCircle(x * tilesize, y*tilesize, range, Pal.accent);
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import arc.math.*;
|
|||
import arc.math.geom.*;
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import arc.util.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.gen.*;
|
||||
|
|
@ -18,7 +19,8 @@ import static mindustry.Vars.*;
|
|||
|
||||
public class PayloadConveyor extends Block{
|
||||
public float moveTime = 70f;
|
||||
public TextureRegion topRegion, edgeRegion;
|
||||
public @LoadRegion("@-top") TextureRegion topRegion;
|
||||
public @LoadRegion("@-edge") TextureRegion edgeRegion;
|
||||
public Interpolation interp = Interpolation.pow5;
|
||||
|
||||
public PayloadConveyor(String name){
|
||||
|
|
@ -30,14 +32,6 @@ public class PayloadConveyor extends Block{
|
|||
outputsPayload = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
super.load();
|
||||
|
||||
topRegion = Core.atlas.find(name + "-top");
|
||||
edgeRegion = Core.atlas.find(name + "-edge");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TextureRegion[] generateIcons(){
|
||||
return new TextureRegion[]{Core.atlas.find(name + "-icon")};
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
package mindustry.world.blocks.distribution;
|
||||
|
||||
import arc.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.util.*;
|
||||
import arc.util.io.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.gen.*;
|
||||
|
|
@ -20,8 +20,9 @@ import static mindustry.Vars.*;
|
|||
public class StackConveyor extends Block implements Autotiler{
|
||||
protected static final int stateMove = 0, stateLoad = 1, stateUnload = 2;
|
||||
|
||||
protected TextureRegion[] regions = new TextureRegion[3];
|
||||
protected TextureRegion edgeRegion, stackRegion;
|
||||
public @LoadRegion(value = "@-#", length = 3) TextureRegion[] regions;
|
||||
public @LoadRegion("@-edge") TextureRegion edgeRegion;
|
||||
public @LoadRegion("@-stack") TextureRegion stackRegion;
|
||||
|
||||
public float speed = 0f;
|
||||
public float recharge = 4f;
|
||||
|
|
@ -43,18 +44,6 @@ public class StackConveyor extends Block implements Autotiler{
|
|||
dumpIncrement = 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
super.load();
|
||||
|
||||
for(int i = 0; i < regions.length; i++){
|
||||
regions[i] = Core.atlas.find(name + "-" + i);
|
||||
}
|
||||
|
||||
edgeRegion = Core.atlas.find(name + "-edge");
|
||||
stackRegion = Core.atlas.find(name + "-stack");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStats(){
|
||||
super.setStats();
|
||||
|
|
|
|||
|
|
@ -4,14 +4,15 @@ import arc.*;
|
|||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
import static mindustry.Vars.world;
|
||||
|
||||
public class StaticWall extends Rock{
|
||||
TextureRegion large;
|
||||
TextureRegion[][] split;
|
||||
public @LoadRegion("@-large") TextureRegion large;
|
||||
public TextureRegion[][] split;
|
||||
|
||||
public StaticWall(String name){
|
||||
super(name);
|
||||
|
|
@ -38,7 +39,6 @@ public class StaticWall extends Rock{
|
|||
@Override
|
||||
public void load(){
|
||||
super.load();
|
||||
large = Core.atlas.find(name + "-large");
|
||||
split = large.split(32, 32);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,233 +0,0 @@
|
|||
package mindustry.world.blocks.experimental;
|
||||
|
||||
import arc.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import arc.util.io.*;
|
||||
import mindustry.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.*;
|
||||
import mindustry.world.blocks.payloads.*;
|
||||
import mindustry.world.consumers.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
//TODO remove
|
||||
public class PayloadUnitFactory extends Block{
|
||||
public float launchVelocity = 0f;
|
||||
public TextureRegion topRegion;
|
||||
public int[] capacities;
|
||||
|
||||
public UnitPlan[] plans = new UnitPlan[0];
|
||||
|
||||
public PayloadUnitFactory(String name){
|
||||
super(name);
|
||||
update = true;
|
||||
hasPower = true;
|
||||
hasItems = true;
|
||||
solid = false;
|
||||
flags = EnumSet.of(BlockFlag.producer);
|
||||
configurable = true;
|
||||
outputsPayload = true;
|
||||
|
||||
config(Integer.class, (tile, i) -> ((UnitFactoryEntity)tile).currentPlan = i < 0 || i >= plans.length ? -1 : i);
|
||||
}
|
||||
|
||||
@Remote(called = Loc.server)
|
||||
public static void onUnitFactorySpawn2(Tile tile){
|
||||
if(!(tile.entity instanceof UnitFactoryEntity)) return;
|
||||
tile.<UnitFactoryEntity>ent().spawned();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(){
|
||||
super.init();
|
||||
|
||||
capacities = new int[Vars.content.items().size];
|
||||
if(consumes.has(ConsumeType.item)){
|
||||
ConsumeItems cons = consumes.get(ConsumeType.item);
|
||||
for(ItemStack stack : cons.items){
|
||||
capacities[stack.item.id] = stack.amount * 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
super.load();
|
||||
|
||||
topRegion = Core.atlas.find(name + "-top");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBars(){
|
||||
super.setBars();
|
||||
bars.add("progress", entity -> new Bar("bar.progress", Pal.ammo, ((UnitFactoryEntity)entity)::fraction));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean outputsItems(){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStats(){
|
||||
super.setStats();
|
||||
|
||||
stats.remove(BlockStat.itemCapacity);
|
||||
//TODO
|
||||
//stats.add(BlockStat.productionTime, produceTime / 60f, StatUnit.seconds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureRegion[] generateIcons(){
|
||||
return new TextureRegion[]{Core.atlas.find(name), Core.atlas.find(name + "-top")};
|
||||
}
|
||||
|
||||
public static class UnitPlan{
|
||||
public UnitType unit;
|
||||
public ItemStack[] requirements;
|
||||
public float time;
|
||||
|
||||
public UnitPlan(UnitType unit, float time, ItemStack[] requirements){
|
||||
this.unit = unit;
|
||||
this.time = time;
|
||||
this.requirements = requirements;
|
||||
}
|
||||
|
||||
UnitPlan(){}
|
||||
}
|
||||
|
||||
public class UnitFactoryEntity extends TileEntity{
|
||||
public int currentPlan = -1;
|
||||
|
||||
public float progress, time, speedScl;
|
||||
public @Nullable UnitPayload payload;
|
||||
|
||||
public float fraction(){
|
||||
return currentPlan == -1 ? 0 : progress / plans[currentPlan].time;
|
||||
}
|
||||
|
||||
public void spawned(){
|
||||
progress = 0f;
|
||||
|
||||
Effects.shake(2f, 3f, this);
|
||||
Fx.producesmoke.at(this);
|
||||
|
||||
if(currentPlan != -1){
|
||||
UnitPlan plan = plans[currentPlan];
|
||||
Unitc unit = plan.unit.create(team);
|
||||
|
||||
payload = new UnitPayload(unit);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildConfiguration(Table table){
|
||||
Array<UnitType> units = Array.with(plans).map(u -> u.unit);
|
||||
|
||||
ItemSelection.buildTable(table, units, () -> currentPlan == -1 ? null : plans[currentPlan].unit, unit -> tile.configure(units.indexOf(unit)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object config(){
|
||||
return currentPlan;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
super.draw();
|
||||
|
||||
if(currentPlan != -1){
|
||||
UnitPlan plan = plans[currentPlan];
|
||||
|
||||
TextureRegion region = plan.unit.icon(Cicon.full);
|
||||
|
||||
Shaders.build.region = region;
|
||||
Shaders.build.progress = progress / plan.time;
|
||||
Shaders.build.color.set(Pal.accent);
|
||||
Shaders.build.color.a = speedScl;
|
||||
Shaders.build.time = -time / 20f;
|
||||
|
||||
Draw.shader(Shaders.build);
|
||||
Draw.rect(region, x, y);
|
||||
Draw.shader();
|
||||
|
||||
Draw.color(Pal.accent);
|
||||
Draw.alpha(speedScl);
|
||||
|
||||
Lines.lineAngleCenter(x + Mathf.sin(time, 20f, Vars.tilesize / 2f * size - 2f), y, 90, size * Vars.tilesize - 4f);
|
||||
|
||||
Draw.reset();
|
||||
}
|
||||
|
||||
Draw.rect(topRegion, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTile(){
|
||||
if(currentPlan < 0 || currentPlan >= plans.length){
|
||||
currentPlan = -1;
|
||||
}
|
||||
|
||||
if((consValid() || tile.isEnemyCheat()) && currentPlan != -1 && payload == null){
|
||||
time += delta() * efficiency() * speedScl * Vars.state.rules.unitBuildSpeedMultiplier;
|
||||
progress += delta() * efficiency() * Vars.state.rules.unitBuildSpeedMultiplier;
|
||||
speedScl = Mathf.lerpDelta(speedScl, 1f, 0.05f);
|
||||
}else{
|
||||
speedScl = Mathf.lerpDelta(speedScl, 0f, 0.05f);
|
||||
}
|
||||
|
||||
if(payload != null && dumpPayload(payload)){
|
||||
payload = null;
|
||||
}
|
||||
|
||||
if(currentPlan != -1){
|
||||
UnitPlan plan = plans[currentPlan];
|
||||
|
||||
if(progress >= plan.time){
|
||||
progress = 0f;
|
||||
|
||||
Call.onUnitFactorySpawn2(tile);
|
||||
useContent(plan.unit);
|
||||
consume();
|
||||
}
|
||||
}else{
|
||||
progress = 0f;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumAccepted(Item item){
|
||||
return capacities[item.id];
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte version(){
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(Writes write){
|
||||
super.write(write);
|
||||
write.f(progress);
|
||||
write.s(currentPlan);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(Reads read, byte revision){
|
||||
super.read(read, revision);
|
||||
progress = read.f();
|
||||
currentPlan = read.s();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,25 +1,19 @@
|
|||
package mindustry.world.blocks.liquid;
|
||||
|
||||
import arc.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
public class ArmoredConduit extends Conduit{
|
||||
public TextureRegion capRegion;
|
||||
public @LoadRegion("@-cap") TextureRegion capRegion;
|
||||
|
||||
public ArmoredConduit(String name){
|
||||
super(name);
|
||||
leakResistance = 10f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
super.load();
|
||||
capRegion = Core.atlas.find(name + "-cap");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean blends(Tile tile, int rotation, int otherx, int othery, int otherrot, Block otherblock){
|
||||
return otherblock.outputsLiquid && blendsArmored(tile, rotation, otherx, othery, otherrot, otherblock);
|
||||
|
|
|
|||
|
|
@ -1,13 +1,14 @@
|
|||
package mindustry.world.blocks.liquid;
|
||||
|
||||
import arc.*;
|
||||
import arc.graphics.*;
|
||||
import arc.func.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.gen.*;
|
||||
|
|
@ -19,9 +20,9 @@ public class Conduit extends LiquidBlock implements Autotiler{
|
|||
public final int timerFlow = timers++;
|
||||
|
||||
public Color botColor = Color.valueOf("565656");
|
||||
|
||||
public TextureRegion[] topRegions = new TextureRegion[7];
|
||||
public TextureRegion[] botRegions = new TextureRegion[7];
|
||||
|
||||
public @LoadRegion(value = "@-top-#", length = 7) TextureRegion[] topRegions;
|
||||
public @LoadRegion(value = "@-bottom-#", length = 7, fallback = "conduit") TextureRegion[] botRegions;
|
||||
|
||||
public float leakResistance = 1.5f;
|
||||
|
||||
|
|
@ -33,17 +34,6 @@ public class Conduit extends LiquidBlock implements Autotiler{
|
|||
conveyorPlacement = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
super.load();
|
||||
|
||||
liquidRegion = Core.atlas.find("conduit-liquid");
|
||||
for(int i = 0; i < topRegions.length; i++){
|
||||
topRegions[i] = Core.atlas.find(name + "-top-" + i);
|
||||
botRegions[i] = Core.atlas.find(name + "-bottom-" + i, Core.atlas.find("conduit-bottom-" + i));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawRequestRegion(BuildRequest req, Eachable<BuildRequest> list){
|
||||
int[] bits = getTiling(req, list);
|
||||
|
|
|
|||
|
|
@ -2,12 +2,15 @@ package mindustry.world.blocks.liquid;
|
|||
|
||||
import arc.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
public class LiquidBlock extends Block{
|
||||
protected TextureRegion liquidRegion, bottomRegion, topRegion;
|
||||
public @LoadRegion("@-liquid") TextureRegion liquidRegion;
|
||||
public @LoadRegion("@-top") TextureRegion bottomRegion;
|
||||
public @LoadRegion("@-bottom") TextureRegion topRegion;
|
||||
|
||||
public LiquidBlock(String name){
|
||||
super(name);
|
||||
|
|
@ -18,15 +21,6 @@ public class LiquidBlock extends Block{
|
|||
outputsLiquid = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
super.load();
|
||||
|
||||
liquidRegion = Core.atlas.find(name + "-liquid");
|
||||
topRegion = Core.atlas.find(name + "-top");
|
||||
bottomRegion = Core.atlas.find(name + "-bottom");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureRegion[] generateIcons(){
|
||||
return new TextureRegion[]{Core.atlas.find(name + "-bottom"), Core.atlas.find(name + "-top")};
|
||||
|
|
|
|||
|
|
@ -2,12 +2,13 @@ package mindustry.world.blocks.power;
|
|||
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.gen.*;
|
||||
|
||||
import static mindustry.Vars.tilesize;
|
||||
|
||||
public class Battery extends PowerDistributor{
|
||||
public int topRegion = reg("-top");
|
||||
public @LoadRegion("@-top") TextureRegion topRegion;
|
||||
|
||||
public Color emptyLightColor = Color.valueOf("f8c266");
|
||||
public Color fullLightColor = Color.valueOf("fb9567");
|
||||
|
|
@ -25,7 +26,7 @@ public class Battery extends PowerDistributor{
|
|||
Fill.square(x, y, tilesize * size / 2f - 1);
|
||||
Draw.color();
|
||||
|
||||
Draw.rect(reg(topRegion), x, y);
|
||||
Draw.rect(topRegion, x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import arc.graphics.g2d.*;
|
|||
import arc.math.*;
|
||||
import arc.util.*;
|
||||
import arc.util.io.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.game.EventType.*;
|
||||
|
|
@ -19,15 +20,15 @@ import static mindustry.Vars.*;
|
|||
public class ImpactReactor extends PowerGenerator{
|
||||
public final int timerUse = timers++;
|
||||
|
||||
public int plasmas = 4;
|
||||
public float warmupSpeed = 0.001f;
|
||||
public float itemDuration = 60f;
|
||||
public int explosionRadius = 50;
|
||||
public int explosionDamage = 2000;
|
||||
|
||||
public Color plasma1 = Color.valueOf("ffd06b"), plasma2 = Color.valueOf("ff361b");
|
||||
public int bottomRegion;
|
||||
public int[] plasmaRegions;
|
||||
|
||||
public @LoadRegion("@-bottom") TextureRegion bottomRegion;
|
||||
public @LoadRegion(value = "@-plasma-#", length = 4) TextureRegion[] plasmaRegions;
|
||||
|
||||
public ImpactReactor(String name){
|
||||
super(name);
|
||||
|
|
@ -36,17 +37,6 @@ public class ImpactReactor extends PowerGenerator{
|
|||
liquidCapacity = 30f;
|
||||
hasItems = true;
|
||||
outputsPower = consumesPower = true;
|
||||
bottomRegion = reg("-bottom");
|
||||
plasmaRegions = new int[plasmas];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
super.load();
|
||||
|
||||
for(int i = 0; i < plasmas; i++){
|
||||
plasmaRegions[i] = reg("-plasma-" + i);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -104,15 +94,15 @@ public class ImpactReactor extends PowerGenerator{
|
|||
|
||||
@Override
|
||||
public void draw(){
|
||||
Draw.rect(reg(bottomRegion), x, y);
|
||||
Draw.rect(bottomRegion, x, y);
|
||||
|
||||
for(int i = 0; i < plasmas; i++){
|
||||
for(int i = 0; i < plasmaRegions.length; i++){
|
||||
float r = size * tilesize - 3f + Mathf.absin(Time.time(), 2f + i * 1f, 5f - i * 0.5f);
|
||||
|
||||
Draw.color(plasma1, plasma2, (float)i / plasmas);
|
||||
Draw.color(plasma1, plasma2, (float)i / plasmaRegions.length);
|
||||
Draw.alpha((0.3f + Mathf.absin(Time.time(), 2f + i * 2f, 0.3f + i * 0.05f)) * warmup);
|
||||
Draw.blend(Blending.additive);
|
||||
Draw.rect(reg(plasmaRegions[i]), x, y, r, r, Time.time() * (12 + i * 6f) * warmup);
|
||||
Draw.rect(plasmaRegions[i], x, y, r, r, Time.time() * (12 + i * 6f) * warmup);
|
||||
Draw.blend();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import arc.graphics.*;
|
|||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.util.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.graphics.*;
|
||||
|
|
@ -30,7 +31,8 @@ public class ItemLiquidGenerator extends PowerGenerator{
|
|||
public Effect generateEffect = Fx.generatespark;
|
||||
public Effect explodeEffect = Fx.generatespark;
|
||||
public Color heatColor = Color.valueOf("ff9b59");
|
||||
public TextureRegion topRegion, liquidRegion;
|
||||
public @LoadRegion("@-top") TextureRegion topRegion;
|
||||
public @LoadRegion("@-liquid") TextureRegion liquidRegion;
|
||||
public boolean randomlyExplode = true;
|
||||
public boolean defaults = false;
|
||||
|
||||
|
|
@ -66,15 +68,6 @@ public class ItemLiquidGenerator extends PowerGenerator{
|
|||
super.init();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
super.load();
|
||||
if(hasItems){
|
||||
topRegion = Core.atlas.find(name + "-top");
|
||||
}
|
||||
liquidRegion = Core.atlas.find(name + "-liquid");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStats(){
|
||||
super.setStats();
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import arc.graphics.g2d.*;
|
|||
import arc.scene.ui.layout.*;
|
||||
import arc.util.*;
|
||||
import arc.util.io.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.world.*;
|
||||
|
|
@ -16,13 +17,12 @@ public class LightBlock extends Block{
|
|||
|
||||
public float brightness = 0.9f;
|
||||
public float radius = 200f;
|
||||
public int topRegion;
|
||||
public @LoadRegion("@-top") TextureRegion topRegion;
|
||||
|
||||
public LightBlock(String name){
|
||||
super(name);
|
||||
hasPower = true;
|
||||
update = true;
|
||||
topRegion = reg("-top");
|
||||
configurable = true;
|
||||
config(Integer.class, (tile, value) -> ((LightEntity)tile).color = value);
|
||||
}
|
||||
|
|
@ -42,7 +42,7 @@ public class LightBlock extends Block{
|
|||
super.draw();
|
||||
Draw.blend(Blending.additive);
|
||||
Draw.color(Tmp.c1.set(color), efficiency() * 0.3f);
|
||||
Draw.rect(reg(topRegion), x, y);
|
||||
Draw.rect(topRegion, x, y);
|
||||
Draw.color();
|
||||
Draw.blend();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import arc.math.*;
|
|||
import arc.math.geom.*;
|
||||
import arc.util.*;
|
||||
import arc.util.io.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.game.EventType.*;
|
||||
|
|
@ -35,7 +36,8 @@ public class NuclearReactor extends PowerGenerator{
|
|||
public float flashThreshold = 0.46f; //heat threshold at which the lights start flashing
|
||||
public float coolantPower = 0.5f;
|
||||
|
||||
public TextureRegion topRegion, lightsRegion;
|
||||
public @LoadRegion("@-top") TextureRegion topRegion;
|
||||
public @LoadRegion("@-lights") TextureRegion lightsRegion;
|
||||
|
||||
public NuclearReactor(String name){
|
||||
super(name);
|
||||
|
|
@ -55,14 +57,6 @@ public class NuclearReactor extends PowerGenerator{
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
super.load();
|
||||
|
||||
topRegion = Core.atlas.find(name + "-center");
|
||||
lightsRegion = Core.atlas.find(name + "-lights");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBars(){
|
||||
super.setBars();
|
||||
|
|
|
|||
|
|
@ -1,21 +1,18 @@
|
|||
package mindustry.world.blocks.power;
|
||||
|
||||
import arc.Core;
|
||||
import arc.math.Mathf;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.util.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.ui.Bar;
|
||||
import arc.util.Eachable;
|
||||
import mindustry.ui.Cicon;
|
||||
import mindustry.world.Tile;
|
||||
import mindustry.world.Block;
|
||||
import arc.graphics.g2d.Draw;
|
||||
import mindustry.graphics.Pal;
|
||||
import arc.graphics.g2d.TextureRegion;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
public class PowerDiode extends Block{
|
||||
public TextureRegion arrow;
|
||||
public @LoadRegion("@-arrow") TextureRegion arrow;
|
||||
|
||||
public PowerDiode(String name){
|
||||
super(name);
|
||||
|
|
@ -34,12 +31,6 @@ public class PowerDiode extends Block{
|
|||
bars.add("front", entity -> new Bar("bar.output", Pal.powerBar, () -> bar(entity.front())));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
super.load();
|
||||
arrow = Core.atlas.find(name + "-arrow");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawRequestRegion(BuildRequest req, Eachable<BuildRequest> list) {
|
||||
TextureRegion reg = icon(Cicon.full);
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import arc.math.geom.*;
|
|||
import arc.struct.*;
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import arc.util.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
|
|
@ -26,7 +27,8 @@ public class PowerNode extends PowerBlock{
|
|||
protected final ObjectSet<PowerGraph> graphs = new ObjectSet<>();
|
||||
protected final Vec2 t1 = new Vec2(), t2 = new Vec2();
|
||||
|
||||
public TextureRegion laser, laserEnd;
|
||||
public @LoadRegion("laser") TextureRegion laser;
|
||||
public @LoadRegion("laser-end") TextureRegion laserEnd;
|
||||
public float laserRange = 6;
|
||||
public int maxNodes = 3;
|
||||
|
||||
|
|
@ -84,14 +86,6 @@ public class PowerNode extends PowerBlock{
|
|||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
super.load();
|
||||
|
||||
laser = Core.atlas.find("laser");
|
||||
laserEnd = Core.atlas.find("laser-end");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBars(){
|
||||
super.setBars();
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import arc.graphics.g2d.*;
|
|||
import arc.math.*;
|
||||
import arc.util.*;
|
||||
import arc.util.io.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.ui.*;
|
||||
|
|
@ -16,7 +17,8 @@ public class Cultivator extends GenericCrafter{
|
|||
public Color plantColorLight = Color.valueOf("7457ce");
|
||||
public Color bottomColor = Color.valueOf("474747");
|
||||
|
||||
public TextureRegion middleRegion, topRegion;
|
||||
public @LoadRegion("@-middle") TextureRegion middleRegion;
|
||||
public @LoadRegion("@-top") TextureRegion topRegion;
|
||||
public Rand random = new Rand(0);
|
||||
public float recurrence = 6f;
|
||||
public Attribute attribute = Attribute.spores;
|
||||
|
|
@ -26,14 +28,6 @@ public class Cultivator extends GenericCrafter{
|
|||
craftEffect = Fx.none;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
super.load();
|
||||
|
||||
middleRegion = Core.atlas.find(name + "-middle");
|
||||
topRegion = Core.atlas.find(name + "-top");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBars(){
|
||||
super.setBars();
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import arc.graphics.g2d.*;
|
|||
import arc.math.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.gen.*;
|
||||
|
|
@ -49,9 +50,9 @@ public class Drill extends Block{
|
|||
|
||||
public boolean drawRim = false;
|
||||
public Color heatColor = Color.valueOf("ff5512");
|
||||
public TextureRegion rimRegion;
|
||||
public TextureRegion rotatorRegion;
|
||||
public TextureRegion topRegion;
|
||||
public @LoadRegion("@-rim") TextureRegion rimRegion;
|
||||
public @LoadRegion("@-rotator") TextureRegion rotatorRegion;
|
||||
public @LoadRegion("@-top") TextureRegion topRegion;
|
||||
|
||||
public Drill(String name){
|
||||
super(name);
|
||||
|
|
@ -76,14 +77,6 @@ public class Drill extends Block{
|
|||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
super.load();
|
||||
rimRegion = Core.atlas.find(name + "-rim");
|
||||
rotatorRegion = Core.atlas.find(name + "-rotator");
|
||||
topRegion = Core.atlas.find(name + "-top");
|
||||
}
|
||||
|
||||
public Item getDrop(Tile tile){
|
||||
return tile.drop();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,14 +2,15 @@ package mindustry.world.blocks.production;
|
|||
|
||||
import arc.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
public class Fracker extends SolidPump{
|
||||
public float itemUseTime = 100f;
|
||||
|
||||
public TextureRegion liquidRegion;
|
||||
public TextureRegion rotatorRegion;
|
||||
public TextureRegion topRegion;
|
||||
public @LoadRegion("@-liquid") TextureRegion liquidRegion;
|
||||
public @LoadRegion("@-rotator") TextureRegion rotatorRegion;
|
||||
public @LoadRegion("@-top") TextureRegion topRegion;
|
||||
|
||||
public Fracker(String name){
|
||||
super(name);
|
||||
|
|
@ -23,15 +24,6 @@ public class Fracker extends SolidPump{
|
|||
stats.add(BlockStat.productionTime, itemUseTime / 60f, StatUnit.seconds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
super.load();
|
||||
|
||||
liquidRegion = Core.atlas.find(name + "-liquid");
|
||||
rotatorRegion = Core.atlas.find(name + "-rotator");
|
||||
topRegion = Core.atlas.find(name + "-top");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean outputsItems(){
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -1,27 +1,21 @@
|
|||
package mindustry.world.blocks.production;
|
||||
|
||||
import arc.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.util.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.graphics.*;
|
||||
|
||||
/** A GenericCrafter with a new glowing region drawn on top. */
|
||||
public class GenericSmelter extends GenericCrafter{
|
||||
public Color flameColor = Color.valueOf("ffc999");
|
||||
public TextureRegion topRegion;
|
||||
public @LoadRegion("@-top") TextureRegion topRegion;
|
||||
|
||||
public GenericSmelter(String name){
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
super.load();
|
||||
topRegion = Core.atlas.find(name + "-top");
|
||||
}
|
||||
|
||||
public class SmelterEntity extends GenericCrafterEntity{
|
||||
@Override
|
||||
public void draw(){
|
||||
|
|
|
|||
|
|
@ -23,13 +23,6 @@ public class Pump extends LiquidBlock{
|
|||
floating = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
super.load();
|
||||
|
||||
liquidRegion = Core.atlas.find("pump-liquid");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStats(){
|
||||
super.setStats();
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import arc.graphics.g2d.*;
|
|||
import arc.math.*;
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import arc.util.io.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
|
|
@ -19,7 +20,8 @@ public class Separator extends Block{
|
|||
public @NonNull ItemStack[] results;
|
||||
public float craftTime;
|
||||
|
||||
public int liquidRegion, spinnerRegion;
|
||||
public @LoadRegion("@-liquid") TextureRegion liquidRegion;
|
||||
public @LoadRegion("@-spinner") TextureRegion spinnerRegion;
|
||||
public float spinnerSpeed = 3f;
|
||||
|
||||
public Separator(String name){
|
||||
|
|
@ -28,9 +30,6 @@ public class Separator extends Block{
|
|||
solid = true;
|
||||
hasItems = true;
|
||||
hasLiquids = true;
|
||||
|
||||
liquidRegion = reg("-liquid");
|
||||
spinnerRegion = reg("-spinner");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -73,11 +72,11 @@ public class Separator extends Block{
|
|||
|
||||
Draw.color(liquids.current().color);
|
||||
Draw.alpha(liquids.total() / liquidCapacity);
|
||||
Draw.rect(reg(liquidRegion), x, y);
|
||||
Draw.rect(liquidRegion, x, y);
|
||||
|
||||
Draw.reset();
|
||||
if(Core.atlas.isFound(reg(spinnerRegion))){
|
||||
Draw.rect(reg(spinnerRegion), x, y, totalProgress * spinnerSpeed);
|
||||
if(Core.atlas.isFound(spinnerRegion)){
|
||||
Draw.rect(spinnerRegion, x, y, totalProgress * spinnerSpeed);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,13 +29,6 @@ public class SolidPump extends Pump{
|
|||
hasPower = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
super.load();
|
||||
|
||||
liquidRegion = Core.atlas.find(name + "-liquid");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPlace(int x, int y, int rotation, boolean valid){
|
||||
if(attribute != null){
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import arc.math.*;
|
|||
import arc.math.geom.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
|
|
@ -23,8 +24,10 @@ public class RepairPoint extends Block{
|
|||
public float repairRadius = 50f;
|
||||
public float repairSpeed = 0.3f;
|
||||
public float powerUse;
|
||||
public TextureRegion baseRegion;
|
||||
public TextureRegion laser, laserEnd;
|
||||
|
||||
public @LoadRegion("@-base") TextureRegion baseRegion;
|
||||
public @LoadRegion("laser") TextureRegion laser;
|
||||
public @LoadRegion("laser-end") TextureRegion laserEnd;
|
||||
|
||||
public RepairPoint(String name){
|
||||
super(name);
|
||||
|
|
@ -35,15 +38,6 @@ public class RepairPoint extends Block{
|
|||
outlineIcon = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
super.load();
|
||||
|
||||
baseRegion = Core.atlas.find(name + "-base");
|
||||
laser = Core.atlas.find("laser");
|
||||
laserEnd = Core.atlas.find("laser-end");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStats(){
|
||||
super.setStats();
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ public class UnitFactory extends Block{
|
|||
|
||||
|
||||
public float launchVelocity = 5f;
|
||||
public TextureRegion topRegion;
|
||||
public @LoadRegion("@-top") TextureRegion topRegion;
|
||||
public int[] capacities;
|
||||
|
||||
public UnitPlan[] plans = new UnitPlan[0];
|
||||
|
|
@ -77,13 +77,6 @@ public class UnitFactory extends Block{
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
super.load();
|
||||
|
||||
topRegion = Core.atlas.find(name + "-top");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBars(){
|
||||
super.setBars();
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
org.gradle.daemon=true
|
||||
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
||||
archash=1a6e4dc2f032b4d40e3183060fdd4d9a422fbd34
|
||||
archash=98e63e76cb6b5c925531ae5518b5182522def509
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue