mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-03-06 07:30:35 +07:00
Better team interaction
This commit is contained in:
parent
070bb4d2d1
commit
7024273a02
@ -172,10 +172,10 @@ public class AndroidLauncher extends AndroidApplication{
|
||||
SaveSlot slot = control.saves.importSave(file);
|
||||
ui.load.runLoadSave(slot);
|
||||
}catch(IOException e){
|
||||
ui.showError(Core.bundle.format("text.save.import.fail", Strings.parseException(e, false)));
|
||||
ui.showError(Core.bundle.format("save.import.fail", Strings.parseException(e, false)));
|
||||
}
|
||||
}else{
|
||||
ui.showError("$text.save.import.invalid");
|
||||
ui.showError("$save.import.invalid");
|
||||
}
|
||||
}else if(map){ //open map
|
||||
Core.app.post(() -> {
|
||||
|
@ -23,9 +23,10 @@ public class Teams{
|
||||
public TeamData get(Team team){
|
||||
if(map[team.ordinal()] == null){
|
||||
//By default, a non-defined team will be enemies of everything.
|
||||
//neutral teams (none) do not have any enemies.
|
||||
Team[] others = new Team[Team.all.length-1];
|
||||
for(int i = 0, j = 0; i < Team.all.length; i++){
|
||||
if(Team.all[i] != team) others[j++] = Team.all[i];
|
||||
if(Team.all[i] != team && team != Team.none && Team.all[i] != Team.none) others[j++] = Team.all[i];
|
||||
}
|
||||
add(team, others);
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ public class OverlayRenderer{
|
||||
|
||||
Tile tile = world.tileWorld(v.x, v.y);
|
||||
if(tile != null) tile = tile.target();
|
||||
if(tile != null && tile.getTeam() == player.getTeam() && tile.block().acceptStack(player.item().item, player.item().amount, tile, player) > 0){
|
||||
if(tile != null && tile.interactable(player.getTeam()) && tile.block().acceptStack(player.item().item, player.item().amount, tile, player) > 0){
|
||||
Draw.color(Pal.place);
|
||||
Lines.square(tile.drawx(), tile.drawy(), tile.block().size * tilesize / 2f + 1 + Mathf.absin(Time.time(), 5f, 1f));
|
||||
Draw.color();
|
||||
|
@ -3,7 +3,6 @@ package io.anuke.mindustry.input;
|
||||
import io.anuke.annotations.Annotations.Loc;
|
||||
import io.anuke.annotations.Annotations.Remote;
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.mindustry.entities.Effects;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.input.InputProcessor;
|
||||
import io.anuke.arc.math.Angles;
|
||||
@ -13,10 +12,10 @@ import io.anuke.arc.scene.ui.layout.Table;
|
||||
import io.anuke.arc.util.Time;
|
||||
import io.anuke.mindustry.content.Blocks;
|
||||
import io.anuke.mindustry.content.Fx;
|
||||
import io.anuke.mindustry.entities.type.Player;
|
||||
import io.anuke.mindustry.entities.Effects;
|
||||
import io.anuke.mindustry.entities.effect.ItemTransfer;
|
||||
import io.anuke.mindustry.entities.traits.BuilderTrait.BuildRequest;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.entities.type.Player;
|
||||
import io.anuke.mindustry.gen.Call;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.mindustry.net.ValidateException;
|
||||
@ -157,7 +156,7 @@ public abstract class InputHandler implements InputProcessor{
|
||||
boolean consumed = false, showedInventory = false;
|
||||
|
||||
//check if tapped block is configurable
|
||||
if(tile.block().configurable && tile.getTeam() == player.getTeam()){
|
||||
if(tile.block().configurable && tile.interactable(player.getTeam())){
|
||||
consumed = true;
|
||||
if(((!frag.config.isShown() && tile.block().shouldShowConfigure(tile, player)) //if the config fragment is hidden, show
|
||||
//alternatively, the current selected block can 'agree' to switch config tiles
|
||||
@ -178,14 +177,14 @@ public abstract class InputHandler implements InputProcessor{
|
||||
}
|
||||
|
||||
//call tapped event
|
||||
if(!consumed && tile.getTeam() == player.getTeam()){
|
||||
if(!consumed && tile.interactable(player.getTeam())){
|
||||
Call.onTileTapped(player, tile);
|
||||
}
|
||||
|
||||
//consume tap event if necessary
|
||||
if(tile.getTeam() == player.getTeam() && tile.block().consumesTap){
|
||||
if(tile.interactable(player.getTeam()) && tile.block().consumesTap){
|
||||
consumed = true;
|
||||
}else if((tile.getTeam() == player.getTeam() || tile.getTeam() == Team.none) && tile.block().synthetic() && !consumed){
|
||||
}else if(tile.interactable(player.getTeam()) && tile.block().synthetic() && !consumed){
|
||||
if(tile.block().hasItems && tile.entity.items.total() > 0){
|
||||
frag.inv.showFor(tile);
|
||||
consumed = true;
|
||||
@ -297,7 +296,7 @@ public abstract class InputHandler implements InputProcessor{
|
||||
|
||||
ItemStack stack = player.item();
|
||||
|
||||
if(tile.block().acceptStack(stack.item, stack.amount, tile, player) > 0 && tile.getTeam() == player.getTeam() && tile.block().hasItems){
|
||||
if(tile.block().acceptStack(stack.item, stack.amount, tile, player) > 0 && tile.interactable(player.getTeam()) && tile.block().hasItems){
|
||||
Call.transferInventory(player, tile);
|
||||
}else{
|
||||
Call.dropItem(player.angleTo(x, y));
|
||||
|
@ -312,6 +312,10 @@ public class Tile implements Position, TargetTrait{
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean interactable(Team team){
|
||||
return getTeam() == Team.none || team == getTeam();
|
||||
}
|
||||
|
||||
public void updateOcclusion(){
|
||||
cost = 1;
|
||||
boolean occluded = false;
|
||||
|
Loading…
Reference in New Issue
Block a user