By popular demand, re-added command center
BIN
core/assets-raw/sprites/blocks/units/command-center.png
Normal file
|
After Width: | Height: | Size: 4.8 KiB |
BIN
core/assets-raw/sprites/ui/icons/icon-command-attack.png
Normal file
|
After Width: | Height: | Size: 109 B |
BIN
core/assets-raw/sprites/ui/icons/icon-command-idle.png
Normal file
|
After Width: | Height: | Size: 95 B |
BIN
core/assets-raw/sprites/ui/icons/icon-command-patrol.png
Normal file
|
After Width: | Height: | Size: 104 B |
BIN
core/assets-raw/sprites/ui/icons/icon-command-retreat.png
Normal file
|
After Width: | Height: | Size: 94 B |
|
Before Width: | Height: | Size: 297 B After Width: | Height: | Size: 2.7 KiB |
|
|
@ -25,9 +25,6 @@ stat.deconstructed = Buildings Deconstructed:[accent] {0}
|
|||
stat.delivered = Resources Launched:
|
||||
stat.rank = Final Rank: [accent]{0}
|
||||
|
||||
placeline = You have selected a block.\nYou can[accent] place in a line[] by[accent] holding down your finger for a few seconds[] and dragging in a direction.\n\n[scarlet]DO IT.
|
||||
removearea = You have selected removal mode.\nYou can[accent] remove blocks in a rectangle[] by[accent] holding down your finger for a few seconds[] and dragging.\n\n[scarlet]DO IT.
|
||||
|
||||
launcheditems = [accent]Launched Items
|
||||
map.delete = Are you sure you want to delete the map "[accent]{0}[]"?
|
||||
level.highscore = High Score: [accent]{0}
|
||||
|
|
@ -807,6 +804,7 @@ block.blast-mixer.name = Blast Mixer
|
|||
block.solar-panel.name = Solar Panel
|
||||
block.solar-panel-large.name = Large Solar Panel
|
||||
block.oil-extractor.name = Oil Extractor
|
||||
block.command-center.name = Command Center
|
||||
block.draug-factory.name = Draug Miner Drone Factory
|
||||
block.spirit-factory.name = Spirit Repair Drone Factory
|
||||
block.phantom-factory.name = Phantom Builder Drone Factory
|
||||
|
|
@ -1031,6 +1029,7 @@ block.ripple.description = An extremely powerful artillery turret. Shoots cluste
|
|||
block.cyclone.description = A large anti-air and anti-ground turret. Fires explosive clumps of flak at nearby units.
|
||||
block.spectre.description = A massive dual-barreled cannon. Shoots large armor-piercing bullets at air and ground targets.
|
||||
block.meltdown.description = A massive laser cannon. Charges and fires a persistent laser beam at nearby enemies. Requires coolant to operate.
|
||||
block.command-center.description = Issues movement commands to allied units across the map.\nCauses units to patrol, attack an enemy core or retreat to the core/factory. When no enemy core is present, units will default to patrolling under the attack command.
|
||||
block.draug-factory.description = Produces Draug mining drones.
|
||||
block.spirit-factory.description = Produces Spirit structural repair drones.
|
||||
block.phantom-factory.description = Produces advanced construction drones.
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 717 B After Width: | Height: | Size: 718 B |
|
Before Width: | Height: | Size: 676 KiB After Width: | Height: | Size: 672 KiB |
|
Before Width: | Height: | Size: 256 KiB After Width: | Height: | Size: 258 KiB |
|
Before Width: | Height: | Size: 575 KiB After Width: | Height: | Size: 581 KiB |
|
|
@ -1,16 +1,14 @@
|
|||
package io.anuke.mindustry.content;
|
||||
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.function.BooleanProvider;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.graphics.*;
|
||||
import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.util.Tmp;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.entities.Damage;
|
||||
import io.anuke.mindustry.entities.bullet.Bullet;
|
||||
import io.anuke.mindustry.entities.bullet.BulletType;
|
||||
import io.anuke.mindustry.game.ContentList;
|
||||
import io.anuke.arc.math.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.*;
|
||||
import io.anuke.mindustry.entities.*;
|
||||
import io.anuke.mindustry.entities.bullet.*;
|
||||
import io.anuke.mindustry.game.*;
|
||||
import io.anuke.mindustry.gen.*;
|
||||
import io.anuke.mindustry.graphics.*;
|
||||
import io.anuke.mindustry.type.*;
|
||||
|
|
@ -24,16 +22,13 @@ import io.anuke.mindustry.world.blocks.production.*;
|
|||
import io.anuke.mindustry.world.blocks.sandbox.*;
|
||||
import io.anuke.mindustry.world.blocks.storage.*;
|
||||
import io.anuke.mindustry.world.blocks.units.*;
|
||||
import io.anuke.mindustry.world.consumers.ConsumeLiquidFilter;
|
||||
import io.anuke.mindustry.world.meta.Attribute;
|
||||
import io.anuke.mindustry.world.modules.LiquidModule;
|
||||
import io.anuke.mindustry.world.consumers.*;
|
||||
import io.anuke.mindustry.world.meta.*;
|
||||
import io.anuke.mindustry.world.modules.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.state;
|
||||
import static io.anuke.mindustry.Vars.world;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class Blocks implements ContentList{
|
||||
public static final BooleanProvider padVisible = () -> state.rules.attackMode || state.rules.pvp || state.isEditor();
|
||||
|
||||
public static Block
|
||||
|
||||
//environment
|
||||
|
|
@ -79,7 +74,7 @@ public class Blocks implements ContentList{
|
|||
duo, scatter, scorch, hail, arc, wave, lancer, swarmer, salvo, fuse, ripple, cyclone, spectre, meltdown,
|
||||
|
||||
//units
|
||||
draugFactory, spiritFactory, phantomFactory, wraithFactory, ghoulFactory, revenantFactory, daggerFactory, crawlerFactory, titanFactory,
|
||||
commandCenter, draugFactory, spiritFactory, phantomFactory, wraithFactory, ghoulFactory, revenantFactory, daggerFactory, crawlerFactory, titanFactory,
|
||||
fortressFactory, repairPoint,
|
||||
|
||||
//upgrades
|
||||
|
|
@ -1648,17 +1643,23 @@ public class Blocks implements ContentList{
|
|||
consumes.items(new ItemStack(Items.silicon, 30), new ItemStack(Items.lead, 20), new ItemStack(Items.titanium, 10));
|
||||
}};
|
||||
|
||||
wraithFactory = new UnitFactory("wraith-factory"){{
|
||||
requirements(Category.units, padVisible, ItemStack.with(Items.titanium, 30, Items.lead, 40, Items.silicon, 45));
|
||||
type = UnitTypes.wraith;
|
||||
produceTime = 750;
|
||||
commandCenter = new CommandCenter("command-center"){{
|
||||
requirements(Category.units, ItemStack.with(Items.copper, 200, Items.lead, 250, Items.silicon, 250, Items.graphite, 100));
|
||||
size = 2;
|
||||
consumes.power(0.6f);
|
||||
health = size * size * 55;
|
||||
}};
|
||||
|
||||
wraithFactory = new UnitFactory("wraith-factory"){{
|
||||
requirements(Category.units, ItemStack.with(Items.titanium, 30, Items.lead, 40, Items.silicon, 45));
|
||||
type = UnitTypes.wraith;
|
||||
produceTime = 700;
|
||||
size = 2;
|
||||
consumes.power(0.5f);
|
||||
consumes.items(new ItemStack(Items.silicon, 10), new ItemStack(Items.titanium, 5));
|
||||
}};
|
||||
|
||||
ghoulFactory = new UnitFactory("ghoul-factory"){{
|
||||
requirements(Category.units, padVisible, ItemStack.with(Items.titanium, 75, Items.lead, 65, Items.silicon, 110));
|
||||
requirements(Category.units, ItemStack.with(Items.titanium, 75, Items.lead, 65, Items.silicon, 110));
|
||||
type = UnitTypes.ghoul;
|
||||
produceTime = 1150;
|
||||
size = 3;
|
||||
|
|
@ -1667,7 +1668,7 @@ public class Blocks implements ContentList{
|
|||
}};
|
||||
|
||||
revenantFactory = new UnitFactory("revenant-factory"){{
|
||||
requirements(Category.units, padVisible, ItemStack.with(Items.plastanium, 50, Items.titanium, 150, Items.lead, 150, Items.silicon, 200));
|
||||
requirements(Category.units, ItemStack.with(Items.plastanium, 50, Items.titanium, 150, Items.lead, 150, Items.silicon, 200));
|
||||
type = UnitTypes.revenant;
|
||||
produceTime = 2000;
|
||||
size = 4;
|
||||
|
|
@ -1676,7 +1677,7 @@ public class Blocks implements ContentList{
|
|||
}};
|
||||
|
||||
daggerFactory = new UnitFactory("dagger-factory"){{
|
||||
requirements(Category.units, padVisible, ItemStack.with(Items.lead, 55, Items.silicon, 35));
|
||||
requirements(Category.units, ItemStack.with(Items.lead, 55, Items.silicon, 35));
|
||||
type = UnitTypes.dagger;
|
||||
produceTime = 850;
|
||||
size = 2;
|
||||
|
|
@ -1685,7 +1686,7 @@ public class Blocks implements ContentList{
|
|||
}};
|
||||
|
||||
crawlerFactory = new UnitFactory("crawler-factory"){{
|
||||
requirements(Category.units, padVisible, ItemStack.with(Items.lead, 25, Items.silicon, 30));
|
||||
requirements(Category.units, ItemStack.with(Items.lead, 25, Items.silicon, 30));
|
||||
type = UnitTypes.crawler;
|
||||
produceTime = 250;
|
||||
size = 2;
|
||||
|
|
@ -1695,7 +1696,7 @@ public class Blocks implements ContentList{
|
|||
}};
|
||||
|
||||
titanFactory = new UnitFactory("titan-factory"){{
|
||||
requirements(Category.units, padVisible, ItemStack.with(Items.graphite, 50, Items.lead, 50, Items.silicon, 45));
|
||||
requirements(Category.units, ItemStack.with(Items.graphite, 50, Items.lead, 50, Items.silicon, 45));
|
||||
type = UnitTypes.titan;
|
||||
produceTime = 1050;
|
||||
size = 3;
|
||||
|
|
@ -1704,7 +1705,7 @@ public class Blocks implements ContentList{
|
|||
}};
|
||||
|
||||
fortressFactory = new UnitFactory("fortress-factory"){{
|
||||
requirements(Category.units, padVisible, ItemStack.with(Items.thorium, 40, Items.lead, 110, Items.silicon, 75));
|
||||
requirements(Category.units, ItemStack.with(Items.thorium, 40, Items.lead, 110, Items.silicon, 75));
|
||||
type = UnitTypes.fortress;
|
||||
produceTime = 2000;
|
||||
size = 3;
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ public class Fx implements ContentList{
|
|||
bigShockwave, nuclearShockwave, explosion, blockExplosion, blockExplosionSmoke, shootSmall, shootHeal, shootSmallSmoke, shootBig, shootBig2, shootBigSmoke,
|
||||
shootBigSmoke2, shootSmallFlame, shootPyraFlame, shootLiquid, shellEjectSmall, shellEjectMedium,
|
||||
shellEjectBig, lancerLaserShoot, lancerLaserShootSmoke, lancerLaserCharge, lancerLaserChargeBegin, lightningCharge, lightningShoot,
|
||||
unitSpawn, spawnShockwave, magmasmoke, impactShockwave, impactcloud, impactsmoke, dynamicExplosion, padlaunch;
|
||||
unitSpawn, spawnShockwave, magmasmoke, impactShockwave, impactcloud, impactsmoke, dynamicExplosion, padlaunch, commandSend;
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
|
|
@ -53,6 +53,13 @@ public class Fx implements ContentList{
|
|||
Draw.reset();
|
||||
});
|
||||
|
||||
commandSend = new Effect(28, e -> {
|
||||
Draw.color(Pal.command);
|
||||
Lines.stroke(e.fout() * 2f);
|
||||
Lines.circle(e.x, e.y, 4f + e.finpow() * 120f);
|
||||
Draw.color();
|
||||
});
|
||||
|
||||
placeBlock = new Effect(16, e -> {
|
||||
Draw.color(Pal.accent);
|
||||
Lines.stroke(3f - e.fin() * 2f);
|
||||
|
|
|
|||
|
|
@ -254,6 +254,7 @@ public class TechTree implements ContentList{
|
|||
});
|
||||
|
||||
node(daggerFactory, () -> {
|
||||
node(commandCenter, () -> {});
|
||||
node(crawlerFactory, () -> {
|
||||
node(titanFactory, () -> {
|
||||
node(fortressFactory, () -> {
|
||||
|
|
@ -296,7 +297,7 @@ public class TechTree implements ContentList{
|
|||
private TechNode node(Block block, Runnable children){
|
||||
ItemStack[] requirements = new ItemStack[block.buildRequirements.length];
|
||||
for(int i = 0; i < requirements.length; i++){
|
||||
requirements[i] = new ItemStack(block.buildRequirements[i].item, 30 + block.buildRequirements[i].amount * 5);
|
||||
requirements[i] = new ItemStack(block.buildRequirements[i].item, 30 + block.buildRequirements[i].amount * 6);
|
||||
}
|
||||
|
||||
return new TechNode(block, requirements, children);
|
||||
|
|
|
|||
|
|
@ -20,6 +20,10 @@ public interface HealthTrait{
|
|||
default void onDeath(){
|
||||
}
|
||||
|
||||
default boolean damaged(){
|
||||
return health() < maxHealth() - 0.0001f;
|
||||
}
|
||||
|
||||
default void damage(float amount){
|
||||
health(health() - amount);
|
||||
if(health() <= 0 && !isDead()){
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import io.anuke.mindustry.gen.*;
|
|||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.mindustry.type.*;
|
||||
import io.anuke.mindustry.world.*;
|
||||
import io.anuke.mindustry.world.blocks.units.CommandCenter.*;
|
||||
import io.anuke.mindustry.world.blocks.units.UnitFactory.*;
|
||||
import io.anuke.mindustry.world.meta.*;
|
||||
|
||||
|
|
@ -25,7 +26,6 @@ import static io.anuke.mindustry.Vars.*;
|
|||
|
||||
/** Base class for AI units. */
|
||||
public abstract class BaseUnit extends Unit implements ShooterTrait{
|
||||
|
||||
protected static int timerIndex = 0;
|
||||
|
||||
protected static final int timerTarget = timerIndex++;
|
||||
|
|
@ -83,6 +83,22 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
|||
return world.tile(spawner);
|
||||
}
|
||||
|
||||
public boolean isCommanded(){
|
||||
return world.indexer.getAllied(team, BlockFlag.comandCenter).size != 0 && world.indexer.getAllied(team, BlockFlag.comandCenter).first().entity instanceof CommandCenterEntity;
|
||||
}
|
||||
|
||||
public UnitCommand getCommand(){
|
||||
if(isCommanded()){
|
||||
return world.indexer.getAllied(team, BlockFlag.comandCenter).first().<CommandCenterEntity>entity().command;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**Called when a command is recieved from the command center.*/
|
||||
public void onCommand(UnitCommand command){
|
||||
|
||||
}
|
||||
|
||||
/** Initialize the type and team of this unit. Only call once! */
|
||||
public void init(UnitType type, Team team){
|
||||
if(this.type != null) throw new RuntimeException("This unit is already initialized!");
|
||||
|
|
@ -303,6 +319,10 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
|||
state.set(getStartState());
|
||||
|
||||
health(maxHealth());
|
||||
|
||||
if(isCommanded()){
|
||||
onCommand(getCommand());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,20 +1,19 @@
|
|||
package io.anuke.mindustry.entities.type;
|
||||
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
import io.anuke.arc.graphics.g2d.Fill;
|
||||
import io.anuke.arc.math.Angles;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.math.geom.Vector2;
|
||||
import io.anuke.arc.util.Time;
|
||||
import io.anuke.arc.util.Tmp;
|
||||
import io.anuke.mindustry.entities.Predict;
|
||||
import io.anuke.mindustry.entities.Units;
|
||||
import io.anuke.mindustry.entities.bullet.BulletType;
|
||||
import io.anuke.mindustry.entities.units.UnitState;
|
||||
import io.anuke.mindustry.graphics.Pal;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.mindustry.world.meta.BlockFlag;
|
||||
import io.anuke.arc.graphics.*;
|
||||
import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.arc.math.*;
|
||||
import io.anuke.arc.math.geom.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.entities.*;
|
||||
import io.anuke.mindustry.entities.bullet.*;
|
||||
import io.anuke.mindustry.entities.units.*;
|
||||
import io.anuke.mindustry.graphics.*;
|
||||
import io.anuke.mindustry.net.*;
|
||||
import io.anuke.mindustry.world.*;
|
||||
import io.anuke.mindustry.world.meta.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.world;
|
||||
|
||||
public abstract class FlyingUnit extends BaseUnit{
|
||||
protected float[] weaponAngles = {0, 0};
|
||||
|
|
@ -80,14 +79,40 @@ public abstract class FlyingUnit extends BaseUnit{
|
|||
return;
|
||||
}
|
||||
|
||||
target = getClosestCore();
|
||||
};
|
||||
target = getSpawner();
|
||||
if(target == null) target = getClosestCore();
|
||||
}
|
||||
|
||||
if(target != null){
|
||||
circle(60f + Mathf.absin(Time.time() + Mathf.randomSeed(id) * 1200f, 70f, 1200f));
|
||||
circle(80f + Mathf.randomSeed(id) * 120);
|
||||
}
|
||||
}
|
||||
};
|
||||
},
|
||||
retreat = new UnitState(){
|
||||
public void entered(){
|
||||
target = null;
|
||||
}
|
||||
|
||||
public void update(){
|
||||
if(retarget()){
|
||||
target = getSpawner();
|
||||
|
||||
Tile repair = Geometry.findClosest(x, y, world.indexer.getAllied(team, BlockFlag.repair));
|
||||
if(repair != null && damaged()) FlyingUnit.this.target = repair.entity;
|
||||
if(target == null) target = getClosestCore();
|
||||
}
|
||||
|
||||
circle(targetHasFlag(BlockFlag.repair) ? 20f : 60f + Mathf.randomSeed(id) * 50, 0.65f * type.speed);
|
||||
}
|
||||
};;
|
||||
|
||||
@Override
|
||||
public void onCommand(UnitCommand command){
|
||||
state.set(command == UnitCommand.retreat ? retreat :
|
||||
command == UnitCommand.attack ? attack :
|
||||
command == UnitCommand.patrol ? patrol :
|
||||
null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void move(float x, float y){
|
||||
|
|
|
|||
|
|
@ -1,20 +1,18 @@
|
|||
package io.anuke.mindustry.entities.type;
|
||||
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
import io.anuke.arc.math.Angles;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.math.geom.Vector2;
|
||||
import io.anuke.arc.util.Time;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.entities.Predict;
|
||||
import io.anuke.mindustry.entities.Units;
|
||||
import io.anuke.mindustry.entities.bullet.BulletType;
|
||||
import io.anuke.mindustry.entities.units.UnitState;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.type.Weapon;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.Floor;
|
||||
import io.anuke.arc.graphics.*;
|
||||
import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.arc.math.*;
|
||||
import io.anuke.arc.math.geom.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.*;
|
||||
import io.anuke.mindustry.entities.*;
|
||||
import io.anuke.mindustry.entities.bullet.*;
|
||||
import io.anuke.mindustry.entities.units.*;
|
||||
import io.anuke.mindustry.game.*;
|
||||
import io.anuke.mindustry.type.*;
|
||||
import io.anuke.mindustry.world.*;
|
||||
import io.anuke.mindustry.world.blocks.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.world;
|
||||
|
||||
|
|
@ -63,8 +61,25 @@ public abstract class GroundUnit extends BaseUnit{
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
retreat = new UnitState(){
|
||||
public void entered(){
|
||||
target = null;
|
||||
}
|
||||
|
||||
public void update(){
|
||||
moveAwayFromCore();
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onCommand(UnitCommand command){
|
||||
state.set(command == UnitCommand.retreat ? retreat :
|
||||
command == UnitCommand.attack ? attack :
|
||||
command == UnitCommand.patrol ? patrol :
|
||||
null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void interpolate(){
|
||||
super.interpolate();
|
||||
|
|
@ -182,9 +197,9 @@ public abstract class GroundUnit extends BaseUnit{
|
|||
protected void patrol(){
|
||||
vec.trns(baseRotation, type.speed * Time.delta());
|
||||
velocity.add(vec.x, vec.y);
|
||||
vec.trns(baseRotation, type.hitsizeTile * 3);
|
||||
vec.trns(baseRotation, type.hitsizeTile * 5);
|
||||
Tile tile = world.tileWorld(x + vec.x, y + vec.y);
|
||||
if((tile == null || tile.solid() || tile.floor().drownTime > 0) || stuckTime > 10f){
|
||||
if((tile == null || tile.solid() || tile.floor().drownTime > 0 || tile.floor().isLiquid) || stuckTime > 10f){
|
||||
baseRotation += Mathf.sign(id % 2 - 0.5f) * Time.delta() * 3f;
|
||||
}
|
||||
|
||||
|
|
@ -234,7 +249,7 @@ public abstract class GroundUnit extends BaseUnit{
|
|||
Tile targetTile = world.pathfinder.getTargetTile(enemy, tile);
|
||||
TileEntity core = getClosestCore();
|
||||
|
||||
if(tile == targetTile || core == null || dst(core) < 90f) return;
|
||||
if(tile == targetTile || core == null || dst(core) < 120f) return;
|
||||
|
||||
velocity.add(vec.trns(angleTo(targetTile), type.speed * Time.delta()));
|
||||
rotation = Mathf.slerpDelta(rotation, baseRotation, type.rotatespeed);
|
||||
|
|
|
|||
|
|
@ -175,10 +175,6 @@ public class TileEntity extends BaseEntity implements TargetTrait, HealthTrait{
|
|||
}
|
||||
}
|
||||
|
||||
public boolean damaged(){
|
||||
return health < maxHealth() - 0.00001f;
|
||||
}
|
||||
|
||||
public Tile getTile(){
|
||||
return tile;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package io.anuke.mindustry.entities.type.base;
|
|||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.math.geom.Geometry;
|
||||
import io.anuke.mindustry.entities.type.FlyingUnit;
|
||||
import io.anuke.mindustry.entities.units.UnitState;
|
||||
import io.anuke.mindustry.entities.units.*;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.meta.BlockFlag;
|
||||
|
||||
|
|
@ -33,6 +33,11 @@ public abstract class BaseDrone extends FlyingUnit{
|
|||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onCommand(UnitCommand command){
|
||||
//do nothing, normal commands are not applicable here
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateRotation(){
|
||||
if(target != null && shouldRotate() && target.dst(this) < type.range){
|
||||
|
|
|
|||
18
core/src/io/anuke/mindustry/entities/units/UnitCommand.java
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
package io.anuke.mindustry.entities.units;
|
||||
|
||||
import io.anuke.arc.*;
|
||||
|
||||
public enum UnitCommand{
|
||||
attack, retreat, patrol;
|
||||
|
||||
private final String localized;
|
||||
public static final UnitCommand[] all = values();
|
||||
|
||||
UnitCommand(){
|
||||
localized = Core.bundle.get("command." + name());
|
||||
}
|
||||
|
||||
public String localized(){
|
||||
return localized;
|
||||
}
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@ package io.anuke.mindustry.io;
|
|||
import io.anuke.annotations.Annotations.ReadClass;
|
||||
import io.anuke.annotations.Annotations.WriteClass;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.util.CommandHandler.*;
|
||||
import io.anuke.mindustry.entities.Effects;
|
||||
import io.anuke.mindustry.entities.Effects.Effect;
|
||||
import io.anuke.mindustry.entities.Entities;
|
||||
|
|
@ -11,6 +12,7 @@ import io.anuke.mindustry.entities.bullet.BulletType;
|
|||
import io.anuke.mindustry.entities.traits.BuilderTrait.BuildRequest;
|
||||
import io.anuke.mindustry.entities.traits.ShooterTrait;
|
||||
import io.anuke.mindustry.entities.type.*;
|
||||
import io.anuke.mindustry.entities.units.*;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.net.Administration.TraceInfo;
|
||||
import io.anuke.mindustry.net.Packets.AdminAction;
|
||||
|
|
@ -177,6 +179,16 @@ public class TypeIO{
|
|||
return Team.all[buffer.get()];
|
||||
}
|
||||
|
||||
@WriteClass(UnitCommand.class)
|
||||
public static void writeUnitCommand(ByteBuffer buffer, UnitCommand reason){
|
||||
buffer.put((byte)reason.ordinal());
|
||||
}
|
||||
|
||||
@ReadClass(UnitCommand.class)
|
||||
public static UnitCommand readUnitCommand(ByteBuffer buffer){
|
||||
return UnitCommand.all[buffer.get()];
|
||||
}
|
||||
|
||||
@WriteClass(AdminAction.class)
|
||||
public static void writeAction(ByteBuffer buffer, AdminAction reason){
|
||||
buffer.put((byte)reason.ordinal());
|
||||
|
|
|
|||
|
|
@ -1,26 +1,22 @@
|
|||
package io.anuke.mindustry.ui.fragments;
|
||||
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.Events;
|
||||
import io.anuke.arc.collection.Array;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.input.KeyCode;
|
||||
import io.anuke.arc.math.geom.Vector2;
|
||||
import io.anuke.arc.scene.Group;
|
||||
import io.anuke.arc.scene.event.Touchable;
|
||||
import io.anuke.arc.scene.style.TextureRegionDrawable;
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.graphics.*;
|
||||
import io.anuke.arc.input.*;
|
||||
import io.anuke.arc.math.geom.*;
|
||||
import io.anuke.arc.scene.*;
|
||||
import io.anuke.arc.scene.event.*;
|
||||
import io.anuke.arc.scene.style.*;
|
||||
import io.anuke.arc.scene.ui.*;
|
||||
import io.anuke.arc.scene.ui.layout.Table;
|
||||
import io.anuke.mindustry.content.Blocks;
|
||||
import io.anuke.mindustry.entities.type.TileEntity;
|
||||
import io.anuke.arc.scene.ui.layout.*;
|
||||
import io.anuke.mindustry.entities.type.*;
|
||||
import io.anuke.mindustry.game.EventType.*;
|
||||
import io.anuke.mindustry.graphics.Pal;
|
||||
import io.anuke.mindustry.input.Binding;
|
||||
import io.anuke.mindustry.input.InputHandler;
|
||||
import io.anuke.mindustry.graphics.*;
|
||||
import io.anuke.mindustry.input.*;
|
||||
import io.anuke.mindustry.type.*;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Block.Icon;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.*;
|
||||
import io.anuke.mindustry.world.Block.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
|
|
@ -151,8 +147,7 @@ public class PlacementFragment extends Fragment{
|
|||
|
||||
button.update(() -> { //color unplacable things gray
|
||||
TileEntity core = player.getClosestCore();
|
||||
Color color = block.buildVisibility == Blocks.padVisible && !block.buildVisibility.get() ? Pal.noplace :
|
||||
state.rules.infiniteResources || (core != null && (core.items.has(block.buildRequirements, state.rules.buildCostMultiplier) || state.rules.infiniteResources)) ? Color.WHITE : Color.GRAY;
|
||||
Color color = state.rules.infiniteResources || (core != null && (core.items.has(block.buildRequirements, state.rules.buildCostMultiplier) || state.rules.infiniteResources)) ? Color.WHITE : Color.GRAY;
|
||||
button.forEach(elem -> elem.setColor(color));
|
||||
button.setChecked(input.block == block);
|
||||
});
|
||||
|
|
@ -204,10 +199,6 @@ public class PlacementFragment extends Fragment{
|
|||
Events.fire(new BlockInfoEvent());
|
||||
}).size(8 * 5).padTop(-5).padRight(-5).right().grow().name("blockinfo");
|
||||
}
|
||||
if(lastDisplay.buildVisibility == Blocks.padVisible && !lastDisplay.buildVisibility.get()){
|
||||
header.row();
|
||||
header.add("$attackpvponly").width(230f).wrap().colspan(3).left();
|
||||
}
|
||||
}).growX().left();
|
||||
topTable.row();
|
||||
//add requirement table
|
||||
|
|
@ -305,7 +296,7 @@ public class PlacementFragment extends Fragment{
|
|||
Array<Block> getByCategory(Category cat){
|
||||
returnArray.clear();
|
||||
for(Block block : content.blocks()){
|
||||
if(block.buildCategory == cat && (block.isVisible() || block.buildVisibility == Blocks.padVisible)){
|
||||
if(block.buildCategory == cat && block.isVisible()){
|
||||
returnArray.add(block);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,129 @@
|
|||
package io.anuke.mindustry.world.blocks.units;
|
||||
|
||||
import io.anuke.annotations.Annotations.*;
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.graphics.*;
|
||||
import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.arc.scene.ui.*;
|
||||
import io.anuke.arc.scene.ui.layout.*;
|
||||
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.entities.units.*;
|
||||
import io.anuke.mindustry.game.*;
|
||||
import io.anuke.mindustry.gen.*;
|
||||
import io.anuke.mindustry.graphics.*;
|
||||
import io.anuke.mindustry.world.*;
|
||||
import io.anuke.mindustry.world.meta.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class CommandCenter extends Block{
|
||||
protected TextureRegion[] commandRegions = new TextureRegion[UnitCommand.all.length];
|
||||
protected Color topColor = Pal.command;
|
||||
protected Color bottomColor = Color.valueOf("5e5e5e");
|
||||
protected Effect effect = Fx.commandSend;
|
||||
|
||||
public CommandCenter(String name){
|
||||
super(name);
|
||||
|
||||
flags = EnumSet.of(BlockFlag.comandCenter);
|
||||
destructible = true;
|
||||
solid = true;
|
||||
configurable = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void placed(Tile tile){
|
||||
super.placed(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();
|
||||
|
||||
for(UnitCommand cmd : UnitCommand.all){
|
||||
commandRegions[cmd.ordinal()] = Core.atlas.find("icon-command-" + cmd.name() + "-small");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Tile tile){
|
||||
CommandCenterEntity entity = tile.entity();
|
||||
super.draw(tile);
|
||||
|
||||
float size = iconsizesmall/4f;
|
||||
|
||||
Draw.color(bottomColor);
|
||||
Draw.rect(commandRegions[entity.command.ordinal()], tile.drawx(), tile.drawy() - 1, size, size);
|
||||
Draw.color(topColor);
|
||||
Draw.rect(commandRegions[entity.command.ordinal()], tile.drawx(), tile.drawy(), size, size);
|
||||
Draw.color();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildTable(Tile tile, Table table){
|
||||
CommandCenterEntity entity = tile.entity();
|
||||
ButtonGroup<ImageButton> group = new ButtonGroup<>();
|
||||
Table buttons = new Table();
|
||||
|
||||
for(UnitCommand cmd : UnitCommand.all){
|
||||
buttons.addImageButton("icon-command-" + cmd.name() + "-small", "clear-toggle-trans", iconsizesmall, () -> Call.onCommandCenterSet(player, tile, cmd))
|
||||
.size(44).group(group).update(b -> b.setChecked(entity.command == cmd));
|
||||
}
|
||||
table.add(buttons);
|
||||
table.row();
|
||||
table.label(() -> entity.command.localized()).style("outline").center().growX().get().setAlignment(Align.center);
|
||||
}
|
||||
|
||||
@Remote(called = Loc.server, forward = true, targets = Loc.both)
|
||||
public static void onCommandCenterSet(Player player, Tile tile, UnitCommand command){
|
||||
Effects.effect(((CommandCenter)tile.block()).effect, tile);
|
||||
|
||||
for(Tile center : world.indexer.getAllied(tile.getTeam(), BlockFlag.comandCenter)){
|
||||
if(center.block() instanceof CommandCenter){
|
||||
CommandCenterEntity entity = center.entity();
|
||||
entity.command = command;
|
||||
}
|
||||
}
|
||||
|
||||
Team team = (player == null ? tile.getTeam() : player.getTeam());
|
||||
|
||||
for(BaseUnit unit : unitGroups[team.ordinal()].all()){
|
||||
unit.onCommand(command);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity newEntity(){
|
||||
return new CommandCenterEntity();
|
||||
}
|
||||
|
||||
public class CommandCenterEntity extends TileEntity{
|
||||
public UnitCommand command = UnitCommand.attack;
|
||||
|
||||
@Override
|
||||
public void write(DataOutput stream) throws IOException{
|
||||
super.write(stream);
|
||||
stream.writeByte(command.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(DataInput stream, byte version) throws IOException{
|
||||
super.read(stream, version);
|
||||
command = UnitCommand.all[stream.readByte()];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -7,6 +7,8 @@ public enum BlockFlag{
|
|||
producer(Float.MAX_VALUE),
|
||||
/** A turret. */
|
||||
turret(Float.MAX_VALUE),
|
||||
/** Only the command center block.*/
|
||||
comandCenter(Float.MAX_VALUE),
|
||||
/** Repair point. */
|
||||
repair(Float.MAX_VALUE);
|
||||
|
||||
|
|
|
|||