Correct names for buildings

This commit is contained in:
Anuken
2020-08-11 11:12:18 -04:00
parent bb3c80c055
commit 2b96d30255
98 changed files with 219 additions and 430 deletions
+1 -1
View File
@@ -261,7 +261,7 @@ public class Control implements ApplicationListener, Loadable{
} }
//TODO move //TODO move
public void handleLaunch(CoreEntity tile){ public void handleLaunch(CoreBuild tile){
LaunchCorec ent = LaunchCore.create(); LaunchCorec ent = LaunchCore.create();
ent.set(tile); ent.set(tile);
ent.block(Blocks.coreShard); ent.block(Blocks.coreShard);
+1 -1
View File
@@ -89,7 +89,7 @@ public class Logic implements ApplicationListener{
Events.on(WorldLoadEvent.class, e -> { Events.on(WorldLoadEvent.class, e -> {
if(state.isCampaign()){ if(state.isCampaign()){
long seconds = state.rules.sector.getSecondsPassed(); long seconds = state.rules.sector.getSecondsPassed();
CoreEntity core = state.rules.defaultTeam.core(); CoreBuild core = state.rules.defaultTeam.core();
//apply fractional damage based on how many turns have passed for this sector //apply fractional damage based on how many turns have passed for this sector
float turnsPassed = seconds / (turnDuration / 60f); float turnsPassed = seconds / (turnDuration / 60f);
+2 -2
View File
@@ -803,11 +803,11 @@ public class NetServer implements ApplicationListener{
public void writeEntitySnapshot(Player player) throws IOException{ public void writeEntitySnapshot(Player player) throws IOException{
syncStream.reset(); syncStream.reset();
Seq<CoreEntity> cores = state.teams.cores(player.team()); Seq<CoreBuild> cores = state.teams.cores(player.team());
dataStream.writeByte(cores.size); dataStream.writeByte(cores.size);
for(CoreEntity entity : cores){ for(CoreBuild entity : cores){
dataStream.writeInt(entity.tile().pos()); dataStream.writeInt(entity.tile().pos());
entity.items.write(Writes.get(dataStream)); entity.items.write(Writes.get(dataStream));
} }
@@ -54,11 +54,13 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra
return unit instanceof Minerc; return unit instanceof Minerc;
} }
public @Nullable CoreEntity closestCore(){ public @Nullable
CoreBuild closestCore(){
return state.teams.closestCore(x, y, team); return state.teams.closestCore(x, y, team);
} }
public @Nullable CoreEntity core(){ public @Nullable
CoreBuild core(){
return team.core(); return team.core();
} }
@@ -104,7 +106,7 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra
clearUnit(); clearUnit();
} }
CoreEntity core = closestCore(); CoreBuild core = closestCore();
if(!dead()){ if(!dead()){
set(unit); set(unit);
+3 -3
View File
@@ -64,7 +64,7 @@ public class SectorInfo{
//update core items //update core items
coreItems.clear(); coreItems.clear();
CoreEntity entity = state.rules.defaultTeam.core(); CoreBuild entity = state.rules.defaultTeam.core();
if(entity != null){ if(entity != null){
ItemModule items = entity.items; ItemModule items = entity.items;
@@ -97,7 +97,7 @@ public class SectorInfo{
updateCoreDeltas(); updateCoreDeltas();
} }
CoreEntity ent = state.rules.defaultTeam.core(); CoreBuild ent = state.rules.defaultTeam.core();
//refresh throughput //refresh throughput
if(time.get(refreshPeriod)){ if(time.get(refreshPeriod)){
@@ -141,7 +141,7 @@ public class SectorInfo{
} }
private void updateCoreDeltas(){ private void updateCoreDeltas(){
CoreEntity ent = state.rules.defaultTeam.core(); CoreBuild ent = state.rules.defaultTeam.core();
for(int i = 0; i < lastCoreItems.length; i++){ for(int i = 0; i < lastCoreItems.length; i++){
lastCoreItems[i] = ent == null ? 0 : ent.items.get(i); lastCoreItems[i] = ent == null ? 0 : ent.items.get(i);
} }
+3 -2
View File
@@ -91,7 +91,8 @@ public class Team implements Comparable<Team>{
return state.teams.get(this); return state.teams.get(this);
} }
public @Nullable CoreEntity core(){ public @Nullable
CoreBuild core(){
return data().core(); return data().core();
} }
@@ -103,7 +104,7 @@ public class Team implements Comparable<Team>{
return state.teams.areEnemies(this, other); return state.teams.areEnemies(this, other);
} }
public Seq<CoreEntity> cores(){ public Seq<CoreBuild> cores(){
return state.teams.cores(this); return state.teams.cores(this);
} }
+14 -11
View File
@@ -21,15 +21,17 @@ public class Teams{
active.add(get(Team.crux)); active.add(get(Team.crux));
} }
public @Nullable CoreEntity closestEnemyCore(float x, float y, Team team){ public @Nullable
CoreBuild closestEnemyCore(float x, float y, Team team){
for(Team enemy : team.enemies()){ for(Team enemy : team.enemies()){
CoreEntity tile = Geometry.findClosest(x, y, enemy.cores()); CoreBuild tile = Geometry.findClosest(x, y, enemy.cores());
if(tile != null) return tile; if(tile != null) return tile;
} }
return null; return null;
} }
public @Nullable CoreEntity closestCore(float x, float y, Team team){ public @Nullable
CoreBuild closestCore(float x, float y, Team team){
return Geometry.findClosest(x, y, get(team).cores); return Geometry.findClosest(x, y, get(team).cores);
} }
@@ -37,10 +39,10 @@ public class Teams{
return get(team).enemies; return get(team).enemies;
} }
public boolean eachEnemyCore(Team team, Boolf<CoreEntity> ret){ public boolean eachEnemyCore(Team team, Boolf<CoreBuild> ret){
for(TeamData data : active){ for(TeamData data : active){
if(areEnemies(team, data.team)){ if(areEnemies(team, data.team)){
for(CoreEntity tile : data.cores){ for(CoreBuild tile : data.cores){
if(ret.get(tile)){ if(ret.get(tile)){
return true; return true;
} }
@@ -68,12 +70,12 @@ public class Teams{
return map[team.id]; return map[team.id];
} }
public Seq<CoreEntity> playerCores(){ public Seq<CoreBuild> playerCores(){
return get(state.rules.defaultTeam).cores; return get(state.rules.defaultTeam).cores;
} }
/** Do not modify! */ /** Do not modify! */
public Seq<CoreEntity> cores(Team team){ public Seq<CoreBuild> cores(Team team){
return get(team).cores; return get(team).cores;
} }
@@ -98,7 +100,7 @@ public class Teams{
return active; return active;
} }
public void registerCore(CoreEntity core){ public void registerCore(CoreBuild core){
TeamData data = get(core.team()); TeamData data = get(core.team());
//add core if not present //add core if not present
if(!data.cores.contains(core)){ if(!data.cores.contains(core)){
@@ -113,7 +115,7 @@ public class Teams{
} }
} }
public void unregisterCore(CoreEntity entity){ public void unregisterCore(CoreBuild entity){
TeamData data = get(entity.team()); TeamData data = get(entity.team());
//remove core //remove core
data.cores.remove(entity); data.cores.remove(entity);
@@ -143,7 +145,7 @@ public class Teams{
} }
public class TeamData{ public class TeamData{
public final Seq<CoreEntity> cores = new Seq<>(); public final Seq<CoreBuild> cores = new Seq<>();
public final Team team; public final Team team;
public final BaseAI ai; public final BaseAI ai;
public Team[] enemies = {}; public Team[] enemies = {};
@@ -166,7 +168,8 @@ public class Teams{
return cores.isEmpty(); return cores.isEmpty();
} }
public @Nullable CoreEntity core(){ public @Nullable
CoreBuild core(){
return cores.isEmpty() ? null : cores.first(); return cores.isEmpty() ? null : cores.first();
} }
+1 -1
View File
@@ -227,7 +227,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
@Remote(targets = Loc.both, called = Loc.server, forward = true) @Remote(targets = Loc.both, called = Loc.server, forward = true)
public static void unitControl(Player player, @Nullable Unit unit){ public static void unitControl(Player player, @Nullable Unit unit){
//clear player unit when they possess a core //clear player unit when they possess a core
if((unit instanceof BlockUnitc && ((BlockUnitc)unit).tile() instanceof CoreEntity)){ if((unit instanceof BlockUnitc && ((BlockUnitc)unit).tile() instanceof CoreBuild)){
Fx.spawn.at(player); Fx.spawn.at(player);
player.clearUnit(); player.clearUnit();
player.deathTimer(60f); //for instant respawn player.deathTimer(60f); //for instant respawn
+8 -8
View File
@@ -178,8 +178,8 @@ public class LExecutor{
int address = exec.numi(position); int address = exec.numi(position);
Building from = exec.building(target); Building from = exec.building(target);
if(from instanceof MemoryEntity){ if(from instanceof MemoryBuild){
MemoryEntity mem = (MemoryEntity)from; MemoryBuild mem = (MemoryBuild)from;
exec.setnum(output, address < 0 || address >= mem.memory.length ? 0 : mem.memory[address]); exec.setnum(output, address < 0 || address >= mem.memory.length ? 0 : mem.memory[address]);
} }
@@ -203,8 +203,8 @@ public class LExecutor{
int address = exec.numi(position); int address = exec.numi(position);
Building from = exec.building(target); Building from = exec.building(target);
if(from instanceof MemoryEntity){ if(from instanceof MemoryBuild){
MemoryEntity mem = (MemoryEntity)from; MemoryBuild mem = (MemoryBuild)from;
if(address >= 0 && address < mem.memory.length){ if(address >= 0 && address < mem.memory.length){
mem.memory[address] = exec.num(value); mem.memory[address] = exec.num(value);
@@ -449,8 +449,8 @@ public class LExecutor{
if(Vars.headless) return; if(Vars.headless) return;
Building build = exec.building(target); Building build = exec.building(target);
if(build instanceof LogicDisplayEntity){ if(build instanceof LogicDisplayBuild){
LogicDisplayEntity d = (LogicDisplayEntity)build; LogicDisplayBuild d = (LogicDisplayBuild)build;
for(int i = 0; i < exec.graphicsBuffer.size; i++){ for(int i = 0; i < exec.graphicsBuffer.size; i++){
d.commands.addLast(exec.graphicsBuffer.items[i]); d.commands.addLast(exec.graphicsBuffer.items[i]);
} }
@@ -504,8 +504,8 @@ public class LExecutor{
public void run(LExecutor exec){ public void run(LExecutor exec){
Building build = exec.building(target); Building build = exec.building(target);
if(build instanceof MessageBlockEntity){ if(build instanceof MessageBuild){
MessageBlockEntity d = (MessageBlockEntity)build; MessageBuild d = (MessageBuild)build;
d.message.setLength(0); d.message.setLength(0);
d.message.append(exec.textBuffer, 0, Math.min(exec.textBuffer.length(), maxTextBuffer)); d.message.append(exec.textBuffer, 0, Math.min(exec.textBuffer.length(), maxTextBuffer));
+2 -2
View File
@@ -26,7 +26,7 @@ public class CoreItemsDisplay extends Table{
margin(4); margin(4);
update(() -> { update(() -> {
CoreEntity core = Vars.player.team().core(); CoreBuild core = Vars.player.team().core();
for(Item item : content.items()){ for(Item item : content.items()){
if(core != null && core.items.get(item) > 0 && usedItems.add(item)){ if(core != null && core.items.get(item) > 0 && usedItems.add(item)){
@@ -38,7 +38,7 @@ public class CoreItemsDisplay extends Table{
int i = 0; int i = 0;
CoreEntity core = Vars.player.team().core(); CoreBuild core = Vars.player.team().core();
for(Item item : content.items()){ for(Item item : content.items()){
if(usedItems.contains(item)){ if(usedItems.contains(item)){
image(item.icon(Cicon.small)).padRight(3); image(item.icon(Cicon.small)).padRight(3);
@@ -37,7 +37,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
private int launchRange; private int launchRange;
private float zoom = 1f, selectAlpha = 1f; private float zoom = 1f, selectAlpha = 1f;
private @Nullable Sector selected, hovered, launchSector; private @Nullable Sector selected, hovered, launchSector;
private CoreEntity launcher; private CoreBuild launcher;
private Mode mode = look; private Mode mode = look;
private boolean launching; private boolean launching;
@@ -93,7 +93,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
return super.show(); return super.show();
} }
public void show(Sector sector, CoreEntity launcher){ public void show(Sector sector, CoreBuild launcher){
this.launcher = launcher; this.launcher = launcher;
selected = null; selected = null;
hovered = null; hovered = null;
@@ -50,7 +50,7 @@ public class LaunchPad extends Block{
bars.add("items", entity -> new Bar(() -> Core.bundle.format("bar.items", entity.items.total()), () -> Pal.items, () -> (float)entity.items.total() / itemCapacity)); bars.add("items", entity -> new Bar(() -> Core.bundle.format("bar.items", entity.items.total()), () -> Pal.items, () -> (float)entity.items.total() / itemCapacity));
} }
public class LaunchPadEntity extends Building{ public class LaunchPadBuild extends Building{
@Override @Override
public void draw(){ public void draw(){
super.draw(); super.draw();
@@ -1,214 +0,0 @@
package mindustry.world.blocks.campaign;
import arc.graphics.*;
import arc.graphics.g2d.*;
import arc.math.*;
import arc.scene.style.*;
import arc.scene.ui.layout.*;
import arc.util.ArcAnnotate.*;
import arc.util.*;
import arc.util.io.*;
import mindustry.annotations.Annotations.*;
import mindustry.content.*;
import mindustry.content.TechTree.*;
import mindustry.ctype.*;
import mindustry.gen.*;
import mindustry.graphics.*;
import mindustry.type.*;
import mindustry.ui.*;
import mindustry.world.*;
import mindustry.world.consumers.*;
import static mindustry.Vars.*;
public class ResearchBlock extends Block{
public float researchSpeed = 1f;
public @Load("@-top") TextureRegion topRegion;
public ResearchBlock(String name){
super(name);
update = true;
solid = true;
hasPower = true;
hasItems = true;
configurable = true;
itemCapacity = 100;
//TODO requirements shrink as time goes on
consumes.add(new ConsumeItemDynamic((ResearchBlockEntity entity) -> entity.researching != null ? entity.researching.requirements : ItemStack.empty));
config(TechNode.class, ResearchBlockEntity::setTo);
}
@Override
public boolean outputsItems(){
return false;
}
@Override
public void setBars(){
super.setBars();
bars.add("progress", (ResearchBlockEntity e) -> new Bar("bar.progress", Pal.ammo, () -> e.researching == null ? 0f : e.researching.progress / e.researching.time));
}
public class ResearchBlockEntity extends Building{
public @Nullable TechNode researching;
public double[] accumulator;
public double[] totalAccumulator;
@Override
public void updateTile(){
if(researching != null){
//don't research something that is already researched
if(researching.content.unlocked()){
setTo(null);
}else{
double totalTicks = researching.time * 60.0;
double amount = researchSpeed * edelta() / totalTicks;
double maxProgress = checkRequired(amount, false);
for(int i = 0; i < researching.requirements.length; i++){
int reqamount = Math.round(state.rules.buildCostMultiplier * researching.requirements[i].amount);
accumulator[i] += Math.min(reqamount * maxProgress, reqamount - totalAccumulator[i] + 0.00001); //add min amount progressed to the accumulator
totalAccumulator[i] = Math.min(totalAccumulator[i] + reqamount * maxProgress, reqamount);
}
maxProgress = checkRequired(maxProgress, true);
float increment = (float)(maxProgress * researching.time);
researching.progress += increment;
//check if it has been researched
if(researching.progress >= researching.time){
researching.content.unlock();
setTo(null);
}
}
}
}
private double checkRequired(double amount, boolean remove){
double maxProgress = amount;
for(int i = 0; i < researching.requirements.length; i++){
int ramount = researching.requirements[i].amount;
int required = (int)(accumulator[i]); //calculate items that are required now
if(!items.has(researching.requirements[i].item) && ramount > 0){
maxProgress = 0f;
}else if(required > 0){ //if this amount is positive...
//calculate how many items it can actually use
int maxUse = Math.min(required, items.get(researching.requirements[i].item));
//get this as a fraction
double fraction = maxUse / (double)required;
//move max progress down if this fraction is less than 1
maxProgress = Math.min(maxProgress, maxProgress * fraction);
accumulator[i] -= maxUse;
//remove stuff that is actually used
if(remove){
items.remove(researching.requirements[i].item, maxUse);
}
}
//else, no items are required yet, so just keep going
}
return maxProgress;
}
private void setTo(@Nullable TechNode value){
researching = value;
if(value != null){
accumulator = new double[researching.requirements.length];
totalAccumulator = new double[researching.requirements.length];
}
}
@Override
public void display(Table table){
super.display(table);
TextureRegionDrawable reg = new TextureRegionDrawable();
table.row();
table.table(t -> {
t.image().update(i -> {
i.setDrawable(researching == null ? Icon.cancel : reg.set(researching.content.icon(Cicon.medium)));
i.setScaling(Scaling.fit);
i.setColor(researching == null ? Color.lightGray : Color.white);
}).size(32).pad(3);
t.label(() -> researching == null ? "@none" : researching.content.localizedName).color(Color.lightGray);
}).left().padTop(4);
}
@Override
public void buildConfiguration(Table table){
}
@Override
public void draw(){
super.draw();
Draw.mixcol(Color.white, Mathf.absin(10f, 0.2f));
Draw.rect(topRegion, x, y);
Draw.reset();
}
@Override
public boolean acceptItem(Building source, Item item){
return items.get(item) < getMaximumAccepted(item);
}
@Override
public int getMaximumAccepted(Item item){
if(researching == null) return 0;
for(int i = 0; i < researching.requirements.length; i++){
if(researching.requirements[i].item == item) return researching.requirements[i].amount;
}
return 0;
}
@Override
public boolean configTapped(){
//configure with tech node
ui.showInfo("this does nothing");
//ui.research.show(node -> {
// configure(node);
// ui.research.hide();
//});
return false;
}
@Override
public void write(Writes write){
super.write(write);
if(researching != null){
write.b(researching.content.getContentType().ordinal());
write.s(researching.content.id);
}else{
write.b(-1);
}
}
@Override
public void read(Reads read, byte revision){
super.read(read, revision);
byte type = read.b();
if(type != -1){
setTo(TechTree.get(content.getByID(ContentType.all[type], read.s())));
}else{
researching = null;
}
}
}
}
@@ -14,7 +14,6 @@ import mindustry.entities.*;
import mindustry.entities.units.*; import mindustry.entities.units.*;
import mindustry.gen.*; import mindustry.gen.*;
import mindustry.logic.*; import mindustry.logic.*;
import mindustry.world.blocks.defense.Door.*;
import static mindustry.Vars.*; import static mindustry.Vars.*;
@@ -32,10 +31,10 @@ public class Door extends Wall{
solidifes = true; solidifes = true;
consumesTap = true; consumesTap = true;
config(Boolean.class, (DoorEntity base, Boolean open) -> { config(Boolean.class, (DoorBuild base, Boolean open) -> {
Sounds.door.at(base); Sounds.door.at(base);
for(DoorEntity entity : base.chained){ for(DoorBuild entity : base.chained){
//skip doors with things in them //skip doors with things in them
if((Units.anyEntities(entity.tile) && !open) || entity.open == open){ if((Units.anyEntities(entity.tile) && !open) || entity.open == open){
continue; continue;
@@ -53,9 +52,9 @@ public class Door extends Wall{
return req.config == Boolean.TRUE ? openRegion : region; return req.config == Boolean.TRUE ? openRegion : region;
} }
public class DoorEntity extends Building{ public class DoorBuild extends Building{
public boolean open = false; public boolean open = false;
public ObjectSet<DoorEntity> chained = new ObjectSet<>(); public ObjectSet<DoorBuild> chained = new ObjectSet<>();
@Override @Override
public void onProximityAdded(){ public void onProximityAdded(){
@@ -68,8 +67,8 @@ public class Door extends Wall{
super.onProximityRemoved(); super.onProximityRemoved();
for(Building b : proximity){ for(Building b : proximity){
if(b instanceof DoorEntity){ if(b instanceof DoorBuild){
((DoorEntity)b).updateChained(); ((DoorBuild)b).updateChained();
} }
} }
} }
@@ -96,14 +95,14 @@ public class Door extends Wall{
flow(chained); flow(chained);
} }
public void flow(ObjectSet<DoorEntity> set){ public void flow(ObjectSet<DoorBuild> set){
if(!set.add(this)) return; if(!set.add(this)) return;
this.chained = set; this.chained = set;
for(Building b : proximity){ for(Building b : proximity){
if(b instanceof DoorEntity){ if(b instanceof DoorBuild){
((DoorEntity)b).flow(set); ((DoorBuild)b).flow(set);
} }
} }
} }
@@ -56,7 +56,7 @@ public class Wall extends Block{
return super.canReplace(other) && health > other.health && size == other.size; return super.canReplace(other) && health > other.health && size == other.size;
} }
public class WallEntity extends Building{ public class WallBuild extends Building{
public float hit; public float hit;
@Override @Override
@@ -19,7 +19,7 @@ public class ChargeTurret extends PowerTurret{
super(name); super(name);
} }
public class ChargeTurretEntity extends PowerTurretEntity{ public class ChargeTurretBuild extends PowerTurretBuild{
public boolean shooting; public boolean shooting;
@Override @Override
@@ -43,7 +43,7 @@ public class ItemTurret extends Turret{
public void build(Building tile, Table table){ public void build(Building tile, Table table){
MultiReqImage image = new MultiReqImage(); MultiReqImage image = new MultiReqImage();
content.items().each(i -> filter.get(i) && i.unlockedNow(), item -> image.add(new ReqImage(new ItemImage(item.icon(Cicon.medium)), content.items().each(i -> filter.get(i) && i.unlockedNow(), item -> image.add(new ReqImage(new ItemImage(item.icon(Cicon.medium)),
() -> tile != null && !((ItemTurretEntity)tile).ammo.isEmpty() && ((ItemEntry)((ItemTurretEntity)tile).ammo.peek()).item == item))); () -> tile != null && !((ItemTurretBuild)tile).ammo.isEmpty() && ((ItemEntry)((ItemTurretBuild)tile).ammo.peek()).item == item)));
table.add(image).size(8 * 4); table.add(image).size(8 * 4);
} }
@@ -51,7 +51,7 @@ public class ItemTurret extends Turret{
@Override @Override
public boolean valid(Building entity){ public boolean valid(Building entity){
//valid when there's any ammo in the turret //valid when there's any ammo in the turret
return !((ItemTurretEntity)entity).ammo.isEmpty(); return !((ItemTurretBuild)entity).ammo.isEmpty();
} }
@Override @Override
@@ -61,7 +61,7 @@ public class ItemTurret extends Turret{
}); });
} }
public class ItemTurretEntity extends TurretEntity{ public class ItemTurretBuild extends TurretBuild{
@Override @Override
public void onProximityAdded(){ public void onProximityAdded(){
super.onProximityAdded(); super.onProximityAdded();
@@ -25,7 +25,7 @@ public class LaserTurret extends PowerTurret{
@Override @Override
public void init(){ public void init(){
consumes.powerCond(powerUse, entity -> ((LaserTurretEntity)entity).bullet != null || ((LaserTurretEntity)entity).target != null); consumes.powerCond(powerUse, entity -> ((LaserTurretBuild)entity).bullet != null || ((LaserTurretBuild)entity).target != null);
super.init(); super.init();
} }
@@ -40,7 +40,7 @@ public class LaserTurret extends PowerTurret{
stats.add(BlockStat.damage, shootType.damage * 60f / 5f, StatUnit.perSecond); stats.add(BlockStat.damage, shootType.damage * 60f / 5f, StatUnit.perSecond);
} }
public class LaserTurretEntity extends PowerTurretEntity{ public class LaserTurretBuild extends PowerTurretBuild{
Bullet bullet; Bullet bullet;
float bulletLife; float bulletLife;
@@ -53,7 +53,7 @@ public class LiquidTurret extends Turret{
}); });
} }
public class LiquidTurretEntity extends TurretEntity{ public class LiquidTurretBuild extends TurretBuild{
@Override @Override
public void draw(){ public void draw(){
@@ -22,11 +22,11 @@ public class PowerTurret extends Turret{
@Override @Override
public void init(){ public void init(){
consumes.powerCond(powerUse, entity -> ((TurretEntity)entity).target != null); consumes.powerCond(powerUse, entity -> ((TurretBuild)entity).target != null);
super.init(); super.init();
} }
public class PowerTurretEntity extends TurretEntity{ public class PowerTurretBuild extends TurretBuild{
@Override @Override
public BulletType useAmmo(){ public BulletType useAmmo(){
@@ -74,8 +74,8 @@ public abstract class Turret extends Block{
public @Load("block-@size") TextureRegion baseRegion; public @Load("block-@size") TextureRegion baseRegion;
public @Load("@-heat") TextureRegion heatRegion; public @Load("@-heat") TextureRegion heatRegion;
public Cons<TurretEntity> drawer = tile -> Draw.rect(region, tile.x + tr2.x, tile.y + tr2.y, tile.rotation - 90); public Cons<TurretBuild> drawer = tile -> Draw.rect(region, tile.x + tr2.x, tile.y + tr2.y, tile.rotation - 90);
public Cons<TurretEntity> heatDrawer = tile -> { public Cons<TurretBuild> heatDrawer = tile -> {
if(tile.heat <= 0.00001f) return; if(tile.heat <= 0.00001f) return;
Draw.color(heatColor, tile.heat); Draw.color(heatColor, tile.heat);
Draw.blend(Blending.additive); Draw.blend(Blending.additive);
@@ -141,7 +141,7 @@ public abstract class Turret extends Block{
public abstract BulletType type(); public abstract BulletType type();
} }
public class TurretEntity extends Building implements ControlBlock, Ranged{ public class TurretBuild extends Building implements ControlBlock, Ranged{
public Seq<AmmoEntry> ammo = new Seq<>(); public Seq<AmmoEntry> ammo = new Seq<>();
public int totalAmmo; public int totalAmmo;
public float reload, rotation = 90, recoil, heat, logicControlTime = -1; public float reload, rotation = 90, recoil, heat, logicControlTime = -1;
@@ -15,7 +15,7 @@ public class ArmoredConveyor extends Conveyor{
return otherblock.outputsItems() && blendsArmored(tile, rotation, otherx, othery, otherrot, otherblock); return otherblock.outputsItems() && blendsArmored(tile, rotation, otherx, othery, otherrot, otherblock);
} }
public class ArmoredConveyorEntity extends ConveyorEntity{ public class ArmoredConveyorBuild extends ConveyorBuild{
@Override @Override
public boolean acceptItem(Building source, Item item){ public boolean acceptItem(Building source, Item item){
return super.acceptItem(source, item) && (source.block() instanceof Conveyor || Edges.getFacingEdge(source.tile(), tile).relativeTo(tile) == rotation); return super.acceptItem(source, item) && (source.block() instanceof Conveyor || Edges.getFacingEdge(source.tile(), tile).relativeTo(tile) == rotation);
@@ -19,7 +19,7 @@ public class BufferedItemBridge extends ExtendingItemBridge{
canOverdrive = true; canOverdrive = true;
} }
public class BufferedItemBridgeEntity extends ExtendingItemBridgeEntity{ public class BufferedItemBridgeBuild extends ExtendingItemBridgeBuild{
ItemBuffer buffer = new ItemBuffer(bufferCapacity); ItemBuffer buffer = new ItemBuffer(bufferCapacity);
@Override @Override
@@ -92,7 +92,7 @@ public class Conveyor extends Block implements Autotiler{
Mathf.mod(req.tile().build.rotation - req.rotation, 2) == 1 ? Blocks.junction : this; Mathf.mod(req.tile().build.rotation - req.rotation, 2) == 1 ? Blocks.junction : this;
} }
public class ConveyorEntity extends Building{ public class ConveyorBuild extends Building{
//parallel array data //parallel array data
public Item[] ids = new Item[capacity]; public Item[] ids = new Item[capacity];
public float[] xs = new float[capacity]; public float[] xs = new float[capacity];
@@ -101,7 +101,7 @@ public class Conveyor extends Block implements Autotiler{
public int len = 0; public int len = 0;
//next entity //next entity
public @Nullable Building next; public @Nullable Building next;
public @Nullable ConveyorEntity nextc; public @Nullable ConveyorBuild nextc;
//whether the next conveyor's rotation == tile rotation //whether the next conveyor's rotation == tile rotation
public boolean aligned; public boolean aligned;
@@ -163,7 +163,7 @@ public class Conveyor extends Block implements Autotiler{
if(front() != null && front() != null){ if(front() != null && front() != null){
next = front(); next = front();
nextc = next instanceof ConveyorEntity && next.team() == team ? (ConveyorEntity)next : null; nextc = next instanceof ConveyorBuild && next.team() == team ? (ConveyorBuild)next : null;
aligned = nextc != null && rotation == next.rotation; aligned = nextc != null && rotation == next.rotation;
} }
} }
@@ -16,7 +16,7 @@ public class ExtendingItemBridge extends ItemBridge{
hasItems = true; hasItems = true;
} }
public class ExtendingItemBridgeEntity extends ItemBridgeEntity{ public class ExtendingItemBridgeBuild extends ItemBridgeBuild{
@Override @Override
public void draw(){ public void draw(){
Draw.rect(region, x, y); Draw.rect(region, x, y);
@@ -44,9 +44,9 @@ public class ItemBridge extends Block{
canOverdrive = false; canOverdrive = false;
//point2 config is relative //point2 config is relative
config(Point2.class, (ItemBridgeEntity tile, Point2 i) -> tile.link = Point2.pack(i.x + tile.tileX(), i.y + tile.tileY())); config(Point2.class, (ItemBridgeBuild tile, Point2 i) -> tile.link = Point2.pack(i.x + tile.tileX(), i.y + tile.tileY()));
//integer is not //integer is not
config(Integer.class, (ItemBridgeEntity tile, Integer i) -> tile.link = i); config(Integer.class, (ItemBridgeBuild tile, Integer i) -> tile.link = i);
} }
@Override @Override
@@ -114,7 +114,7 @@ public class ItemBridge extends Block{
return ((other.block() == tile.block() && tile.block() == this) || (!(tile.block() instanceof ItemBridge) && other.block() == this)) return ((other.block() == tile.block() && tile.block() == this) || (!(tile.block() instanceof ItemBridge) && other.block() == this))
&& (other.team() == tile.team() || tile.block() != this) && (other.team() == tile.team() || tile.block() != this)
&& (!checkDouble || other.<ItemBridgeEntity>bc().link != tile.pos()); && (!checkDouble || other.<ItemBridgeBuild>bc().link != tile.pos());
} }
public Tile findLink(int x, int y){ public Tile findLink(int x, int y){
@@ -124,7 +124,7 @@ public class ItemBridge extends Block{
return null; return null;
} }
public class ItemBridgeEntity extends Building{ public class ItemBridgeBuild extends Building{
public int link = -1; public int link = -1;
public IntSet incoming = new IntSet(); public IntSet incoming = new IntSet();
public float uptime; public float uptime;
@@ -208,7 +208,7 @@ public class ItemBridge extends Block{
@Override @Override
public boolean onConfigureTileTapped(Building other){ public boolean onConfigureTileTapped(Building other){
//reverse connection //reverse connection
if(other instanceof ItemBridgeEntity && ((ItemBridgeEntity)other).link == pos()){ if(other instanceof ItemBridgeBuild && ((ItemBridgeBuild)other).link == pos()){
configure(other.pos()); configure(other.pos());
other.configure(-1); other.configure(-1);
return true; return true;
@@ -230,7 +230,7 @@ public class ItemBridge extends Block{
while(it.hasNext){ while(it.hasNext){
int i = it.next(); int i = it.next();
Tile other = world.tile(i); Tile other = world.tile(i);
if(!linkValid(tile, other, false) || other.<ItemBridgeEntity>bc().link != tile.pos()){ if(!linkValid(tile, other, false) || other.<ItemBridgeBuild>bc().link != tile.pos()){
it.remove(); it.remove();
} }
} }
@@ -248,7 +248,7 @@ public class ItemBridge extends Block{
dump(); dump();
uptime = 0f; uptime = 0f;
}else{ }else{
((ItemBridgeEntity)other.build).incoming.add(tile.pos()); ((ItemBridgeBuild)other.build).incoming.add(tile.pos());
if(consValid() && Mathf.zero(1f - efficiency())){ if(consValid() && Mathf.zero(1f - efficiency())){
uptime = Mathf.lerpDelta(uptime, 1f, 0.04f); uptime = Mathf.lerpDelta(uptime, 1f, 0.04f);
@@ -358,7 +358,7 @@ public class ItemBridge extends Block{
} }
protected boolean linked(Building source){ protected boolean linked(Building source){
return source instanceof ItemBridgeEntity && linkValid(source.tile(), tile) && ((ItemBridgeEntity)source).link == pos(); return source instanceof ItemBridgeBuild && linkValid(source.tile(), tile) && ((ItemBridgeBuild)source).link == pos();
} }
@Override @Override
@@ -26,7 +26,7 @@ public class Junction extends Block{
return true; return true;
} }
public class JunctionEntity extends Building{ public class JunctionBuild extends Building{
public DirectionalItemBuffer buffer = new DirectionalItemBuffer(capacity); public DirectionalItemBuffer buffer = new DirectionalItemBuffer(capacity);
@Override @Override
@@ -42,8 +42,8 @@ public class MassDriver extends Block{
hasPower = true; hasPower = true;
outlineIcon = true; outlineIcon = true;
//point2 is relative //point2 is relative
config(Point2.class, (MassDriverEntity tile, Point2 point) -> tile.link = Point2.pack(point.x + tile.tileX(), point.y + tile.tileY())); config(Point2.class, (MassDriverBuild tile, Point2 point) -> tile.link = Point2.pack(point.x + tile.tileX(), point.y + tile.tileY()));
config(Integer.class, (MassDriverEntity tile, Integer point) -> tile.link = point); config(Integer.class, (MassDriverBuild tile, Integer point) -> tile.link = point);
} }
@Override @Override
@@ -75,7 +75,7 @@ public class MassDriver extends Block{
} }
public class DriverBulletData implements Poolable{ public class DriverBulletData implements Poolable{
public MassDriverEntity from, to; public MassDriverBuild from, to;
public int[] items = new int[content.items().size]; public int[] items = new int[content.items().size];
@Override @Override
@@ -85,7 +85,7 @@ public class MassDriver extends Block{
} }
} }
public class MassDriverEntity extends Building{ public class MassDriverBuild extends Building{
public int link = -1; public int link = -1;
public float rotation = 90; public float rotation = 90;
public float reload = 0f; public float reload = 0f;
@@ -153,7 +153,7 @@ public class MassDriver extends Block{
items.total() >= minDistribute && //must shoot minimum amount of items items.total() >= minDistribute && //must shoot minimum amount of items
link.block().itemCapacity - link.items.total() >= minDistribute //must have minimum amount of space link.block().itemCapacity - link.items.total() >= minDistribute //must have minimum amount of space
){ ){
MassDriverEntity other = (MassDriverEntity)link; MassDriverBuild other = (MassDriverBuild)link;
other.waitingShooters.add(tile); other.waitingShooters.add(tile);
if(reload <= 0.0001f){ if(reload <= 0.0001f){
@@ -235,7 +235,7 @@ public class MassDriver extends Block{
return items.total() < itemCapacity && linkValid(); return items.total() < itemCapacity && linkValid();
} }
protected void fire(MassDriverEntity target){ protected void fire(MassDriverBuild target){
//reset reload, use power. //reset reload, use power.
reload = 1f; reload = 1f;
@@ -290,7 +290,7 @@ public class MassDriver extends Block{
protected boolean shooterValid(Tile other){ protected boolean shooterValid(Tile other){
if(other == null) return true; if(other == null) return true;
if(!(other.block() instanceof MassDriver)) return false; if(!(other.block() instanceof MassDriver)) return false;
MassDriverEntity entity = other.bc(); MassDriverBuild entity = other.bc();
return entity.link == tile.pos() && tile.dst(other) <= range; return entity.link == tile.pos() && tile.dst(other) <= range;
} }
@@ -30,7 +30,7 @@ public class OverflowGate extends Block{
return true; return true;
} }
public class OverflowGateEntity extends Building{ public class OverflowGateBuild extends Building{
public Item lastItem; public Item lastItem;
public Tile lastInput; public Tile lastInput;
public float time; public float time;
@@ -48,7 +48,7 @@ public class PayloadConveyor extends Block{
} }
} }
public class PayloadConveyorEntity extends Building{ public class PayloadConveyorBuild extends Building{
public @Nullable Payload item; public @Nullable Payload item;
public float progress, itemRotation, animation; public float progress, itemRotation, animation;
public @Nullable Building next; public @Nullable Building next;
@@ -24,7 +24,7 @@ public class PayloadRouter extends PayloadConveyor{
Draw.rect(overRegion, req.drawx(), req.drawy()); Draw.rect(overRegion, req.drawx(), req.drawy());
} }
public class PayloadRouterEntity extends PayloadConveyorEntity{ public class PayloadRouterBuild extends PayloadConveyorBuild{
public float smoothRot; public float smoothRot;
@Override @Override
@@ -20,7 +20,7 @@ public class Router extends Block{
noUpdateDisabled = true; noUpdateDisabled = true;
} }
public class RouterEntity extends Building{ public class RouterBuild extends Building{
public Item lastItem; public Item lastItem;
public Tile lastInput; public Tile lastInput;
public float time; public float time;
@@ -28,8 +28,8 @@ public class Sorter extends Block{
unloadable = false; unloadable = false;
saveConfig = true; saveConfig = true;
config(Item.class, (SorterEntity tile, Item item) -> tile.sortItem = item); config(Item.class, (SorterBuild tile, Item item) -> tile.sortItem = item);
configClear((SorterEntity tile) -> tile.sortItem = null); configClear((SorterBuild tile) -> tile.sortItem = null);
} }
@Override @Override
@@ -44,10 +44,10 @@ public class Sorter extends Block{
@Override @Override
public int minimapColor(Tile tile){ public int minimapColor(Tile tile){
return tile.<SorterEntity>bc().sortItem == null ? 0 : tile.<SorterEntity>bc().sortItem.color.rgba(); return tile.<SorterBuild>bc().sortItem == null ? 0 : tile.<SorterBuild>bc().sortItem.color.rgba();
} }
public class SorterEntity extends Building{ public class SorterBuild extends Building{
public @Nullable Item sortItem; public @Nullable Item sortItem;
@Override @Override
@@ -52,16 +52,16 @@ public class StackConveyor extends Block implements Autotiler{
@Override @Override
public boolean blends(Tile tile, int rotation, int otherx, int othery, int otherrot, Block otherblock){ public boolean blends(Tile tile, int rotation, int otherx, int othery, int otherrot, Block otherblock){
if(tile.build instanceof StackConveyorEntity){ if(tile.build instanceof StackConveyorBuild){
int state = ((StackConveyorEntity)tile.build).state; int state = ((StackConveyorBuild)tile.build).state;
if(state == stateLoad){ //standard conveyor mode if(state == stateLoad){ //standard conveyor mode
return otherblock.outputsItems() && lookingAtEither(tile, rotation, otherx, othery, otherrot, otherblock); return otherblock.outputsItems() && lookingAtEither(tile, rotation, otherx, othery, otherrot, otherblock);
}else if(state == stateUnload){ //router mode }else if(state == stateUnload){ //router mode
return otherblock.acceptsItems && return otherblock.acceptsItems &&
(notLookingAt(tile, rotation, otherx, othery, otherrot, otherblock) || (notLookingAt(tile, rotation, otherx, othery, otherrot, otherblock) ||
(otherblock instanceof StackConveyor && facing(otherx, othery, otherrot, tile.x, tile.y))) && (otherblock instanceof StackConveyor && facing(otherx, othery, otherrot, tile.x, tile.y))) &&
!(world.build(otherx, othery) instanceof StackConveyorEntity && ((StackConveyorEntity)world.build(otherx, othery)).state == stateUnload) && !(world.build(otherx, othery) instanceof StackConveyorBuild && ((StackConveyorBuild)world.build(otherx, othery)).state == stateUnload) &&
!(world.build(otherx, othery) instanceof StackConveyorEntity && ((StackConveyorEntity)world.build(otherx, othery)).state == stateMove && !(world.build(otherx, othery) instanceof StackConveyorBuild && ((StackConveyorBuild)world.build(otherx, othery)).state == stateMove &&
!facing(otherx, othery, otherrot, tile.x, tile.y)); !facing(otherx, othery, otherrot, tile.x, tile.y));
} }
} }
@@ -87,13 +87,13 @@ public class StackConveyor extends Block implements Autotiler{
@Override @Override
public boolean rotatedOutput(int x, int y){ public boolean rotatedOutput(int x, int y){
Building tile = world.build(x, y); Building tile = world.build(x, y);
if(tile instanceof StackConveyorEntity){ if(tile instanceof StackConveyorBuild){
return ((StackConveyorEntity)tile).state != stateUnload; return ((StackConveyorBuild)tile).state != stateUnload;
} }
return super.rotatedOutput(x, y); return super.rotatedOutput(x, y);
} }
public class StackConveyorEntity extends Building{ public class StackConveyorBuild extends Building{
public int state, blendprox; public int state, blendprox;
public int link = -1; public int link = -1;
@@ -159,10 +159,10 @@ public class StackConveyor extends Block implements Autotiler{
//update other conveyor state when this conveyor's state changes //update other conveyor state when this conveyor's state changes
if(state != lastState){ if(state != lastState){
for(Building near : proximity){ for(Building near : proximity){
if(near instanceof StackConveyorEntity){ if(near instanceof StackConveyorBuild){
near.onProximityUpdate(); near.onProximityUpdate();
for(Building other : near.proximity){ for(Building other : near.proximity){
if(!(other instanceof StackConveyorEntity)) other.onProximityUpdate(); if(!(other instanceof StackConveyorBuild)) other.onProximityUpdate();
} }
} }
} }
@@ -195,7 +195,7 @@ public class StackConveyor extends Block implements Autotiler{
if(front() != null if(front() != null
&& front().team == team && front().team == team
&& front().block instanceof StackConveyor){ && front().block instanceof StackConveyor){
StackConveyorEntity e = (StackConveyorEntity)front(); StackConveyorBuild e = (StackConveyorBuild)front();
// sleep if its occupied // sleep if its occupied
if(e.link == -1){ if(e.link == -1){
@@ -33,16 +33,16 @@ public class BlockForge extends PayloadAcceptor{
hasPower = true; hasPower = true;
rotate = true; rotate = true;
config(Block.class, (BlockForgeEntity tile, Block block) -> tile.recipe = block); config(Block.class, (BlockForgeBuild tile, Block block) -> tile.recipe = block);
consumes.add(new ConsumeItemDynamic((BlockForgeEntity e) -> e.recipe != null ? e.recipe.requirements : ItemStack.empty)); consumes.add(new ConsumeItemDynamic((BlockForgeBuild e) -> e.recipe != null ? e.recipe.requirements : ItemStack.empty));
} }
@Override @Override
public void setBars(){ public void setBars(){
super.setBars(); super.setBars();
bars.add("progress", entity -> new Bar("bar.progress", Pal.ammo, () -> ((BlockForgeEntity)entity).progress)); bars.add("progress", entity -> new Bar("bar.progress", Pal.ammo, () -> ((BlockForgeBuild)entity).progress));
} }
@Override @Override
@@ -51,7 +51,7 @@ public class BlockForge extends PayloadAcceptor{
Draw.rect(outRegion, req.drawx(), req.drawy(), req.rotation * 90); Draw.rect(outRegion, req.drawx(), req.drawy(), req.rotation * 90);
} }
public class BlockForgeEntity extends PayloadAcceptorEntity<BlockPayload>{ public class BlockForgeBuild extends PayloadAcceptorBuild<BlockPayload>{
public @Nullable Block recipe; public @Nullable Block recipe;
public float progress, time, heat; public float progress, time, heat;
@@ -40,7 +40,7 @@ public class BlockLoader extends PayloadAcceptor{
public void setBars(){ public void setBars(){
super.setBars(); super.setBars();
bars.add("progress", entity -> new Bar("bar.progress", Pal.ammo, ((BlockLoaderEntity)entity)::fraction)); bars.add("progress", entity -> new Bar("bar.progress", Pal.ammo, ((BlockLoaderBuild)entity)::fraction));
} }
@Override @Override
@@ -50,7 +50,7 @@ public class BlockLoader extends PayloadAcceptor{
Draw.rect(topRegion, req.drawx(), req.drawy()); Draw.rect(topRegion, req.drawx(), req.drawy());
} }
public class BlockLoaderEntity extends PayloadAcceptorEntity<BlockPayload>{ public class BlockLoaderBuild extends PayloadAcceptorBuild<BlockPayload>{
@Override @Override
public boolean acceptPayload(Building source, Payload payload){ public boolean acceptPayload(Building source, Payload payload){
@@ -16,7 +16,7 @@ public class BlockUnloader extends BlockLoader{
return true; return true;
} }
public class BlockUnloaderEntity extends BlockLoaderEntity{ public class BlockUnloaderBuild extends BlockLoaderBuild{
@Override @Override
public boolean acceptItem(Building source, Item item){ public boolean acceptItem(Building source, Item item){
@@ -10,7 +10,7 @@ public class LegacyCommandCenter extends LegacyBlock{
update = true; update = true;
} }
public class LegacyCommandCenterEntity extends Building{ public class LegacyCommandCenterBuild extends Building{
@Override @Override
public void read(Reads read, byte revision){ public void read(Reads read, byte revision){
super.read(read, revision); super.read(read, revision);
@@ -11,7 +11,7 @@ public class LegacyMechPad extends LegacyBlock{
hasPower = true; hasPower = true;
} }
public class LegacyMechPadEntity extends Building{ public class LegacyMechPadBuild extends Building{
@Override @Override
public void read(Reads read, byte revision){ public void read(Reads read, byte revision){
@@ -13,7 +13,7 @@ public class LegacyUnitFactory extends LegacyBlock{
solid = false; solid = false;
} }
public class LegacyUnitFactoryEntity extends Building{ public class LegacyUnitFactoryBuild extends Building{
@Override @Override
public void read(Reads read, byte revision){ public void read(Reads read, byte revision){
@@ -19,7 +19,7 @@ public class ArmoredConduit extends Conduit{
return otherblock.outputsLiquid && blendsArmored(tile, rotation, otherx, othery, otherrot, otherblock); return otherblock.outputsLiquid && blendsArmored(tile, rotation, otherx, othery, otherrot, otherblock);
} }
public class ArmoredConduitEntity extends ConduitEntity{ public class ArmoredConduitBuild extends ConduitBuild{
@Override @Override
public void draw(){ public void draw(){
super.draw(); super.draw();
@@ -72,7 +72,7 @@ public class Conduit extends LiquidBlock implements Autotiler{
return new TextureRegion[]{Core.atlas.find("conduit-bottom"), topRegions[0]}; return new TextureRegion[]{Core.atlas.find("conduit-bottom"), topRegions[0]};
} }
public class ConduitEntity extends LiquidBlockEntity{ public class ConduitBuild extends LiquidBuild{
public float smoothLiquid; public float smoothLiquid;
public int blendbits, xscl, yscl, blending; public int blendbits, xscl, yscl, blending;
@@ -25,7 +25,7 @@ public class LiquidBlock extends Block{
return new TextureRegion[]{bottomRegion, topRegion}; return new TextureRegion[]{bottomRegion, topRegion};
} }
public class LiquidBlockEntity extends Building{ public class LiquidBuild extends Building{
@Override @Override
public void draw(){ public void draw(){
float rotation = rotate ? rotdeg() : 0; float rotation = rotate ? rotdeg() : 0;
@@ -18,7 +18,7 @@ public class LiquidBridge extends ItemBridge{
group = BlockGroup.liquids; group = BlockGroup.liquids;
} }
public class LiquidBridgeEntity extends ItemBridgeEntity{ public class LiquidBridgeBuild extends ItemBridgeBuild{
@Override @Override
public void updateTile(){ public void updateTile(){
time += cycleSpeed * delta(); time += cycleSpeed * delta();
@@ -30,7 +30,7 @@ public class LiquidBridge extends ItemBridge{
if(other == null || !linkValid(tile, other.tile())){ if(other == null || !linkValid(tile, other.tile())){
dumpLiquid(liquids.current()); dumpLiquid(liquids.current());
}else{ }else{
((ItemBridgeEntity)other).incoming.add(tile.pos()); ((ItemBridgeBuild)other).incoming.add(tile.pos());
if(consValid()){ if(consValid()){
float alpha = 0.04f; float alpha = 0.04f;
@@ -18,7 +18,7 @@ public class LiquidExtendingBridge extends ExtendingItemBridge{
group = BlockGroup.liquids; group = BlockGroup.liquids;
} }
public class LiquidExtendingBridgeEntity extends ExtendingItemBridgeEntity{ public class LiquidExtendingBridgeBuild extends ExtendingItemBridgeBuild{
@Override @Override
public void updateTile(){ public void updateTile(){
time += cycleSpeed * delta(); time += cycleSpeed * delta();
@@ -30,7 +30,7 @@ public class LiquidExtendingBridge extends ExtendingItemBridge{
if(other == null || !linkValid(tile, other.tile())){ if(other == null || !linkValid(tile, other.tile())){
dumpLiquid(liquids.current()); dumpLiquid(liquids.current());
}else{ }else{
((ItemBridgeEntity)other).incoming.add(tile.pos()); ((ItemBridgeBuild)other).incoming.add(tile.pos());
if(consValid()){ if(consValid()){
uptime = Mathf.lerpDelta(uptime, 1f, 0.04f); uptime = Mathf.lerpDelta(uptime, 1f, 0.04f);
@@ -28,7 +28,7 @@ public class LiquidJunction extends LiquidBlock{
return new TextureRegion[]{region}; return new TextureRegion[]{region};
} }
public class LiquidJunctionEntity extends Building{ public class LiquidJunctionBuild extends Building{
@Override @Override
public void draw(){ public void draw(){
Draw.rect(region, x, y); Draw.rect(region, x, y);
@@ -9,7 +9,7 @@ public class LiquidRouter extends LiquidBlock{
super(name); super(name);
} }
public class LiquidRouterEntity extends LiquidBlockEntity{ public class LiquidRouterEntity extends LiquidBuild{
@Override @Override
public void updateTile(){ public void updateTile(){
if(liquids.total() > 0.01f){ if(liquids.total() > 0.01f){
@@ -30,7 +30,7 @@ public class LogicBlock extends Block{
update = true; update = true;
configurable = true; configurable = true;
config(String.class, (LogicEntity entity, String value) -> { config(String.class, (LogicBuild entity, String value) -> {
if(value.startsWith("{")){ //it's json if(value.startsWith("{")){ //it's json
try{ try{
LogicConfig conf = JsonIO.read(LogicConfig.class, value); LogicConfig conf = JsonIO.read(LogicConfig.class, value);
@@ -49,7 +49,7 @@ public class LogicBlock extends Block{
} }
}); });
config(Integer.class, (LogicEntity entity, Integer pos) -> { config(Integer.class, (LogicBuild entity, Integer pos) -> {
if(entity.connections.contains(pos)){ if(entity.connections.contains(pos)){
entity.connections.removeValue(pos); entity.connections.removeValue(pos);
}else{ }else{
@@ -60,7 +60,7 @@ public class LogicBlock extends Block{
}); });
} }
public class LogicEntity extends Building{ public class LogicBuild extends Building{
/** logic "source code" as list of asm statements */ /** logic "source code" as list of asm statements */
public String code = ""; public String code = "";
public LExecutor executor = new LExecutor(); public LExecutor executor = new LExecutor();
@@ -30,16 +30,12 @@ public class LogicDisplay extends Block{
update = true; update = true;
} }
public class LogicDisplayEntity extends Building{ public class LogicDisplayBuild extends Building{
public FrameBuffer buffer; public FrameBuffer buffer;
public float color = Color.whiteFloatBits; public float color = Color.whiteFloatBits;
public float stroke = 1f; public float stroke = 1f;
public LongQueue commands = new LongQueue(); public LongQueue commands = new LongQueue();
public LogicDisplayEntity(){
}
@Override @Override
public void draw(){ public void draw(){
super.draw(); super.draw();
@@ -12,7 +12,7 @@ public class MemoryBlock extends Block{
destructible = true; destructible = true;
} }
public class MemoryEntity extends Building{ public class MemoryBuild extends Building{
public double[] memory = new double[memoryCapacity]; public double[] memory = new double[memoryCapacity];
@Override @Override
@@ -29,7 +29,7 @@ public class MessageBlock extends Block{
solid = true; solid = true;
destructible = true; destructible = true;
config(String.class, (MessageBlockEntity tile, String text) -> { config(String.class, (MessageBuild tile, String text) -> {
if(net.server() && text.length() > maxTextLength){ if(net.server() && text.length() > maxTextLength){
throw new ValidateException(player, "Player has gone above text limit."); throw new ValidateException(player, "Player has gone above text limit.");
} }
@@ -53,7 +53,7 @@ public class MessageBlock extends Block{
}); });
} }
public class MessageBlockEntity extends Building{ public class MessageBuild extends Building{
public StringBuilder message = new StringBuilder(); public StringBuilder message = new StringBuilder();
@Override @Override
@@ -14,10 +14,10 @@ public class SwitchBlock extends Block{
configurable = true; configurable = true;
update = true; update = true;
config(Boolean.class, (ButtonEntity entity, Boolean b) -> entity.on = b); config(Boolean.class, (SwitchBuild entity, Boolean b) -> entity.on = b);
} }
public class ButtonEntity extends Building{ public class SwitchBuild extends Building{
public boolean on; public boolean on;
@Override @Override
@@ -19,7 +19,7 @@ public class Battery extends PowerDistributor{
consumesPower = true; consumesPower = true;
} }
public class BatteryEntity extends Building{ public class BatteryBuild extends Building{
@Override @Override
public void draw(){ public void draw(){
Draw.color(emptyLightColor, fullLightColor, power.status); Draw.color(emptyLightColor, fullLightColor, power.status);
@@ -28,7 +28,7 @@ public class BurnerGenerator extends ItemLiquidGenerator{
return turbineRegions[0].found() ? new TextureRegion[]{region, turbineRegions[0], turbineRegions[1], capRegion} : super.icons(); return turbineRegions[0].found() ? new TextureRegion[]{region, turbineRegions[0], turbineRegions[1], capRegion} : super.icons();
} }
public class BurnerGeneratorEntity extends ItemLiquidGeneratorEntity{ public class BurnerGeneratorBuild extends ItemLiquidGeneratorBuild{
@Override @Override
public void draw(){ public void draw(){
@@ -43,7 +43,7 @@ public class ImpactReactor extends PowerGenerator{
public void setBars(){ public void setBars(){
super.setBars(); super.setBars();
bars.add("poweroutput", (GeneratorEntity entity) -> new Bar(() -> bars.add("poweroutput", (GeneratorBuild entity) -> new Bar(() ->
Core.bundle.format("bar.poweroutput", Core.bundle.format("bar.poweroutput",
Strings.fixed(Math.max(entity.getPowerProduction() - consumes.getPower().usage, 0) * 60 * entity.timeScale(), 1)), Strings.fixed(Math.max(entity.getPowerProduction() - consumes.getPower().usage, 0) * 60 * entity.timeScale(), 1)),
() -> Pal.powerBar, () -> Pal.powerBar,
@@ -64,7 +64,7 @@ public class ImpactReactor extends PowerGenerator{
return new TextureRegion[]{bottomRegion, region}; return new TextureRegion[]{bottomRegion, region};
} }
public class FusionReactorEntity extends GeneratorEntity{ public class FusionReactorBuild extends GeneratorBuild{
public float warmup; public float warmup;
@@ -84,7 +84,7 @@ public class ItemLiquidGenerator extends PowerGenerator{
return 0.0f; return 0.0f;
} }
public class ItemLiquidGeneratorEntity extends GeneratorEntity{ public class ItemLiquidGeneratorBuild extends GeneratorBuild{
public float explosiveness, heat, totalTime; public float explosiveness, heat, totalTime;
@Override @Override
@@ -25,10 +25,10 @@ public class LightBlock extends Block{
configurable = true; configurable = true;
saveConfig = true; saveConfig = true;
config(Integer.class, (LightEntity tile, Integer value) -> tile.color = value); config(Integer.class, (LightBuild tile, Integer value) -> tile.color = value);
} }
public class LightEntity extends Building{ public class LightBuild extends Building{
public int color = Pal.accent.rgba(); public int color = Pal.accent.rgba();
public float smoothTime = 1f; public float smoothTime = 1f;
@@ -61,10 +61,10 @@ public class NuclearReactor extends PowerGenerator{
@Override @Override
public void setBars(){ public void setBars(){
super.setBars(); super.setBars();
bars.add("heat", (NuclearReactorEntity entity) -> new Bar("bar.heat", Pal.lightOrange, () -> entity.heat)); bars.add("heat", (NuclearReactorBuild entity) -> new Bar("bar.heat", Pal.lightOrange, () -> entity.heat));
} }
public class NuclearReactorEntity extends GeneratorEntity{ public class NuclearReactorBuild extends GeneratorBuild{
public float heat; public float heat;
@Override @Override
@@ -42,7 +42,7 @@ public class PowerDiode extends Block{
return (tile != null && tile.block().hasPower) ? tile.power.graph.getLastPowerStored() / tile.power.graph.getTotalBatteryCapacity() : 0f; return (tile != null && tile.block().hasPower) ? tile.power.graph.getLastPowerStored() / tile.power.graph.getTotalBatteryCapacity() : 0f;
} }
public class PowerDiodeEntity extends Building{ public class PowerDiodeBuild extends Building{
@Override @Override
public void draw(){ public void draw(){
Draw.rect(region, x, y, 0); Draw.rect(region, x, y, 0);
@@ -32,7 +32,7 @@ public class PowerGenerator extends PowerDistributor{
super.setBars(); super.setBars();
if(hasPower && outputsPower && !consumes.hasPower()){ if(hasPower && outputsPower && !consumes.hasPower()){
bars.add("power", (GeneratorEntity entity) -> new Bar(() -> bars.add("power", (GeneratorBuild entity) -> new Bar(() ->
Core.bundle.format("bar.poweroutput", Core.bundle.format("bar.poweroutput",
Strings.fixed(entity.getPowerProduction() * 60 * entity.timeScale(), 1)), Strings.fixed(entity.getPowerProduction() * 60 * entity.timeScale(), 1)),
() -> Pal.powerBar, () -> Pal.powerBar,
@@ -45,7 +45,7 @@ public class PowerGenerator extends PowerDistributor{
return false; return false;
} }
public class GeneratorEntity extends Building{ public class GeneratorBuild extends Building{
public float generateTime; public float generateTime;
/** The efficiency of the producer. An efficiency of 1.0 means 100% */ /** The efficiency of the producer. An efficiency of 1.0 means 100% */
public float productionEfficiency = 0.0f; public float productionEfficiency = 0.0f;
@@ -272,7 +272,7 @@ public class PowerNode extends PowerBlock{
}); });
} }
public class PowerNodeEntity extends Building{ public class PowerNodeBuild extends Building{
@Override @Override
public void placed(){ public void placed(){
@@ -21,7 +21,7 @@ public class SolarGenerator extends PowerGenerator{
stats.add(generationType, powerProduction * 60.0f, StatUnit.powerSecond); stats.add(generationType, powerProduction * 60.0f, StatUnit.powerSecond);
} }
public class SolarGeneratorEntity extends GeneratorEntity{ public class SolarGeneratorBuild extends GeneratorBuild{
@Override @Override
public void updateTile(){ public void updateTile(){
productionEfficiency = productionEfficiency =
@@ -36,7 +36,7 @@ public class ThermalGenerator extends PowerGenerator{
return tile.getLinkedTilesAs(this, tempTiles).sumf(other -> other.floor().attributes.get(attribute)) > 0.01f; return tile.getLinkedTilesAs(this, tempTiles).sumf(other -> other.floor().attributes.get(attribute)) > 0.01f;
} }
public class ThermalGeneratorEntity extends GeneratorEntity{ public class ThermalGeneratorBuild extends GeneratorBuild{
public float sum; public float sum;
@Override @Override
@@ -40,7 +40,7 @@ public class AttributeSmelter extends GenericSmelter{
stats.add(BlockStat.affinities, attribute, boostScale); stats.add(BlockStat.affinities, attribute, boostScale);
} }
public class AttributeSmelterEntity extends SmelterEntity{ public class AttributeSmelterBuild extends SmelterBuild{
public float attrsum; public float attrsum;
@Override @Override
@@ -31,7 +31,7 @@ public class Cultivator extends GenericCrafter{
@Override @Override
public void setBars(){ public void setBars(){
super.setBars(); super.setBars();
bars.add("multiplier", (CultivatorEntity entity) -> new Bar(() -> bars.add("multiplier", (CultivatorBuild entity) -> new Bar(() ->
Core.bundle.formatFloat("bar.efficiency", Core.bundle.formatFloat("bar.efficiency",
((entity.boost + 1f + attribute.env()) * entity.warmup) * 100f, 1), ((entity.boost + 1f + attribute.env()) * entity.warmup) * 100f, 1),
() -> Pal.ammo, () -> Pal.ammo,
@@ -55,7 +55,7 @@ public class Cultivator extends GenericCrafter{
return new TextureRegion[]{region, topRegion}; return new TextureRegion[]{region, topRegion};
} }
public class CultivatorEntity extends GenericCrafterEntity{ public class CultivatorBuild extends GenericCrafterBuild{
public float warmup; public float warmup;
public float boost; public float boost;
@@ -86,7 +86,7 @@ public class Drill extends Block{
public void setBars(){ public void setBars(){
super.setBars(); super.setBars();
bars.add("drillspeed", (DrillEntity e) -> bars.add("drillspeed", (DrillBuild e) ->
new Bar(() -> Core.bundle.format("bar.drillspeed", Strings.fixed(e.lastDrillSpeed * 60 * e.timeScale(), 2)), () -> Pal.ammo, () -> e.warmup)); new Bar(() -> Core.bundle.format("bar.drillspeed", Strings.fixed(e.lastDrillSpeed * 60 * e.timeScale(), 2)), () -> Pal.ammo, () -> e.warmup));
} }
@@ -205,7 +205,7 @@ public class Drill extends Block{
return drops != null && drops.hardness <= tier; return drops != null && drops.hardness <= tier;
} }
public class DrillEntity extends Building{ public class DrillBuild extends Building{
public float progress; public float progress;
public int index; public int index;
public float warmup; public float warmup;
@@ -33,7 +33,7 @@ public class Fracker extends SolidPump{
return new TextureRegion[]{region, rotatorRegion, topRegion}; return new TextureRegion[]{region, rotatorRegion, topRegion};
} }
public class FrackerEntity extends SolidPumpEntity{ public class FrackerBuild extends SolidPumpBuild{
public float accumulator; public float accumulator;
@Override @Override
@@ -78,7 +78,7 @@ public class GenericCrafter extends Block{
return outputItem != null; return outputItem != null;
} }
public class GenericCrafterEntity extends Building{ public class GenericCrafterBuild extends Building{
public float progress; public float progress;
public float totalProgress; public float totalProgress;
public float warmup; public float warmup;
@@ -16,7 +16,7 @@ public class GenericSmelter extends GenericCrafter{
super(name); super(name);
} }
public class SmelterEntity extends GenericCrafterEntity{ public class SmelterBuild extends GenericCrafterBuild{
@Override @Override
public void draw(){ public void draw(){
super.draw(); super.draw();
@@ -22,7 +22,7 @@ public class Incinerator extends Block{
solid = true; solid = true;
} }
public class IncineratorEntity extends Building{ public class IncineratorBuild extends Building{
public float heat; public float heat;
@Override @Override
@@ -30,7 +30,7 @@ public class LiquidConverter extends GenericCrafter{
stats.add(BlockStat.output, outputLiquid.liquid, outputLiquid.amount * craftTime, false); stats.add(BlockStat.output, outputLiquid.liquid, outputLiquid.amount * craftTime, false);
} }
public class LiquidConverterEntity extends GenericCrafterEntity{ public class LiquidConverterBuild extends GenericCrafterBuild{
@Override @Override
public void drawLight(){ public void drawLight(){
if(hasLiquids && drawLiquidLight && outputLiquid.liquid.lightColor.a > 0.001f){ if(hasLiquids && drawLiquidLight && outputLiquid.liquid.lightColor.a > 0.001f){
@@ -46,7 +46,7 @@ public class PayloadAcceptor extends Block{
); );
} }
public class PayloadAcceptorEntity<T extends Payload> extends Building{ public class PayloadAcceptorBuild<T extends Payload> extends Building{
public @Nullable T payload; public @Nullable T payload;
public Vec2 payVector = new Vec2(); public Vec2 payVector = new Vec2();
public float payRotation; public float payRotation;
@@ -77,7 +77,7 @@ public class Pump extends LiquidBlock{
return tile != null && tile.floor().liquidDrop != null; return tile != null && tile.floor().liquidDrop != null;
} }
public class PumpEntity extends LiquidBlockEntity{ public class PumpBuild extends LiquidBuild{
public float amount = 0f; public float amount = 0f;
public Liquid liquidDrop = null; public Liquid liquidDrop = null;
@@ -51,7 +51,7 @@ public class Separator extends Block{
stats.add(BlockStat.productionTime, craftTime / 60f, StatUnit.seconds); stats.add(BlockStat.productionTime, craftTime / 60f, StatUnit.seconds);
} }
public class SeparatorEntity extends Building{ public class SeparatorBuild extends Building{
public float progress; public float progress;
public float totalProgress; public float totalProgress;
public float warmup; public float warmup;
@@ -44,7 +44,7 @@ public class SolidPump extends Pump{
@Override @Override
public void setBars(){ public void setBars(){
super.setBars(); super.setBars();
bars.add("efficiency", (SolidPumpEntity entity) -> new Bar(() -> Core.bundle.formatFloat("bar.pumpspeed", bars.add("efficiency", (SolidPumpBuild entity) -> new Bar(() -> Core.bundle.formatFloat("bar.pumpspeed",
entity.lastPump / Time.delta * 60, 1), entity.lastPump / Time.delta * 60, 1),
() -> Pal.ammo, () -> Pal.ammo,
() -> entity.warmup)); () -> entity.warmup));
@@ -77,7 +77,7 @@ public class SolidPump extends Pump{
return new TextureRegion[]{region, rotatorRegion, topRegion}; return new TextureRegion[]{region, rotatorRegion, topRegion};
} }
public class SolidPumpEntity extends PumpEntity{ public class SolidPumpBuild extends PumpBuild{
public float warmup; public float warmup;
public float pumpTime; public float pumpTime;
public float boost; public float boost;
@@ -24,8 +24,8 @@ public class ItemSource extends Block{
configurable = true; configurable = true;
saveConfig = true; saveConfig = true;
config(Item.class, (ItemSourceEntity tile, Item item) -> tile.outputItem = item); config(Item.class, (ItemSourceBuild tile, Item item) -> tile.outputItem = item);
configClear((ItemSourceEntity tile) -> tile.outputItem = null); configClear((ItemSourceBuild tile) -> tile.outputItem = null);
} }
@Override @Override
@@ -44,7 +44,7 @@ public class ItemSource extends Block{
return true; return true;
} }
public class ItemSourceEntity extends Building{ public class ItemSourceBuild extends Building{
Item outputItem; Item outputItem;
@Override @Override
@@ -11,7 +11,7 @@ public class ItemVoid extends Block{
update = solid = acceptsItems = true; update = solid = acceptsItems = true;
} }
public class ItemVoidEntity extends Building{ public class ItemVoidBuild extends Building{
@Override @Override
public void handleItem(Building source, Item item){} public void handleItem(Building source, Item item){}
@@ -25,8 +25,8 @@ public class LiquidSource extends Block{
outputsLiquid = true; outputsLiquid = true;
saveConfig = true; saveConfig = true;
config(Liquid.class, (LiquidSourceEntity tile, Liquid l) -> tile.source = l); config(Liquid.class, (LiquidSourceBuild tile, Liquid l) -> tile.source = l);
configClear((LiquidSourceEntity tile) -> tile.source = null); configClear((LiquidSourceBuild tile) -> tile.source = null);
} }
@Override @Override
@@ -41,7 +41,7 @@ public class LiquidSource extends Block{
drawRequestConfigCenter(req, req.config, "center"); drawRequestConfigCenter(req, req.config, "center");
} }
public class LiquidSourceEntity extends Building{ public class LiquidSourceBuild extends Building{
public @Nullable Liquid source = null; public @Nullable Liquid source = null;
@Override @Override
@@ -19,7 +19,7 @@ public class LiquidVoid extends Block{
bars.remove("liquid"); bars.remove("liquid");
} }
public class LiquidVoidEntity extends Building{ public class LiquidVoidBuild extends Building{
@Override @Override
public boolean acceptLiquid(Building source, Liquid liquid, float amount){ public boolean acceptLiquid(Building source, Liquid liquid, float amount){
return true; return true;
@@ -11,7 +11,7 @@ public class PowerSource extends PowerNode{
consumesPower = false; consumesPower = false;
} }
public class PowerSourceEntity extends PowerNodeEntity{ public class PowerSourceBuild extends PowerNodeBuild{
@Override @Override
public float getPowerProduction(){ public float getPowerProduction(){
return 10000f; return 10000f;
@@ -57,7 +57,7 @@ public class CoreBlock extends StorageBlock{
public static void playerSpawn(Tile tile, Player player){ public static void playerSpawn(Tile tile, Player player){
if(player == null || tile == null) return; if(player == null || tile == null) return;
CoreEntity entity = tile.bc(); CoreBuild entity = tile.bc();
CoreBlock block = (CoreBlock)tile.block(); CoreBlock block = (CoreBlock)tile.block();
Fx.spawn.at(entity); Fx.spawn.at(entity);
@@ -76,7 +76,7 @@ public class CoreBlock extends StorageBlock{
public void setStats(){ public void setStats(){
super.setStats(); super.setStats();
bars.add("capacity", (CoreEntity e) -> bars.add("capacity", (CoreBuild e) ->
new Bar( new Bar(
() -> Core.bundle.format("bar.capacity", UI.formatAmount(e.storageCapacity)), () -> Core.bundle.format("bar.capacity", UI.formatAmount(e.storageCapacity)),
() -> Pal.items, () -> Pal.items,
@@ -98,7 +98,7 @@ public class CoreBlock extends StorageBlock{
@Override @Override
public boolean canPlaceOn(Tile tile, Team team){ public boolean canPlaceOn(Tile tile, Team team){
if(tile == null) return false; if(tile == null) return false;
CoreEntity core = team.core(); CoreBuild core = team.core();
//must have all requirements //must have all requirements
if(core == null || (!state.rules.infiniteResources && !core.items.has(requirements))) return false; if(core == null || (!state.rules.infiniteResources && !core.items.has(requirements))) return false;
return canReplace(tile.block()); return canReplace(tile.block());
@@ -126,7 +126,7 @@ public class CoreBlock extends StorageBlock{
@Override @Override
public void beforePlaceBegan(Tile tile, Block previous){ public void beforePlaceBegan(Tile tile, Block previous){
if(tile.build instanceof CoreEntity){ if(tile.build instanceof CoreBuild){
//right before placing, create a "destination" item array which is all the previous items minus core requirements //right before placing, create a "destination" item array which is all the previous items minus core requirements
ItemModule items = tile.build.items.copy(); ItemModule items = tile.build.items.copy();
if(!state.rules.infiniteResources){ if(!state.rules.infiniteResources){
@@ -151,7 +151,7 @@ public class CoreBlock extends StorageBlock{
} }
} }
public class CoreEntity extends Building implements ControlBlock{ public class CoreBuild extends Building implements ControlBlock{
public int storageCapacity; public int storageCapacity;
//note that this unit is never actually used for control; the possession handler makes the player respawn when this unit is controlled //note that this unit is never actually used for control; the possession handler makes the player respawn when this unit is controlled
public @NonNull BlockUnitc unit = Nulls.blockUnit; public @NonNull BlockUnitc unit = Nulls.blockUnit;
@@ -207,7 +207,7 @@ public class CoreBlock extends StorageBlock{
storageCapacity = itemCapacity + proximity().sum(e -> isContainer(e) && owns(e) ? e.block().itemCapacity : 0); storageCapacity = itemCapacity + proximity().sum(e -> isContainer(e) && owns(e) ? e.block().itemCapacity : 0);
proximity.each(e -> isContainer(e) && owns(e), t -> { proximity.each(e -> isContainer(e) && owns(e), t -> {
t.items = items; t.items = items;
((StorageBlockEntity)t).linkedCore = this; ((StorageBuild)t).linkedCore = this;
}); });
for(Building other : state.teams.cores(team)){ for(Building other : state.teams.cores(team)){
@@ -221,7 +221,7 @@ public class CoreBlock extends StorageBlock{
} }
} }
for(CoreEntity other : state.teams.cores(team)){ for(CoreBuild other : state.teams.cores(team)){
other.storageCapacity = storageCapacity; other.storageCapacity = storageCapacity;
} }
} }
@@ -245,15 +245,15 @@ public class CoreBlock extends StorageBlock{
public boolean isContainer(Building tile){ public boolean isContainer(Building tile){
return tile instanceof StorageBlockEntity && (((StorageBlockEntity)tile).linkedCore == this || ((StorageBlockEntity)tile).linkedCore == null); return tile instanceof StorageBuild && (((StorageBuild)tile).linkedCore == this || ((StorageBuild)tile).linkedCore == null);
} }
public boolean owns(Building tile){ public boolean owns(Building tile){
return tile instanceof StorageBlockEntity && (((StorageBlockEntity)tile).linkedCore == this || ((StorageBlockEntity)tile).linkedCore == null); return tile instanceof StorageBuild && (((StorageBuild)tile).linkedCore == this || ((StorageBuild)tile).linkedCore == null);
} }
public boolean owns(Building core, Building tile){ public boolean owns(Building core, Building tile){
return tile instanceof StorageBlockEntity && (((StorageBlockEntity)tile).linkedCore == core || ((StorageBlockEntity)tile).linkedCore == null); return tile instanceof StorageBuild && (((StorageBuild)tile).linkedCore == core || ((StorageBuild)tile).linkedCore == null);
} }
@Override @Override
@@ -270,7 +270,7 @@ public class CoreBlock extends StorageBlock{
float fract = 1f / total / state.teams.cores(team).size; float fract = 1f / total / state.teams.cores(team).size;
proximity.each(e -> isContainer(e) && e.items == items && owns(e), t -> { proximity.each(e -> isContainer(e) && e.items == items && owns(e), t -> {
StorageBlockEntity ent = (StorageBlockEntity)t; StorageBuild ent = (StorageBuild)t;
ent.linkedCore = null; ent.linkedCore = null;
ent.items = new ItemModule(); ent.items = new ItemModule();
for(Item item : content.items()){ for(Item item : content.items()){
@@ -285,7 +285,7 @@ public class CoreBlock extends StorageBlock{
items.set(item, Math.min(items.get(item), max)); items.set(item, Math.min(items.get(item), max));
} }
for(CoreEntity other : state.teams.cores(team)){ for(CoreBuild other : state.teams.cores(team)){
other.onProximityUpdate(); other.onProximityUpdate();
} }
} }
@@ -20,7 +20,7 @@ public abstract class StorageBlock extends Block{
return false; return false;
} }
public class StorageBlockEntity extends Building{ public class StorageBuild extends Building{
protected @Nullable Building linkedCore; protected @Nullable Building linkedCore;
@Override @Override
@@ -27,8 +27,8 @@ public class Unloader extends Block{
saveConfig = true; saveConfig = true;
itemCapacity = 0; itemCapacity = 0;
config(Item.class, (UnloaderEntity tile, Item item) -> tile.sortItem = item); config(Item.class, (UnloaderBuild tile, Item item) -> tile.sortItem = item);
configClear((UnloaderEntity tile) -> tile.sortItem = null); configClear((UnloaderBuild tile) -> tile.sortItem = null);
} }
@Override @Override
@@ -42,7 +42,7 @@ public class Unloader extends Block{
bars.remove("items"); bars.remove("items");
} }
public class UnloaderEntity extends Building{ public class UnloaderBuild extends Building{
public Item sortItem = null; public Item sortItem = null;
public Building dumpingTo; public Building dumpingTo;
@@ -82,7 +82,7 @@ public class Unloader extends Block{
@Override @Override
public void buildConfiguration(Table table){ public void buildConfiguration(Table table){
ItemSelection.buildTable(table, content.items(), () -> tile.<UnloaderEntity>bc().sortItem, item -> configure(item)); ItemSelection.buildTable(table, content.items(), () -> tile.<UnloaderBuild>bc().sortItem, item -> configure(item));
} }
@Override @Override
@@ -43,8 +43,8 @@ public class Reconstructor extends UnitBlock{
public void setBars(){ public void setBars(){
super.setBars(); super.setBars();
bars.add("progress", (ReconstructorEntity entity) -> new Bar("bar.progress", Pal.ammo, entity::fraction)); bars.add("progress", (ReconstructorBuild entity) -> new Bar("bar.progress", Pal.ammo, entity::fraction));
bars.add("units", (ReconstructorEntity e) -> bars.add("units", (ReconstructorBuild e) ->
new Bar( new Bar(
() -> e.unit() == null ? "[lightgray]" + Iconc.cancel : () -> e.unit() == null ? "[lightgray]" + Iconc.cancel :
Core.bundle.format("bar.unitcap", Core.bundle.format("bar.unitcap",
@@ -77,7 +77,7 @@ public class Reconstructor extends UnitBlock{
super.init(); super.init();
} }
public class ReconstructorEntity extends UnitBlockEntity{ public class ReconstructorBuild extends UnitBuild{
public float fraction(){ public float fraction(){
return progress / constructTime; return progress / constructTime;
@@ -47,7 +47,7 @@ public class RepairPoint extends Block{
@Override @Override
public void init(){ public void init(){
consumes.powerCond(powerUse, entity -> ((RepairPointEntity)entity).target != null); consumes.powerCond(powerUse, entity -> ((RepairPointBuild)entity).target != null);
super.init(); super.init();
} }
@@ -61,7 +61,7 @@ public class RepairPoint extends Block{
return new TextureRegion[]{baseRegion, region}; return new TextureRegion[]{baseRegion, region};
} }
public class RepairPointEntity extends Building{ public class RepairPointBuild extends Building{
public Unit target; public Unit target;
public float strength, rotation = 90; public float strength, rotation = 90;
@@ -33,7 +33,7 @@ public class ResupplyPoint extends Block{
Drawf.dashCircle(x * tilesize + offset, y * tilesize + offset, range, Pal.placing); Drawf.dashCircle(x * tilesize + offset, y * tilesize + offset, range, Pal.placing);
} }
public class ResupplyPointEntity extends Building{ public class ResupplyPointBuild extends Building{
@Override @Override
public void drawSelect(){ public void drawSelect(){
@@ -26,11 +26,11 @@ public class UnitBlock extends PayloadAcceptor{
@Remote(called = Loc.server) @Remote(called = Loc.server)
public static void unitBlockSpawn(Tile tile){ public static void unitBlockSpawn(Tile tile){
if(!(tile.build instanceof UnitBlockEntity)) return; if(!(tile.build instanceof UnitBuild)) return;
tile.<UnitBlockEntity>bc().spawned(); tile.<UnitBuild>bc().spawned();
} }
public class UnitBlockEntity extends PayloadAcceptorEntity<UnitPayload>{ public class UnitBuild extends PayloadAcceptorBuild<UnitPayload>{
public float progress, time, speedScl; public float progress, time, speedScl;
public void spawned(){ public void spawned(){
@@ -41,12 +41,12 @@ public class UnitFactory extends UnitBlock{
outputsPayload = true; outputsPayload = true;
rotate = true; rotate = true;
config(Integer.class, (UnitFactoryEntity tile, Integer i) -> { config(Integer.class, (UnitFactoryBuild tile, Integer i) -> {
tile.currentPlan = i < 0 || i >= plans.length ? -1 : i; tile.currentPlan = i < 0 || i >= plans.length ? -1 : i;
tile.progress = 0; tile.progress = 0;
}); });
consumes.add(new ConsumeItemDynamic((UnitFactoryEntity e) -> e.currentPlan != -1 ? plans[e.currentPlan].requirements : ItemStack.empty)); consumes.add(new ConsumeItemDynamic((UnitFactoryBuild e) -> e.currentPlan != -1 ? plans[e.currentPlan].requirements : ItemStack.empty));
} }
@Override @Override
@@ -65,9 +65,9 @@ public class UnitFactory extends UnitBlock{
@Override @Override
public void setBars(){ public void setBars(){
super.setBars(); super.setBars();
bars.add("progress", (UnitFactoryEntity e) -> new Bar("bar.progress", Pal.ammo, e::fraction)); bars.add("progress", (UnitFactoryBuild e) -> new Bar("bar.progress", Pal.ammo, e::fraction));
bars.add("units", (UnitFactoryEntity e) -> bars.add("units", (UnitFactoryBuild e) ->
new Bar( new Bar(
() -> e.unit() == null ? "[lightgray]" + Iconc.cancel : () -> e.unit() == null ? "[lightgray]" + Iconc.cancel :
Core.bundle.format("bar.unitcap", Core.bundle.format("bar.unitcap",
@@ -118,7 +118,7 @@ public class UnitFactory extends UnitBlock{
UnitPlan(){} UnitPlan(){}
} }
public class UnitFactoryEntity extends UnitBlockEntity{ public class UnitFactoryBuild extends UnitBuild{
public int currentPlan = -1; public int currentPlan = -1;
public float fraction(){ public float fraction(){
@@ -15,7 +15,7 @@ public class DrawAnimation extends DrawBlock{
public TextureRegion liquid, top; public TextureRegion liquid, top;
@Override @Override
public void draw(GenericCrafterEntity entity){ public void draw(GenericCrafterBuild entity){
Draw.rect(entity.block.region, entity.x, entity.y); Draw.rect(entity.block.region, entity.x, entity.y);
Draw.rect( Draw.rect(
sine ? sine ?
+1 -1
View File
@@ -9,7 +9,7 @@ import mindustry.world.blocks.production.GenericCrafter.*;
public class DrawBlock{ public class DrawBlock{
/** Draws the block. */ /** Draws the block. */
public void draw(GenericCrafterEntity entity){ public void draw(GenericCrafterBuild entity){
Draw.rect(entity.block.region, entity.x, entity.y, entity.block.rotate ? entity.rotdeg() : 0); Draw.rect(entity.block.region, entity.x, entity.y, entity.block.rotate ? entity.rotdeg() : 0);
} }
+1 -1
View File
@@ -11,7 +11,7 @@ public class DrawGlow extends DrawBlock{
public TextureRegion top; public TextureRegion top;
@Override @Override
public void draw(GenericCrafterEntity entity){ public void draw(GenericCrafterBuild entity){
Draw.rect(entity.block.region, entity.x, entity.y); Draw.rect(entity.block.region, entity.x, entity.y);
Draw.alpha(Mathf.absin(entity.totalProgress, glowScale, glowAmount) * entity.warmup); Draw.alpha(Mathf.absin(entity.totalProgress, glowScale, glowAmount) * entity.warmup);
Draw.rect(top, entity.x, entity.y); Draw.rect(top, entity.x, entity.y);
+1 -1
View File
@@ -10,7 +10,7 @@ public class DrawMixer extends DrawBlock{
public TextureRegion liquid, top, bottom; public TextureRegion liquid, top, bottom;
@Override @Override
public void draw(GenericCrafterEntity entity){ public void draw(GenericCrafterBuild entity){
float rotation = entity.block.rotate ? entity.rotdeg() : 0; float rotation = entity.block.rotate ? entity.rotdeg() : 0;
Draw.rect(bottom, entity.x, entity.y, rotation); Draw.rect(bottom, entity.x, entity.y, rotation);
@@ -9,7 +9,7 @@ public class DrawRotator extends DrawBlock{
public TextureRegion rotator; public TextureRegion rotator;
@Override @Override
public void draw(GenericCrafterEntity entity){ public void draw(GenericCrafterBuild entity){
Draw.rect(entity.block.region, entity.x, entity.y); Draw.rect(entity.block.region, entity.x, entity.y);
Draw.rect(rotator, entity.x, entity.y, entity.totalProgress * 2f); Draw.rect(rotator, entity.x, entity.y, entity.totalProgress * 2f);
} }
+1 -1
View File
@@ -12,7 +12,7 @@ public class DrawWeave extends DrawBlock{
public TextureRegion weave, bottom; public TextureRegion weave, bottom;
@Override @Override
public void draw(GenericCrafterEntity entity){ public void draw(GenericCrafterBuild entity){
Draw.rect(bottom, entity.x, entity.y); Draw.rect(bottom, entity.x, entity.y);
Draw.rect(weave, entity.x, entity.y, entity.totalProgress); Draw.rect(weave, entity.x, entity.y, entity.totalProgress);
@@ -8,6 +8,7 @@ import mindustry.game.*;
import mindustry.type.*; import mindustry.type.*;
import mindustry.world.*; import mindustry.world.*;
import mindustry.world.blocks.power.*; import mindustry.world.blocks.power.*;
import mindustry.world.blocks.power.ItemLiquidGenerator.*;
import org.junit.jupiter.api.*; import org.junit.jupiter.api.*;
import java.util.*; import java.util.*;
@@ -26,7 +27,7 @@ public class ItemLiquidGeneratorTests extends PowerTestFixture{
private ItemLiquidGenerator generator; private ItemLiquidGenerator generator;
private Tile tile; private Tile tile;
private ItemLiquidGenerator.ItemLiquidGeneratorEntity entity; private ItemLiquidGeneratorBuild entity;
private final float fakeItemDuration = 60f; //ticks private final float fakeItemDuration = 60f; //ticks
private final float maximumLiquidUsage = 0.5f; private final float maximumLiquidUsage = 0.5f;
@@ -38,7 +39,7 @@ public class ItemLiquidGeneratorTests extends PowerTestFixture{
powerProduction = 0.1f; powerProduction = 0.1f;
itemDuration = fakeItemDuration; itemDuration = fakeItemDuration;
maxLiquidGenerate = maximumLiquidUsage; maxLiquidGenerate = maximumLiquidUsage;
entityType = ItemLiquidGeneratorEntity::new; entityType = ItemLiquidGeneratorBuild::new;
} }
@Override @Override
@@ -43,14 +43,14 @@ public class PowerTestFixture{
protected static PowerGenerator createFakeProducerBlock(float producedPower){ protected static PowerGenerator createFakeProducerBlock(float producedPower){
return new PowerGenerator("fakegen"){{ return new PowerGenerator("fakegen"){{
entityType = () -> new GeneratorEntity(); entityType = () -> new GeneratorBuild();
powerProduction = producedPower; powerProduction = producedPower;
}}; }};
} }
protected static Battery createFakeBattery(float capacity){ protected static Battery createFakeBattery(float capacity){
return new Battery("fakebattery"){{ return new Battery("fakebattery"){{
entityType = () -> new BatteryEntity(); entityType = () -> new BatteryBuild();
consumes.powerBuffered(capacity); consumes.powerBuffered(capacity);
}}; }};
} }
+4 -3
View File
@@ -7,6 +7,7 @@ import mindustry.*;
import mindustry.core.*; import mindustry.core.*;
import mindustry.world.*; import mindustry.world.*;
import mindustry.world.blocks.power.*; import mindustry.world.blocks.power.*;
import mindustry.world.blocks.power.PowerGenerator.*;
import mindustry.world.consumers.*; import mindustry.world.consumers.*;
import org.junit.jupiter.api.*; import org.junit.jupiter.api.*;
@@ -54,7 +55,7 @@ public class PowerTests extends PowerTestFixture{
void simulateDirectConsumption(float producedPower, float requiredPower, float expectedSatisfaction, String parameterDescription){ void simulateDirectConsumption(float producedPower, float requiredPower, float expectedSatisfaction, String parameterDescription){
Tile producerTile = createFakeTile(0, 0, createFakeProducerBlock(producedPower)); Tile producerTile = createFakeTile(0, 0, createFakeProducerBlock(producedPower));
producerTile.<PowerGenerator.GeneratorEntity>bc().productionEfficiency = 1f; producerTile.<GeneratorBuild>bc().productionEfficiency = 1f;
Tile directConsumerTile = createFakeTile(0, 1, createFakeDirectConsumer(requiredPower)); Tile directConsumerTile = createFakeTile(0, 1, createFakeDirectConsumer(requiredPower));
PowerGraph powerGraph = new PowerGraph(); PowerGraph powerGraph = new PowerGraph();
@@ -94,7 +95,7 @@ public class PowerTests extends PowerTestFixture{
if(producedPower > 0.0f){ if(producedPower > 0.0f){
Tile producerTile = createFakeTile(0, 0, createFakeProducerBlock(producedPower)); Tile producerTile = createFakeTile(0, 0, createFakeProducerBlock(producedPower));
producerTile.<PowerGenerator.GeneratorEntity>bc().productionEfficiency = 1f; producerTile.<GeneratorBuild>bc().productionEfficiency = 1f;
powerGraph.add(producerTile.build); powerGraph.add(producerTile.build);
} }
Tile directConsumerTile = null; Tile directConsumerTile = null;
@@ -119,7 +120,7 @@ public class PowerTests extends PowerTestFixture{
@Test @Test
void directConsumptionStopsWithNoPower(){ void directConsumptionStopsWithNoPower(){
Tile producerTile = createFakeTile(0, 0, createFakeProducerBlock(10.0f)); Tile producerTile = createFakeTile(0, 0, createFakeProducerBlock(10.0f));
producerTile.<PowerGenerator.GeneratorEntity>bc().productionEfficiency = 1.0f; producerTile.<GeneratorBuild>bc().productionEfficiency = 1.0f;
Tile consumerTile = createFakeTile(0, 1, createFakeDirectConsumer(5.0f)); Tile consumerTile = createFakeTile(0, 1, createFakeDirectConsumer(5.0f));
PowerGraph powerGraph = new PowerGraph(); PowerGraph powerGraph = new PowerGraph();
@@ -81,7 +81,7 @@ public class SectorDataGenerator{
} }
} }
CoreEntity entity = Team.sharded.core(); CoreBuild entity = Team.sharded.core();
int cx = entity.tileX(), cy = entity.tileY(); int cx = entity.tileX(), cy = entity.tileY();
int nearTiles = 0; int nearTiles = 0;