Cleanup continues
This commit is contained in:
@@ -20,7 +20,7 @@ import mindustry.annotations.Annotations.*;
|
||||
import mindustry.ctype.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.effect.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
@@ -467,12 +467,12 @@ public class Block extends BlockStorage{
|
||||
}
|
||||
|
||||
/** Called when the block is tapped. */
|
||||
public void tapped(Tile tile, Player player){
|
||||
public void tapped(Tile tile, Playerc player){
|
||||
|
||||
}
|
||||
|
||||
/** Called when arbitrary configuration is applied to a tile. */
|
||||
public void configured(Tile tile, @Nullable Player player, int value){
|
||||
public void configured(Tile tile, @Nullable Playerc player, int value){
|
||||
|
||||
}
|
||||
|
||||
@@ -503,12 +503,12 @@ public class Block extends BlockStorage{
|
||||
}
|
||||
|
||||
/** Returns whether this config menu should show when the specified player taps it. */
|
||||
public boolean shouldShowConfigure(Tile tile, Player player){
|
||||
public boolean shouldShowConfigure(Tile tile, Playerc player){
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Whether this configuration should be hidden now. Called every frame the config is open. */
|
||||
public boolean shouldHideConfigure(Tile tile, Player player){
|
||||
public boolean shouldHideConfigure(Tile tile, Playerc player){
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import arc.math.*;
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import arc.util.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.game.EventType.*;
|
||||
@@ -55,7 +55,7 @@ public class BuildBlock extends Block{
|
||||
public static void onDeconstructFinish(Tile tile, Block block, int builderID){
|
||||
Team team = tile.getTeam();
|
||||
Fx.breakBlock.at(tile.drawx(), tile.drawy(), block.size);
|
||||
Events.fire(new BlockBuildEndEvent(tile, playerGroup.getByID(builderID), team, true));
|
||||
Events.fire(new BlockBuildEndEvent(tile, Groups.player.getByID(builderID), team, true));
|
||||
tile.remove();
|
||||
if(shouldPlay()) Sounds.breaks.at(tile, calcPitch(false));
|
||||
}
|
||||
@@ -105,7 +105,7 @@ public class BuildBlock extends Block{
|
||||
Call.onConstructFinish(tile, block, builderID, rotation, team, skipConfig);
|
||||
tile.block().placed(tile);
|
||||
|
||||
Events.fire(new BlockBuildEndEvent(tile, playerGroup.getByID(builderID), team, false));
|
||||
Events.fire(new BlockBuildEndEvent(tile, Groups.player.getByID(builderID), team, false));
|
||||
if(shouldPlay()) Sounds.place.at(tile, calcPitch(true));
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ public class BuildBlock extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tapped(Tile tile, Player player){
|
||||
public void tapped(Tile tile, Playerc player){
|
||||
BuildEntity entity = tile.ent();
|
||||
|
||||
//if the target is constructible, begin constructing
|
||||
@@ -279,7 +279,7 @@ public class BuildBlock extends Block{
|
||||
|
||||
progress = Mathf.clamp(progress - amount);
|
||||
|
||||
if(builder instanceof Player){
|
||||
if(builder instanceof Playerc){
|
||||
builderID = builder.getID();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,9 +2,8 @@ package mindustry.world.blocks;
|
||||
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
@@ -12,7 +11,7 @@ import static mindustry.Vars.net;
|
||||
|
||||
public class RespawnBlock{
|
||||
|
||||
public static void drawRespawn(Tile tile, float heat, float progress, float time, Player player, Mech to){
|
||||
public static void drawRespawn(Tile tile, float heat, float progress, float time, Playerc player, Mech to){
|
||||
progress = Mathf.clamp(progress);
|
||||
|
||||
Draw.color(Pal.darkMetal);
|
||||
@@ -67,7 +66,7 @@ public class RespawnBlock{
|
||||
Draw.reset();
|
||||
|
||||
if(net.active() && player != null){
|
||||
tile.block().drawPlaceText(player.name, tile.x, tile.y - (Math.max((tile.block().size-1)/2, 0)), true);
|
||||
tile.block().drawPlaceText(player.name(), tile.x, tile.y - (Math.max((tile.block().size-1)/2, 0)), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public class DeflectorWall extends Wall{
|
||||
|
||||
bullet.hitbox(rect2);
|
||||
|
||||
Vec2 position = Geometry.raycastRect(bullet.x - bullet.velocity().x*Time.delta(), bullet.y - bullet.velocity().y*Time.delta(), bullet.x + bullet.velocity().x*Time.delta(), bullet.y + bullet.velocity().y*Time.delta(),
|
||||
Vec2 position = Geometry.raycastRect(bullet.x - bullet.vel().x*Time.delta(), bullet.y - bullet.vel().y*Time.delta(), bullet.x + bullet.vel().x*Time.delta(), bullet.y + bullet.vel().y*Time.delta(),
|
||||
rect.setSize(size * tilesize + rect2.width*2 + rect2.height*2).setCenter(entity.getX(), entity.getY()));
|
||||
|
||||
if(position != null){
|
||||
@@ -58,9 +58,9 @@ public class DeflectorWall extends Wall{
|
||||
}
|
||||
|
||||
if(penX > penY){
|
||||
bullet.velocity().x *= -1;
|
||||
bullet.vel().x *= -1;
|
||||
}else{
|
||||
bullet.velocity().y *= -1;
|
||||
bullet.vel().y *= -1;
|
||||
}
|
||||
|
||||
//bullet.updateVelocity();
|
||||
|
||||
@@ -8,7 +8,6 @@ import arc.graphics.g2d.*;
|
||||
import arc.math.geom.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.world.*;
|
||||
@@ -35,7 +34,7 @@ public class Door extends Wall{
|
||||
}
|
||||
|
||||
@Remote(called = Loc.server)
|
||||
public static void onDoorToggle(Player player, Tile tile, boolean open){
|
||||
public static void onDoorToggle(Playerc player, Tile tile, boolean open){
|
||||
DoorEntity entity = tile.ent();
|
||||
if(entity != null){
|
||||
entity.open = open;
|
||||
@@ -80,7 +79,7 @@ public class Door extends Wall{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tapped(Tile tile, Player player){
|
||||
public void tapped(Tile tile, Playerc player){
|
||||
DoorEntity entity = tile.ent();
|
||||
|
||||
if((Units.anyEntities(tile) && entity.open) || !tile.entity.timer(timerToggle, 30f)){
|
||||
|
||||
@@ -18,7 +18,7 @@ public class SurgeWall extends Wall{
|
||||
public void handleBulletHit(Tilec entity, Bullet bullet){
|
||||
super.handleBulletHit(entity, bullet);
|
||||
if(Mathf.chance(lightningChance)){
|
||||
Lightning.create(entity.team(), Pal.surge, lightningDamage, bullet.x, bullet.y, bullet.rot() + 180f, lightningLength);
|
||||
Lightning.create(entity.team(), Pal.surge, lightningDamage, bullet.x, bullet.y, bullet.rotation() + 180f, lightningLength);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import arc.scene.ui.layout.*;
|
||||
import mindustry.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.bullet.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
|
||||
@@ -23,8 +23,8 @@ public class BufferedItemBridge extends ExtendingItemBridge{
|
||||
public void updateTransport(Tile tile, Tile other){
|
||||
BufferedItemBridgeEntity entity = tile.ent();
|
||||
|
||||
if(entity.buffer.accepts() && entity.getItems().total() > 0){
|
||||
entity.buffer.accept(entity.getItems().take());
|
||||
if(entity.buffer.accepts() && entity.items().total() > 0){
|
||||
entity.buffer.accept(entity.items().take());
|
||||
}
|
||||
|
||||
Item item = entity.buffer.poll();
|
||||
|
||||
@@ -8,7 +8,7 @@ import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.util.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
@@ -45,7 +45,7 @@ public class ItemBridge extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configured(Tile tile, Player player, int value){
|
||||
public void configured(Tile tile, Playerc player, int value){
|
||||
tile.<ItemBridgeEntity>ent().link = value;
|
||||
}
|
||||
|
||||
@@ -201,13 +201,13 @@ public class ItemBridge extends Block{
|
||||
ItemBridgeEntity entity = tile.ent();
|
||||
|
||||
if(entity.uptime >= 0.5f && entity.timer(timerTransport, transportTime)){
|
||||
Item item = entity.getItems().take();
|
||||
Item item = entity.items().take();
|
||||
if(item != null && other.block().acceptItem(item, other, tile)){
|
||||
other.block().handleItem(item, other, tile);
|
||||
entity.cycleSpeed = Mathf.lerpDelta(entity.cycleSpeed, 4f, 0.05f);
|
||||
}else{
|
||||
entity.cycleSpeed = Mathf.lerpDelta(entity.cycleSpeed, 1f, 0.01f);
|
||||
if(item != null) entity.getItems().add(item, 1);
|
||||
if(item != null) entity.items().add(item, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import arc.util.pooling.Pool.*;
|
||||
import arc.util.pooling.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
@@ -45,7 +45,7 @@ public class MassDriver extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configured(Tile tile, Player player, int value){
|
||||
public void configured(Tile tile, Playerc player, int value){
|
||||
tile.<MassDriverEntity>ent().link = value;
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ public class MassDriver extends Block{
|
||||
//switch states
|
||||
if(entity.state == DriverState.idle){
|
||||
//start accepting when idle and there's space
|
||||
if(!entity.waitingShooters.isEmpty() && (itemCapacity - entity.getItems().total() >= minDistribute)){
|
||||
if(!entity.waitingShooters.isEmpty() && (itemCapacity - entity.items().total() >= minDistribute)){
|
||||
entity.state = DriverState.accepting;
|
||||
}else if(hasLink){ //switch to shooting if there's a valid link.
|
||||
entity.state = DriverState.shooting;
|
||||
@@ -99,7 +99,7 @@ public class MassDriver extends Block{
|
||||
|
||||
if(entity.state == DriverState.accepting){
|
||||
//if there's nothing shooting at this, bail - OR, items full
|
||||
if(entity.currentShooter() == null || (itemCapacity - entity.getItems().total() < minDistribute)){
|
||||
if(entity.currentShooter() == null || (itemCapacity - entity.items().total() < minDistribute)){
|
||||
entity.state = DriverState.idle;
|
||||
return;
|
||||
}
|
||||
@@ -108,7 +108,7 @@ public class MassDriver extends Block{
|
||||
entity.rotation = Mathf.slerpDelta(entity.rotation, tile.angleTo(entity.currentShooter()), rotateSpeed * entity.efficiency());
|
||||
}else if(entity.state == DriverState.shooting){
|
||||
//if there's nothing to shoot at OR someone wants to shoot at this thing, bail
|
||||
if(!hasLink || (!entity.waitingShooters.isEmpty() && (itemCapacity - entity.getItems().total() >= minDistribute))){
|
||||
if(!hasLink || (!entity.waitingShooters.isEmpty() && (itemCapacity - entity.items().total() >= minDistribute))){
|
||||
entity.state = DriverState.idle;
|
||||
return;
|
||||
}
|
||||
@@ -240,10 +240,10 @@ public class MassDriver extends Block{
|
||||
data.to = other;
|
||||
int totalUsed = 0;
|
||||
for(int i = 0; i < content.items().size; i++){
|
||||
int maxTransfer = Math.min(entity.getItems().get(content.item(i)), ((MassDriver)tile.block()).itemCapacity - totalUsed);
|
||||
int maxTransfer = Math.min(entity.items().get(content.item(i)), ((MassDriver)tile.block()).itemCapacity - totalUsed);
|
||||
data.items[i] = maxTransfer;
|
||||
totalUsed += maxTransfer;
|
||||
entity.getItems().remove(content.item(i), maxTransfer);
|
||||
entity.items().remove(content.item(i), maxTransfer);
|
||||
}
|
||||
|
||||
float angle = tile.angleTo(target);
|
||||
@@ -262,12 +262,12 @@ public class MassDriver extends Block{
|
||||
}
|
||||
|
||||
protected void handlePayload(MassDriverEntity entity, Bullet bullet, DriverBulletData data){
|
||||
int totalItems = entity.getItems().total();
|
||||
int totalItems = entity.items().total();
|
||||
|
||||
//add all the items possible
|
||||
for(int i = 0; i < data.items.length; i++){
|
||||
int maxAdd = Math.min(data.items[i], itemCapacity * 2 - totalItems);
|
||||
entity.getItems().add(content.item(i), maxAdd);
|
||||
entity.items().add(content.item(i), maxAdd);
|
||||
data.items[i] -= maxAdd;
|
||||
totalItems += maxAdd;
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import arc.math.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import arc.util.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
@@ -44,7 +44,7 @@ public class Sorter extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configured(Tile tile, Player player, int value){
|
||||
public void configured(Tile tile, Playerc player, int value){
|
||||
tile.<SorterEntity>ent().sortItem = content.item(value);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ import arc.scene.ui.layout.*;
|
||||
import arc.util.*;
|
||||
import arc.util.pooling.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.net.*;
|
||||
@@ -36,7 +35,7 @@ public class MessageBlock extends Block{
|
||||
}
|
||||
|
||||
@Remote(targets = Loc.both, called = Loc.both, forward = true)
|
||||
public static void setMessageBlockText(Player player, Tile tile, String text){
|
||||
public static void setMessageBlockText(Playerc player, Tile tile, String text){
|
||||
if(!Units.canInteract(player, tile)) return;
|
||||
if(net.server() && text.length() > maxTextLength){
|
||||
throw new ValidateException(player, "Player has gone above text limit.");
|
||||
|
||||
@@ -4,7 +4,6 @@ import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.util.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
@@ -63,7 +62,7 @@ public class LightBlock extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configured(Tile tile, Player player, int value){
|
||||
public void configured(Tile tile, Playerc player, int value){
|
||||
tile.<LightEntity>ent().color = value;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.util.*;
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.*;
|
||||
@@ -38,7 +38,7 @@ public class PowerNode extends PowerBlock{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configured(Tile tile, Player player, int value){
|
||||
public void configured(Tile tile, Playerc player, int value){
|
||||
Tilec entity = tile.entity;
|
||||
Tile other = world.tile(value);
|
||||
boolean contains = entity.getPower().links.contains(value), valid = other != null && other.entity != null && other.entity.power() != null;
|
||||
|
||||
@@ -6,7 +6,7 @@ import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.util.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
@@ -4,7 +4,7 @@ import arc.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.util.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
@@ -29,7 +29,7 @@ public class ItemSource extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configured(Tile tile, Player player, int value){
|
||||
public void configured(Tile tile, Playerc player, int value){
|
||||
tile.<ItemSourceEntity>ent().outputItem = content.item(value);
|
||||
}
|
||||
|
||||
@@ -73,9 +73,9 @@ public class ItemSource extends Block{
|
||||
ItemSourceEntity entity = tile.ent();
|
||||
if(entity.outputItem == null) return;
|
||||
|
||||
entity.getItems().set(entity.outputItem, 1);
|
||||
entity.items().set(entity.outputItem, 1);
|
||||
tryDump(tile, entity.outputItem);
|
||||
entity.getItems().set(entity.outputItem, 0);
|
||||
entity.items().set(entity.outputItem, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -8,7 +8,7 @@ import arc.scene.ui.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.util.*;
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.type.*;
|
||||
@@ -108,7 +108,7 @@ public class LiquidSource extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configured(Tile tile, Player player, int value){
|
||||
public void configured(Tile tile, Playerc player, int value){
|
||||
tile.<LiquidSourceEntity>ent().source = value == -1 ? null : content.liquid(value);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.graphics.*;
|
||||
@@ -22,7 +22,7 @@ import mindustry.world.modules.*;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class CoreBlock extends StorageBlock{
|
||||
public Mech mech = Mechs.starter;
|
||||
public UnitDef mech = UnitTypes.starter;
|
||||
|
||||
public CoreBlock(String name){
|
||||
super(name);
|
||||
@@ -38,15 +38,16 @@ public class CoreBlock extends StorageBlock{
|
||||
}
|
||||
|
||||
@Remote(called = Loc.server)
|
||||
public static void onUnitRespawn(Tile tile, Player player){
|
||||
public static void onUnitRespawn(Tile tile, Playerc player){
|
||||
if(player == null || tile.entity == null) return;
|
||||
|
||||
CoreEntity entity = tile.ent();
|
||||
Fx.spawn.at(entity);
|
||||
entity.progress = 0;
|
||||
entity.spawnPlayer = player;
|
||||
entity.spawnPlayer.onRespawn(tile);
|
||||
entity.spawnPlayer.applyImpulse(0, 8f);
|
||||
//TODO fix
|
||||
//entity.spawnPlayer.onRespawn(tile);
|
||||
//entity.spawnPlayer.applyImpulse(0, 8f);
|
||||
entity.spawnPlayer = null;
|
||||
}
|
||||
|
||||
@@ -58,7 +59,7 @@ public class CoreBlock extends StorageBlock{
|
||||
new Bar(
|
||||
() -> Core.bundle.format("bar.capacity", ui.formatAmount(((CoreEntity)e).storageCapacity)),
|
||||
() -> Pal.items,
|
||||
() -> e.items.total() / (float)(((CoreEntity)e).storageCapacity * content.items().count(i -> i.type == ItemType.material))
|
||||
() -> e.items().total() / (float)(((CoreEntity)e).storageCapacity * content.items().count(i -> i.type == ItemType.material))
|
||||
));
|
||||
}
|
||||
|
||||
@@ -83,21 +84,21 @@ public class CoreBlock extends StorageBlock{
|
||||
CoreEntity entity = tile.ent();
|
||||
|
||||
for(Tilec other : state.teams.cores(tile.getTeam())){
|
||||
if(other.tile != tile){
|
||||
entity.items() = other.items;
|
||||
if(other.tile() != tile){
|
||||
entity.items(other.items());
|
||||
}
|
||||
}
|
||||
state.teams.registerCore(entity);
|
||||
|
||||
entity.storageCapacity = itemCapacity + entity.proximity().sum(e -> isContainer(e) ? e.block().itemCapacity : 0);
|
||||
entity.proximity().each(this::isContainer, t -> {
|
||||
t.entity.items() = entity.items();
|
||||
t.entity.items(entity.items());
|
||||
t.<StorageBlockEntity>ent().linkedCore = tile;
|
||||
});
|
||||
|
||||
for(Tilec other : state.teams.cores(tile.getTeam())){
|
||||
if(other.tile == tile) continue;
|
||||
entity.storageCapacity += other.block.itemCapacity + other.proximity().sum(e -> isContainer(e) ? e.block().itemCapacity : 0);
|
||||
if(other.tile() == tile) continue;
|
||||
entity.storageCapacity += other.block().itemCapacity + other.proximity().sum(e -> isContainer(e) ? e.block().itemCapacity : 0);
|
||||
}
|
||||
|
||||
if(!world.isGenerating()){
|
||||
@@ -135,9 +136,10 @@ public class CoreBlock extends StorageBlock{
|
||||
|
||||
@Override
|
||||
public float handleDamage(Tile tile, float amount){
|
||||
if(player != null && tile.getTeam() == player.team()){
|
||||
Events.fire(Trigger.teamCoreDamage);
|
||||
}
|
||||
//TODO implement
|
||||
//if(player != null && tile.getTeam() == player.team()){
|
||||
// Events.fire(Trigger.teamCoreDamage);
|
||||
//}
|
||||
return amount;
|
||||
}
|
||||
|
||||
@@ -155,9 +157,9 @@ public class CoreBlock extends StorageBlock{
|
||||
tile.entity.proximity().each(e -> isContainer(e) && e.entity.items() == tile.entity.items(), t -> {
|
||||
StorageBlockEntity ent = (StorageBlockEntity)t.entity;
|
||||
ent.linkedCore = null;
|
||||
ent.items = new ItemModule();
|
||||
ent.items(new ItemModule());
|
||||
for(Item item : content.items()){
|
||||
ent.items.set(item, (int)(fract * tile.entity.items().get(item)));
|
||||
ent.items().set(item, (int)(fract * tile.entity.items().get(item)));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -169,7 +171,7 @@ public class CoreBlock extends StorageBlock{
|
||||
}
|
||||
|
||||
for(CoreEntity other : state.teams.cores(tile.getTeam())){
|
||||
other.block.onProximityUpdate(other.tile);
|
||||
other.block().onProximityUpdate(other.tile());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,7 +187,8 @@ public class CoreBlock extends StorageBlock{
|
||||
CoreEntity entity = tile.ent();
|
||||
|
||||
if(entity.heat > 0.001f){
|
||||
RespawnBlock.drawRespawn(tile, entity.heat, entity.progress, entity.time, entity.spawnPlayer, mech);
|
||||
//TODO implement
|
||||
//RespawnBlock.drawRespawn(tile, entity.heat, entity.progress, entity.time, entity.spawnPlayer, mech);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,6 +206,8 @@ public class CoreBlock extends StorageBlock{
|
||||
public void update(Tile tile){
|
||||
CoreEntity entity = tile.ent();
|
||||
|
||||
//TODO implement
|
||||
/*
|
||||
if(entity.spawnPlayer != null){
|
||||
if(!entity.spawnPlayer.dead() || !entity.spawnPlayer.isAdded()){
|
||||
entity.spawnPlayer = null;
|
||||
@@ -219,7 +224,7 @@ public class CoreBlock extends StorageBlock{
|
||||
}
|
||||
}else{
|
||||
entity.heat = Mathf.lerpDelta(entity.heat, 0f, 0.1f);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -229,26 +234,11 @@ public class CoreBlock extends StorageBlock{
|
||||
return entity.spawnPlayer != null;
|
||||
}
|
||||
|
||||
public class CoreEntity extends Tilec implements SpawnerTrait{
|
||||
protected Player spawnPlayer;
|
||||
public class CoreEntity extends Tilec{
|
||||
protected Playerc spawnPlayer;
|
||||
protected float progress;
|
||||
protected float time;
|
||||
protected float heat;
|
||||
protected int storageCapacity;
|
||||
|
||||
@Override
|
||||
public boolean hasUnit(Unitc unit){
|
||||
return unit == spawnPlayer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSpawning(Player player){
|
||||
if(!netServer.isWaitingForPlayers() && spawnPlayer == null){
|
||||
spawnPlayer = player;
|
||||
progress = 0f;
|
||||
player.mech = mech;
|
||||
player.beginRespawning(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.util.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
@@ -54,7 +54,7 @@ public class Unloader extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configured(Tile tile, Player player, int value){
|
||||
public void configured(Tile tile, Playerc player, int value){
|
||||
tile.entity.items().clear();
|
||||
tile.<UnloaderEntity>ent().sortItem = content.item(value);
|
||||
}
|
||||
@@ -65,14 +65,14 @@ public class Unloader extends Block{
|
||||
|
||||
if(tile.entity.timer(timerUnload, speed / entity.timeScale) && tile.entity.items().total() == 0){
|
||||
for(Tile other : tile.entity.proximity()){
|
||||
if(other.interactable(tile.getTeam()) && other.block().unloadable && other.block().hasItems && entity.getItems().total() == 0 &&
|
||||
if(other.interactable(tile.getTeam()) && other.block().unloadable && other.block().hasItems && entity.items().total() == 0 &&
|
||||
((entity.sortItem == null && other.entity.items().total() > 0) || hasItem(other, entity.sortItem))){
|
||||
offloadNear(tile, removeItem(other, entity.sortItem));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(entity.getItems().total() > 0){
|
||||
if(entity.items().total() > 0){
|
||||
tryDump(tile);
|
||||
}
|
||||
}
|
||||
@@ -85,10 +85,10 @@ public class Unloader extends Block{
|
||||
Tilec entity = tile.entity;
|
||||
|
||||
if(item == null){
|
||||
return entity.getItems().take();
|
||||
return entity.items().take();
|
||||
}else{
|
||||
if(entity.getItems().has(item)){
|
||||
entity.getItems().remove(item, 1);
|
||||
if(entity.items().has(item)){
|
||||
entity.items().remove(item, 1);
|
||||
return item;
|
||||
}
|
||||
|
||||
@@ -103,9 +103,9 @@ public class Unloader extends Block{
|
||||
private boolean hasItem(Tile tile, Item item){
|
||||
Tilec entity = tile.entity;
|
||||
if(item == null){
|
||||
return entity.getItems().total() > 0;
|
||||
return entity.items().total() > 0;
|
||||
}else{
|
||||
return entity.getItems().has(item);
|
||||
return entity.items().has(item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.graphics.*;
|
||||
@@ -102,7 +102,7 @@ public class CommandCenter extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configured(Tile tile, Player player, int value){
|
||||
public void configured(Tile tile, Playerc player, int value){
|
||||
UnitCommand command = UnitCommand.all[value];
|
||||
((CommandCenter)tile.block()).effect.at(tile);
|
||||
|
||||
|
||||
@@ -9,10 +9,11 @@ import arc.math.geom.*;
|
||||
import arc.util.*;
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.*;
|
||||
import mindustry.world.meta.*;
|
||||
@@ -22,7 +23,7 @@ import java.io.*;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class MechPad extends Block{
|
||||
public @NonNull Mech mech;
|
||||
public @NonNull UnitDef mech;
|
||||
public float buildTime = 60 * 5;
|
||||
|
||||
public MechPad(String name){
|
||||
@@ -43,7 +44,7 @@ public class MechPad extends Block{
|
||||
}
|
||||
|
||||
@Remote(targets = Loc.both, called = Loc.server)
|
||||
public static void onMechFactoryTap(Player player, Tile tile){
|
||||
public static void onMechFactoryTap(Playerc player, Tile tile){
|
||||
if(player == null || tile == null || !(tile.block() instanceof MechPad) || !checkValidTap(tile, player)) return;
|
||||
|
||||
MechFactoryEntity entity = tile.ent();
|
||||
@@ -64,9 +65,9 @@ public class MechPad extends Block{
|
||||
if(entity.player == null) return;
|
||||
Mech mech = ((MechPad)tile.block()).mech;
|
||||
boolean resetSpawner = !entity.sameMech && entity.player.mech == mech;
|
||||
entity.player.mech = !entity.sameMech && entity.player.mech == mech ? Mechs.starter : mech;
|
||||
entity.player.mech = !entity.sameMech && entity.player.mech == mech ? UnitTypes.starter : mech;
|
||||
|
||||
Player player = entity.player;
|
||||
Playerc player = entity.player;
|
||||
|
||||
entity.progress = 0;
|
||||
entity.player.onRespawn(tile);
|
||||
@@ -76,7 +77,7 @@ public class MechPad extends Block{
|
||||
Events.fire(new MechChangeEvent(player, player.mech));
|
||||
}
|
||||
|
||||
protected static boolean checkValidTap(Tile tile, Player player){
|
||||
protected static boolean checkValidTap(Tile tile, Playerc player){
|
||||
MechFactoryEntity entity = tile.ent();
|
||||
return !player.dead() && tile.interactable(player.team()) && Math.abs(player.x - tile.drawx()) <= tile.block().size * tilesize &&
|
||||
Math.abs(player.y - tile.drawy()) <= tile.block().size * tilesize && entity.consValid() && entity.player == null;
|
||||
@@ -93,12 +94,12 @@ public class MechPad extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tapped(Tile tile, Player player){
|
||||
public void tapped(Tile tile, Playerc player){
|
||||
MechFactoryEntity entity = tile.ent();
|
||||
|
||||
if(checkValidTap(tile, player)){
|
||||
Call.onMechFactoryTap(player, tile);
|
||||
}else if(player.isLocal && mobile && !player.dead() && entity.consValid() && entity.player == null){
|
||||
}else if(player.isLocal() && mobile && !player.dead() && entity.consValid() && entity.player == null){
|
||||
//deselect on double taps
|
||||
player.moveTarget = player.moveTarget == tile.entity ? null : tile.entity;
|
||||
}
|
||||
@@ -109,7 +110,7 @@ public class MechPad extends Block{
|
||||
MechFactoryEntity entity = tile.ent();
|
||||
|
||||
if(entity.player != null){
|
||||
RespawnBlock.drawRespawn(tile, entity.heat, entity.progress, entity.time, entity.player, (!entity.sameMech && entity.player.mech == mech ? Mechs.starter : mech));
|
||||
RespawnBlock.drawRespawn(tile, entity.heat, entity.progress, entity.time, entity.player, (!entity.sameMech && entity.player.mech == mech ? UnitTypes.starter : mech));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +134,7 @@ public class MechPad extends Block{
|
||||
}
|
||||
|
||||
public class MechFactoryEntity extends Tilec implements SpawnerTrait{
|
||||
Player player;
|
||||
Playerc player;
|
||||
boolean sameMech;
|
||||
float progress;
|
||||
float time;
|
||||
@@ -145,7 +146,7 @@ public class MechPad extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSpawning(Player unit){
|
||||
public void updateSpawning(Playerc unit){
|
||||
if(player == null){
|
||||
progress = 0f;
|
||||
player = unit;
|
||||
|
||||
@@ -1,33 +1,27 @@
|
||||
package mindustry.world.blocks.units;
|
||||
|
||||
import arc.*;
|
||||
import mindustry.annotations.Annotations.Loc;
|
||||
import mindustry.annotations.Annotations.Remote;
|
||||
import arc.struct.EnumSet;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.Mathf;
|
||||
import mindustry.Vars;
|
||||
import mindustry.content.Fx;
|
||||
import mindustry.entities.Effects;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.gen.Call;
|
||||
import mindustry.graphics.Pal;
|
||||
import mindustry.graphics.Shaders;
|
||||
import arc.math.*;
|
||||
import arc.struct.*;
|
||||
import mindustry.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.ui.Bar;
|
||||
import mindustry.ui.Cicon;
|
||||
import mindustry.world.Block;
|
||||
import mindustry.world.Tile;
|
||||
import mindustry.world.consumers.ConsumeItems;
|
||||
import mindustry.world.consumers.ConsumeType;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.consumers.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
import java.io.*;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
import static mindustry.Vars.net;
|
||||
|
||||
public class UnitFactory extends Block{
|
||||
public UnitType unitType;
|
||||
public UnitDef unitType;
|
||||
public float produceTime = 1000f;
|
||||
public float launchVelocity = 0f;
|
||||
public TextureRegion topRegion;
|
||||
@@ -58,12 +52,14 @@ public class UnitFactory extends Block{
|
||||
Fx.producesmoke.at(tile.drawx(), tile.drawy());
|
||||
|
||||
if(!net.client()){
|
||||
BaseUnit unit = factory.unitType.create(tile.getTeam());
|
||||
//TODO create the unit
|
||||
/*
|
||||
Unitc unit = factory.unitType.create(tile.getTeam());
|
||||
unit.setSpawner(tile);
|
||||
unit.set(tile.drawx() + Mathf.range(4), tile.drawy() + Mathf.range(4));
|
||||
unit.add();
|
||||
unit.velocity().y = factory.launchVelocity;
|
||||
Events.fire(new UnitCreateEvent(unit));
|
||||
unit.vel().y = factory.launchVelocity;
|
||||
Events.fire(new UnitCreateEvent(unit));*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -53,8 +53,8 @@ public class ConsumeItemFilter extends Consume{
|
||||
public void trigger(Tilec entity){
|
||||
for(int i = 0; i < content.items().size; i++){
|
||||
Item item = content.item(i);
|
||||
if(entity.getItems() != null && entity.getItems().has(item) && this.filter.get(item)){
|
||||
entity.getItems().remove(item, 1);
|
||||
if(entity.items() != null && entity.items().has(item) && this.filter.get(item)){
|
||||
entity.items().remove(item, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -64,7 +64,7 @@ public class ConsumeItemFilter extends Consume{
|
||||
public boolean valid(Tilec entity){
|
||||
for(int i = 0; i < content.items().size; i++){
|
||||
Item item = content.item(i);
|
||||
if(entity.getItems() != null && entity.getItems().has(item) && this.filter.get(item)){
|
||||
if(entity.items() != null && entity.items().has(item) && this.filter.get(item)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,13 +54,13 @@ public class ConsumeItems extends Consume{
|
||||
@Override
|
||||
public void trigger(Tilec entity){
|
||||
for(ItemStack stack : items){
|
||||
entity.getItems().remove(stack);
|
||||
entity.items().remove(stack);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean valid(Tilec entity){
|
||||
return entity.getItems() != null && entity.getItems().has(items);
|
||||
return entity.items() != null && entity.items().has(items);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,7 +3,7 @@ package mindustry.world.consumers;
|
||||
import arc.struct.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.ui.Cicon;
|
||||
|
||||
Reference in New Issue
Block a user