Int configuration / Drone rebuilding
This commit is contained in:
@@ -20,6 +20,7 @@ public class Units{
|
||||
private static float cdist;
|
||||
private static boolean boolResult;
|
||||
|
||||
/** @return whether this player can interact with a specific tile. if either of these are null, returns true.*/
|
||||
public static boolean canInteract(Player player, Tile tile){
|
||||
return player == null || tile == null || tile.interactable(player.getTeam());
|
||||
}
|
||||
|
||||
@@ -104,7 +104,11 @@ public interface BuilderTrait extends Entity, TeamTrait{
|
||||
if(current.breaking){
|
||||
entity.deconstruct(unit, core, 1f / entity.buildCost * Time.delta() * getBuildPower(tile) * state.rules.buildSpeedMultiplier);
|
||||
}else{
|
||||
entity.construct(unit, core, 1f / entity.buildCost * Time.delta() * getBuildPower(tile) * state.rules.buildSpeedMultiplier);
|
||||
if(entity.construct(unit, core, 1f / entity.buildCost * Time.delta() * getBuildPower(tile) * state.rules.buildSpeedMultiplier)){
|
||||
if(current.hasConfig){
|
||||
Call.onTileConfig(null, tile, current.config);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
current.progress = entity.progress;
|
||||
@@ -257,6 +261,8 @@ public interface BuilderTrait extends Entity, TeamTrait{
|
||||
public final int x, y, rotation;
|
||||
public final Block block;
|
||||
public final boolean breaking;
|
||||
public boolean hasConfig;
|
||||
public int config;
|
||||
|
||||
public float progress;
|
||||
public boolean initialized;
|
||||
@@ -279,6 +285,12 @@ public interface BuilderTrait extends Entity, TeamTrait{
|
||||
this.breaking = true;
|
||||
}
|
||||
|
||||
public BuildRequest configure(int config){
|
||||
this.config = config;
|
||||
this.hasConfig = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Tile tile(){
|
||||
return world.tile(x, y);
|
||||
}
|
||||
|
||||
@@ -43,8 +43,7 @@ public class TileEntity extends BaseEntity implements TargetTrait, HealthTrait{
|
||||
private boolean dead = false;
|
||||
private boolean sleeping;
|
||||
private float sleepTime;
|
||||
private @Nullable
|
||||
SoundLoop sound;
|
||||
private @Nullable SoundLoop sound;
|
||||
|
||||
@Remote(called = Loc.server, unreliable = true)
|
||||
public static void onTileDamage(Tile tile, float health){
|
||||
@@ -232,6 +231,11 @@ public class TileEntity extends BaseEntity implements TargetTrait, HealthTrait{
|
||||
return proximity;
|
||||
}
|
||||
|
||||
/** Tile configuration. Defaults to 0. Used for block rebuilding. */
|
||||
public int config(){
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removed(){
|
||||
if(sound != null){
|
||||
|
||||
@@ -1,23 +1,19 @@
|
||||
package io.anuke.mindustry.entities.type.base;
|
||||
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.Events;
|
||||
import io.anuke.arc.collection.IntIntMap;
|
||||
import io.anuke.arc.collection.Queue;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.math.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.entities.EntityGroup;
|
||||
import io.anuke.mindustry.entities.traits.BuilderTrait;
|
||||
import io.anuke.mindustry.entities.traits.TargetTrait;
|
||||
import io.anuke.mindustry.*;
|
||||
import io.anuke.mindustry.entities.*;
|
||||
import io.anuke.mindustry.entities.traits.*;
|
||||
import io.anuke.mindustry.entities.type.*;
|
||||
import io.anuke.mindustry.entities.units.UnitState;
|
||||
import io.anuke.mindustry.game.EventType.BuildSelectEvent;
|
||||
import io.anuke.mindustry.game.Teams.TeamData;
|
||||
import io.anuke.mindustry.gen.BrokenBlock;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.BuildBlock;
|
||||
import io.anuke.mindustry.world.blocks.BuildBlock.BuildEntity;
|
||||
import io.anuke.mindustry.entities.units.*;
|
||||
import io.anuke.mindustry.game.EventType.*;
|
||||
import io.anuke.mindustry.game.Teams.*;
|
||||
import io.anuke.mindustry.world.*;
|
||||
import io.anuke.mindustry.world.blocks.*;
|
||||
import io.anuke.mindustry.world.blocks.BuildBlock.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
@@ -45,7 +41,7 @@ public class BuilderDrone extends BaseDrone implements BuilderTrait{
|
||||
BuildEntity entity = (BuildEntity)target;
|
||||
TileEntity core = getClosestCore();
|
||||
|
||||
if(isBuilding() && entity == null && isRebuild()){
|
||||
if(isBuilding() && entity == null && canRebuild()){
|
||||
target = world.tile(buildRequest().x, buildRequest().y);
|
||||
circle(placeDistance * 0.7f);
|
||||
target = null;
|
||||
@@ -151,9 +147,9 @@ public class BuilderDrone extends BaseDrone implements BuilderTrait{
|
||||
}
|
||||
}
|
||||
|
||||
boolean isRebuild(){
|
||||
boolean canRebuild(){
|
||||
//disabled until further notice, reason being that it's too annoying when playing enemies and too broken for ally use
|
||||
return false; //Vars.state.rules.enemyCheat && team == waveTeam;
|
||||
return timer.get(timerTarget, 80) && Units.closestEnemy(getTeam(), x, y, 100f, u -> !(u instanceof BaseDrone)) == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -188,12 +184,12 @@ public class BuilderDrone extends BaseDrone implements BuilderTrait{
|
||||
}
|
||||
}
|
||||
|
||||
if(isRebuild() && !isBuilding()){
|
||||
if(canRebuild() && !isBuilding()){
|
||||
TeamData data = Vars.state.teams.get(team);
|
||||
if(!data.brokenBlocks.isEmpty()){
|
||||
long block = data.brokenBlocks.removeLast();
|
||||
BrokenBlock block = data.brokenBlocks.removeLast();
|
||||
|
||||
placeQueue.addFirst(new BuildRequest(BrokenBlock.x(block), BrokenBlock.y(block), BrokenBlock.rotation(block), content.block(BrokenBlock.block(block))));
|
||||
placeQueue.addFirst(new BuildRequest(block.x, block.y, block.rotation, content.block(block.block)).configure(block.config));
|
||||
setState(build);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user