Many various internal changes
This commit is contained in:
@@ -66,7 +66,7 @@ public class BuildBlock extends Block{
|
||||
public static void onConstructFinish(Tile tile, Block block, int builderID, byte rotation, Team team, boolean skipConfig){
|
||||
if(tile == null) return;
|
||||
float healthf = tile.entity == null ? 1f : tile.entity.healthf();
|
||||
world.setBlock(tile, block, team, rotation);
|
||||
tile.set(block, team, rotation);
|
||||
if(tile.entity != null){
|
||||
tile.entity.health = block.health * healthf;
|
||||
}
|
||||
|
||||
@@ -84,12 +84,12 @@ public class CoreBlock extends StorageBlock{
|
||||
public void onProximityUpdate(Tile tile){
|
||||
CoreEntity entity = tile.ent();
|
||||
|
||||
for(Tile other : state.teams.get(tile.getTeam()).cores){
|
||||
if(other != tile){
|
||||
entity.items = other.entity.items;
|
||||
for(TileEntity other : state.teams.cores(tile.getTeam())){
|
||||
if(other.tile != tile){
|
||||
entity.items = other.items;
|
||||
}
|
||||
}
|
||||
state.teams.get(tile.getTeam()).cores.add(tile);
|
||||
state.teams.registerCore(entity);
|
||||
|
||||
entity.storageCapacity = itemCapacity + entity.proximity().sum(e -> isContainer(e) ? e.block().itemCapacity : 0);
|
||||
entity.proximity().each(this::isContainer, t -> {
|
||||
@@ -97,9 +97,9 @@ public class CoreBlock extends StorageBlock{
|
||||
t.<StorageBlockEntity>ent().linkedCore = tile;
|
||||
});
|
||||
|
||||
for(Tile other : state.teams.get(tile.getTeam()).cores){
|
||||
if(other == tile) continue;
|
||||
entity.storageCapacity += other.block().itemCapacity + other.entity.proximity().sum(e -> isContainer(e) ? e.block().itemCapacity : 0);
|
||||
for(TileEntity other : state.teams.cores(tile.getTeam())){
|
||||
if(other.tile == tile) continue;
|
||||
entity.storageCapacity += other.block.itemCapacity + entity.proximity().sum(e -> isContainer(e) ? e.block().itemCapacity : 0);
|
||||
}
|
||||
|
||||
if(!world.isGenerating()){
|
||||
@@ -108,9 +108,8 @@ public class CoreBlock extends StorageBlock{
|
||||
}
|
||||
}
|
||||
|
||||
for(Tile other : state.teams.get(tile.getTeam()).cores){
|
||||
CoreEntity oe = other.ent();
|
||||
oe.storageCapacity = entity.storageCapacity;
|
||||
for(CoreEntity other : state.teams.cores(tile.getTeam())){
|
||||
other.storageCapacity = entity.storageCapacity;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,8 +150,9 @@ public class CoreBlock extends StorageBlock{
|
||||
|
||||
@Override
|
||||
public void removed(Tile tile){
|
||||
CoreEntity entity = tile.ent();
|
||||
int total = tile.entity.proximity().count(e -> e.entity.items == tile.entity.items);
|
||||
float fract = 1f / total / state.teams.get(tile.getTeam()).cores.size;
|
||||
float fract = 1f / total / state.teams.cores(tile.getTeam()).size;
|
||||
|
||||
tile.entity.proximity().each(e -> isContainer(e) && e.entity.items == tile.entity.items, t -> {
|
||||
StorageBlockEntity ent = (StorageBlockEntity)t.entity;
|
||||
@@ -163,22 +163,23 @@ public class CoreBlock extends StorageBlock{
|
||||
}
|
||||
});
|
||||
|
||||
state.teams.get(tile.getTeam()).cores.remove(tile);
|
||||
state.teams.unregisterCore(entity);
|
||||
|
||||
int max = itemCapacity * state.teams.get(tile.getTeam()).cores.size;
|
||||
int max = itemCapacity * state.teams.cores(tile.getTeam()).size;
|
||||
for(Item item : content.items()){
|
||||
tile.entity.items.set(item, Math.min(tile.entity.items.get(item), max));
|
||||
}
|
||||
|
||||
for(Tile other : state.teams.get(tile.getTeam()).cores){
|
||||
other.block().onProximityUpdate(other);
|
||||
for(CoreEntity other : state.teams.cores(tile.getTeam())){
|
||||
other.block.onProximityUpdate(other.tile);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void placed(Tile tile){
|
||||
super.placed(tile);
|
||||
state.teams.get(tile.getTeam()).cores.add(tile);
|
||||
CoreEntity entity = tile.ent();
|
||||
state.teams.registerCore(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -58,7 +58,7 @@ public class CommandCenter extends Block{
|
||||
ObjectSet<Tile> set = indexer.getAllied(tile.getTeam(), BlockFlag.comandCenter);
|
||||
|
||||
if(set.size == 1){
|
||||
for(BaseUnit unit : unitGroups[(int) tile.getTeam().id].all()){
|
||||
for(BaseUnit unit : unitGroups[(int)tile.getTeam().id].all()){
|
||||
unit.onCommand(UnitCommand.all[0]);
|
||||
}
|
||||
}
|
||||
@@ -116,7 +116,7 @@ public class CommandCenter extends Block{
|
||||
|
||||
Team team = (player == null ? tile.getTeam() : player.getTeam());
|
||||
|
||||
for(BaseUnit unit : unitGroups[(int) team.id].all()){
|
||||
for(BaseUnit unit : unitGroups[(int)team.id].all()){
|
||||
unit.onCommand(command);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user