mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-03-13 11:29:48 +07:00
Cleanup
This commit is contained in:
parent
3a52fb2afe
commit
c7622198fd
@ -23,7 +23,6 @@ public enum Gamemode{
|
||||
rules.waveTimer = true;
|
||||
|
||||
rules.waveSpacing /= 2f;
|
||||
rules.teams.get(rules.waveTeam).ai = true;
|
||||
rules.teams.get(rules.waveTeam).infiniteResources = true;
|
||||
}, map -> map.teams.contains(state.rules.waveTeam.id)),
|
||||
pvp(rules -> {
|
||||
|
@ -426,7 +426,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
if(controlledType != null){
|
||||
Unit unit = Units.closest(player.team(), player.x, player.y, u -> !u.isPlayer() && u.type == controlledType && !u.dead);
|
||||
if(unit == null && controlledType == UnitTypes.block){
|
||||
unit = world.buildWorld(player.x, player.y) instanceof ControlBlock ? ((ControlBlock)world.buildWorld(player.x, player.y)).unit() : null;
|
||||
unit = world.buildWorld(player.x, player.y) instanceof ControlBlock cont && cont.canControl() ? cont.unit() : null;
|
||||
}
|
||||
|
||||
if(unit != null){
|
||||
@ -990,8 +990,8 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
}
|
||||
|
||||
Building tile = world.buildWorld(Core.input.mouseWorld().x, Core.input.mouseWorld().y);
|
||||
if(tile instanceof ControlBlock && tile.team == player.team()){
|
||||
return ((ControlBlock)tile).unit();
|
||||
if(tile instanceof ControlBlock cont && cont.canControl() && tile.team == player.team()){
|
||||
return cont.unit();
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -24,6 +24,7 @@ import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
import static mindustry.input.PlaceMode.*;
|
||||
@ -936,7 +937,7 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
unit.aim(player.mouseX = Core.input.mouseWorldX(), player.mouseY = Core.input.mouseWorldY());
|
||||
}else if(target == null){
|
||||
player.shooting = false;
|
||||
if(Core.settings.getBool("autotarget")){
|
||||
if(Core.settings.getBool("autotarget") && !(player.unit() instanceof BlockUnitUnit u && u.tile() instanceof ControlBlock c && !c.shouldAutoTarget())){
|
||||
target = Units.closestTarget(unit.team, unit.x, unit.y, range, u -> u.team != Team.derelict, u -> u.team != Team.derelict);
|
||||
|
||||
if(allowHealing && target == null){
|
||||
|
@ -185,7 +185,7 @@ public class TypeIO{
|
||||
return unit == null ? Nulls.unit : unit;
|
||||
}else if(type == 1){ //block
|
||||
Building tile = world.build(id);
|
||||
return tile instanceof ControlBlock ? ((ControlBlock)tile).unit() : Nulls.unit;
|
||||
return tile instanceof ControlBlock cont ? cont.unit() : Nulls.unit;
|
||||
}
|
||||
return Nulls.unit;
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
launching = false;
|
||||
|
||||
zoom = 1f;
|
||||
planets.zoom = 2f;
|
||||
planets.zoom = 1f;
|
||||
selectAlpha = 0f;
|
||||
launchSector = state.getSector();
|
||||
|
||||
@ -112,7 +112,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
//update view to sector
|
||||
lookAt(sector);
|
||||
zoom = 1f;
|
||||
planets.zoom = 2f;
|
||||
planets.zoom = 1f;
|
||||
selectAlpha = 0f;
|
||||
launchSector = sector;
|
||||
|
||||
@ -159,10 +159,6 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
|
||||
if(selectAlpha > 0.01f){
|
||||
if(canSelect(sec) || sec.unlocked()){
|
||||
//TODO remove completely?
|
||||
//if(sec.baseCoverage > 0){
|
||||
//planets.fill(sec, Tmp.c1.set(Team.crux.color).a(0.5f * sec.baseCoverage * selectAlpha), -0.002f);
|
||||
//}
|
||||
|
||||
Color color =
|
||||
sec.hasBase() ? Team.sharded.color :
|
||||
|
@ -10,4 +10,14 @@ public interface ControlBlock{
|
||||
default boolean isControlled(){
|
||||
return unit().isPlayer();
|
||||
}
|
||||
|
||||
/** @return whether this block can be controlled at all. */
|
||||
default boolean canControl(){
|
||||
return true;
|
||||
}
|
||||
|
||||
/** @return whether targets should automatically be selected (on mobile) */
|
||||
default boolean shouldAutoTarget(){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package mindustry.world.blocks.distribution;
|
||||
|
||||
import arc.math.*;
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import arc.util.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.type.*;
|
||||
@ -27,19 +27,27 @@ public class Router extends Block{
|
||||
public Item lastItem;
|
||||
public Tile lastInput;
|
||||
public float time;
|
||||
public @NonNull BlockUnitc unit = Nulls.blockUnit;
|
||||
|
||||
@Override
|
||||
public void created(){
|
||||
unit = (BlockUnitc)UnitTypes.block.create(team);
|
||||
unit.tile(this);
|
||||
}
|
||||
public @Nullable BlockUnitc unit;
|
||||
|
||||
@Override
|
||||
public Unit unit(){
|
||||
if(unit == null){
|
||||
unit = (BlockUnitc)UnitTypes.block.create(team);
|
||||
unit.tile(this);
|
||||
}
|
||||
return (Unit)unit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canControl(){
|
||||
return size == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldAutoTarget(){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTile(){
|
||||
if(lastItem == null && items.any()){
|
||||
@ -87,8 +95,9 @@ public class Router extends Block{
|
||||
}
|
||||
|
||||
public Building getTileTarget(Item item, Tile from, boolean set){
|
||||
if(isControlled()){
|
||||
if(unit != null && isControlled()){
|
||||
unit.health(health);
|
||||
unit.ammo(unit.type().ammoCapacity * (items.total() > 0 ? 1f : 0f));
|
||||
unit.team(team);
|
||||
|
||||
int angle = Mathf.mod((int)((angleTo(unit.aimX(), unit.aimY()) + 45) / 90), 4);
|
||||
|
Loading…
Reference in New Issue
Block a user