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