Upgradeable cores
This commit is contained in:
@@ -198,8 +198,8 @@ public class Block extends UnlockableContent{
|
||||
|
||||
public void drawBase(Tile tile){
|
||||
//delegates to entity unless it is null
|
||||
if(tile.entity != null){
|
||||
tile.entity.draw();
|
||||
if(tile.build != null){
|
||||
tile.build.draw();
|
||||
}else{
|
||||
Draw.rect(region, tile.drawx(), tile.drawy(), rotate ? tile.rotation * 90 : 0);
|
||||
}
|
||||
@@ -255,11 +255,11 @@ public class Block extends UnlockableContent{
|
||||
}
|
||||
|
||||
public TextureRegion getDisplayIcon(Tile tile){
|
||||
return tile.entity == null ? icon(Cicon.medium) : tile.entity.getDisplayIcon();
|
||||
return tile.build == null ? icon(Cicon.medium) : tile.build.getDisplayIcon();
|
||||
}
|
||||
|
||||
public String getDisplayName(Tile tile){
|
||||
return tile.entity == null ? localizedName : tile.entity.getDisplayName();
|
||||
return tile.build == null ? localizedName : tile.build.getDisplayName();
|
||||
}
|
||||
|
||||
/** @return a custom minimap color for this or 0 to use default colors. */
|
||||
@@ -333,7 +333,7 @@ public class Block extends UnlockableContent{
|
||||
}
|
||||
|
||||
public boolean canReplace(Block other){
|
||||
return (other != this || rotate) && this.group != BlockGroup.none && other.group == this.group;
|
||||
return (other != this || rotate) && this.group != BlockGroup.none && other.group == this.group && size == other.size;
|
||||
}
|
||||
|
||||
/** @return a possible replacement for this block when placed in a line by the player. */
|
||||
@@ -479,6 +479,11 @@ public class Block extends UnlockableContent{
|
||||
return isVisible() && buildPlaceability.placeable() && !state.rules.bannedBlocks.contains(this);
|
||||
}
|
||||
|
||||
/** Called when building of this block begins. */
|
||||
public void placeBegan(Tile tile, Block previous){
|
||||
|
||||
}
|
||||
|
||||
/** @return a message detailing why this block can't be placed. */
|
||||
public String unplaceableMessage(){
|
||||
return state.rules.bannedBlocks.contains(this) ? Core.bundle.get("banned") : buildPlaceability.message();
|
||||
|
||||
@@ -3,6 +3,7 @@ package mindustry.world;
|
||||
import arc.*;
|
||||
import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.util.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
@@ -25,8 +26,8 @@ public class Build{
|
||||
//this should never happen, but it doesn't hurt to check for links
|
||||
float prevPercent = 1f;
|
||||
|
||||
if(tile.entity != null){
|
||||
prevPercent = tile.entity.healthf();
|
||||
if(tile.build != null){
|
||||
prevPercent = tile.build.healthf();
|
||||
}
|
||||
|
||||
int rotation = tile.rotation();
|
||||
@@ -34,8 +35,8 @@ public class Build{
|
||||
Block sub = BuildBlock.get(previous.size);
|
||||
|
||||
tile.setBlock(sub, team, rotation);
|
||||
tile.<BuildEntity>ent().setDeconstruct(previous);
|
||||
tile.entity.health(tile.entity.maxHealth() * prevPercent);
|
||||
tile.<BuildEntity>bc().setDeconstruct(previous);
|
||||
tile.build.health(tile.build.maxHealth() * prevPercent);
|
||||
|
||||
Core.app.post(() -> Events.fire(new BlockBuildBeginEvent(tile, team, true)));
|
||||
}
|
||||
@@ -56,7 +57,9 @@ public class Build{
|
||||
Block sub = BuildBlock.get(result.size);
|
||||
|
||||
tile.setBlock(sub, team, rotation);
|
||||
tile.<BuildEntity>ent().setConstruct(previous, result);
|
||||
tile.<BuildEntity>bc().setConstruct(previous, result);
|
||||
|
||||
result.placeBegan(tile, previous);
|
||||
|
||||
Core.app.post(() -> Events.fire(new BlockBuildBeginEvent(tile, team, false)));
|
||||
}
|
||||
@@ -80,14 +83,33 @@ public class Build{
|
||||
|
||||
if(tile == null) return false;
|
||||
|
||||
//ca check
|
||||
//campaign darkness check
|
||||
if(world.getDarkness(x, y) >= 3){
|
||||
return false;
|
||||
}
|
||||
|
||||
if(type.isMultiblock()){
|
||||
if((type.canReplace(tile.block()) || (tile.block instanceof BuildBlock && tile.<BuildEntity>ent().cblock == type)) && tile.block().size == type.size && type.canPlaceOn(tile, team) && tile.interactable(team)){
|
||||
return true;
|
||||
if((type.canReplace(tile.block()) || (tile.block instanceof BuildBlock && tile.<BuildEntity>bc().cblock == type)) &&
|
||||
type.canPlaceOn(tile, team) && tile.interactable(team)){
|
||||
|
||||
//if the block can be replaced but the sizes differ, check all the spaces around the block to make sure it can fit
|
||||
if(type.size != tile.block().size){
|
||||
int offsetx = -(type.size - 1) / 2;
|
||||
int offsety = -(type.size - 1) / 2;
|
||||
|
||||
//this does not check *all* the conditions for placeability yet
|
||||
for(int dx = 0; dx < type.size; dx++){
|
||||
for(int dy = 0; dy < type.size; dy++){
|
||||
int wx = dx + offsetx + x, wy = dy + offsety + y;
|
||||
|
||||
Tile check = world.tile(wx, wy);
|
||||
if(check == null || (!check.block.alwaysReplace && check.block != tile.block)) return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//make sure that the new block can fit the old one
|
||||
return type.bounds(x, y, Tmp.r1).grow(0.01f).contains(tile.block.bounds(tile.centerX(), tile.centerY(), Tmp.r2));
|
||||
}
|
||||
|
||||
//TODO should water blocks be placeable here?
|
||||
@@ -106,7 +128,7 @@ public class Build{
|
||||
Tile other = world.tile(x + dx + offsetx, y + dy + offsety);
|
||||
if(
|
||||
other == null ||
|
||||
(other.block() != Blocks.air && !other.block().alwaysReplace) ||
|
||||
!other.block().alwaysReplace ||
|
||||
!other.floor().placeableOn ||
|
||||
(other.floor().isDeep() && !type.floating && !type.requiresWater) ||
|
||||
(type.requiresWater && tile.floor().liquidDrop != Liquids.water)
|
||||
@@ -122,7 +144,7 @@ public class Build{
|
||||
&& (!tile.floor().isDeep() || type.floating || type.requiresWater)
|
||||
&& tile.floor().placeableOn
|
||||
&& (!type.requiresWater || tile.floor().liquidDrop == Liquids.water)
|
||||
&& (((type.canReplace(tile.block()) || (tile.block instanceof BuildBlock && tile.<BuildEntity>ent().cblock == type))
|
||||
&& (((type.canReplace(tile.block()) || (tile.block instanceof BuildBlock && tile.<BuildEntity>bc().cblock == type))
|
||||
&& !(type == tile.block() && rotation == tile.rotation() && type.rotate)) || tile.block().alwaysReplace || tile.block() == Blocks.air)
|
||||
&& tile.block().isMultiblock() == type.isMultiblock() && type.canPlaceOn(tile, team);
|
||||
}
|
||||
|
||||
@@ -22,19 +22,19 @@ public class CachedTile extends Tile{
|
||||
|
||||
@Override
|
||||
protected void changeEntity(Team team, Prov<Building> entityprov){
|
||||
entity = null;
|
||||
build = null;
|
||||
|
||||
Block block = block();
|
||||
|
||||
if(block.hasEntity()){
|
||||
Building n = entityprov.get();
|
||||
n.cons(new ConsumeModule(entity));
|
||||
n.cons(new ConsumeModule(build));
|
||||
n.tile(this);
|
||||
n.block(block);
|
||||
if(block.hasItems) n.items(new ItemModule());
|
||||
if(block.hasLiquids) n.liquids(new LiquidModule());
|
||||
if(block.hasPower) n.power(new PowerModule());
|
||||
entity = n;
|
||||
build = n;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public class Tile implements Position, QuadTreeObject, Displayable{
|
||||
/** Tile traversal cost. */
|
||||
public short cost = 1;
|
||||
/** Tile entity, usually null. */
|
||||
public @Nullable Building entity;
|
||||
public @Nullable Building build;
|
||||
public short x, y;
|
||||
protected @NonNull Block block;
|
||||
protected @NonNull Floor floor;
|
||||
@@ -105,9 +105,11 @@ public class Tile implements Position, QuadTreeObject, Displayable{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/** Convenience method that returns the building of this tile with a cast.
|
||||
* Method name is shortened to prevent conflict. */
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends Building> T ent(){
|
||||
return (T)entity;
|
||||
public <T extends Building> T bc(){
|
||||
return (T)build;
|
||||
}
|
||||
|
||||
public float worldx(){
|
||||
@@ -148,17 +150,25 @@ public class Tile implements Position, QuadTreeObject, Displayable{
|
||||
}
|
||||
|
||||
public Team team(){
|
||||
return entity == null ? Team.derelict : entity.team();
|
||||
return build == null ? Team.derelict : build.team();
|
||||
}
|
||||
|
||||
public void setTeam(Team team){
|
||||
if(entity != null){
|
||||
entity.team(team);
|
||||
if(build != null){
|
||||
build.team(team);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isCenter(){
|
||||
return entity == null || entity.tile() == this;
|
||||
return build == null || build.tile() == this;
|
||||
}
|
||||
|
||||
public int centerX(){
|
||||
return build == null ? x : build.tile.x;
|
||||
}
|
||||
|
||||
public int centerY(){
|
||||
return build == null ? y : build.tile.y;
|
||||
}
|
||||
|
||||
public byte getTeamID(){
|
||||
@@ -177,15 +187,15 @@ public class Tile implements Position, QuadTreeObject, Displayable{
|
||||
preChanged();
|
||||
changeEntity(team, entityprov);
|
||||
|
||||
if(entity != null){
|
||||
entity.team(team);
|
||||
if(build != null){
|
||||
build.team(team);
|
||||
}
|
||||
|
||||
//set up multiblock
|
||||
if(block.isMultiblock()){
|
||||
int offsetx = -(block.size - 1) / 2;
|
||||
int offsety = -(block.size - 1) / 2;
|
||||
Building entity = this.entity;
|
||||
Building entity = this.build;
|
||||
Block block = this.block;
|
||||
|
||||
//two passes: first one clears, second one sets
|
||||
@@ -204,7 +214,7 @@ public class Tile implements Position, QuadTreeObject, Displayable{
|
||||
}else{
|
||||
//second pass: assign changed data
|
||||
//assign entity and type to blocks, so they act as proxies for this one
|
||||
other.entity = entity;
|
||||
other.build = entity;
|
||||
other.block = block;
|
||||
}
|
||||
}
|
||||
@@ -213,7 +223,7 @@ public class Tile implements Position, QuadTreeObject, Displayable{
|
||||
}
|
||||
}
|
||||
|
||||
this.entity = entity;
|
||||
this.build = entity;
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
@@ -235,8 +245,8 @@ public class Tile implements Position, QuadTreeObject, Displayable{
|
||||
this.overlay = (Floor)Blocks.air;
|
||||
|
||||
recache();
|
||||
if(entity != null){
|
||||
entity.onProximityUpdate();
|
||||
if(build != null){
|
||||
build.onProximityUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -342,7 +352,7 @@ public class Tile implements Position, QuadTreeObject, Displayable{
|
||||
}
|
||||
|
||||
public boolean solid(){
|
||||
return block.solid || (entity != null && entity.checkSolid());
|
||||
return block.solid || (build != null && build.checkSolid());
|
||||
}
|
||||
|
||||
public boolean breakable(){
|
||||
@@ -497,15 +507,15 @@ public class Tile implements Position, QuadTreeObject, Displayable{
|
||||
}
|
||||
|
||||
protected void preChanged(){
|
||||
if(entity != null){
|
||||
if(build != null){
|
||||
//only call removed() for the center block - this only gets called once.
|
||||
entity.onRemoved();
|
||||
entity.removeFromProximity();
|
||||
build.onRemoved();
|
||||
build.removeFromProximity();
|
||||
|
||||
//remove this tile's dangling entities
|
||||
if(entity.block().isMultiblock()){
|
||||
int cx = entity.tileX(), cy = entity.tileY();
|
||||
int size = entity.block.size;
|
||||
if(build.block().isMultiblock()){
|
||||
int cx = build.tileX(), cy = build.tileY();
|
||||
int size = build.block.size;
|
||||
int offsetx = -(size - 1) / 2;
|
||||
int offsety = -(size - 1) / 2;
|
||||
for(int dx = 0; dx < size; dx++){
|
||||
@@ -514,7 +524,7 @@ public class Tile implements Position, QuadTreeObject, Displayable{
|
||||
if(other != null){
|
||||
//reset entity and block *manually* - thus, preChanged() will not be called anywhere else, for multiblocks
|
||||
if(other != this){ //do not remove own entity so it can be processed in changed()
|
||||
other.entity = null;
|
||||
other.build = null;
|
||||
other.block = Blocks.air;
|
||||
|
||||
//manually call changed event
|
||||
@@ -535,10 +545,10 @@ public class Tile implements Position, QuadTreeObject, Displayable{
|
||||
}
|
||||
|
||||
protected void changeEntity(Team team, Prov<Building> entityprov){
|
||||
if(entity != null){
|
||||
int size = entity.block.size;
|
||||
entity.remove();
|
||||
entity = null;
|
||||
if(build != null){
|
||||
int size = build.block.size;
|
||||
build.remove();
|
||||
build = null;
|
||||
|
||||
//update edge entities
|
||||
tileSet.clear();
|
||||
@@ -557,14 +567,14 @@ public class Tile implements Position, QuadTreeObject, Displayable{
|
||||
}
|
||||
|
||||
if(block.hasEntity()){
|
||||
entity = entityprov.get().init(this, team, block.update);
|
||||
build = entityprov.get().init(this, team, block.update);
|
||||
}
|
||||
}
|
||||
|
||||
protected void changed(){
|
||||
if(!world.isGenerating()){
|
||||
if(entity != null){
|
||||
entity.updateProximity();
|
||||
if(build != null){
|
||||
build.updateProximity();
|
||||
}else{
|
||||
//since the entity won't update proximity for us, update proximity for all nearby tiles manually
|
||||
for(Point2 p : Geometry.d4){
|
||||
@@ -609,7 +619,7 @@ public class Tile implements Position, QuadTreeObject, Displayable{
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return floor.name + ":" + block.name + ":" + overlay + "[" + x + "," + y + "] " + "entity=" + (entity == null ? "null" : (entity.getClass().getSimpleName())) + ":" + team();
|
||||
return floor.name + ":" + block.name + ":" + overlay + "[" + x + "," + y + "] " + "entity=" + (build == null ? "null" : (build.getClass().getSimpleName())) + ":" + team();
|
||||
}
|
||||
|
||||
//remote utility methods
|
||||
@@ -632,18 +642,18 @@ 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;
|
||||
if(tile.build != null){
|
||||
tile.build.health = health;
|
||||
|
||||
if(tile.entity.damaged()){
|
||||
indexer.notifyTileDamaged(tile.entity);
|
||||
if(tile.build.damaged()){
|
||||
indexer.notifyTileDamaged(tile.build);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Remote(called = Loc.server)
|
||||
public static void onTileDestroyed(Tile tile){
|
||||
if(tile.entity == null) return;
|
||||
tile.entity.killed();
|
||||
if(tile.build == null) return;
|
||||
tile.build.killed();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,13 +59,13 @@ public class BuildBlock extends Block{
|
||||
@Remote(called = Loc.server)
|
||||
public static void onConstructFinish(Tile tile, Block block, int builderID, byte rotation, Team team, boolean skipConfig){
|
||||
if(tile == null) return;
|
||||
float healthf = tile.entity.healthf();
|
||||
float healthf = tile.build.healthf();
|
||||
tile.setBlock(block, team, rotation);
|
||||
tile.entity.health(block.health * healthf);
|
||||
tile.build.health(block.health * healthf);
|
||||
//last builder was this local client player, call placed()
|
||||
if(!headless && builderID == player.unit().id()){
|
||||
if(!skipConfig){
|
||||
tile.entity.playerPlaced();
|
||||
tile.build.playerPlaced();
|
||||
}
|
||||
}
|
||||
Fx.placeBlock.at(tile.drawx(), tile.drawy(), block.size);
|
||||
@@ -97,7 +97,7 @@ public class BuildBlock extends Block{
|
||||
|
||||
public static void constructed(Tile tile, Block block, int builderID, byte rotation, Team team, boolean skipConfig){
|
||||
Call.onConstructFinish(tile, block, builderID, rotation, team, skipConfig);
|
||||
tile.entity.placed();
|
||||
tile.build.placed();
|
||||
|
||||
Events.fire(new BlockBuildEndEvent(tile, Groups.unit.getByID(builderID), team, false));
|
||||
if(shouldPlay()) Sounds.place.at(tile, calcPitch(true));
|
||||
|
||||
@@ -39,7 +39,7 @@ public class Wall extends Block{
|
||||
|
||||
@Override
|
||||
public boolean canReplace(Block other){
|
||||
return super.canReplace(other) && health > other.health;
|
||||
return super.canReplace(other) && health > other.health && size == other.size;
|
||||
}
|
||||
|
||||
public class WallEntity extends Building{
|
||||
|
||||
@@ -101,7 +101,7 @@ public class LaserTurret extends PowerTurret{
|
||||
|
||||
@Override
|
||||
protected void bullet(BulletType type, float angle){
|
||||
bullet = type.create(tile.entity, team, x + tr.x, y + tr.y, angle);
|
||||
bullet = type.create(tile.build, team, x + tr.x, y + tr.y, angle);
|
||||
bulletLife = shootDuration;
|
||||
}
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ public class LiquidTurret extends Turret{
|
||||
shootSound.at(tile);
|
||||
|
||||
if(shootShake > 0){
|
||||
Effects.shake(shootShake, shootShake, tile.entity);
|
||||
Effects.shake(shootShake, shootShake, tile.build);
|
||||
}
|
||||
|
||||
recoil = recoilAmount;
|
||||
|
||||
@@ -112,7 +112,7 @@ public class ItemBridge extends Block{
|
||||
return false;
|
||||
}
|
||||
|
||||
return (other.block() == tile.block() || (!(tile.block() instanceof ItemBridge) && other.block() == this)) && (other.team() == tile.team() || tile.block() != this) && (!checkDouble || other.<ItemBridgeEntity>ent().link != tile.pos());
|
||||
return (other.block() == tile.block() || (!(tile.block() instanceof ItemBridge) && other.block() == this)) && (other.team() == tile.team() || tile.block() != this) && (!checkDouble || other.<ItemBridgeEntity>bc().link != tile.pos());
|
||||
}
|
||||
|
||||
public Tile findLink(int x, int y){
|
||||
@@ -134,7 +134,7 @@ public class ItemBridge extends Block{
|
||||
public void playerPlaced(){
|
||||
Tile link = findLink(tile.x, tile.y);
|
||||
if(linkValid(tile, link)){
|
||||
link.entity.configure(tile.pos());
|
||||
link.build.configure(tile.pos());
|
||||
}
|
||||
|
||||
lastPlaced = tile.pos();
|
||||
@@ -154,7 +154,7 @@ public class ItemBridge extends Block{
|
||||
private void drawInput(Tile other){
|
||||
if(!linkValid(tile, other, false)) return;
|
||||
boolean linked = other.pos() == link;
|
||||
if(!linked && !(other.<ItemBridgeEntity>ent().link == tile.pos())) return;
|
||||
if(!linked && !(other.<ItemBridgeEntity>bc().link == tile.pos())) return;
|
||||
|
||||
Tmp.v2.trns(tile.angleTo(other), 2f);
|
||||
float tx = tile.drawx(), ty = tile.drawy();
|
||||
@@ -227,7 +227,7 @@ public class ItemBridge extends Block{
|
||||
while(it.hasNext){
|
||||
int i = it.next();
|
||||
Tile other = world.tile(i);
|
||||
if(!linkValid(tile, other, false) || other.<ItemBridgeEntity>ent().link != tile.pos()){
|
||||
if(!linkValid(tile, other, false) || other.<ItemBridgeEntity>bc().link != tile.pos()){
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
@@ -245,7 +245,7 @@ public class ItemBridge extends Block{
|
||||
dump();
|
||||
uptime = 0f;
|
||||
}else{
|
||||
((ItemBridgeEntity)other.entity).incoming.add(tile.pos());
|
||||
((ItemBridgeEntity)other.build).incoming.add(tile.pos());
|
||||
|
||||
if(consValid() && Mathf.zero(1f - efficiency())){
|
||||
uptime = Mathf.lerpDelta(uptime, 1f, 0.04f);
|
||||
@@ -253,7 +253,7 @@ public class ItemBridge extends Block{
|
||||
uptime = Mathf.lerpDelta(uptime, 0f, 0.02f);
|
||||
}
|
||||
|
||||
updateTransport(other.entity);
|
||||
updateTransport(other.build);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -290,7 +290,7 @@ public class MassDriver extends Block{
|
||||
protected boolean shooterValid(Tile other){
|
||||
if(other == null) return true;
|
||||
if(!(other.block() instanceof MassDriver)) return false;
|
||||
MassDriverEntity entity = other.ent();
|
||||
MassDriverEntity entity = other.bc();
|
||||
return entity.link == tile.pos() && tile.dst(other) <= range;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ public class Sorter extends Block{
|
||||
|
||||
@Override
|
||||
public int minimapColor(Tile tile){
|
||||
return tile.<SorterEntity>ent().sortItem == null ? 0 : tile.<SorterEntity>ent().sortItem.color.rgba();
|
||||
return tile.<SorterEntity>bc().sortItem == null ? 0 : tile.<SorterEntity>bc().sortItem.color.rgba();
|
||||
}
|
||||
|
||||
public class SorterEntity extends Building{
|
||||
|
||||
@@ -52,8 +52,8 @@ public class StackConveyor extends Block implements Autotiler{
|
||||
|
||||
@Override
|
||||
public boolean blends(Tile tile, int rotation, int otherx, int othery, int otherrot, Block otherblock){
|
||||
if(tile.entity instanceof StackConveyorEntity){
|
||||
int state = ((StackConveyorEntity)tile.entity).state;
|
||||
if(tile.build instanceof StackConveyorEntity){
|
||||
int state = ((StackConveyorEntity)tile.build).state;
|
||||
if(state == stateLoad){ //standard conveyor mode
|
||||
return otherblock.outputsItems() && lookingAtEither(tile, rotation, otherx, othery, otherrot, otherblock);
|
||||
}else if(state == stateUnload){ //router mode
|
||||
|
||||
@@ -178,8 +178,8 @@ public class PowerNode extends PowerBlock{
|
||||
|
||||
tempTileEnts.clear();
|
||||
graphs.clear();
|
||||
if(tile.entity != null && tile.entity.power != null){
|
||||
graphs.add(tile.entity.power.graph);
|
||||
if(tile.build != null && tile.build.power != null){
|
||||
graphs.add(tile.build.power.graph);
|
||||
}
|
||||
|
||||
Geometry.circle(tile.x, tile.y, (int)(laserRange + 2), (x, y) -> {
|
||||
|
||||
@@ -10,6 +10,7 @@ import arc.util.ArcAnnotate.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
@@ -52,7 +53,7 @@ public class CoreBlock extends StorageBlock{
|
||||
public static void onPlayerSpawn(Tile tile, Player player){
|
||||
if(player == null || tile == null) return;
|
||||
|
||||
CoreEntity entity = tile.ent();
|
||||
CoreEntity entity = tile.bc();
|
||||
CoreBlock block = (CoreBlock)tile.block();
|
||||
Fx.spawn.at(entity);
|
||||
|
||||
@@ -91,6 +92,27 @@ public class CoreBlock extends StorageBlock{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canReplace(Block other){
|
||||
//coreblocks can upgrade smaller cores
|
||||
return super.canReplace(other) || (other instanceof CoreBlock && size > other.size);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceOn(Tile tile, Team team){
|
||||
return canReplace(tile.block());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void placeBegan(Tile tile, Block previous){
|
||||
//finish placement immediately when a block is replaced.
|
||||
if(previous instanceof CoreBlock){
|
||||
tile.setBlock(this, tile.team());
|
||||
Fx.placeBlock.at(tile, tile.block().size);
|
||||
Fx.upgradeCore.at(tile, tile.block().size);
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
@@ -82,7 +82,7 @@ public class Unloader extends Block{
|
||||
|
||||
@Override
|
||||
public void buildConfiguration(Table table){
|
||||
ItemSelection.buildTable(table, content.items(), () -> tile.<UnloaderEntity>ent().sortItem, item -> configure(item));
|
||||
ItemSelection.buildTable(table, content.items(), () -> tile.<UnloaderEntity>bc().sortItem, item -> configure(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -26,8 +26,8 @@ public class UnitBlock extends PayloadAcceptor{
|
||||
|
||||
@Remote(called = Loc.server)
|
||||
public static void onUnitBlockSpawn(Tile tile){
|
||||
if(!(tile.entity instanceof UnitBlockEntity)) return;
|
||||
tile.<UnitBlockEntity>ent().spawned();
|
||||
if(!(tile.build instanceof UnitBlockEntity)) return;
|
||||
tile.<UnitBlockEntity>bc().spawned();
|
||||
}
|
||||
|
||||
public class UnitBlockEntity extends PayloadAcceptorEntity<UnitPayload>{
|
||||
|
||||
@@ -68,7 +68,7 @@ public class ConsumePower extends Consume{
|
||||
* @return The amount of power which is requested per tick.
|
||||
*/
|
||||
public float requestedPower(Building entity){
|
||||
if(entity.tile().entity == null) return 0f;
|
||||
if(entity.tile().build == null) return 0f;
|
||||
if(buffered){
|
||||
return (1f-entity.power.status)*capacity;
|
||||
}else{
|
||||
|
||||
Reference in New Issue
Block a user