Full command center implementation

This commit is contained in:
Anuken
2018-07-26 17:51:25 -04:00
parent 49e19ab34d
commit c832a7b93f
10 changed files with 729 additions and 668 deletions

View File

@@ -138,6 +138,7 @@ public class Recipes implements ContentList{
new Recipe(units, UnitBlocks.repairPoint, new ItemStack(Items.lead, 30), new ItemStack(Items.tungsten, 30), new ItemStack(Items.silicon, 30));
new Recipe(units, UnitBlocks.resupplyPoint, new ItemStack(Items.lead, 30), new ItemStack(Items.tungsten, 30), new ItemStack(Items.silicon, 30));
new Recipe(units, UnitBlocks.commandCenter, new ItemStack(Items.lead, 30), new ItemStack(Items.tungsten, 30), new ItemStack(Items.silicon, 30));
//LIQUIDS
new Recipe(liquid, LiquidBlocks.conduit, new ItemStack(Items.lead, 1))

View File

@@ -65,7 +65,7 @@ public class UnitBlocks extends BlockList implements ContentList{
}};
commandCenter = new CommandCenter("command-center"){{
size = 2;
}};
}
}

View File

@@ -32,9 +32,7 @@ public class Bullet extends BulletEntity<BulletType> implements TeamTrait, SyncT
private Object data;
private boolean supressCollision;
/**
* Internal use only!
*/
/**Internal use only!*/
public Bullet(){
}

View File

@@ -1,24 +1,30 @@
package io.anuke.mindustry.world.blocks.units;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.utils.ObjectSet;
import io.anuke.annotations.Annotations.Loc;
import io.anuke.annotations.Annotations.Remote;
import io.anuke.mindustry.entities.Player;
import io.anuke.mindustry.entities.TileEntity;
import io.anuke.mindustry.entities.units.BaseUnit;
import io.anuke.mindustry.entities.units.UnitCommand;
import io.anuke.mindustry.gen.Call;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.meta.BlockFlag;
import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.scene.ui.ButtonGroup;
import io.anuke.ucore.scene.ui.ImageButton;
import io.anuke.ucore.scene.ui.layout.Table;
import io.anuke.ucore.util.EnumSet;
import static io.anuke.mindustry.Vars.unitGroups;
import static io.anuke.mindustry.Vars.world;
import static io.anuke.mindustry.Vars.*;
public class CommandCenter extends Block{
protected TextureRegion[] commandRegions = new TextureRegion[UnitCommand.values().length];
protected Color topColor = Color.valueOf("eab678");
protected Color bottomColor = Color.valueOf("d4986b");
public CommandCenter(String name){
super(name);
@@ -29,6 +35,17 @@ public class CommandCenter extends Block{
configurable = true;
}
@Override
public void placed(Tile tile){
ObjectSet<Tile> set = world.indexer().getAllied(tile.getTeam(), BlockFlag.comandCenter);
if(set.size > 0){
CommandCenterEntity entity = tile.entity();
CommandCenterEntity oe = set.first().entity();
entity.command = oe.command;
}
}
@Override
public void load(){
super.load();
@@ -43,19 +60,29 @@ public class CommandCenter extends Block{
CommandCenterEntity entity = tile.entity();
super.draw(tile);
Draw.colorl(0.3f);
Draw.rect(commandRegions[entity.command.ordinal()], tile.drawx(), tile.drawy() - 1);
Draw.color(topColor);
Draw.rect(commandRegions[entity.command.ordinal()], tile.drawx(), tile.drawy());
Draw.color();
}
@Override
public void buildTable(Tile tile, Table table){
//TODO
CommandCenterEntity entity = tile.entity();
ButtonGroup<ImageButton> group = new ButtonGroup<>();
for(UnitCommand cmd : UnitCommand.values()){
table.addImageButton("command-" + cmd.name(), "toggle", 8*3, () -> threads.run(() -> Call.onCommandCenterSet(players[0], tile, cmd))).size(40f, 44f)
.checked(entity.command == cmd).group(group);
}
}
@Remote(called = Loc.server, forward = true, targets = Loc.both)
public static void onCommandCenterSet(Player player, Tile tile, UnitCommand command){
for(Tile center : world.indexer().getAllied(tile.getTeam(), BlockFlag.comandCenter)){
if(center.block() instanceof CommandCenter){
CommandCenterEntity entity = tile.entity();
CommandCenterEntity entity = center.entity();
entity.command = command;
}
}