argh
This commit is contained in:
@@ -172,7 +172,7 @@ public class Block extends UnlockableContent{
|
||||
/** Whether this block has instant transfer.*/
|
||||
public boolean instantTransfer = false;
|
||||
|
||||
protected Prov<Tilec> entityType = null; //initialized later
|
||||
protected Prov<Building> entityType = null; //initialized later
|
||||
public ObjectMap<Class<?>, Cons2> configurations = new ObjectMap<>();
|
||||
|
||||
protected TextureRegion[] generatedIcons;
|
||||
@@ -184,7 +184,7 @@ public class Block extends UnlockableContent{
|
||||
|
||||
public static TextureRegion[][] cracks;
|
||||
protected static final Seq<Tile> tempTiles = new Seq<>();
|
||||
protected static final Seq<Tilec> tempTileEnts = new Seq<>();
|
||||
protected static final Seq<Building> tempTileEnts = new Seq<>();
|
||||
|
||||
/** Dump timer ID.*/
|
||||
protected final int timerDump = timers++;
|
||||
@@ -307,15 +307,15 @@ public class Block extends UnlockableContent{
|
||||
bars.add("health", entity -> new Bar("blocks.health", Pal.health, entity::healthf).blink(Color.white));
|
||||
|
||||
if(hasLiquids){
|
||||
Func<Tilec, Liquid> current;
|
||||
Func<Building, Liquid> current;
|
||||
if(consumes.has(ConsumeType.liquid) && consumes.get(ConsumeType.liquid) instanceof ConsumeLiquid){
|
||||
Liquid liquid = consumes.<ConsumeLiquid>get(ConsumeType.liquid).liquid;
|
||||
current = entity -> liquid;
|
||||
}else{
|
||||
current = entity -> entity.liquids().current();
|
||||
current = entity -> entity.liquids.current();
|
||||
}
|
||||
bars.add("liquid", entity -> new Bar(() -> entity.liquids().get(current.get(entity)) <= 0.001f ? Core.bundle.get("bar.liquid") : current.get(entity).localizedName,
|
||||
() -> current.get(entity).barColor(), () -> entity.liquids().get(current.get(entity)) / liquidCapacity));
|
||||
bars.add("liquid", entity -> new Bar(() -> entity.liquids.get(current.get(entity)) <= 0.001f ? Core.bundle.get("bar.liquid") : current.get(entity).localizedName,
|
||||
() -> current.get(entity).barColor(), () -> entity.liquids.get(current.get(entity)) / liquidCapacity));
|
||||
}
|
||||
|
||||
if(hasPower && consumes.hasPower()){
|
||||
@@ -323,12 +323,12 @@ public class Block extends UnlockableContent{
|
||||
boolean buffered = cons.buffered;
|
||||
float capacity = cons.capacity;
|
||||
|
||||
bars.add("power", entity -> new Bar(() -> buffered ? Core.bundle.format("bar.poweramount", Float.isNaN(entity.power().status * capacity) ? "<ERROR>" : (int)(entity.power().status * capacity)) :
|
||||
Core.bundle.get("bar.power"), () -> Pal.powerBar, () -> Mathf.zero(cons.requestedPower(entity)) && entity.power().graph.getPowerProduced() + entity.power().graph.getBatteryStored() > 0f ? 1f : entity.power().status));
|
||||
bars.add("power", entity -> new Bar(() -> buffered ? Core.bundle.format("bar.poweramount", Float.isNaN(entity.power.status * capacity) ? "<ERROR>" : (int)(entity.power.status * capacity)) :
|
||||
Core.bundle.get("bar.power"), () -> Pal.powerBar, () -> Mathf.zero(cons.requestedPower(entity)) && entity.power.graph.getPowerProduced() + entity.power.graph.getBatteryStored() > 0f ? 1f : entity.power.status));
|
||||
}
|
||||
|
||||
if(hasItems && configurable){
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -383,12 +383,12 @@ public class Block extends UnlockableContent{
|
||||
}
|
||||
|
||||
/** Configure when a null value is passed.*/
|
||||
public <E extends Tilec> void configClear(Cons<E> cons){
|
||||
public <E extends Building> void configClear(Cons<E> cons){
|
||||
configurations.put(void.class, (tile, value) -> cons.get((E)tile));
|
||||
}
|
||||
|
||||
/** Listen for a config by class type. */
|
||||
public <T, E extends Tilec> void config(Class<T> type, Cons2<E, T> config){
|
||||
public <T, E extends Building> void config(Class<T> type, Cons2<E, T> config){
|
||||
configurations.put(type, config);
|
||||
}
|
||||
|
||||
@@ -454,7 +454,7 @@ public class Block extends UnlockableContent{
|
||||
return destructible || update;
|
||||
}
|
||||
|
||||
public final Tilec newEntity(){
|
||||
public final Building newEntity(){
|
||||
return entityType.get();
|
||||
}
|
||||
|
||||
@@ -536,11 +536,11 @@ public class Block extends UnlockableContent{
|
||||
}
|
||||
|
||||
while(entityType == null && Block.class.isAssignableFrom(current)){
|
||||
//first class that is subclass of Tilec
|
||||
Class<?> type = Structs.find(current.getDeclaredClasses(), t -> Tilec.class.isAssignableFrom(t) && !t.isInterface());
|
||||
//first class that is subclass of Building
|
||||
Class<?> type = Structs.find(current.getDeclaredClasses(), t -> Building.class.isAssignableFrom(t) && !t.isInterface());
|
||||
if(type != null){
|
||||
//these are inner classes, so they have an implicit parameter generated
|
||||
Constructor<? extends Tilec> cons = (Constructor<? extends Tilec>)type.getDeclaredConstructor(type.getDeclaringClass());
|
||||
Constructor<? extends Building> cons = (Constructor<? extends Building>)type.getDeclaredConstructor(type.getDeclaringClass());
|
||||
entityType = () -> {
|
||||
try{
|
||||
return cons.newInstance(this);
|
||||
@@ -559,7 +559,7 @@ public class Block extends UnlockableContent{
|
||||
|
||||
if(entityType == null){
|
||||
//assign default value
|
||||
entityType = TileEntity::create;
|
||||
entityType = Building::create;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ public class Build{
|
||||
return;
|
||||
}
|
||||
|
||||
Tile tile = world.tilec(x, y);
|
||||
Tile tile = world.Building(x, y);
|
||||
//this should never happen, but it doesn't hurt to check for links
|
||||
float prevPercent = 1f;
|
||||
|
||||
|
||||
@@ -21,13 +21,13 @@ public class CachedTile extends Tile{
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void changeEntity(Team team, Prov<Tilec> entityprov){
|
||||
protected void changeEntity(Team team, Prov<Building> entityprov){
|
||||
entity = null;
|
||||
|
||||
Block block = block();
|
||||
|
||||
if(block.hasEntity()){
|
||||
Tilec n = entityprov.get();
|
||||
Building n = entityprov.get();
|
||||
n.cons(new ConsumeModule(entity));
|
||||
n.tile(this);
|
||||
n.block(block);
|
||||
|
||||
@@ -50,7 +50,7 @@ public class Edges{
|
||||
}
|
||||
}
|
||||
|
||||
public static Tile getFacingEdge(Tilec tile, Tilec other){
|
||||
public static Tile getFacingEdge(Building tile, Building other){
|
||||
return getFacingEdge(tile.block(), tile.tileX(), tile.tileY(), other.tile());
|
||||
}
|
||||
|
||||
|
||||
@@ -19,12 +19,12 @@ import mindustry.world.blocks.environment.*;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class Tile implements Position, QuadTreeObject, Displayable{
|
||||
static final ObjectSet<Tilec> tileSet = new ObjectSet<>();
|
||||
static final ObjectSet<Building> tileSet = new ObjectSet<>();
|
||||
|
||||
/** Tile traversal cost. */
|
||||
public short cost = 1;
|
||||
/** Tile entity, usually null. */
|
||||
public @Nullable Tilec entity;
|
||||
public @Nullable Building entity;
|
||||
public short x, y;
|
||||
protected @NonNull Block block;
|
||||
protected @NonNull Floor floor;
|
||||
@@ -106,7 +106,7 @@ public class Tile implements Position, QuadTreeObject, Displayable{
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends TileEntity> T ent(){
|
||||
public <T extends Building> T ent(){
|
||||
return (T)entity;
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ public class Tile implements Position, QuadTreeObject, Displayable{
|
||||
setBlock(type, team, rotation, type::newEntity);
|
||||
}
|
||||
|
||||
public void setBlock(@NonNull Block type, Team team, int rotation, Prov<Tilec> entityprov){
|
||||
public void setBlock(@NonNull Block type, Team team, int rotation, Prov<Building> entityprov){
|
||||
changing = true;
|
||||
|
||||
this.block = type;
|
||||
@@ -185,7 +185,7 @@ public class Tile implements Position, QuadTreeObject, Displayable{
|
||||
if(block.isMultiblock()){
|
||||
int offsetx = -(block.size - 1) / 2;
|
||||
int offsety = -(block.size - 1) / 2;
|
||||
Tilec entity = this.entity;
|
||||
Building entity = this.entity;
|
||||
Block block = this.block;
|
||||
|
||||
//two passes: first one clears, second one sets
|
||||
@@ -425,7 +425,7 @@ public class Tile implements Position, QuadTreeObject, Displayable{
|
||||
return null;
|
||||
}
|
||||
|
||||
public Tilec getNearbyEntity(int rotation){
|
||||
public Building getNearbyEntity(int rotation){
|
||||
if(rotation == 0) return world.ent(x + 1, y);
|
||||
if(rotation == 1) return world.ent(x, y + 1);
|
||||
if(rotation == 2) return world.ent(x - 1, y);
|
||||
@@ -434,19 +434,19 @@ public class Tile implements Position, QuadTreeObject, Displayable{
|
||||
}
|
||||
|
||||
// ▲ ▲ ▼ ▼ ◀ ▶ ◀ ▶ B A
|
||||
public @Nullable Tilec front(){
|
||||
public @Nullable Building front(){
|
||||
return getNearbyEntity((rotation + 4) % 4);
|
||||
}
|
||||
|
||||
public @Nullable Tilec right(){
|
||||
public @Nullable Building right(){
|
||||
return getNearbyEntity((rotation + 3) % 4);
|
||||
}
|
||||
|
||||
public @Nullable Tilec back(){
|
||||
public @Nullable Building back(){
|
||||
return getNearbyEntity((rotation + 2) % 4);
|
||||
}
|
||||
|
||||
public @Nullable Tilec left(){
|
||||
public @Nullable Building left(){
|
||||
return getNearbyEntity((rotation + 1) % 4);
|
||||
}
|
||||
|
||||
@@ -505,7 +505,7 @@ public class Tile implements Position, QuadTreeObject, Displayable{
|
||||
//remove this tile's dangling entities
|
||||
if(entity.block().isMultiblock()){
|
||||
int cx = entity.tileX(), cy = entity.tileY();
|
||||
int size = entity.block().size;
|
||||
int size = entity.block.size;
|
||||
int offsetx = -(size - 1) / 2;
|
||||
int offsety = -(size - 1) / 2;
|
||||
for(int dx = 0; dx < size; dx++){
|
||||
@@ -534,9 +534,9 @@ public class Tile implements Position, QuadTreeObject, Displayable{
|
||||
}
|
||||
}
|
||||
|
||||
protected void changeEntity(Team team, Prov<Tilec> entityprov){
|
||||
protected void changeEntity(Team team, Prov<Building> entityprov){
|
||||
if(entity != null){
|
||||
int size = entity.block().size;
|
||||
int size = entity.block.size;
|
||||
entity.remove();
|
||||
entity = null;
|
||||
|
||||
@@ -544,14 +544,14 @@ public class Tile implements Position, QuadTreeObject, Displayable{
|
||||
tileSet.clear();
|
||||
|
||||
for(Point2 edge : Edges.getEdges(size)){
|
||||
Tilec other = world.ent(x + edge.x, y + edge.y);
|
||||
Building other = world.ent(x + edge.x, y + edge.y);
|
||||
if(other != null){
|
||||
tileSet.add(other);
|
||||
}
|
||||
}
|
||||
|
||||
//update proximity, since multiblock was just removed
|
||||
for(Tilec t : tileSet){
|
||||
for(Building t : tileSet){
|
||||
t.updateProximity();
|
||||
}
|
||||
}
|
||||
@@ -568,7 +568,7 @@ public class Tile implements Position, QuadTreeObject, Displayable{
|
||||
}else{
|
||||
//since the entity won't update proximity for us, update proximity for all nearby tiles manually
|
||||
for(Point2 p : Geometry.d4){
|
||||
Tilec tile = world.ent(x + p.x, y + p.y);
|
||||
Building tile = world.ent(x + p.x, y + p.y);
|
||||
if(tile != null && !tile.tile().changing){
|
||||
tile.onProximityUpdate();
|
||||
}
|
||||
@@ -633,7 +633,7 @@ public class Tile implements Position, QuadTreeObject, Displayable{
|
||||
@Remote(called = Loc.server, unreliable = true)
|
||||
public static void onTileDamage(Tile tile, float health){
|
||||
if(tile.entity != null){
|
||||
tile.entity.health(health);
|
||||
tile.entity.health = health;
|
||||
|
||||
if(tile.entity.damaged()){
|
||||
indexer.notifyTileDamaged(tile.entity);
|
||||
|
||||
@@ -146,7 +146,7 @@ public interface Autotiler{
|
||||
}
|
||||
|
||||
default boolean blends(Tile tile, int rotation, int direction){
|
||||
Tilec other = tile.getNearbyEntity(Mathf.mod(rotation - direction, 4));
|
||||
Building other = tile.getNearbyEntity(Mathf.mod(rotation - direction, 4));
|
||||
return other != null && other.team() == tile.team() && blends(tile, rotation, other.tileX(), other.tileY(), other.rotation(), other.block());
|
||||
}
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ public class BuildBlock extends Block{
|
||||
return true;
|
||||
}
|
||||
|
||||
public class BuildEntity extends TileEntity{
|
||||
public class BuildEntity extends Building{
|
||||
/**
|
||||
* The recipe of the block that is being constructed.
|
||||
* If there is no recipe for this block, as is the case with rocks, 'previous' is used.
|
||||
@@ -148,7 +148,7 @@ public class BuildBlock extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tapped(Playerc player){
|
||||
public void tapped(Player player){
|
||||
//if the target is constructible, begin constructing
|
||||
if(!headless && cblock != null){
|
||||
if(control.input.buildWasAutoPaused && !control.input.isBuilding && player.isBuilder()){
|
||||
@@ -190,7 +190,7 @@ public class BuildBlock extends Block{
|
||||
});
|
||||
}
|
||||
|
||||
public boolean construct(Unitc builder, @Nullable Tilec core, float amount, boolean configured){
|
||||
public boolean construct(Unitc builder, @Nullable Building core, float amount, boolean configured){
|
||||
if(cblock == null){
|
||||
kill();
|
||||
return false;
|
||||
@@ -220,7 +220,7 @@ public class BuildBlock extends Block{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void deconstruct(Unitc builder, @Nullable Tilec core, float amount){
|
||||
public void deconstruct(Unitc builder, @Nullable Building core, float amount){
|
||||
float deconstructMultiplier = state.rules.deconstructRefundMultiplier;
|
||||
|
||||
if(cblock != null){
|
||||
|
||||
@@ -4,7 +4,7 @@ import mindustry.gen.*;
|
||||
|
||||
/** Any block that has a proxy unit that can be controlled by a player. */
|
||||
public interface ControlBlock{
|
||||
Unitc unit();
|
||||
Unit unit();
|
||||
|
||||
/** @return whether this block is being controlled by a player. */
|
||||
default boolean isControlled(){
|
||||
|
||||
@@ -46,10 +46,10 @@ public class LaunchPad extends Block{
|
||||
public void setBars(){
|
||||
super.setBars();
|
||||
|
||||
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 TileEntity{
|
||||
public class LaunchPadEntity extends Building{
|
||||
@Override
|
||||
public void draw(){
|
||||
super.draw();
|
||||
@@ -85,7 +85,7 @@ public class LaunchPad extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Tilec source, Item item){
|
||||
public boolean acceptItem(Building source, Item item){
|
||||
return items.total() < itemCapacity;
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ public class LaunchPad extends Block{
|
||||
|
||||
//launch when full and base conditions are met
|
||||
if(items.total() >= itemCapacity && efficiency() >= 1f && timer(timerLaunch, launchTime / timeScale)){
|
||||
LaunchPayloadc entity = LaunchPayloadEntity.create();
|
||||
LaunchPayload entity = LaunchPayload.create();
|
||||
items.each((item, amount) -> entity.stacks().add(new ItemStack(item, amount)));
|
||||
entity.set(this);
|
||||
entity.lifetime(120f);
|
||||
@@ -109,7 +109,7 @@ public class LaunchPad extends Block{
|
||||
}
|
||||
|
||||
@EntityDef(LaunchPayloadc.class)
|
||||
@Component
|
||||
@Component(base = true)
|
||||
static abstract class LaunchPayloadComp implements Drawc, Timedc, Teamc{
|
||||
@Import float x,y;
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ public class ResearchBlock extends Block{
|
||||
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 TileEntity{
|
||||
public class ResearchBlockEntity extends Building{
|
||||
public @Nullable TechNode researching;
|
||||
|
||||
public double[] accumulator;
|
||||
@@ -162,7 +162,7 @@ public class ResearchBlock extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Tilec source, Item item){
|
||||
public boolean acceptItem(Building source, Item item){
|
||||
return items.get(item) < getMaximumAccepted(item);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ public class DeflectorWall extends Wall{
|
||||
super(name);
|
||||
}
|
||||
|
||||
public class DeflectorEntity extends TileEntity{
|
||||
public class DeflectorEntity extends Building{
|
||||
public float hit;
|
||||
|
||||
@Override
|
||||
@@ -40,7 +40,7 @@ public class DeflectorWall extends Wall{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean collision(Bulletc bullet){
|
||||
public boolean collision(Bullet bullet){
|
||||
super.collision(bullet);
|
||||
|
||||
//doesn't reflect powerful bullets
|
||||
|
||||
@@ -41,7 +41,7 @@ public class Door extends Wall{
|
||||
return req.config == Boolean.TRUE ? openRegion : region;
|
||||
}
|
||||
|
||||
public class DoorEntity extends TileEntity{
|
||||
public class DoorEntity extends Building{
|
||||
public boolean open = false;
|
||||
|
||||
@Override
|
||||
@@ -60,7 +60,7 @@ public class Door extends Wall{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tapped(Playerc player){
|
||||
public void tapped(Player player){
|
||||
if((Units.anyEntities(tile) && open) || !timer(timerToggle, 30f)){
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ public class ForceProjector extends Block{
|
||||
Draw.color();
|
||||
}
|
||||
|
||||
public class ForceProjectorEntity extends TileEntity{
|
||||
public class ForceProjectorEntity extends Building{
|
||||
boolean broken = true;
|
||||
float buildup = 0f;
|
||||
float radscl = 0f;
|
||||
|
||||
@@ -55,7 +55,7 @@ public class MendProjector extends Block{
|
||||
Drawf.dashCircle(x * tilesize + offset(), y * tilesize + offset(), range, Pal.accent);
|
||||
}
|
||||
|
||||
public class MendEntity extends TileEntity{
|
||||
public class MendEntity extends Building{
|
||||
float heat;
|
||||
float charge = Mathf.random(reload);
|
||||
float phaseHeat;
|
||||
|
||||
@@ -60,7 +60,7 @@ public class OverdriveProjector extends Block{
|
||||
}
|
||||
}
|
||||
|
||||
public class OverdriveEntity extends TileEntity{
|
||||
public class OverdriveEntity extends Building{
|
||||
float heat;
|
||||
float charge = Mathf.random(reload);
|
||||
float phaseHeat;
|
||||
|
||||
@@ -51,9 +51,9 @@ public class PointDefenseTurret extends Block{
|
||||
return new TextureRegion[]{baseRegion, region};
|
||||
}
|
||||
|
||||
public class PointDefenseEntity extends TileEntity{
|
||||
public class PointDefenseEntity extends Building{
|
||||
public float rotation = 90, reload;
|
||||
public @Nullable Bulletc target;
|
||||
public @Nullable Bullet target;
|
||||
|
||||
@Override
|
||||
public void updateTile(){
|
||||
|
||||
@@ -25,7 +25,7 @@ public class ShockMine extends Block{
|
||||
rebuildable = false;
|
||||
}
|
||||
|
||||
public class ShockMineEntity extends TileEntity{
|
||||
public class ShockMineEntity extends Building{
|
||||
|
||||
@Override
|
||||
public void drawTeam(){
|
||||
@@ -42,7 +42,7 @@ public class ShockMine extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unitOn(Unitc unit){
|
||||
public void unitOn(Unit unit){
|
||||
if(unit.team() != team && timer(timerDamage, cooldown)){
|
||||
for(int i = 0; i < tendrils; i++){
|
||||
Lightning.create(team, Pal.lancerLaser, damage, x, y, Mathf.random(360f), length);
|
||||
|
||||
@@ -14,9 +14,9 @@ public class SurgeWall extends Wall{
|
||||
super(name);
|
||||
}
|
||||
|
||||
public class SurgeEntity extends TileEntity{
|
||||
public class SurgeEntity extends Building{
|
||||
@Override
|
||||
public boolean collision(Bulletc bullet){
|
||||
public boolean collision(Bullet bullet){
|
||||
super.collision(bullet);
|
||||
if(Mathf.chance(lightningChance)){
|
||||
Lightning.create(team(), Pal.surge, lightningDamage, x, y, bullet.rotation() + 180f, lightningLength);
|
||||
|
||||
@@ -42,7 +42,7 @@ public class Wall extends Block{
|
||||
return super.canReplace(other) && health > other.health;
|
||||
}
|
||||
|
||||
public class WallEntity extends TileEntity{
|
||||
public class WallEntity extends Building{
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
|
||||
@@ -40,7 +40,7 @@ public class ItemTurret extends Turret{
|
||||
stats.add(BlockStat.ammo, new AmmoListValue<>(ammoTypes));
|
||||
consumes.add(new ConsumeItemFilter(i -> ammoTypes.containsKey(i)){
|
||||
@Override
|
||||
public void build(Tilec tile, Table table){
|
||||
public void build(Building tile, Table table){
|
||||
MultiReqImage image = new MultiReqImage();
|
||||
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)));
|
||||
@@ -49,7 +49,7 @@ public class ItemTurret extends Turret{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean valid(Tilec entity){
|
||||
public boolean valid(Building entity){
|
||||
//valid when there's any ammo in the turret
|
||||
return !((ItemTurretEntity)entity).ammo.isEmpty();
|
||||
}
|
||||
@@ -103,7 +103,7 @@ public class ItemTurret extends Turret{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleItem(Tilec source, Item item){
|
||||
public void handleItem(Building source, Item item){
|
||||
|
||||
if(item == Items.pyratite){
|
||||
Events.fire(Trigger.flameAmmo);
|
||||
@@ -134,7 +134,7 @@ public class ItemTurret extends Turret{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Tilec source, Item item){
|
||||
public boolean acceptItem(Building source, Item item){
|
||||
return ammoTypes.get(item) != null && totalAmmo + ammoTypes.get(item).ammoMultiplier <= maxAmmo;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ public class LaserTurret extends PowerTurret{
|
||||
}
|
||||
|
||||
public class LaserTurretEntity extends PowerTurretEntity{
|
||||
Bulletc bullet;
|
||||
Bullet bullet;
|
||||
float bulletLife;
|
||||
|
||||
@Override
|
||||
|
||||
@@ -37,8 +37,8 @@ public class LiquidTurret extends Turret{
|
||||
stats.add(BlockStat.ammo, new AmmoListValue<>(ammoTypes));
|
||||
consumes.add(new ConsumeLiquidFilter(i -> ammoTypes.containsKey(i), 1f){
|
||||
@Override
|
||||
public boolean valid(Tilec entity){
|
||||
return entity.liquids().total() > 0.001f;
|
||||
public boolean valid(Building entity){
|
||||
return entity.liquids.total() > 0.001f;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -118,12 +118,12 @@ public class LiquidTurret extends Turret{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Tilec source, Item item){
|
||||
public boolean acceptItem(Building source, Item item){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptLiquid(Tilec source, Liquid liquid, float amount){
|
||||
public boolean acceptLiquid(Building source, Liquid liquid, float amount){
|
||||
return ammoTypes.get(liquid) != null
|
||||
&& (liquids.current() == liquid || (ammoTypes.containsKey(liquids.current())
|
||||
&& liquids.get(liquids.current()) <= ammoTypes.get(liquids.current()).ammoMultiplier + 0.001f));
|
||||
|
||||
@@ -138,7 +138,7 @@ public abstract class Turret extends Block{
|
||||
public abstract BulletType type();
|
||||
}
|
||||
|
||||
public class TurretEntity extends TileEntity implements ControlBlock{
|
||||
public class TurretEntity extends Building implements ControlBlock{
|
||||
public Seq<AmmoEntry> ammo = new Seq<>();
|
||||
public int totalAmmo;
|
||||
public float reload, rotation = 90, recoil, heat;
|
||||
@@ -154,8 +154,8 @@ public abstract class Turret extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public Unitc unit(){
|
||||
return unit;
|
||||
public Unit unit(){
|
||||
return (Unit)unit;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -237,7 +237,7 @@ public abstract class Turret extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleLiquid(Tilec source, Liquid liquid, float amount){
|
||||
public void handleLiquid(Building source, Liquid liquid, float amount){
|
||||
if(acceptCoolant && liquids.currentAmount() <= 0.001f){
|
||||
Events.fire(Trigger.turretCool);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ public class ArmoredConveyor extends Conveyor{
|
||||
|
||||
public class ArmoredConveyorEntity extends ConveyorEntity{
|
||||
@Override
|
||||
public boolean acceptItem(Tilec 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) == tile.rotation());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public class BufferedItemBridge extends ExtendingItemBridge{
|
||||
ItemBuffer buffer = new ItemBuffer(bufferCapacity);
|
||||
|
||||
@Override
|
||||
public void updateTransport(Tilec other){
|
||||
public void updateTransport(Building other){
|
||||
if(buffer.accepts() && items.total() > 0){
|
||||
buffer.accept(items.take());
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ public class Conveyor extends Block implements Autotiler{
|
||||
Mathf.mod(req.tile().rotation() - req.rotation, 2) == 1 ? Blocks.junction : this;
|
||||
}
|
||||
|
||||
public class ConveyorEntity extends TileEntity{
|
||||
public class ConveyorEntity extends Building{
|
||||
//parallel array data
|
||||
Item[] ids = new Item[capacity];
|
||||
float[] xs = new float[capacity];
|
||||
@@ -99,7 +99,7 @@ public class Conveyor extends Block implements Autotiler{
|
||||
//amount of items, always < capacity
|
||||
int len = 0;
|
||||
//next entity
|
||||
@Nullable Tilec next;
|
||||
@Nullable Building next;
|
||||
@Nullable ConveyorEntity nextc;
|
||||
//whether the next conveyor's rotation == tile rotation
|
||||
boolean aligned;
|
||||
@@ -169,7 +169,7 @@ public class Conveyor extends Block implements Autotiler{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unitOn(Unitc unit){
|
||||
public void unitOn(Unit unit){
|
||||
if(clogHeat > 0.5f){
|
||||
return;
|
||||
}
|
||||
@@ -287,7 +287,7 @@ public class Conveyor extends Block implements Autotiler{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Tilec source, Item item){
|
||||
public boolean acceptItem(Building source, Item item){
|
||||
if(len >= capacity) return false;
|
||||
Tile facing = Edges.getFacingEdge(source.tile(), tile);
|
||||
int direction = Math.abs(facing.relativeTo(tile.x, tile.y) - tile.rotation());
|
||||
@@ -295,7 +295,7 @@ public class Conveyor extends Block implements Autotiler{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleItem(Tilec source, Item item){
|
||||
public void handleItem(Building source, Item item){
|
||||
if(len >= capacity) return;
|
||||
|
||||
byte r = tile.rotation();
|
||||
|
||||
@@ -122,7 +122,7 @@ public class ItemBridge extends Block{
|
||||
return null;
|
||||
}
|
||||
|
||||
public class ItemBridgeEntity extends TileEntity{
|
||||
public class ItemBridgeEntity extends Building{
|
||||
public int link = -1;
|
||||
public IntSet incoming = new IntSet();
|
||||
public float uptime;
|
||||
@@ -203,7 +203,7 @@ public class ItemBridge extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onConfigureTileTapped(Tilec other){
|
||||
public boolean onConfigureTileTapped(Building other){
|
||||
//reverse connection
|
||||
if(other instanceof ItemBridgeEntity && ((ItemBridgeEntity)other).link == pos()){
|
||||
configure(other.pos());
|
||||
@@ -257,7 +257,7 @@ public class ItemBridge extends Block{
|
||||
}
|
||||
}
|
||||
|
||||
public void updateTransport(Tilec other){
|
||||
public void updateTransport(Building other){
|
||||
if(uptime >= 0.5f && timer(timerTransport, transportTime)){
|
||||
Item item = items.take();
|
||||
if(item != null && other.acceptItem(this, item)){
|
||||
@@ -314,7 +314,7 @@ public class ItemBridge extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Tilec source, Item item){
|
||||
public boolean acceptItem(Building source, Item item){
|
||||
if(team != source.team()) return false;
|
||||
|
||||
Tile other = world.tile(link);
|
||||
@@ -332,12 +332,12 @@ public class ItemBridge extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDumpLiquid(Tilec to, Liquid liquid){
|
||||
public boolean canDumpLiquid(Building to, Liquid liquid){
|
||||
return checkDump(to);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptLiquid(Tilec source, Liquid liquid, float amount){
|
||||
public boolean acceptLiquid(Building source, Liquid liquid, float amount){
|
||||
if(team != source.team() || !hasLiquids) return false;
|
||||
|
||||
Tile other = world.tile(link);
|
||||
@@ -355,11 +355,11 @@ public class ItemBridge extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDump(Tilec to, Item item){
|
||||
public boolean canDump(Building to, Item item){
|
||||
return checkDump(to);
|
||||
}
|
||||
|
||||
protected boolean checkDump(Tilec to){
|
||||
protected boolean checkDump(Building to){
|
||||
Tile other = world.tile(link);
|
||||
if(!linkValid(tile, other)){
|
||||
Tile edge = Edges.getFacingEdge(to.tile(), tile);
|
||||
|
||||
@@ -26,7 +26,7 @@ public class Junction extends Block{
|
||||
return true;
|
||||
}
|
||||
|
||||
public class JunctionEntity extends TileEntity{
|
||||
public class JunctionEntity extends Building{
|
||||
DirectionalItemBuffer buffer = new DirectionalItemBuffer(capacity);
|
||||
|
||||
@Override
|
||||
@@ -46,7 +46,7 @@ public class Junction extends Block{
|
||||
if(Time.time() >= time + speed / timeScale || Time.time() < time){
|
||||
|
||||
Item item = content.item(BufferItem.item(l));
|
||||
Tilec dest = nearby(i);
|
||||
Building dest = nearby(i);
|
||||
|
||||
//skip blocks that don't want the item, keep waiting until they do
|
||||
if(dest == null || !dest.acceptItem(this, item) || dest.team() != team){
|
||||
@@ -62,17 +62,17 @@ public class Junction extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleItem(Tilec source, Item item){
|
||||
public void handleItem(Building source, Item item){
|
||||
int relative = source.relativeTo(tile);
|
||||
buffer.accept(relative, item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Tilec source, Item item){
|
||||
public boolean acceptItem(Building source, Item item){
|
||||
int relative = source.relativeTo(tile);
|
||||
|
||||
if(relative == -1 || !buffer.accepts(relative)) return false;
|
||||
Tilec to = nearby(relative);
|
||||
Building to = nearby(relative);
|
||||
return to != null && to.team() == team;
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ public class MassDriver extends Block{
|
||||
|
||||
//check if a mass driver is selected while placing this driver
|
||||
if(!control.input.frag.config.isShown()) return;
|
||||
Tilec selected = control.input.frag.config.getSelectedTile();
|
||||
Building selected = control.input.frag.config.getSelectedTile();
|
||||
if(selected == null || !(selected.block() instanceof MassDriver) || !(selected.dst(x * tilesize, y * tilesize) <= range)) return;
|
||||
|
||||
//if so, draw a dotted line towards it while it is in range
|
||||
@@ -85,7 +85,7 @@ public class MassDriver extends Block{
|
||||
}
|
||||
}
|
||||
|
||||
public class MassDriverEntity extends TileEntity{
|
||||
public class MassDriverEntity extends Building{
|
||||
int link = -1;
|
||||
float rotation = 90;
|
||||
float reload = 0f;
|
||||
@@ -98,7 +98,7 @@ public class MassDriver extends Block{
|
||||
|
||||
@Override
|
||||
public void updateTile(){
|
||||
Tilec link = world.ent(this.link);
|
||||
Building link = world.ent(this.link);
|
||||
boolean hasLink = linkValid();
|
||||
|
||||
//reload regardless of state
|
||||
@@ -212,7 +212,7 @@ public class MassDriver extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onConfigureTileTapped(Tilec other){
|
||||
public boolean onConfigureTileTapped(Building other){
|
||||
if(this == other){
|
||||
configure(-1);
|
||||
return false;
|
||||
@@ -230,7 +230,7 @@ public class MassDriver extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Tilec source, Item item){
|
||||
public boolean acceptItem(Building source, Item item){
|
||||
//mass drivers that ouput only cannot accept items
|
||||
return items.total() < itemCapacity && linkValid();
|
||||
}
|
||||
@@ -265,7 +265,7 @@ public class MassDriver extends Block{
|
||||
Effects.shake(shake, shake, this);
|
||||
}
|
||||
|
||||
public void handlePayload(Bulletc bullet, DriverBulletData data){
|
||||
public void handlePayload(Bullet bullet, DriverBulletData data){
|
||||
int totalItems = items.total();
|
||||
|
||||
//add all the items possible
|
||||
|
||||
@@ -30,7 +30,7 @@ public class OverflowGate extends Block{
|
||||
return true;
|
||||
}
|
||||
|
||||
public class OverflowGateEntity extends TileEntity{
|
||||
public class OverflowGateEntity extends Building{
|
||||
Item lastItem;
|
||||
Tile lastInput;
|
||||
float time;
|
||||
@@ -62,7 +62,7 @@ public class OverflowGate extends Block{
|
||||
}
|
||||
|
||||
time += 1f / speed * Time.delta();
|
||||
Tilec target = getTileTarget(lastItem, lastInput, false);
|
||||
Building target = getTileTarget(lastItem, lastInput, false);
|
||||
|
||||
if(target != null && (time >= 1f)){
|
||||
getTileTarget(lastItem, lastInput, true);
|
||||
@@ -74,28 +74,28 @@ public class OverflowGate extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Tilec source, Item item){
|
||||
public boolean acceptItem(Building source, Item item){
|
||||
return team == source.team() && lastItem == null && items.total() == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleItem(Tilec source, Item item){
|
||||
public void handleItem(Building source, Item item){
|
||||
items.add(item, 1);
|
||||
lastItem = item;
|
||||
time = 0f;
|
||||
lastInput = source.tile();
|
||||
}
|
||||
|
||||
public @Nullable Tilec getTileTarget(Item item, Tile src, boolean flip){
|
||||
public @Nullable Building getTileTarget(Item item, Tile src, boolean flip){
|
||||
int from = relativeToEdge(src);
|
||||
if(from == -1) return null;
|
||||
Tilec to = nearby((from + 2) % 4);
|
||||
Building to = nearby((from + 2) % 4);
|
||||
boolean canForward = to != null && to.acceptItem(this, item) && to.team() == team && !(to.block() instanceof OverflowGate);
|
||||
|
||||
|
||||
if(!canForward || invert){
|
||||
Tilec a = nearby(Mathf.mod(from - 1, 4));
|
||||
Tilec b = nearby(Mathf.mod(from + 1, 4));
|
||||
Building a = nearby(Mathf.mod(from - 1, 4));
|
||||
Building b = nearby(Mathf.mod(from + 1, 4));
|
||||
boolean ac = a != null && a.acceptItem(this, item) && !(a.block() instanceof OverflowGate) && a.team() == team;
|
||||
boolean bc = b != null && b.acceptItem(this, item) && !(b.block() instanceof OverflowGate) && b.team() == team;
|
||||
|
||||
|
||||
@@ -41,17 +41,17 @@ public class PayloadConveyor extends Block{
|
||||
super.drawPlace(x, y, rotation, valid);
|
||||
|
||||
for(int i = 0; i < 4; i++){
|
||||
Tilec other = world.ent(x + Geometry.d4x[i] * size, y + Geometry.d4y[i] * size);
|
||||
Building other = world.ent(x + Geometry.d4x[i] * size, y + Geometry.d4y[i] * size);
|
||||
if(other != null && other.block().outputsPayload && other.block().size == size){
|
||||
Drawf.selected(other.tileX(), other.tileY(), other.block(), Pal.accent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PayloadConveyorEntity extends TileEntity{
|
||||
public class PayloadConveyorEntity extends Building{
|
||||
public @Nullable Payload item;
|
||||
public float progress, itemRotation, animation;
|
||||
public @Nullable Tilec next;
|
||||
public @Nullable Building next;
|
||||
public boolean blocked;
|
||||
public int step = -1, stepAccepted = -1;
|
||||
|
||||
@@ -66,7 +66,7 @@ public class PayloadConveyor extends Block{
|
||||
public void onProximityUpdate(){
|
||||
super.onProximityUpdate();
|
||||
|
||||
Tilec accept = nearby(Geometry.d4(rotation()).x * size, Geometry.d4(rotation()).y * size);
|
||||
Building accept = nearby(Geometry.d4(rotation()).x * size, Geometry.d4(rotation()).y * size);
|
||||
//next block must be aligned and of the same size
|
||||
if(accept != null && (
|
||||
//same size
|
||||
@@ -180,13 +180,13 @@ public class PayloadConveyor extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptPayload(Tilec source, Payload payload){
|
||||
public boolean acceptPayload(Building source, Payload payload){
|
||||
//accepting payloads from units isn't supported
|
||||
return this.item == null && progress <= 5f && source != this && payload.fits();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePayload(Tilec source, Payload payload){
|
||||
public void handlePayload(Building source, Payload payload){
|
||||
this.item = payload;
|
||||
this.stepAccepted = curStep();
|
||||
this.itemRotation = source.angleTo(this);
|
||||
|
||||
@@ -19,7 +19,7 @@ public class Router extends Block{
|
||||
unloadable = false;
|
||||
}
|
||||
|
||||
public class RouterEntity extends TileEntity{
|
||||
public class RouterEntity extends Building{
|
||||
Item lastItem;
|
||||
Tile lastInput;
|
||||
float time;
|
||||
@@ -32,7 +32,7 @@ public class Router extends Block{
|
||||
|
||||
if(lastItem != null){
|
||||
time += 1f / speed * delta();
|
||||
Tilec target = getTileTarget(lastItem, lastInput, false);
|
||||
Building target = getTileTarget(lastItem, lastInput, false);
|
||||
|
||||
if(target != null && (time >= 1f || !(target.block() instanceof Router))){
|
||||
getTileTarget(lastItem, lastInput, true);
|
||||
@@ -44,12 +44,12 @@ public class Router extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Tilec source, Item item){
|
||||
public boolean acceptItem(Building source, Item item){
|
||||
return team == source.team() && lastItem == null && items.total() == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleItem(Tilec source, Item item){
|
||||
public void handleItem(Building source, Item item){
|
||||
items.add(item, 1);
|
||||
lastItem = item;
|
||||
time = 0f;
|
||||
@@ -65,10 +65,10 @@ public class Router extends Block{
|
||||
return result;
|
||||
}
|
||||
|
||||
Tilec getTileTarget(Item item, Tile from, boolean set){
|
||||
Building getTileTarget(Item item, Tile from, boolean set){
|
||||
int counter = tile.rotation();
|
||||
for(int i = 0; i < proximity.size; i++){
|
||||
Tilec other = proximity.get((i + counter) % proximity.size);
|
||||
Building other = proximity.get((i + counter) % proximity.size);
|
||||
if(set) tile.rotation((byte)((tile.rotation() + 1) % proximity.size));
|
||||
if(other.tile() == from && from.block() == Blocks.overflowGate) continue;
|
||||
if(other.acceptItem(this, item)){
|
||||
|
||||
@@ -47,11 +47,11 @@ public class Sorter extends Block{
|
||||
return tile.<SorterEntity>ent().sortItem == null ? 0 : tile.<SorterEntity>ent().sortItem.color.rgba();
|
||||
}
|
||||
|
||||
public class SorterEntity extends TileEntity{
|
||||
public class SorterEntity extends Building{
|
||||
@Nullable Item sortItem;
|
||||
|
||||
@Override
|
||||
public void configured(Playerc player, Object value){
|
||||
public void configured(Player player, Object value){
|
||||
super.configured(player, value);
|
||||
|
||||
if(!headless){
|
||||
@@ -73,28 +73,28 @@ public class Sorter extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Tilec source, Item item){
|
||||
Tilec to = getTileTarget(item, source, false);
|
||||
public boolean acceptItem(Building source, Item item){
|
||||
Building to = getTileTarget(item, source, false);
|
||||
|
||||
return to != null && to.acceptItem(this, item) && to.team() == team;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleItem(Tilec source, Item item){
|
||||
Tilec to = getTileTarget(item, source, true);
|
||||
public void handleItem(Building source, Item item){
|
||||
Building to = getTileTarget(item, source, true);
|
||||
|
||||
to.handleItem(this, item);
|
||||
}
|
||||
|
||||
boolean isSame(Tilec other){
|
||||
boolean isSame(Building other){
|
||||
//uncomment comment below to prevent sorter/gate chaining (hacky)
|
||||
return other != null && (other.block() instanceof Sorter/* || other.block() instanceof OverflowGate */);
|
||||
}
|
||||
|
||||
Tilec getTileTarget(Item item, Tilec source, boolean flip){
|
||||
Building getTileTarget(Item item, Building source, boolean flip){
|
||||
int dir = source.relativeTo(tile.x, tile.y);
|
||||
if(dir == -1) return null;
|
||||
Tilec to;
|
||||
Building to;
|
||||
|
||||
if((item == sortItem) != invert){
|
||||
//prevent 3-chains
|
||||
@@ -103,8 +103,8 @@ public class Sorter extends Block{
|
||||
}
|
||||
to = nearby(dir);
|
||||
}else{
|
||||
Tilec a = nearby(Mathf.mod(dir - 1, 4));
|
||||
Tilec b = nearby(Mathf.mod(dir + 1, 4));
|
||||
Building a = nearby(Mathf.mod(dir - 1, 4));
|
||||
Building b = nearby(Mathf.mod(dir + 1, 4));
|
||||
boolean ac = a != null && !(a.block().instantTransfer && source.block().instantTransfer) &&
|
||||
a.acceptItem(this, item);
|
||||
boolean bc = b != null && !(b.block().instantTransfer && source.block().instantTransfer) &&
|
||||
@@ -136,7 +136,7 @@ public class Sorter extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onConfigureTileTapped(Tilec other){
|
||||
public boolean onConfigureTileTapped(Building other){
|
||||
if(this == other){
|
||||
deselect();
|
||||
configure(null);
|
||||
|
||||
@@ -84,14 +84,14 @@ public class StackConveyor extends Block implements Autotiler{
|
||||
|
||||
@Override
|
||||
public boolean rotatedOutput(int x, int y){
|
||||
Tilec tile = world.ent(x, y);
|
||||
Building tile = world.ent(x, y);
|
||||
if(tile instanceof StackConveyorEntity){
|
||||
return ((StackConveyorEntity)tile).state != stateUnload;
|
||||
}
|
||||
return super.rotatedOutput(x, y);
|
||||
}
|
||||
|
||||
public class StackConveyorEntity extends TileEntity{
|
||||
public class StackConveyorEntity extends Building{
|
||||
public int state, blendprox;
|
||||
|
||||
public int link = -1;
|
||||
@@ -155,7 +155,7 @@ public class StackConveyor extends Block implements Autotiler{
|
||||
|
||||
//update other conveyor state when this conveyor's state changes
|
||||
if(state != lastState){
|
||||
for(Tilec near : proximity){
|
||||
for(Building near : proximity){
|
||||
if(near instanceof StackConveyorEntity){
|
||||
near.onProximityUpdate();
|
||||
}
|
||||
@@ -224,7 +224,7 @@ public class StackConveyor extends Block implements Autotiler{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleItem(Tilec source, Item item){
|
||||
public void handleItem(Building source, Item item){
|
||||
if(items.empty()) poofIn();
|
||||
super.handleItem(source, item);
|
||||
lastItem = item;
|
||||
@@ -247,7 +247,7 @@ public class StackConveyor extends Block implements Autotiler{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Tilec source, Item item){
|
||||
public boolean acceptItem(Building source, Item item){
|
||||
if(this == source) return true; // player threw items
|
||||
if(cooldown > recharge - 1f) return false; // still cooling down
|
||||
return !((state != stateLoad) // not a loading dock
|
||||
|
||||
@@ -56,7 +56,7 @@ public class BlockForge extends PayloadAcceptor{
|
||||
public float progress, time, heat;
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Tilec source, Item item){
|
||||
public boolean acceptItem(Building source, Item item){
|
||||
return items.get(item) < getMaximumAccepted(item);
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public class BlockForge extends PayloadAcceptor{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptPayload(Tilec source, Payload payload){
|
||||
public boolean acceptPayload(Building source, Payload payload){
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ public class BlockLoader extends PayloadAcceptor{
|
||||
public class BlockLoaderEntity extends PayloadAcceptorEntity<BlockPayload>{
|
||||
|
||||
@Override
|
||||
public boolean acceptPayload(Tilec source, Payload payload){
|
||||
public boolean acceptPayload(Building source, Payload payload){
|
||||
return super.acceptPayload(source, payload) &&
|
||||
(payload instanceof BlockPayload) &&
|
||||
((((BlockPayload)payload).entity.block().hasItems && ((BlockPayload)payload).block().unloadable && ((BlockPayload)payload).block().itemCapacity >= 10)/* ||
|
||||
@@ -61,7 +61,7 @@ public class BlockLoader extends PayloadAcceptor{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Tilec source, Item item){
|
||||
public boolean acceptItem(Building source, Item item){
|
||||
return items.total() < itemCapacity;
|
||||
}
|
||||
|
||||
@@ -117,9 +117,9 @@ public class BlockLoader extends PayloadAcceptor{
|
||||
if(payload.block().hasLiquids && liquids.total() >= 0.001f){
|
||||
Liquid liq = liquids.current();
|
||||
float total = liquids.currentAmount();
|
||||
float flow = Math.min(Math.min(liquidsLoaded * delta(), payload.block().liquidCapacity - payload.entity.liquids().get(liq) - 0.0001f), total);
|
||||
float flow = Math.min(Math.min(liquidsLoaded * delta(), payload.block().liquidCapacity - payload.entity.liquids.get(liq) - 0.0001f), total);
|
||||
if(payload.entity.acceptLiquid(payload.entity, liq, flow)){
|
||||
payload.entity.liquids().add(liq, flow);
|
||||
payload.entity.liquids.add(liq, flow);
|
||||
liquids.remove(liq, flow);
|
||||
}
|
||||
}*/
|
||||
@@ -127,13 +127,13 @@ public class BlockLoader extends PayloadAcceptor{
|
||||
}
|
||||
|
||||
public float fraction(){
|
||||
return payload == null ? 0f : payload.entity.items().total() / (float)payload.entity.block().itemCapacity;
|
||||
return payload == null ? 0f : payload.entity.items.total() / (float)payload.entity.block().itemCapacity;
|
||||
}
|
||||
|
||||
public boolean shouldExport(){
|
||||
return payload != null &&
|
||||
((payload.block().hasLiquids && payload.entity.liquids().total() >= payload.block().liquidCapacity - 0.001f) ||
|
||||
(payload.block().hasItems && payload.entity.items().total() >= payload.block().itemCapacity));
|
||||
((payload.block().hasLiquids && payload.entity.liquids.total() >= payload.block().liquidCapacity - 0.001f) ||
|
||||
(payload.block().hasItems && payload.entity.items.total() >= payload.block().itemCapacity));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ public class BlockUnloader extends BlockLoader{
|
||||
public class BlockUnloaderEntity extends BlockLoaderEntity{
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Tilec source, Item item){
|
||||
public boolean acceptItem(Building source, Item item){
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -35,9 +35,9 @@ public class BlockUnloader extends BlockLoader{
|
||||
//load up items a set amount of times
|
||||
for(int j = 0; j < itemsLoaded && !full(); j++){
|
||||
for(int i = 0; i < items.length(); i++){
|
||||
if(payload.entity.items().get(i) > 0){
|
||||
if(payload.entity.items.get(i) > 0){
|
||||
Item item = content.item(i);
|
||||
payload.entity.items().remove(item, 1);
|
||||
payload.entity.items.remove(item, 1);
|
||||
items.add(item, 1);
|
||||
break;
|
||||
}
|
||||
@@ -56,12 +56,12 @@ public class BlockUnloader extends BlockLoader{
|
||||
|
||||
@Override
|
||||
public float fraction(){
|
||||
return payload == null ? 0f : 1f - payload.entity.items().total() / (float)payload.entity.block().itemCapacity;
|
||||
return payload == null ? 0f : 1f - payload.entity.items.total() / (float)payload.entity.block().itemCapacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldExport(){
|
||||
return payload != null && (payload.block().hasItems && payload.entity.items().empty());
|
||||
return payload != null && (payload.block().hasItems && payload.entity.items.empty());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,12 +12,12 @@ public class ProcessorBlock extends Block{
|
||||
configurable = true;
|
||||
}
|
||||
|
||||
public class ProcessorEntity extends TileEntity{
|
||||
public class ProcessorEntity extends Building{
|
||||
//all tiles in the block network - does not include itself
|
||||
Seq<Tilec> network = new Seq<>();
|
||||
Seq<Building> network = new Seq<>();
|
||||
|
||||
@Override
|
||||
public boolean onConfigureTileTapped(Tilec other){
|
||||
public boolean onConfigureTileTapped(Building other){
|
||||
if(other == this) return true;
|
||||
|
||||
if(!network.contains(other)){
|
||||
|
||||
@@ -10,7 +10,7 @@ public class LegacyCommandCenter extends LegacyBlock{
|
||||
update = true;
|
||||
}
|
||||
|
||||
public class LegacyCommandCenterEntity extends TileEntity{
|
||||
public class LegacyCommandCenterEntity extends Building{
|
||||
@Override
|
||||
public void read(Reads read, byte revision){
|
||||
super.read(read, revision);
|
||||
|
||||
@@ -11,7 +11,7 @@ public class LegacyMechPad extends LegacyBlock{
|
||||
hasPower = true;
|
||||
}
|
||||
|
||||
public class LegacyMechPadEntity extends TileEntity{
|
||||
public class LegacyMechPadEntity extends Building{
|
||||
|
||||
@Override
|
||||
public void read(Reads read, byte revision){
|
||||
|
||||
@@ -13,7 +13,7 @@ public class LegacyUnitFactory extends LegacyBlock{
|
||||
solid = false;
|
||||
}
|
||||
|
||||
public class LegacyUnitFactoryEntity extends TileEntity{
|
||||
public class LegacyUnitFactoryEntity extends Building{
|
||||
|
||||
@Override
|
||||
public void read(Reads read, byte revision){
|
||||
|
||||
@@ -25,14 +25,14 @@ public class ArmoredConduit extends Conduit{
|
||||
super.draw();
|
||||
|
||||
// draw the cap when a conduit would normally leak
|
||||
Tilec next = tile.front();
|
||||
Building next = tile.front();
|
||||
if(next != null && next.team() == team && next.block().hasLiquids) return;
|
||||
|
||||
Draw.rect(capRegion, x, y, tile.rotdeg());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptLiquid(Tilec source, Liquid liquid, float amount){
|
||||
public boolean acceptLiquid(Building source, Liquid liquid, float amount){
|
||||
return super.acceptLiquid(source, liquid, amount) && (source.block() instanceof Conduit) || Edges.getFacingEdge(source.tile(), tile).absoluteRelativeTo(tile.x, tile.y) == tile.rotation();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ public class Conduit extends LiquidBlock implements Autotiler{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptLiquid(Tilec source, Liquid liquid, float amount){
|
||||
public boolean acceptLiquid(Building source, Liquid liquid, float amount){
|
||||
noSleep();
|
||||
return liquids.get(liquid) + amount < liquidCapacity && (liquids.current() == liquid || liquids.currentAmount() < 0.2f)
|
||||
&& ((source.relativeTo(tile.x, tile.y) + 2) % 4 != tile.rotation());
|
||||
|
||||
@@ -25,7 +25,7 @@ public class LiquidBlock extends Block{
|
||||
return new TextureRegion[]{bottomRegion, topRegion};
|
||||
}
|
||||
|
||||
public class LiquidBlockEntity extends TileEntity{
|
||||
public class LiquidBlockEntity extends Building{
|
||||
@Override
|
||||
public void draw(){
|
||||
float rotation = rotate ? rotdeg() : 0;
|
||||
|
||||
@@ -26,7 +26,7 @@ public class LiquidBridge extends ItemBridge{
|
||||
|
||||
checkIncoming();
|
||||
|
||||
Tilec other = world.ent(link);
|
||||
Building other = world.ent(link);
|
||||
if(other == null || !linkValid(tile, other.tile())){
|
||||
dumpLiquid(liquids.current());
|
||||
}else{
|
||||
@@ -54,7 +54,7 @@ public class LiquidBridge extends ItemBridge{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Tilec source, Item item){
|
||||
public boolean acceptItem(Building source, Item item){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public class LiquidExtendingBridge extends ExtendingItemBridge{
|
||||
|
||||
checkIncoming();
|
||||
|
||||
Tilec other = world.ent(link);
|
||||
Building other = world.ent(link);
|
||||
if(other == null || !linkValid(tile, other.tile())){
|
||||
dumpLiquid(liquids.current());
|
||||
}else{
|
||||
@@ -49,7 +49,7 @@ public class LiquidExtendingBridge extends ExtendingItemBridge{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Tilec source, Item item){
|
||||
public boolean acceptItem(Building source, Item item){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,17 +28,17 @@ public class LiquidJunction extends LiquidBlock{
|
||||
return new TextureRegion[]{region};
|
||||
}
|
||||
|
||||
public class LiquidJunctionEntity extends TileEntity{
|
||||
public class LiquidJunctionEntity extends Building{
|
||||
@Override
|
||||
public void draw(){
|
||||
Draw.rect(region, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Tilec getLiquidDestination(Tilec source, Liquid liquid){
|
||||
public Building getLiquidDestination(Building source, Liquid liquid){
|
||||
int dir = source.relativeTo(tile.x, tile.y);
|
||||
dir = (dir + 4) % 4;
|
||||
Tilec next = nearby(dir);
|
||||
Building next = nearby(dir);
|
||||
if(next == null || (!next.acceptLiquid(this, liquid, 0f) && !(next.block() instanceof LiquidJunction))){
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ public class LiquidRouter extends LiquidBlock{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptLiquid(Tilec source, Liquid liquid, float amount){
|
||||
public boolean acceptLiquid(Building source, Liquid liquid, float amount){
|
||||
return liquids.get(liquid) + amount < liquidCapacity && (liquids.current() == liquid || liquids.currentAmount() < 0.2f);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,13 +11,13 @@ import mindustry.world.*;
|
||||
import static mindustry.Vars.tilesize;
|
||||
|
||||
public class BlockPayload implements Payload{
|
||||
public Tilec entity;
|
||||
public Building entity;
|
||||
|
||||
public BlockPayload(Block block, Team team){
|
||||
this.entity = block.newEntity().create(block, team);
|
||||
}
|
||||
|
||||
public BlockPayload(Tilec entity){
|
||||
public BlockPayload(Building entity){
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ public interface Payload{
|
||||
return (T)payload;
|
||||
}else if(type == payloadUnit){
|
||||
byte id = read.b();
|
||||
Unitc unit = (Unitc)EntityMapping.map(id).get();
|
||||
Unit unit = (Unit)EntityMapping.map(id).get();
|
||||
unit.read(read);
|
||||
return (T)new UnitPayload(unit);
|
||||
}
|
||||
|
||||
@@ -9,15 +9,15 @@ import mindustry.graphics.*;
|
||||
import mindustry.ui.*;
|
||||
|
||||
public class UnitPayload implements Payload{
|
||||
public Unitc unit;
|
||||
public Unit unit;
|
||||
|
||||
public UnitPayload(Unitc unit){
|
||||
public UnitPayload(Unit unit){
|
||||
this.unit = unit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fits(){
|
||||
return unit.hitSize() <= 16f;
|
||||
return unit.hitSize <= 16f;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -39,7 +39,7 @@ public class UnitPayload implements Payload{
|
||||
if(Vars.net.client()) return true;
|
||||
|
||||
//prevents stacking
|
||||
unit.vel().add(Mathf.range(0.5f), Mathf.range(0.5f));
|
||||
unit.vel.add(Mathf.range(0.5f), Mathf.range(0.5f));
|
||||
unit.add();
|
||||
|
||||
return true;
|
||||
@@ -47,7 +47,7 @@ public class UnitPayload implements Payload{
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
Drawf.shadow(unit.x(), unit.y(), 20);
|
||||
Draw.rect(unit.type().icon(Cicon.full), unit.x(), unit.y(), unit.rotation() - 90);
|
||||
Drawf.shadow(unit.x, unit.y, 20);
|
||||
Draw.rect(unit.type().icon(Cicon.full), unit.x, unit.y, unit.rotation - 90);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ public class Battery extends PowerDistributor{
|
||||
consumesPower = true;
|
||||
}
|
||||
|
||||
public class BatteryEntity extends TileEntity{
|
||||
public class BatteryEntity extends Building{
|
||||
@Override
|
||||
public void draw(){
|
||||
Draw.color(emptyLightColor, fullLightColor, power.status);
|
||||
|
||||
@@ -6,15 +6,15 @@ import mindustry.world.consumers.ConsumePower;
|
||||
|
||||
/** A power consumer that only activates sometimes. */
|
||||
public class ConditionalConsumePower extends ConsumePower{
|
||||
private final Boolf<Tilec> consume;
|
||||
private final Boolf<Building> consume;
|
||||
|
||||
public ConditionalConsumePower(float usage, Boolf<Tilec> consume){
|
||||
public ConditionalConsumePower(float usage, Boolf<Building> consume){
|
||||
super(usage, 0, false);
|
||||
this.consume = consume;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float requestedPower(Tilec entity){
|
||||
public float requestedPower(Building entity){
|
||||
return consume.get(entity) ? usage : 0f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ public class LightBlock extends Block{
|
||||
config(Integer.class, (LightEntity tile, Integer value) -> tile.color = value);
|
||||
}
|
||||
|
||||
public class LightEntity extends TileEntity{
|
||||
public class LightEntity extends Building{
|
||||
public int color = Pal.accent.rgba();
|
||||
|
||||
@Override
|
||||
|
||||
@@ -38,11 +38,11 @@ public class PowerDiode extends Block{
|
||||
}
|
||||
|
||||
// battery % of the graph on either side, defaults to zero
|
||||
public float bar(Tilec tile){
|
||||
return (tile != null && tile.block().hasPower) ? tile.power().graph.getBatteryStored() / tile.power().graph.getTotalBatteryCapacity() : 0f;
|
||||
public float bar(Building tile){
|
||||
return (tile != null && tile.block().hasPower) ? tile.power.graph.getBatteryStored() / tile.power.graph.getTotalBatteryCapacity() : 0f;
|
||||
}
|
||||
|
||||
public class PowerDiodeEntity extends TileEntity{
|
||||
public class PowerDiodeEntity extends Building{
|
||||
@Override
|
||||
public void draw(){
|
||||
Draw.rect(region, x, y, 0);
|
||||
|
||||
@@ -45,7 +45,7 @@ public class PowerGenerator extends PowerDistributor{
|
||||
return false;
|
||||
}
|
||||
|
||||
public class GeneratorEntity extends TileEntity{
|
||||
public class GeneratorEntity extends Building{
|
||||
public float generateTime;
|
||||
/** The efficiency of the producer. An efficiency of 1.0 means 100% */
|
||||
public float productionEfficiency = 0.0f;
|
||||
|
||||
@@ -8,15 +8,15 @@ import mindustry.gen.*;
|
||||
import mindustry.world.consumers.*;
|
||||
|
||||
public class PowerGraph{
|
||||
private final static Queue<Tilec> queue = new Queue<>();
|
||||
private final static Seq<Tilec> outArray1 = new Seq<>();
|
||||
private final static Seq<Tilec> outArray2 = new Seq<>();
|
||||
private final static Queue<Building> queue = new Queue<>();
|
||||
private final static Seq<Building> outArray1 = new Seq<>();
|
||||
private final static Seq<Building> outArray2 = new Seq<>();
|
||||
private final static IntSet closedSet = new IntSet();
|
||||
|
||||
private final ObjectSet<Tilec> producers = new ObjectSet<>();
|
||||
private final ObjectSet<Tilec> consumers = new ObjectSet<>();
|
||||
private final ObjectSet<Tilec> batteries = new ObjectSet<>();
|
||||
private final ObjectSet<Tilec> all = new ObjectSet<>();
|
||||
private final ObjectSet<Building> producers = new ObjectSet<>();
|
||||
private final ObjectSet<Building> consumers = new ObjectSet<>();
|
||||
private final ObjectSet<Building> batteries = new ObjectSet<>();
|
||||
private final ObjectSet<Building> all = new ObjectSet<>();
|
||||
|
||||
private final WindowedMean powerBalance = new WindowedMean(60);
|
||||
private float lastPowerProduced, lastPowerNeeded, lastUsageFraction;
|
||||
@@ -61,7 +61,7 @@ public class PowerGraph{
|
||||
|
||||
public float getPowerProduced(){
|
||||
float powerProduced = 0f;
|
||||
for(Tilec producer : producers){
|
||||
for(Building producer : producers){
|
||||
powerProduced += producer.getPowerProduction() * producer.delta();
|
||||
}
|
||||
return powerProduced;
|
||||
@@ -69,7 +69,7 @@ public class PowerGraph{
|
||||
|
||||
public float getPowerNeeded(){
|
||||
float powerNeeded = 0f;
|
||||
for(Tilec consumer : consumers){
|
||||
for(Building consumer : consumers){
|
||||
Consumers consumes = consumer.block().consumes;
|
||||
if(consumes.hasPower()){
|
||||
ConsumePower consumePower = consumes.getPower();
|
||||
@@ -83,7 +83,7 @@ public class PowerGraph{
|
||||
|
||||
public float getBatteryStored(){
|
||||
float totalAccumulator = 0f;
|
||||
for(Tilec battery : batteries){
|
||||
for(Building battery : batteries){
|
||||
Consumers consumes = battery.block().consumes;
|
||||
if(consumes.hasPower()){
|
||||
totalAccumulator += battery.power().status * consumes.getPower().capacity;
|
||||
@@ -94,7 +94,7 @@ public class PowerGraph{
|
||||
|
||||
public float getBatteryCapacity(){
|
||||
float totalCapacity = 0f;
|
||||
for(Tilec battery : batteries){
|
||||
for(Building battery : batteries){
|
||||
if(battery.block().consumes.hasPower()){
|
||||
ConsumePower power = battery.block().consumes.getPower();
|
||||
totalCapacity += (1f - battery.power().status) * power.capacity;
|
||||
@@ -105,7 +105,7 @@ public class PowerGraph{
|
||||
|
||||
public float getTotalBatteryCapacity(){
|
||||
float totalCapacity = 0f;
|
||||
for(Tilec battery : batteries){
|
||||
for(Building battery : batteries){
|
||||
if(battery.block().consumes.hasPower()){
|
||||
totalCapacity += battery.block().consumes.getPower().capacity;
|
||||
}
|
||||
@@ -119,7 +119,7 @@ public class PowerGraph{
|
||||
|
||||
float used = Math.min(stored, needed);
|
||||
float consumedPowerPercentage = Math.min(1.0f, needed / stored);
|
||||
for(Tilec battery : batteries){
|
||||
for(Building battery : batteries){
|
||||
Consumers consumes = battery.block().consumes;
|
||||
if(consumes.hasPower()){
|
||||
battery.power().status *= (1f-consumedPowerPercentage);
|
||||
@@ -134,7 +134,7 @@ public class PowerGraph{
|
||||
float chargedPercent = Math.min(excess/capacity, 1f);
|
||||
if(Mathf.equal(capacity, 0f)) return 0f;
|
||||
|
||||
for(Tilec battery : batteries){
|
||||
for(Building battery : batteries){
|
||||
Consumers consumes = battery.block().consumes;
|
||||
if(consumes.hasPower()){
|
||||
ConsumePower consumePower = consumes.getPower();
|
||||
@@ -149,7 +149,7 @@ public class PowerGraph{
|
||||
public void distributePower(float needed, float produced){
|
||||
//distribute even if not needed. this is because some might be requiring power but not using it; it updates consumers
|
||||
float coverage = Mathf.zero(needed) && Mathf.zero(produced) ? 0f : Mathf.zero(needed) ? 1f : Math.min(1, produced / needed);
|
||||
for(Tilec consumer : consumers){
|
||||
for(Building consumer : consumers){
|
||||
Consumers consumes = consumer.block().consumes;
|
||||
if(consumes.hasPower()){
|
||||
ConsumePower consumePower = consumes.getPower();
|
||||
@@ -180,8 +180,8 @@ public class PowerGraph{
|
||||
return;
|
||||
}else if(!consumers.isEmpty() && consumers.first().cheating()){
|
||||
//when cheating, just set status to 1
|
||||
for(Tilec tile : consumers){
|
||||
tile.power().status = 1f;
|
||||
for(Building tile : consumers){
|
||||
tile.power.status = 1f;
|
||||
}
|
||||
|
||||
lastPowerNeeded = lastPowerProduced = lastUsageFraction = 1f;
|
||||
@@ -221,15 +221,15 @@ public class PowerGraph{
|
||||
lastUsageFraction = Mathf.zero(rawProduced) ? 1f : Mathf.clamp(powerNeeded / rawProduced);
|
||||
}
|
||||
|
||||
public void add(PowerGraph graph){
|
||||
for(Tilec tile : graph.all){
|
||||
public void addGraph(PowerGraph graph){
|
||||
for(Building tile : graph.all){
|
||||
add(tile);
|
||||
}
|
||||
}
|
||||
|
||||
public void add(Tilec tile){
|
||||
if(tile == null || tile.power() == null) return;
|
||||
tile.power().graph = this;
|
||||
public void add(Building tile){
|
||||
if(tile == null || tile.power == null) return;
|
||||
tile.power.graph = this;
|
||||
all.add(tile);
|
||||
|
||||
if(tile.block().outputsPower && tile.block().consumesPower && !tile.block().consumes.getPower().buffered){
|
||||
@@ -244,14 +244,14 @@ public class PowerGraph{
|
||||
}
|
||||
}
|
||||
|
||||
public void reflow(Tilec tile){
|
||||
public void reflow(Building tile){
|
||||
queue.clear();
|
||||
queue.addLast(tile);
|
||||
closedSet.clear();
|
||||
while(queue.size > 0){
|
||||
Tilec child = queue.removeFirst();
|
||||
Building child = queue.removeFirst();
|
||||
add(child);
|
||||
for(Tilec next : child.getPowerConnections(outArray2)){
|
||||
for(Building next : child.getPowerConnections(outArray2)){
|
||||
if(!closedSet.contains(next.pos())){
|
||||
queue.addLast(next);
|
||||
closedSet.add(next.pos());
|
||||
@@ -260,20 +260,20 @@ public class PowerGraph{
|
||||
}
|
||||
}
|
||||
|
||||
private void removeSingle(Tilec tile){
|
||||
private void removeSingle(Building tile){
|
||||
all.remove(tile);
|
||||
producers.remove(tile);
|
||||
consumers.remove(tile);
|
||||
batteries.remove(tile);
|
||||
}
|
||||
|
||||
public void remove(Tilec tile){
|
||||
public void remove(Building tile){
|
||||
removeSingle(tile);
|
||||
//begin by clearing the closed set
|
||||
closedSet.clear();
|
||||
|
||||
//go through all the connections of this tile
|
||||
for(Tilec other : tile.getPowerConnections(outArray1)){
|
||||
for(Building other : tile.getPowerConnections(outArray1)){
|
||||
//a graph has already been assigned to this tile from a previous call, skip it
|
||||
if(other.power().graph != this) continue;
|
||||
|
||||
@@ -285,13 +285,13 @@ public class PowerGraph{
|
||||
queue.addLast(other);
|
||||
while(queue.size > 0){
|
||||
//get child from queue
|
||||
Tilec child = queue.removeFirst();
|
||||
Building child = queue.removeFirst();
|
||||
//remove it from this graph
|
||||
removeSingle(child);
|
||||
//add it to the new branch graph
|
||||
graph.add(child);
|
||||
//go through connections
|
||||
for(Tilec next : child.getPowerConnections(outArray2)){
|
||||
for(Building next : child.getPowerConnections(outArray2)){
|
||||
//make sure it hasn't looped back, and that the new graph being assigned hasn't already been assigned
|
||||
//also skip closed tiles
|
||||
if(next != tile && next.power().graph != graph && !closedSet.contains(next.pos())){
|
||||
@@ -305,7 +305,7 @@ public class PowerGraph{
|
||||
}
|
||||
}
|
||||
|
||||
private boolean otherConsumersAreValid(Tilec tile, Consume consumePower){
|
||||
private boolean otherConsumersAreValid(Building tile, Consume consumePower){
|
||||
for(Consume cons : tile.block().consumes.all()){
|
||||
if(cons != consumePower && !cons.isOptional() && !cons.valid(tile)){
|
||||
return false;
|
||||
|
||||
@@ -40,8 +40,8 @@ public class PowerNode extends PowerBlock{
|
||||
consumesPower = false;
|
||||
outputsPower = false;
|
||||
config(Integer.class, (entity, value) -> {
|
||||
PowerModule power = entity.power();
|
||||
Tilec other = world.ent(value);
|
||||
PowerModule power = entity.power;
|
||||
Building other = world.ent(value);
|
||||
boolean contains = power.links.contains(value), valid = other != null && other.power() != null;
|
||||
|
||||
if(contains){
|
||||
@@ -73,15 +73,15 @@ public class PowerNode extends PowerBlock{
|
||||
}
|
||||
}
|
||||
|
||||
power.graph.add(other.power().graph);
|
||||
power.graph.addGraph(other.power.graph);
|
||||
}
|
||||
});
|
||||
|
||||
config(Point2[].class, (tile, value) -> {
|
||||
tile.power().links.clear();
|
||||
tile.power.links.clear();
|
||||
for(Point2 p : value){
|
||||
if(tile.power().links.size < maxNodes){
|
||||
tile.power().links.add(Point2.pack(p.x + tile.tileX(), p.y + tile.tileY()));
|
||||
if(tile.power.links.size < maxNodes){
|
||||
tile.power.links.add(Point2.pack(p.x + tile.tileX(), p.y + tile.tileY()));
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -92,15 +92,15 @@ public class PowerNode extends PowerBlock{
|
||||
super.setBars();
|
||||
bars.add("power", entity -> new Bar(() ->
|
||||
Core.bundle.format("bar.powerbalance",
|
||||
((entity.power().graph.getPowerBalance() >= 0 ? "+" : "") + Strings.fixed(entity.power().graph.getPowerBalance() * 60, 1))),
|
||||
((entity.power.graph.getPowerBalance() >= 0 ? "+" : "") + Strings.fixed(entity.power.graph.getPowerBalance() * 60, 1))),
|
||||
() -> Pal.powerBar,
|
||||
() -> Mathf.clamp(entity.power().graph.getLastPowerProduced() / entity.power().graph.getLastPowerNeeded())));
|
||||
() -> Mathf.clamp(entity.power.graph.getLastPowerProduced() / entity.power.graph.getLastPowerNeeded())));
|
||||
|
||||
bars.add("batteries", entity -> new Bar(() ->
|
||||
Core.bundle.format("bar.powerstored",
|
||||
(ui.formatAmount((int)entity.power().graph.getBatteryStored())), ui.formatAmount((int)entity.power().graph.getTotalBatteryCapacity())),
|
||||
(ui.formatAmount((int)entity.power.graph.getBatteryStored())), ui.formatAmount((int)entity.power.graph.getTotalBatteryCapacity())),
|
||||
() -> Pal.powerBar,
|
||||
() -> Mathf.clamp(entity.power().graph.getBatteryStored() / entity.power().graph.getTotalBatteryCapacity())));
|
||||
() -> Mathf.clamp(entity.power.graph.getBatteryStored() / entity.power.graph.getTotalBatteryCapacity())));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -157,7 +157,7 @@ public class PowerNode extends PowerBlock{
|
||||
return Intersector.overlaps(Tmp.cr1.set(srcx, srcy, range), other.getHitbox(Tmp.r1));
|
||||
}
|
||||
|
||||
protected boolean overlaps(Tilec src, Tilec other, float range){
|
||||
protected boolean overlaps(Building src, Building other, float range){
|
||||
return overlaps(src.x(), src.y(), other.tile(), range);
|
||||
}
|
||||
|
||||
@@ -170,20 +170,20 @@ public class PowerNode extends PowerBlock{
|
||||
return Intersector.overlaps(Tmp.cr1.set(src.worldx() + offset(), src.worldy() + offset(), laserRange * tilesize), Tmp.r1.setSize(size * tilesize).setCenter(other.worldx() + offset(), other.worldy() + offset()));
|
||||
}
|
||||
|
||||
protected void getPotentialLinks(Tile tile, Cons<Tilec> others){
|
||||
Boolf<Tilec> valid = other -> other != null && other.tile() != tile && other.power() != null &&
|
||||
protected void getPotentialLinks(Tile tile, Cons<Building> others){
|
||||
Boolf<Building> valid = other -> other != null && other.tile() != tile && other.power() != null &&
|
||||
((!other.block().outputsPower && other.block().consumesPower) || (other.block().outputsPower && !other.block().consumesPower) || other.block() instanceof PowerNode) &&
|
||||
overlaps(tile.x * tilesize + offset(), tile.y * tilesize + offset(), other.tile(), laserRange * tilesize) && other.team() == player.team()
|
||||
&& !other.proximity().contains(e -> e.tile() == tile) && !graphs.contains(other.power().graph);
|
||||
|
||||
tempTileEnts.clear();
|
||||
graphs.clear();
|
||||
if(tile.entity != null && tile.entity.power() != null){
|
||||
graphs.add(tile.entity.power().graph);
|
||||
if(tile.entity != null && tile.entity.power != null){
|
||||
graphs.add(tile.entity.power.graph);
|
||||
}
|
||||
|
||||
Geometry.circle(tile.x, tile.y, (int)(laserRange + 2), (x, y) -> {
|
||||
Tilec other = world.ent(x, y);
|
||||
Building other = world.ent(x, y);
|
||||
if(valid.get(other) && !tempTileEnts.contains(other)){
|
||||
tempTileEnts.add(other);
|
||||
}
|
||||
@@ -219,11 +219,11 @@ public class PowerNode extends PowerBlock{
|
||||
}
|
||||
}
|
||||
|
||||
public boolean linkValid(Tilec tile, Tilec link){
|
||||
public boolean linkValid(Building tile, Building link){
|
||||
return linkValid(tile, link, true);
|
||||
}
|
||||
|
||||
public boolean linkValid(Tilec tile, Tilec link, boolean checkMaxNodes){
|
||||
public boolean linkValid(Building tile, Building link, boolean checkMaxNodes){
|
||||
if(tile == link || link == null || !link.block().hasPower || tile.team() != link.team()) return false;
|
||||
|
||||
if(overlaps(tile, link, laserRange * tilesize) || (link.block() instanceof PowerNode && overlaps(link, tile, ((PowerNode)link.block()).laserRange * tilesize))){
|
||||
@@ -239,7 +239,7 @@ public class PowerNode extends PowerBlock{
|
||||
return insulated(tile.x, tile.y, other.x, other.y);
|
||||
}
|
||||
|
||||
public static boolean insulated(Tilec tile, Tilec other){
|
||||
public static boolean insulated(Building tile, Building other){
|
||||
return insulated(tile.tileX(), tile.tileY(), other.tileX(), other.tileY());
|
||||
}
|
||||
|
||||
@@ -249,10 +249,10 @@ public class PowerNode extends PowerBlock{
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
public static void insulators(int x, int y, int x2, int y2, Cons<Tilec> iterator){
|
||||
public static void insulators(int x, int y, int x2, int y2, Cons<Building> iterator){
|
||||
world.raycastEach(x, y, x2, y2, (wx, wy) -> {
|
||||
|
||||
Tilec tile = world.ent(wx, wy);
|
||||
Building tile = world.ent(wx, wy);
|
||||
if(tile != null && tile.block().insulated){
|
||||
iterator.get(tile);
|
||||
}
|
||||
@@ -261,19 +261,19 @@ public class PowerNode extends PowerBlock{
|
||||
});
|
||||
}
|
||||
|
||||
public class PowerNodeEntity extends TileEntity{
|
||||
public class PowerNodeEntity extends Building{
|
||||
|
||||
@Override
|
||||
public void placed(){
|
||||
if(net.client()) return;
|
||||
|
||||
Boolf<Tilec> valid = other -> other != null && other != this && ((!other.block().outputsPower && other.block().consumesPower) ||
|
||||
Boolf<Building> valid = other -> other != null && other != this && ((!other.block().outputsPower && other.block().consumesPower) ||
|
||||
(other.block().outputsPower && !other.block().consumesPower) || other.block() instanceof PowerNode) && linkValid(this, other)
|
||||
&& !other.proximity().contains(this) && other.power().graph != power.graph;
|
||||
|
||||
tempTileEnts.clear();
|
||||
Geometry.circle(tile.x, tile.y, (int)(laserRange + 2), (x, y) -> {
|
||||
Tilec other = world.ent(x, y);
|
||||
Building other = world.ent(x, y);
|
||||
if(valid.get(other)){
|
||||
if(!insulated(this, other)){
|
||||
tempTileEnts.add(other);
|
||||
@@ -301,7 +301,7 @@ public class PowerNode extends PowerBlock{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onConfigureTileTapped(Tilec other){
|
||||
public boolean onConfigureTileTapped(Building other){
|
||||
if(linkValid(this, other)){
|
||||
configure(other.pos());
|
||||
return false;
|
||||
@@ -346,7 +346,7 @@ public class PowerNode extends PowerBlock{
|
||||
|
||||
for(int x = (int)(tile.x - laserRange - 2); x <= tile.x + laserRange + 2; x++){
|
||||
for(int y = (int)(tile.y - laserRange - 2); y <= tile.y + laserRange + 2; y++){
|
||||
Tilec link = world.ent(x, y);
|
||||
Building link = world.ent(x, y);
|
||||
|
||||
if(link != this && linkValid(this, link, false)){
|
||||
boolean linked = linked(link);
|
||||
@@ -370,7 +370,7 @@ public class PowerNode extends PowerBlock{
|
||||
Draw.z(Layer.power);
|
||||
|
||||
for(int i = 0; i < power.links.size; i++){
|
||||
Tilec link = world.ent(power.links.get(i));
|
||||
Building link = world.ent(power.links.get(i));
|
||||
|
||||
if(!linkValid(this, link)) continue;
|
||||
|
||||
@@ -382,11 +382,11 @@ public class PowerNode extends PowerBlock{
|
||||
Draw.reset();
|
||||
}
|
||||
|
||||
protected boolean linked(Tilec other){
|
||||
protected boolean linked(Building other){
|
||||
return power.links.contains(other.pos());
|
||||
}
|
||||
|
||||
protected void drawLaserTo(Tilec target){
|
||||
protected void drawLaserTo(Building target){
|
||||
drawLaser(team, x, y, target.x(), target.y(), power.graph.getSatisfaction(), size, target.block().size);
|
||||
}
|
||||
|
||||
|
||||
@@ -205,7 +205,7 @@ public class Drill extends Block{
|
||||
return drops != null && drops.hardness <= tier;
|
||||
}
|
||||
|
||||
public class DrillEntity extends TileEntity{
|
||||
public class DrillEntity extends Building{
|
||||
public float progress;
|
||||
public int index;
|
||||
public float warmup;
|
||||
|
||||
@@ -79,7 +79,7 @@ public class GenericCrafter extends Block{
|
||||
return outputItem != null;
|
||||
}
|
||||
|
||||
public class GenericCrafterEntity extends TileEntity{
|
||||
public class GenericCrafterEntity extends Building{
|
||||
public float progress;
|
||||
public float totalProgress;
|
||||
public float warmup;
|
||||
|
||||
@@ -22,7 +22,7 @@ public class Incinerator extends Block{
|
||||
solid = true;
|
||||
}
|
||||
|
||||
public class IncineratorEntity extends TileEntity{
|
||||
public class IncineratorEntity extends Building{
|
||||
public float heat;
|
||||
|
||||
@Override
|
||||
@@ -54,26 +54,26 @@ public class Incinerator extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleItem(Tilec source, Item item){
|
||||
public void handleItem(Building source, Item item){
|
||||
if(Mathf.chance(0.3)){
|
||||
effect.at(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Tilec source, Item item){
|
||||
public boolean acceptItem(Building source, Item item){
|
||||
return heat > 0.5f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleLiquid(Tilec source, Liquid liquid, float amount){
|
||||
public void handleLiquid(Building source, Liquid liquid, float amount){
|
||||
if(Mathf.chance(0.02)){
|
||||
effect.at(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptLiquid(Tilec source, Liquid liquid, float amount){
|
||||
public boolean acceptLiquid(Building source, Liquid liquid, float amount){
|
||||
return heat > 0.5f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,9 +26,9 @@ public class PayloadAcceptor extends Block{
|
||||
update = true;
|
||||
}
|
||||
|
||||
public static boolean blends(Tilec tile, int direction){
|
||||
public static boolean blends(Building tile, int direction){
|
||||
int size = tile.block().size;
|
||||
Tilec accept = tile.nearby(Geometry.d4(direction).x * size, Geometry.d4(direction).y * size);
|
||||
Building accept = tile.nearby(Geometry.d4(direction).x * size, Geometry.d4(direction).y * size);
|
||||
return accept != null &&
|
||||
accept.block().outputsPayload &&
|
||||
|
||||
@@ -46,18 +46,18 @@ public class PayloadAcceptor extends Block{
|
||||
);
|
||||
}
|
||||
|
||||
public class PayloadAcceptorEntity<T extends Payload> extends TileEntity{
|
||||
public class PayloadAcceptorEntity<T extends Payload> extends Building{
|
||||
public @Nullable T payload;
|
||||
public Vec2 payVector = new Vec2();
|
||||
public float payRotation;
|
||||
|
||||
@Override
|
||||
public boolean acceptPayload(Tilec source, Payload payload){
|
||||
public boolean acceptPayload(Building source, Payload payload){
|
||||
return this.payload == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePayload(Tilec source, Payload payload){
|
||||
public void handlePayload(Building source, Payload payload){
|
||||
this.payload = (T)payload;
|
||||
this.payVector.set(source).sub(this).clamp(-size * tilesize / 2f, size * tilesize / 2f, -size * tilesize / 2f, size * tilesize / 2f);
|
||||
this.payRotation = source.angleTo(this);
|
||||
@@ -105,7 +105,7 @@ public class PayloadAcceptor extends Block{
|
||||
if(payVector.len() >= size * tilesize/2f){
|
||||
payVector.clamp(-size * tilesize / 2f, size * tilesize / 2f, -size * tilesize / 2f, size * tilesize / 2f);
|
||||
|
||||
Tilec front = front();
|
||||
Building front = front();
|
||||
if(front != null && front.block().outputsPayload){
|
||||
if(movePayload(payload)){
|
||||
payload = null;
|
||||
|
||||
@@ -51,7 +51,7 @@ public class Separator extends Block{
|
||||
stats.add(BlockStat.productionTime, craftTime / 60f, StatUnit.seconds);
|
||||
}
|
||||
|
||||
public class SeparatorEntity extends TileEntity{
|
||||
public class SeparatorEntity extends Building{
|
||||
public float progress;
|
||||
public float totalProgress;
|
||||
public float warmup;
|
||||
@@ -130,7 +130,7 @@ public class Separator extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDump(Tilec to, Item item){
|
||||
public boolean canDump(Building to, Item item){
|
||||
return !consumes.itemFilters.get(item.id);
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ public class ItemSource extends Block{
|
||||
return true;
|
||||
}
|
||||
|
||||
public class ItemSourceEntity extends TileEntity{
|
||||
public class ItemSourceEntity extends Building{
|
||||
Item outputItem;
|
||||
|
||||
@Override
|
||||
@@ -73,7 +73,7 @@ public class ItemSource extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onConfigureTileTapped(Tilec other){
|
||||
public boolean onConfigureTileTapped(Building other){
|
||||
if(this == other){
|
||||
deselect();
|
||||
configure(null);
|
||||
@@ -84,7 +84,7 @@ public class ItemSource extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Tilec source, Item item){
|
||||
public boolean acceptItem(Building source, Item item){
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,12 +11,12 @@ public class ItemVoid extends Block{
|
||||
update = solid = acceptsItems = true;
|
||||
}
|
||||
|
||||
public class ItemVoidEntity extends TileEntity{
|
||||
public class ItemVoidEntity extends Building{
|
||||
@Override
|
||||
public void handleItem(Tilec source, Item item){}
|
||||
public void handleItem(Building source, Item item){}
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Tilec source, Item item){
|
||||
public boolean acceptItem(Building source, Item item){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class LiquidSource extends Block{
|
||||
drawRequestConfigCenter(req, req.config, "center");
|
||||
}
|
||||
|
||||
public class LiquidSourceEntity extends TileEntity{
|
||||
public class LiquidSourceEntity extends Building{
|
||||
public @Nullable Liquid source = null;
|
||||
|
||||
@Override
|
||||
@@ -71,7 +71,7 @@ public class LiquidSource extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onConfigureTileTapped(Tilec other){
|
||||
public boolean onConfigureTileTapped(Building other){
|
||||
if(this == other){
|
||||
deselect();
|
||||
configure(null);
|
||||
|
||||
@@ -19,14 +19,14 @@ public class LiquidVoid extends Block{
|
||||
bars.remove("liquid");
|
||||
}
|
||||
|
||||
public class LiquidVoidEntity extends TileEntity{
|
||||
public class LiquidVoidEntity extends Building{
|
||||
@Override
|
||||
public boolean acceptLiquid(Tilec source, Liquid liquid, float amount){
|
||||
public boolean acceptLiquid(Building source, Liquid liquid, float amount){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleLiquid(Tilec source, Liquid liquid, float amount){
|
||||
public void handleLiquid(Building source, Liquid liquid, float amount){
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ public class CoreBlock extends StorageBlock{
|
||||
}
|
||||
|
||||
@Remote(called = Loc.server)
|
||||
public static void onPlayerSpawn(Tile tile, Playerc player){
|
||||
public static void onPlayerSpawn(Tile tile, Player player){
|
||||
if(player == null || tile == null) return;
|
||||
|
||||
CoreEntity entity = tile.ent();
|
||||
@@ -57,7 +57,7 @@ public class CoreBlock extends StorageBlock{
|
||||
Fx.spawn.at(entity);
|
||||
|
||||
if(!net.client()){
|
||||
Unitc unit = block.unitType.create(tile.team());
|
||||
Unit unit = block.unitType.create(tile.team());
|
||||
unit.set(entity);
|
||||
unit.rotation(90f);
|
||||
unit.impulse(0f, 3f);
|
||||
@@ -91,7 +91,7 @@ public class CoreBlock extends StorageBlock{
|
||||
return false;
|
||||
}
|
||||
|
||||
public class CoreEntity extends TileEntity implements ControlBlock{
|
||||
public class CoreEntity extends Building implements ControlBlock{
|
||||
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
|
||||
public @NonNull BlockUnitc unit = Nulls.blockUnit;
|
||||
@@ -103,11 +103,11 @@ public class CoreBlock extends StorageBlock{
|
||||
}
|
||||
|
||||
@Override
|
||||
public Unitc unit(){
|
||||
return unit;
|
||||
public Unit unit(){
|
||||
return (Unit)unit;
|
||||
}
|
||||
|
||||
public void requestSpawn(Playerc player){
|
||||
public void requestSpawn(Player player){
|
||||
Call.onPlayerSpawn(tile, player);
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ public class CoreBlock extends StorageBlock{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Tilec source, Item item){
|
||||
public boolean acceptItem(Building source, Item item){
|
||||
return items.get(item) < getMaximumAccepted(item);
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ public class CoreBlock extends StorageBlock{
|
||||
|
||||
@Override
|
||||
public void onProximityUpdate(){
|
||||
for(Tilec other : state.teams.cores(team)){
|
||||
for(Building other : state.teams.cores(team)){
|
||||
if(other.tile() != tile){
|
||||
items(other.items());
|
||||
}
|
||||
@@ -150,7 +150,7 @@ public class CoreBlock extends StorageBlock{
|
||||
((StorageBlockEntity)t).linkedCore = this;
|
||||
});
|
||||
|
||||
for(Tilec other : state.teams.cores(team)){
|
||||
for(Building other : state.teams.cores(team)){
|
||||
if(other.tile() == tile) continue;
|
||||
storageCapacity += other.block().itemCapacity + other.proximity().sum(e -> isContainer(e) && owns(other, e) ? e.block().itemCapacity : 0);
|
||||
}
|
||||
@@ -169,7 +169,7 @@ public class CoreBlock extends StorageBlock{
|
||||
@Override
|
||||
public void drawSelect(){
|
||||
Lines.stroke(1f, Pal.accent);
|
||||
Cons<Tilec> outline = t -> {
|
||||
Cons<Building> outline = t -> {
|
||||
for(int i = 0; i < 4; i++){
|
||||
Point2 p = Geometry.d8edge[i];
|
||||
float offset = -Math.max(t.block().size - 1, 0) / 2f * tilesize;
|
||||
@@ -184,15 +184,15 @@ public class CoreBlock extends StorageBlock{
|
||||
}
|
||||
|
||||
|
||||
public boolean isContainer(Tilec tile){
|
||||
public boolean isContainer(Building tile){
|
||||
return tile instanceof StorageBlockEntity && (((StorageBlockEntity)tile).linkedCore == this || ((StorageBlockEntity)tile).linkedCore == null);
|
||||
}
|
||||
|
||||
public boolean owns(Tilec tile){
|
||||
public boolean owns(Building tile){
|
||||
return tile instanceof StorageBlockEntity && (((StorageBlockEntity)tile).linkedCore == this || ((StorageBlockEntity)tile).linkedCore == null);
|
||||
}
|
||||
|
||||
public boolean owns(Tilec core, Tilec tile){
|
||||
public boolean owns(Building core, Building tile){
|
||||
return tile instanceof StorageBlockEntity && (((StorageBlockEntity)tile).linkedCore == core || ((StorageBlockEntity)tile).linkedCore == null);
|
||||
}
|
||||
|
||||
@@ -237,7 +237,7 @@ public class CoreBlock extends StorageBlock{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleItem(Tilec source, Item item){
|
||||
public void handleItem(Building source, Item item){
|
||||
if(net.server() || !net.active()){
|
||||
super.handleItem(source, item);
|
||||
if(state.rules.tutorial){
|
||||
|
||||
@@ -54,7 +54,7 @@ public class MessageBlock extends Block{
|
||||
});
|
||||
}
|
||||
|
||||
public class MessageBlockEntity extends TileEntity{
|
||||
public class MessageBlockEntity extends Building{
|
||||
public String message = "";
|
||||
public String[] lines = {""};
|
||||
|
||||
|
||||
@@ -20,11 +20,11 @@ public abstract class StorageBlock extends Block{
|
||||
return false;
|
||||
}
|
||||
|
||||
public class StorageBlockEntity extends TileEntity{
|
||||
protected @Nullable Tilec linkedCore;
|
||||
public class StorageBlockEntity extends Building{
|
||||
protected @Nullable Building linkedCore;
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Tilec source, Item item){
|
||||
public boolean acceptItem(Building source, Item item){
|
||||
return linkedCore != null ? linkedCore.acceptItem(source, item) : items.get(item) < getMaximumAccepted(item);
|
||||
}
|
||||
|
||||
|
||||
@@ -42,14 +42,14 @@ public class Unloader extends Block{
|
||||
bars.remove("items");
|
||||
}
|
||||
|
||||
public class UnloaderEntity extends TileEntity{
|
||||
public class UnloaderEntity extends Building{
|
||||
public Item sortItem = null;
|
||||
public Tilec dumpingTo;
|
||||
public Building dumpingTo;
|
||||
|
||||
@Override
|
||||
public void updateTile(){
|
||||
if(timer(timerUnload, speed / timeScale())){
|
||||
for(Tilec other : proximity){
|
||||
for(Building other : proximity){
|
||||
if(other.interactable(team) && other.block().unloadable && other.block().hasItems
|
||||
&& ((sortItem == null && other.items().total() > 0) || (sortItem != null && other.items().has(sortItem)))){
|
||||
//make sure the item can't be dumped back into this block
|
||||
@@ -86,7 +86,7 @@ public class Unloader extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onConfigureTileTapped(Tilec other){
|
||||
public boolean onConfigureTileTapped(Building other){
|
||||
if(this == other){
|
||||
deselect();
|
||||
configure(null);
|
||||
@@ -97,7 +97,7 @@ public class Unloader extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDump(Tilec to, Item item){
|
||||
public boolean canDump(Building to, Item item){
|
||||
return !(to.block() instanceof StorageBlock) && to != dumpingTo;
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ public class Reconstructor extends UnitBlock{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptPayload(Tilec source, Payload payload){
|
||||
public boolean acceptPayload(Building source, Payload payload){
|
||||
return this.payload == null
|
||||
&& relativeTo(source) != rotation()
|
||||
&& payload instanceof UnitPayload
|
||||
|
||||
@@ -59,7 +59,7 @@ public class RepairPoint extends Block{
|
||||
return new TextureRegion[]{baseRegion, region};
|
||||
}
|
||||
|
||||
public class RepairPointEntity extends TileEntity{
|
||||
public class RepairPointEntity extends Building{
|
||||
public Unitc target;
|
||||
public float strength, rotation = 90;
|
||||
|
||||
@@ -107,7 +107,7 @@ public class RepairPoint extends Block{
|
||||
|
||||
if(timer(timerTarget, 20)){
|
||||
rect.setSize(repairRadius * 2).setCenter(x, y);
|
||||
target = Units.closest(team, x, y, repairRadius, Unitc::damaged);
|
||||
target = Units.closest(team, x, y, repairRadius, Unit::damaged);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ public class ResupplyPoint extends Block{
|
||||
Drawf.dashCircle(x * tilesize + offset(), y * tilesize + offset(), range, Pal.placing);
|
||||
}
|
||||
|
||||
public class ResupplyPointEntity extends TileEntity{
|
||||
public class ResupplyPointEntity extends Building{
|
||||
|
||||
@Override
|
||||
public void drawSelect(){
|
||||
@@ -50,10 +50,10 @@ public class ResupplyPoint extends Block{
|
||||
|
||||
/** Tries to resupply nearby units.
|
||||
* @return whether resupplying was successful. If unit ammo is disabled, always returns false. */
|
||||
public static boolean resupply(TileEntity tile, float range, int ammoAmount, Color ammoColor){
|
||||
public static boolean resupply(Building tile, float range, int ammoAmount, Color ammoColor){
|
||||
if(!state.rules.unitAmmo) return false;
|
||||
|
||||
Unitc unit = Units.closest(tile.team, tile.x, tile.y, range, u -> u.ammo() <= u.type().ammoCapacity - ammoAmount);
|
||||
Unit unit = Units.closest(tile.team, tile.x, tile.y, range, u -> u.ammo() <= u.type().ammoCapacity - ammoAmount);
|
||||
if(unit != null){
|
||||
Fx.itemTransfer.at(tile.x, tile.y, ammoAmount / 2f, ammoColor, unit);
|
||||
unit.ammo(Math.min(unit.ammo() + ammoAmount, unit.type().ammoCapacity));
|
||||
|
||||
@@ -40,7 +40,7 @@ public class UnitBlock extends PayloadAcceptor{
|
||||
Fx.smeltsmoke.at(x + Tmp.v1.x, y + Tmp.v1.y);
|
||||
|
||||
if(!net.client() && payload != null){
|
||||
Unitc unit = payload.unit;
|
||||
Unit unit = payload.unit;
|
||||
unit.set(x, y);
|
||||
unit.rotation(rotdeg());
|
||||
unit.vel().trns(rotdeg(), payloadSpeed * 2f).add(Mathf.range(0.3f), Mathf.range(0.3f));
|
||||
|
||||
@@ -117,7 +117,7 @@ public class UnitFactory extends UnitBlock{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptPayload(Tilec source, Payload payload){
|
||||
public boolean acceptPayload(Building source, Payload payload){
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -202,7 +202,7 @@ public class UnitFactory extends UnitBlock{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Tilec source, Item item){
|
||||
public boolean acceptItem(Building source, Item item){
|
||||
return currentPlan != -1 && items.get(item) < getMaximumAccepted(item) &&
|
||||
Structs.contains(plans[currentPlan].requirements, stack -> stack.item == item);
|
||||
}
|
||||
|
||||
@@ -58,16 +58,16 @@ public abstract class Consume{
|
||||
|
||||
public abstract ConsumeType type();
|
||||
|
||||
public abstract void build(Tilec tile, Table table);
|
||||
public abstract void build(Building tile, Table table);
|
||||
|
||||
/** Called when a consumption is triggered manually. */
|
||||
public void trigger(Tilec entity){}
|
||||
public void trigger(Building entity){}
|
||||
|
||||
public abstract String getIcon();
|
||||
|
||||
public abstract void update(Tilec entity);
|
||||
public abstract void update(Building entity);
|
||||
|
||||
public abstract boolean valid(Tilec entity);
|
||||
public abstract boolean valid(Building entity);
|
||||
|
||||
public abstract void display(BlockStats stats);
|
||||
}
|
||||
|
||||
@@ -11,10 +11,10 @@ import mindustry.ui.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
public class ConsumeItemDynamic extends Consume{
|
||||
public final @NonNull Func<Tilec, ItemStack[]> items;
|
||||
public final @NonNull Func<Building, ItemStack[]> items;
|
||||
|
||||
public <T extends Tilec> ConsumeItemDynamic(Func<T, ItemStack[]> items){
|
||||
this.items = (Func<Tilec, ItemStack[]>)items;
|
||||
public <T extends Building> ConsumeItemDynamic(Func<T, ItemStack[]> items){
|
||||
this.items = (Func<Building, ItemStack[]>)items;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -28,7 +28,7 @@ public class ConsumeItemDynamic extends Consume{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(Tilec tile, Table table){
|
||||
public void build(Building tile, Table table){
|
||||
ItemStack[][] current = {items.get(tile)};
|
||||
|
||||
table.update(() -> {
|
||||
@@ -41,10 +41,10 @@ public class ConsumeItemDynamic extends Consume{
|
||||
rebuild(tile, table);
|
||||
}
|
||||
|
||||
private void rebuild(Tilec tile, Table table){
|
||||
private void rebuild(Building tile, Table table){
|
||||
for(ItemStack stack : items.get(tile)){
|
||||
table.add(new ReqImage(new ItemImage(stack.item.icon(Cicon.medium), stack.amount),
|
||||
() -> tile.items() != null && tile.items().has(stack.item, stack.amount))).size(8 * 4).padRight(6 * Mathf.digits(stack.amount));
|
||||
() -> tile.items != null && tile.items.has(stack.item, stack.amount))).size(8 * 4).padRight(6 * Mathf.digits(stack.amount));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,20 +54,20 @@ public class ConsumeItemDynamic extends Consume{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Tilec entity){
|
||||
public void update(Building entity){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void trigger(Tilec entity){
|
||||
public void trigger(Building entity){
|
||||
for(ItemStack stack : items.get(entity)){
|
||||
entity.items().remove(stack);
|
||||
entity.items.remove(stack);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean valid(Tilec entity){
|
||||
return entity.items() != null && entity.items().has(items.get(entity));
|
||||
public boolean valid(Building entity){
|
||||
return entity.items != null && entity.items.has(items.get(entity));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -31,10 +31,10 @@ public class ConsumeItemFilter extends Consume{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(Tilec tile, Table table){
|
||||
public void build(Building tile, Table table){
|
||||
MultiReqImage image = new MultiReqImage();
|
||||
content.items().each(i -> filter.get(i) && i.unlockedNow(), item -> image.add(new ReqImage(new ItemImage(item.icon(Cicon.medium), 1),
|
||||
() -> tile.items() != null && tile.items().has(item))));
|
||||
() -> tile.items != null && tile.items.has(item))));
|
||||
|
||||
table.add(image).size(8 * 4);
|
||||
}
|
||||
@@ -45,26 +45,26 @@ public class ConsumeItemFilter extends Consume{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Tilec entity){
|
||||
public void update(Building entity){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void trigger(Tilec entity){
|
||||
public void trigger(Building entity){
|
||||
for(int i = 0; i < content.items().size; i++){
|
||||
Item item = content.item(i);
|
||||
if(entity.items() != null && entity.items().has(item) && this.filter.get(item)){
|
||||
entity.items().remove(item, 1);
|
||||
if(entity.items != null && entity.items.has(item) && this.filter.get(item)){
|
||||
entity.items.remove(item, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean valid(Tilec entity){
|
||||
public boolean valid(Building entity){
|
||||
for(int i = 0; i < content.items().size; i++){
|
||||
Item item = content.item(i);
|
||||
if(entity.items() != null && entity.items().has(item) && this.filter.get(item)){
|
||||
if(entity.items != null && entity.items.has(item) && this.filter.get(item)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,10 +35,10 @@ public class ConsumeItems extends Consume{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(Tilec tile, Table table){
|
||||
public void build(Building tile, Table table){
|
||||
for(ItemStack stack : items){
|
||||
table.add(new ReqImage(new ItemImage(stack.item.icon(Cicon.medium), stack.amount),
|
||||
() -> tile.items() != null && tile.items().has(stack.item, stack.amount))).size(8 * 4).padRight(Mathf.digits(stack.amount) * 6);
|
||||
() -> tile.items != null && tile.items.has(stack.item, stack.amount))).size(8 * 4).padRight(Mathf.digits(stack.amount) * 6);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,20 +48,20 @@ public class ConsumeItems extends Consume{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Tilec entity){
|
||||
public void update(Building entity){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void trigger(Tilec entity){
|
||||
public void trigger(Building entity){
|
||||
for(ItemStack stack : items){
|
||||
entity.items().remove(stack);
|
||||
entity.items.remove(stack);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean valid(Tilec entity){
|
||||
return entity.items() != null && entity.items().has(items);
|
||||
public boolean valid(Building entity){
|
||||
return entity.items != null && entity.items.has(items);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -26,7 +26,7 @@ public class ConsumeLiquid extends ConsumeLiquidBase{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(Tilec tile, Table table){
|
||||
public void build(Building tile, Table table){
|
||||
table.add(new ReqImage(liquid.icon(Cicon.medium), () -> valid(tile))).size(8 * 4);
|
||||
}
|
||||
|
||||
@@ -36,13 +36,13 @@ public class ConsumeLiquid extends ConsumeLiquidBase{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Tilec entity){
|
||||
entity.liquids().remove(liquid, Math.min(use(entity), entity.liquids().get(liquid)));
|
||||
public void update(Building entity){
|
||||
entity.liquids.remove(liquid, Math.min(use(entity), entity.liquids.get(liquid)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean valid(Tilec entity){
|
||||
return entity != null && entity.liquids() != null && entity.liquids().get(liquid) >= use(entity);
|
||||
public boolean valid(Building entity){
|
||||
return entity != null && entity.liquids != null && entity.liquids.get(liquid) >= use(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -22,7 +22,7 @@ public abstract class ConsumeLiquidBase extends Consume{
|
||||
return ConsumeType.liquid;
|
||||
}
|
||||
|
||||
protected float use(Tilec entity){
|
||||
protected float use(Building entity){
|
||||
return Math.min(amount * entity.delta(), entity.block().liquidCapacity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,10 +28,10 @@ public class ConsumeLiquidFilter extends ConsumeLiquidBase{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(Tilec tile, Table table){
|
||||
public void build(Building tile, Table table){
|
||||
Seq<Liquid> list = content.liquids().select(l -> !l.isHidden() && filter.get(l));
|
||||
MultiReqImage image = new MultiReqImage();
|
||||
list.each(liquid -> image.add(new ReqImage(liquid.icon(Cicon.medium), () -> tile.liquids() != null && tile.liquids().get(liquid) >= use(tile))));
|
||||
list.each(liquid -> image.add(new ReqImage(liquid.icon(Cicon.medium), () -> tile.liquids != null && tile.liquids.get(liquid) >= use(tile))));
|
||||
|
||||
table.add(image).size(8 * 4);
|
||||
}
|
||||
@@ -42,13 +42,13 @@ public class ConsumeLiquidFilter extends ConsumeLiquidBase{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Tilec entity){
|
||||
entity.liquids().remove(entity.liquids().current(), use(entity));
|
||||
public void update(Building entity){
|
||||
entity.liquids.remove(entity.liquids.current(), use(entity));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean valid(Tilec entity){
|
||||
return entity != null && entity.liquids() != null && filter.get(entity.liquids().current()) && entity.liquids().currentAmount() >= use(entity);
|
||||
public boolean valid(Building entity){
|
||||
return entity != null && entity.liquids != null && filter.get(entity.liquids.current()) && entity.liquids.currentAmount() >= use(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -30,7 +30,7 @@ public class ConsumePower extends Consume{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(Tilec tile, Table table){
|
||||
public void build(Building tile, Table table){
|
||||
//No tooltip for power, for now
|
||||
}
|
||||
|
||||
@@ -40,16 +40,16 @@ public class ConsumePower extends Consume{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Tilec entity){
|
||||
// Nothing to do since PowerGraph directly updates entity.power().status
|
||||
public void update(Building entity){
|
||||
// Nothing to do since PowerGraph directly updates entity.power.status
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean valid(Tilec entity){
|
||||
public boolean valid(Building entity){
|
||||
if(buffered){
|
||||
return true;
|
||||
}else{
|
||||
return entity.power().status > 0f;
|
||||
return entity.power.status > 0f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,10 +67,10 @@ public class ConsumePower extends Consume{
|
||||
* @param entity The entity which contains the power module.
|
||||
* @return The amount of power which is requested per tick.
|
||||
*/
|
||||
public float requestedPower(Tilec entity){
|
||||
public float requestedPower(Building entity){
|
||||
if(entity.tile().entity == null) return 0f;
|
||||
if(buffered){
|
||||
return (1f-entity.power().status)*capacity;
|
||||
return (1f-entity.power.status)*capacity;
|
||||
}else{
|
||||
try{
|
||||
return usage * Mathf.num(entity.shouldConsume());
|
||||
|
||||
@@ -52,7 +52,7 @@ public class Consumers{
|
||||
}
|
||||
|
||||
/** Creates a consumer which only consumes power when the condition is met. */
|
||||
public ConsumePower powerCond(float usage, Boolf<Tilec> cons){
|
||||
public ConsumePower powerCond(float usage, Boolf<Building> cons){
|
||||
return add(new ConditionalConsumePower(usage, cons));
|
||||
}
|
||||
|
||||
|
||||
@@ -6,10 +6,10 @@ import mindustry.gen.*;
|
||||
import mindustry.ui.Bar;
|
||||
|
||||
public class BlockBars{
|
||||
private OrderedMap<String, Func<Tilec, Bar>> bars = new OrderedMap<>();
|
||||
private OrderedMap<String, Func<Building, Bar>> bars = new OrderedMap<>();
|
||||
|
||||
public <T extends Tilec> void add(String name, Func<T, Bar> sup){
|
||||
bars.put(name, (Func<Tilec, Bar>)sup);
|
||||
public <T extends Building> void add(String name, Func<T, Bar> sup){
|
||||
bars.put(name, (Func<Building, Bar>)sup);
|
||||
}
|
||||
|
||||
public void remove(String name){
|
||||
@@ -18,7 +18,7 @@ public class BlockBars{
|
||||
bars.remove(name);
|
||||
}
|
||||
|
||||
public Iterable<Func<Tilec, Bar>> list(){
|
||||
public Iterable<Func<Building, Bar>> list(){
|
||||
return bars.values();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,6 @@ public class Producers{
|
||||
}
|
||||
|
||||
interface Produce{
|
||||
void add(Tilec entity);
|
||||
void add(Building entity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,9 +7,9 @@ import mindustry.world.meta.*;
|
||||
|
||||
public class ConsumeModule extends BlockModule{
|
||||
private boolean valid, optionalValid;
|
||||
private final Tilec entity;
|
||||
private final Building entity;
|
||||
|
||||
public ConsumeModule(Tilec entity){
|
||||
public ConsumeModule(Building entity){
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user