Entity type cleanup
This commit is contained in:
@@ -139,6 +139,7 @@ public class Block extends BlockStorage{
|
||||
|
||||
protected TextureRegion[] cacheRegions = {};
|
||||
protected Array<String> cacheRegionStrings = new Array<>();
|
||||
protected Prov<TileEntity> entityType = TileEntity::new;
|
||||
|
||||
protected Array<Tile> tempTiles = new Array<>();
|
||||
protected TextureRegion[] generatedIcons;
|
||||
@@ -856,8 +857,8 @@ public class Block extends BlockStorage{
|
||||
return destructible || update;
|
||||
}
|
||||
|
||||
public TileEntity newEntity(){
|
||||
return new TileEntity();
|
||||
public final TileEntity newEntity(){
|
||||
return entityType.get();
|
||||
}
|
||||
|
||||
/** Offset for placing and drawing multiblocks. */
|
||||
|
||||
@@ -42,6 +42,7 @@ public class BuildBlock extends Block{
|
||||
layer = Layer.placement;
|
||||
consumesTap = true;
|
||||
solidifes = true;
|
||||
entityType = BuildEntity::new;
|
||||
|
||||
buildBlocks[size - 1] = this;
|
||||
}
|
||||
@@ -197,11 +198,6 @@ public class BuildBlock extends Block{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity newEntity(){
|
||||
return new BuildEntity();
|
||||
}
|
||||
|
||||
public class BuildEntity extends TileEntity{
|
||||
/**
|
||||
* The recipe of the block that is being constructed.
|
||||
|
||||
@@ -20,6 +20,7 @@ public class DeflectorWall extends Wall{
|
||||
|
||||
public DeflectorWall(String name){
|
||||
super(name);
|
||||
entityType = DeflectorEntity::new;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -72,11 +73,6 @@ public class DeflectorWall extends Wall{
|
||||
((DeflectorEntity)entity).hit = 1f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity newEntity(){
|
||||
return new DeflectorEntity();
|
||||
}
|
||||
|
||||
public static class DeflectorEntity extends TileEntity{
|
||||
public float hit;
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ public class Door extends Wall{
|
||||
solid = false;
|
||||
solidifes = true;
|
||||
consumesTap = true;
|
||||
entityType = DoorEntity::new;
|
||||
}
|
||||
|
||||
@Remote(called = Loc.server)
|
||||
@@ -89,11 +90,6 @@ public class Door extends Wall{
|
||||
Call.onDoorToggle(null, tile, !entity.open);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity newEntity(){
|
||||
return new DoorEntity();
|
||||
}
|
||||
|
||||
public class DoorEntity extends TileEntity{
|
||||
public boolean open = false;
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@ public class ForceProjector extends Block{
|
||||
hasLiquids = true;
|
||||
hasItems = true;
|
||||
consumes.add(new ConsumeLiquidFilter(liquid -> liquid.temperature <= 0.5f && liquid.flammability < 0.1f, 0.1f)).boost().update(false);
|
||||
entityType = ForceEntity::new;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -179,11 +180,6 @@ public class ForceProjector extends Block{
|
||||
Draw.reset();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity newEntity(){
|
||||
return new ForceEntity();
|
||||
}
|
||||
|
||||
class ForceEntity extends TileEntity{
|
||||
ShieldEntity shield;
|
||||
boolean broken = true;
|
||||
|
||||
@@ -38,6 +38,7 @@ public class MendProjector extends Block{
|
||||
update = true;
|
||||
hasPower = true;
|
||||
hasItems = true;
|
||||
entityType = MendEntity::new;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -137,11 +138,6 @@ public class MendProjector extends Block{
|
||||
renderer.lights.add(tile.drawx(), tile.drawy(), 50f * tile.entity.efficiency(), color, 0.7f * tile.entity.efficiency());
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity newEntity(){
|
||||
return new MendEntity();
|
||||
}
|
||||
|
||||
class MendEntity extends TileEntity{
|
||||
float heat;
|
||||
float charge = Mathf.random(reload);
|
||||
|
||||
@@ -37,6 +37,7 @@ public class OverdriveProjector extends Block{
|
||||
hasPower = true;
|
||||
hasItems = true;
|
||||
canOverdrive = false;
|
||||
entityType = OverdriveEntity::new;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -137,11 +138,6 @@ public class OverdriveProjector extends Block{
|
||||
Draw.reset();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity newEntity(){
|
||||
return new OverdriveEntity();
|
||||
}
|
||||
|
||||
class OverdriveEntity extends TileEntity{
|
||||
float heat;
|
||||
float charge = Mathf.random(reload);
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
package io.anuke.mindustry.world.blocks.defense.turrets;
|
||||
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.util.Time;
|
||||
import io.anuke.mindustry.content.Fx;
|
||||
import io.anuke.mindustry.entities.Effects;
|
||||
import io.anuke.mindustry.entities.Effects.Effect;
|
||||
import io.anuke.mindustry.entities.bullet.BulletType;
|
||||
import io.anuke.mindustry.entities.type.TileEntity;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.arc.math.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.content.*;
|
||||
import io.anuke.mindustry.entities.*;
|
||||
import io.anuke.mindustry.entities.Effects.*;
|
||||
import io.anuke.mindustry.entities.bullet.*;
|
||||
import io.anuke.mindustry.world.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.tilesize;
|
||||
|
||||
@@ -21,6 +20,7 @@ public class ChargeTurret extends PowerTurret{
|
||||
|
||||
public ChargeTurret(String name){
|
||||
super(name);
|
||||
entityType = LaserTurretEntity::new;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -59,11 +59,6 @@ public class ChargeTurret extends PowerTurret{
|
||||
return !entity.shooting;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity newEntity(){
|
||||
return new LaserTurretEntity();
|
||||
}
|
||||
|
||||
public class LaserTurretEntity extends TurretEntity{
|
||||
public boolean shooting;
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ public class ItemTurret extends CooledTurret{
|
||||
public ItemTurret(String name){
|
||||
super(name);
|
||||
hasItems = true;
|
||||
entityType = ItemTurretEntity::new;
|
||||
}
|
||||
|
||||
/** Initializes accepted ammo map. Format: [item1, bullet1, item2, bullet2...] */
|
||||
@@ -148,11 +149,6 @@ public class ItemTurret extends CooledTurret{
|
||||
return ammo != null && ammo.get(item) != null && entity.totalAmmo + ammo.get(item).ammoMultiplier <= maxAmmo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity newEntity(){
|
||||
return new ItemTurretEntity();
|
||||
}
|
||||
|
||||
public class ItemTurretEntity extends TurretEntity{
|
||||
@Override
|
||||
public void write(DataOutput stream) throws IOException{
|
||||
|
||||
@@ -23,6 +23,7 @@ public class LaserTurret extends PowerTurret{
|
||||
|
||||
consumes.add(new ConsumeLiquidFilter(liquid -> liquid.temperature <= 0.5f && liquid.flammability < 0.1f, 0.01f)).update(false);
|
||||
coolantMultiplier = 1f;
|
||||
entityType = LaserTurretEntity::new;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -99,11 +100,6 @@ public class LaserTurret extends PowerTurret{
|
||||
entity.bulletLife = shootDuration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity newEntity(){
|
||||
return new LaserTurretEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldActiveSound(Tile tile){
|
||||
LaserTurretEntity entity = tile.entity();
|
||||
|
||||
@@ -79,6 +79,7 @@ public abstract class Turret extends Block{
|
||||
group = BlockGroup.turrets;
|
||||
flags = EnumSet.of(BlockFlag.turret);
|
||||
outlineIcon = true;
|
||||
entityType = TurretEntity::new;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -305,11 +306,6 @@ public abstract class Turret extends Block{
|
||||
return (tile.entity instanceof TurretEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity newEntity(){
|
||||
return new TurretEntity();
|
||||
}
|
||||
|
||||
public static abstract class AmmoEntry{
|
||||
public int amount;
|
||||
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
package io.anuke.mindustry.world.blocks.distribution;
|
||||
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.mindustry.entities.type.TileEntity;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.world.ItemBuffer;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.arc.math.*;
|
||||
import io.anuke.mindustry.type.*;
|
||||
import io.anuke.mindustry.world.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
@@ -18,6 +16,7 @@ public class BufferedItemBridge extends ExtendingItemBridge{
|
||||
super(name);
|
||||
hasPower = false;
|
||||
hasItems = true;
|
||||
entityType = BufferedItemBridgeEntity::new;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -38,11 +37,6 @@ public class BufferedItemBridge extends ExtendingItemBridge{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity newEntity(){
|
||||
return new BufferedItemBridgeEntity();
|
||||
}
|
||||
|
||||
class BufferedItemBridgeEntity extends ItemBridgeEntity{
|
||||
ItemBuffer buffer = new ItemBuffer(bufferCapacity, speed);
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ public class Conveyor extends Block implements Autotiler{
|
||||
hasItems = true;
|
||||
itemCapacity = 4;
|
||||
conveyorPlacement = true;
|
||||
entityType = ConveyorEntity::new;
|
||||
|
||||
idleSound = Sounds.conveyor;
|
||||
idleSoundVolume = 0.004f;
|
||||
@@ -342,11 +343,6 @@ public class Conveyor extends Block implements Autotiler{
|
||||
entity.lastInserted = (byte)(entity.convey.size - 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity newEntity(){
|
||||
return new ConveyorEntity();
|
||||
}
|
||||
|
||||
public static class ConveyorEntity extends TileEntity{
|
||||
|
||||
LongArray convey = new LongArray();
|
||||
|
||||
@@ -41,6 +41,7 @@ public class ItemBridge extends Block{
|
||||
hasItems = true;
|
||||
unloadable = false;
|
||||
group = BlockGroup.transportation;
|
||||
entityType = ItemBridgeEntity::new;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -340,11 +341,6 @@ public class ItemBridge extends Block{
|
||||
return rel != rel2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity newEntity(){
|
||||
return new ItemBridgeEntity();
|
||||
}
|
||||
|
||||
public boolean linkValid(Tile tile, Tile other){
|
||||
return linkValid(tile, other, true);
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ public class Junction extends Block{
|
||||
instantTransfer = true;
|
||||
group = BlockGroup.transportation;
|
||||
unloadable = false;
|
||||
entityType = JunctionEntity::new;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -87,11 +88,6 @@ public class Junction extends Block{
|
||||
return to != null && to.link().entity != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity newEntity(){
|
||||
return new JunctionEntity();
|
||||
}
|
||||
|
||||
class JunctionEntity extends TileEntity{
|
||||
DirectionalItemBuffer buffer = new DirectionalItemBuffer(capacity, speed);
|
||||
|
||||
|
||||
@@ -42,16 +42,9 @@ public class MassDriver extends Block{
|
||||
layer = Layer.turret;
|
||||
hasPower = true;
|
||||
outlineIcon = true;
|
||||
entityType = MassDriverEntity::new;
|
||||
}
|
||||
|
||||
/*
|
||||
@Remote(targets = Loc.both, called = Loc.server, forward = true)
|
||||
public static void linkMassDriver(Player player, Tile tile, int position){
|
||||
if(!Units.canInteract(player, tile)) return;
|
||||
MassDriverEntity entity = tile.entity();
|
||||
entity.link = position;
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public void configured(Tile tile, Player player, int value){
|
||||
tile.<MassDriverEntity>entity().link = value;
|
||||
@@ -213,11 +206,6 @@ public class MassDriver extends Block{
|
||||
return tile.entity.items.total() < itemCapacity && linkValid(tile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity newEntity(){
|
||||
return new MassDriverEntity();
|
||||
}
|
||||
|
||||
protected void fire(Tile tile, Tile target){
|
||||
MassDriverEntity entity = tile.entity();
|
||||
MassDriverEntity other = target.entity();
|
||||
|
||||
@@ -19,6 +19,7 @@ public class OverflowGate extends Block{
|
||||
update = true;
|
||||
group = BlockGroup.transportation;
|
||||
unloadable = false;
|
||||
entityType = OverflowGateEntity::new;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -108,11 +109,6 @@ public class OverflowGate extends Block{
|
||||
return to;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity newEntity(){
|
||||
return new OverflowGateEntity();
|
||||
}
|
||||
|
||||
public class OverflowGateEntity extends TileEntity{
|
||||
Item lastItem;
|
||||
Tile lastInput;
|
||||
|
||||
@@ -19,6 +19,7 @@ public class Router extends Block{
|
||||
itemCapacity = 1;
|
||||
group = BlockGroup.transportation;
|
||||
unloadable = false;
|
||||
entityType = RouterEntity::new;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -82,11 +83,6 @@ public class Router extends Block{
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity newEntity(){
|
||||
return new RouterEntity();
|
||||
}
|
||||
|
||||
public class RouterEntity extends TileEntity{
|
||||
Item lastItem;
|
||||
Tile lastInput;
|
||||
|
||||
@@ -28,6 +28,7 @@ public class Sorter extends Block{
|
||||
group = BlockGroup.transportation;
|
||||
configurable = true;
|
||||
unloadable = false;
|
||||
entityType = SorterEntity::new;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -137,12 +138,6 @@ public class Sorter extends Block{
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity newEntity(){
|
||||
return new SorterEntity();
|
||||
}
|
||||
|
||||
|
||||
public class SorterEntity extends TileEntity{
|
||||
@Nullable Item sortItem;
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ public class Conduit extends LiquidBlock implements Autotiler{
|
||||
solid = false;
|
||||
floating = true;
|
||||
conveyorPlacement = true;
|
||||
entityType = ConduitEntity::new;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -130,11 +131,6 @@ public class Conduit extends LiquidBlock implements Autotiler{
|
||||
&& ((source.absoluteRelativeTo(tile.x, tile.y) + 2) % 4 != tile.rotation());
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity newEntity(){
|
||||
return new ConduitEntity();
|
||||
}
|
||||
|
||||
public static class ConduitEntity extends TileEntity{
|
||||
public float smoothLiquid;
|
||||
|
||||
|
||||
@@ -7,14 +7,12 @@ import io.anuke.arc.graphics.*;
|
||||
import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.arc.math.geom.*;
|
||||
import io.anuke.arc.scene.ui.*;
|
||||
import io.anuke.arc.scene.ui.TextField.*;
|
||||
import io.anuke.arc.scene.ui.layout.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.arc.util.pooling.*;
|
||||
import io.anuke.mindustry.entities.*;
|
||||
import io.anuke.mindustry.entities.type.*;
|
||||
import io.anuke.mindustry.gen.*;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.mindustry.net.*;
|
||||
import io.anuke.mindustry.ui.*;
|
||||
import io.anuke.mindustry.ui.dialogs.*;
|
||||
@@ -33,6 +31,7 @@ public class MessageBlock extends Block{
|
||||
configurable = true;
|
||||
solid = true;
|
||||
destructible = true;
|
||||
entityType = MessageBlockEntity::new;
|
||||
}
|
||||
|
||||
@Remote(targets = Loc.both, called = Loc.both, forward = true)
|
||||
@@ -147,11 +146,6 @@ public class MessageBlock extends Block{
|
||||
table.setPosition(pos.x, pos.y, Align.bottom);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity newEntity(){
|
||||
return new MessageBlockEntity();
|
||||
}
|
||||
|
||||
public class MessageBlockEntity extends TileEntity{
|
||||
protected String message = "";
|
||||
protected String[] lines = {""};
|
||||
|
||||
@@ -7,7 +7,6 @@ import io.anuke.arc.math.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.content.*;
|
||||
import io.anuke.mindustry.entities.*;
|
||||
import io.anuke.mindustry.entities.type.*;
|
||||
import io.anuke.mindustry.game.EventType.*;
|
||||
import io.anuke.mindustry.gen.*;
|
||||
import io.anuke.mindustry.graphics.*;
|
||||
@@ -39,6 +38,7 @@ public class ImpactReactor extends PowerGenerator{
|
||||
liquidCapacity = 30f;
|
||||
hasItems = true;
|
||||
outputsPower = consumesPower = true;
|
||||
entityType = FusionReactorEntity::new;
|
||||
|
||||
bottomRegion = reg("-bottom");
|
||||
plasmaRegions = new int[plasmas];
|
||||
@@ -127,11 +127,6 @@ public class ImpactReactor extends PowerGenerator{
|
||||
return new TextureRegion[]{Core.atlas.find(name + "-bottom"), Core.atlas.find(name)};
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity newEntity(){
|
||||
return new FusionReactorEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyed(Tile tile){
|
||||
super.onDestroyed(tile);
|
||||
|
||||
@@ -8,7 +8,6 @@ import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.content.*;
|
||||
import io.anuke.mindustry.entities.*;
|
||||
import io.anuke.mindustry.entities.Effects.*;
|
||||
import io.anuke.mindustry.entities.type.*;
|
||||
import io.anuke.mindustry.type.*;
|
||||
import io.anuke.mindustry.world.*;
|
||||
import io.anuke.mindustry.world.consumers.*;
|
||||
@@ -37,15 +36,15 @@ public class ItemLiquidGenerator extends PowerGenerator{
|
||||
protected boolean defaults = false;
|
||||
|
||||
public ItemLiquidGenerator(boolean hasItems, boolean hasLiquids, String name){
|
||||
super(name);
|
||||
this(name);
|
||||
this.hasItems = hasItems;
|
||||
this.hasLiquids = hasLiquids;
|
||||
|
||||
setDefaults();
|
||||
}
|
||||
|
||||
public ItemLiquidGenerator(String name){
|
||||
super(name);
|
||||
this.entityType = ItemLiquidGeneratorEntity::new;
|
||||
}
|
||||
|
||||
protected void setDefaults(){
|
||||
@@ -189,11 +188,6 @@ public class ItemLiquidGenerator extends PowerGenerator{
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity newEntity(){
|
||||
return new ItemLiquidGeneratorEntity();
|
||||
}
|
||||
|
||||
public static class ItemLiquidGeneratorEntity extends GeneratorEntity{
|
||||
public float explosiveness;
|
||||
public float heat;
|
||||
|
||||
@@ -2,6 +2,7 @@ package io.anuke.mindustry.world.blocks.power;
|
||||
|
||||
import io.anuke.arc.graphics.*;
|
||||
import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.mindustry.entities.type.*;
|
||||
import io.anuke.mindustry.world.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.renderer;
|
||||
@@ -17,6 +18,8 @@ public class LightBlock extends Block{
|
||||
hasPower = true;
|
||||
update = true;
|
||||
topRegion = reg("-top");
|
||||
configurable = true;
|
||||
entityType = LightEntity::new;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -29,8 +32,17 @@ public class LightBlock extends Block{
|
||||
Draw.blend();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configured(Tile tile, Player player, int value){
|
||||
tile.<LightEntity>entity().color = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawLight(Tile tile){
|
||||
renderer.lights.add(tile.drawx(), tile.drawy(), radius, color, brightness * tile.entity.efficiency());
|
||||
}
|
||||
|
||||
public class LightEntity extends TileEntity{
|
||||
public int color;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import io.anuke.arc.math.geom.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.content.*;
|
||||
import io.anuke.mindustry.entities.*;
|
||||
import io.anuke.mindustry.entities.type.*;
|
||||
import io.anuke.mindustry.game.EventType.*;
|
||||
import io.anuke.mindustry.gen.*;
|
||||
import io.anuke.mindustry.graphics.*;
|
||||
@@ -46,6 +45,7 @@ public class NuclearReactor extends PowerGenerator{
|
||||
liquidCapacity = 30;
|
||||
hasItems = true;
|
||||
hasLiquids = true;
|
||||
entityType = NuclearReactorEntity::new;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -181,11 +181,6 @@ public class NuclearReactor extends PowerGenerator{
|
||||
Draw.reset();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity newEntity(){
|
||||
return new NuclearReactorEntity();
|
||||
}
|
||||
|
||||
public static class NuclearReactorEntity extends GeneratorEntity{
|
||||
public float heat;
|
||||
public float flash;
|
||||
|
||||
@@ -20,6 +20,7 @@ public class PowerGenerator extends PowerDistributor{
|
||||
super(name);
|
||||
baseExplosiveness = 5f;
|
||||
flags = EnumSet.of(BlockFlag.producer);
|
||||
entityType = GeneratorEntity::new;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -51,11 +52,6 @@ public class PowerGenerator extends PowerDistributor{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity newEntity(){
|
||||
return new GeneratorEntity();
|
||||
}
|
||||
|
||||
public static class GeneratorEntity extends TileEntity{
|
||||
public float generateTime;
|
||||
/** The efficiency of the producer. An efficiency of 1.0 means 100% */
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package io.anuke.mindustry.world.blocks.power;
|
||||
|
||||
import io.anuke.arc.collection.EnumSet;
|
||||
import io.anuke.mindustry.entities.type.TileEntity;
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.mindustry.world.*;
|
||||
import io.anuke.mindustry.world.meta.StatUnit;
|
||||
import io.anuke.mindustry.world.meta.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.state;
|
||||
|
||||
@@ -13,6 +12,7 @@ public class SolarGenerator extends PowerGenerator{
|
||||
super(name);
|
||||
// Remove the BlockFlag.producer flag to make this a lower priority target than other generators.
|
||||
flags = EnumSet.of();
|
||||
entityType = GeneratorEntity::new;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -27,12 +27,4 @@ public class SolarGenerator extends PowerGenerator{
|
||||
stats.remove(generationType);
|
||||
stats.add(generationType, powerProduction * 60.0f, StatUnit.powerSecond);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity newEntity(){
|
||||
return new GeneratorEntity(){{
|
||||
productionEfficiency = 1.0f;
|
||||
}};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ public class Cultivator extends GenericCrafter{
|
||||
public Cultivator(String name){
|
||||
super(name);
|
||||
craftEffect = Fx.none;
|
||||
entityType = CultivatorEntity::new;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -94,11 +95,6 @@ public class Cultivator extends GenericCrafter{
|
||||
return new TextureRegion[]{Core.atlas.find(name), Core.atlas.find(name + "-top"),};
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity newEntity(){
|
||||
return new CultivatorEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProximityAdded(Tile tile){
|
||||
super.onProximityAdded(tile);
|
||||
|
||||
@@ -66,6 +66,7 @@ public class Drill extends Block{
|
||||
hasLiquids = true;
|
||||
liquidCapacity = 5f;
|
||||
hasItems = true;
|
||||
entityType = DrillEntity::new;
|
||||
|
||||
idleSound = Sounds.drill;
|
||||
idleSoundVolume = 0.003f;
|
||||
@@ -300,11 +301,6 @@ public class Drill extends Block{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity newEntity(){
|
||||
return new DrillEntity();
|
||||
}
|
||||
|
||||
public int tier(){
|
||||
return tier;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package io.anuke.mindustry.world.blocks.production;
|
||||
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.mindustry.entities.type.*;
|
||||
import io.anuke.mindustry.world.*;
|
||||
import io.anuke.mindustry.world.meta.*;
|
||||
|
||||
@@ -16,6 +15,7 @@ public class Fracker extends SolidPump{
|
||||
public Fracker(String name){
|
||||
super(name);
|
||||
hasItems = true;
|
||||
entityType = FrackerEntity::new;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -85,11 +85,6 @@ public class Fracker extends SolidPump{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity newEntity(){
|
||||
return new FrackerEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float typeLiquid(Tile tile){
|
||||
return tile.entity.liquids.get(result);
|
||||
|
||||
@@ -36,6 +36,7 @@ public class GenericCrafter extends Block{
|
||||
health = 60;
|
||||
idleSound = Sounds.machine;
|
||||
idleSoundVolume = 0.03f;
|
||||
entityType = GenericCrafterEntity::new;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -142,11 +143,6 @@ public class GenericCrafter extends Block{
|
||||
return outputLiquid == null || !(tile.entity.liquids.get(outputLiquid.liquid) >= liquidCapacity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity newEntity(){
|
||||
return new GenericCrafterEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumAccepted(Tile tile, Item item){
|
||||
return itemCapacity;
|
||||
|
||||
@@ -24,6 +24,7 @@ public class Incinerator extends Block{
|
||||
hasLiquids = true;
|
||||
update = true;
|
||||
solid = true;
|
||||
entityType = IncineratorEntity::new;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -84,11 +85,6 @@ public class Incinerator extends Block{
|
||||
return entity.heat > 0.5f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity newEntity(){
|
||||
return new IncineratorEntity();
|
||||
}
|
||||
|
||||
public static class IncineratorEntity extends TileEntity{
|
||||
public float heat;
|
||||
}
|
||||
|
||||
@@ -1,21 +1,15 @@
|
||||
package io.anuke.mindustry.world.blocks.production;
|
||||
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
import io.anuke.arc.graphics.g2d.Lines;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.graphics.*;
|
||||
import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.arc.math.*;
|
||||
import io.anuke.arc.util.ArcAnnotate.*;
|
||||
import io.anuke.mindustry.entities.type.TileEntity;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.type.ItemStack;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.production.GenericCrafter.GenericCrafterEntity;
|
||||
import io.anuke.mindustry.world.consumers.ConsumeLiquidBase;
|
||||
import io.anuke.mindustry.world.consumers.ConsumeType;
|
||||
import io.anuke.mindustry.world.meta.BlockStat;
|
||||
import io.anuke.mindustry.world.meta.StatUnit;
|
||||
import io.anuke.mindustry.world.meta.values.ItemFilterValue;
|
||||
import io.anuke.mindustry.type.*;
|
||||
import io.anuke.mindustry.world.*;
|
||||
import io.anuke.mindustry.world.blocks.production.GenericCrafter.*;
|
||||
import io.anuke.mindustry.world.consumers.*;
|
||||
import io.anuke.mindustry.world.meta.*;
|
||||
import io.anuke.mindustry.world.meta.values.*;
|
||||
|
||||
/**
|
||||
* Extracts a random list of items from an input item and an input liquid.
|
||||
@@ -39,6 +33,7 @@ public class Separator extends Block{
|
||||
hasLiquids = true;
|
||||
|
||||
liquidRegion = reg("-liquid");
|
||||
entityType = GenericCrafterEntity::new;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -123,9 +118,4 @@ public class Separator extends Block{
|
||||
tryDump(tile);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity newEntity(){
|
||||
return new GenericCrafterEntity();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ public class SolidPump extends Pump{
|
||||
public SolidPump(String name){
|
||||
super(name);
|
||||
hasPower = true;
|
||||
entityType = SolidPumpEntity::new;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -134,11 +135,6 @@ public class SolidPump extends Pump{
|
||||
return tile != null && !tile.floor().isLiquid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity newEntity(){
|
||||
return new SolidPumpEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProximityAdded(Tile tile){
|
||||
super.onProximityAdded(tile);
|
||||
|
||||
@@ -25,6 +25,7 @@ public class ItemSource extends Block{
|
||||
solid = true;
|
||||
group = BlockGroup.transportation;
|
||||
configurable = true;
|
||||
entityType = ItemSourceEntity::new;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -91,11 +92,6 @@ public class ItemSource extends Block{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity newEntity(){
|
||||
return new ItemSourceEntity();
|
||||
}
|
||||
|
||||
public class ItemSourceEntity extends TileEntity{
|
||||
Item outputItem;
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ public class LiquidSource extends Block{
|
||||
liquidCapacity = 100f;
|
||||
configurable = true;
|
||||
outputsLiquid = true;
|
||||
entityType = LiquidSourceEntity::new;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -106,11 +107,6 @@ public class LiquidSource extends Block{
|
||||
table.add(cont);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity newEntity(){
|
||||
return new LiquidSourceEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configured(Tile tile, Player player, int value){
|
||||
tile.<LiquidSourceEntity>entity().source = value == -1 ? null : content.liquid(value);
|
||||
|
||||
@@ -36,6 +36,7 @@ public class CoreBlock extends StorageBlock{
|
||||
activeSound = Sounds.respawning;
|
||||
activeSoundVolume = 1f;
|
||||
layer = Layer.overlay;
|
||||
entityType = CoreEntity::new;
|
||||
}
|
||||
|
||||
@Remote(called = Loc.server)
|
||||
@@ -229,11 +230,6 @@ public class CoreBlock extends StorageBlock{
|
||||
return entity.spawnPlayer != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity newEntity(){
|
||||
return new CoreEntity();
|
||||
}
|
||||
|
||||
public class CoreEntity extends TileEntity implements SpawnerTrait{
|
||||
protected Player spawnPlayer;
|
||||
protected float progress;
|
||||
|
||||
@@ -11,6 +11,7 @@ public abstract class StorageBlock extends Block{
|
||||
public StorageBlock(String name){
|
||||
super(name);
|
||||
hasItems = true;
|
||||
entityType = StorageBlockEntity::new;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -69,11 +70,6 @@ public abstract class StorageBlock extends Block{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity newEntity(){
|
||||
return new StorageBlockEntity();
|
||||
}
|
||||
|
||||
public class StorageBlockEntity extends TileEntity{
|
||||
protected @Nullable
|
||||
Tile linkedCore;
|
||||
|
||||
@@ -27,6 +27,7 @@ public class Unloader extends Block{
|
||||
health = 70;
|
||||
hasItems = true;
|
||||
configurable = true;
|
||||
entityType = UnloaderEntity::new;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -128,11 +129,6 @@ public class Unloader extends Block{
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity newEntity(){
|
||||
return new UnloaderEntity();
|
||||
}
|
||||
|
||||
public static class UnloaderEntity extends TileEntity{
|
||||
public Item sortItem = null;
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ public class CommandCenter extends Block{
|
||||
destructible = true;
|
||||
solid = true;
|
||||
configurable = true;
|
||||
entityType = CommandCenterEntity::new;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -122,11 +123,6 @@ public class CommandCenter extends Block{
|
||||
Events.fire(new CommandIssueEvent(tile, command));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity newEntity(){
|
||||
return new CommandCenterEntity();
|
||||
}
|
||||
|
||||
public class CommandCenterEntity extends TileEntity{
|
||||
public UnitCommand command = UnitCommand.attack;
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ public class MechPad extends Block{
|
||||
hasPower = true;
|
||||
layer = Layer.overlay;
|
||||
flags = EnumSet.of(BlockFlag.mechPad);
|
||||
entityType = MechFactoryEntity::new;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -134,11 +135,6 @@ public class MechPad extends Block{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity newEntity(){
|
||||
return new MechFactoryEntity();
|
||||
}
|
||||
|
||||
public class MechFactoryEntity extends TileEntity implements SpawnerTrait{
|
||||
Player player;
|
||||
boolean sameMech;
|
||||
|
||||
@@ -36,6 +36,7 @@ public class RepairPoint extends Block{
|
||||
layer2 = Layer.power;
|
||||
hasPower = true;
|
||||
outlineIcon = true;
|
||||
entityType = RepairPointEntity::new;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -126,11 +127,6 @@ public class RepairPoint extends Block{
|
||||
return entity.target != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity newEntity(){
|
||||
return new RepairPointEntity();
|
||||
}
|
||||
|
||||
public class RepairPointEntity extends TileEntity{
|
||||
public Unit target;
|
||||
public float strength, rotation = 90;
|
||||
|
||||
@@ -41,6 +41,7 @@ public class UnitFactory extends Block{
|
||||
hasItems = true;
|
||||
solid = false;
|
||||
flags = EnumSet.of(BlockFlag.producer);
|
||||
entityType = UnitFactoryEntity::new;
|
||||
}
|
||||
|
||||
@Remote(called = Loc.server)
|
||||
@@ -175,16 +176,12 @@ public class UnitFactory extends Block{
|
||||
entity.cons.trigger();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumAccepted(Tile tile, Item item){
|
||||
return capacities[item.id];
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity newEntity(){
|
||||
return new UnitFactoryEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldConsume(Tile tile){
|
||||
UnitFactoryEntity entity = tile.entity();
|
||||
|
||||
Reference in New Issue
Block a user