New team system / Prototype dedicated PvP gamemode
This commit is contained in:
@@ -244,6 +244,10 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
return playerGroup;
|
||||
}
|
||||
|
||||
public void setTeam(Team team){
|
||||
this.team = team;
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
//region draw methods
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.badlogic.gdx.math.Vector2;
|
||||
import io.anuke.mindustry.content.blocks.Blocks;
|
||||
import io.anuke.mindustry.entities.traits.*;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.game.TeamInfo.TeamData;
|
||||
import io.anuke.mindustry.game.Teams.TeamData;
|
||||
import io.anuke.mindustry.net.Interpolator;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.mindustry.type.StatusEffect;
|
||||
@@ -179,17 +179,13 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
|
||||
}
|
||||
|
||||
public TileEntity getClosestCore(){
|
||||
if(state.teams.has(team)){
|
||||
TeamData data = state.teams.get(team);
|
||||
TeamData data = state.teams.get(team);
|
||||
|
||||
Tile tile = Geometry.findClosest(x, y, data.cores);
|
||||
if(tile == null){
|
||||
return null;
|
||||
}else{
|
||||
return tile.entity;
|
||||
}
|
||||
}else{
|
||||
Tile tile = Geometry.findClosest(x, y, data.cores);
|
||||
if(tile == null){
|
||||
return null;
|
||||
}else{
|
||||
return tile.entity;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package io.anuke.mindustry.entities;
|
||||
|
||||
import com.badlogic.gdx.math.Rectangle;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.utils.ObjectSet;
|
||||
import io.anuke.mindustry.entities.traits.TargetTrait;
|
||||
import io.anuke.mindustry.entities.units.BaseUnit;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
@@ -12,6 +11,7 @@ import io.anuke.ucore.entities.EntityGroup;
|
||||
import io.anuke.ucore.entities.EntityPhysics;
|
||||
import io.anuke.ucore.function.Consumer;
|
||||
import io.anuke.ucore.function.Predicate;
|
||||
import io.anuke.ucore.util.EnumSet;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
@@ -106,13 +106,7 @@ public class Units{
|
||||
* Returns the neareset ally tile in a range.
|
||||
*/
|
||||
public static TileEntity findAllyTile(Team team, float x, float y, float range, Predicate<Tile> pred){
|
||||
for(Team enemy : state.teams.alliesOf(team)){
|
||||
TileEntity entity = world.indexer().findTile(enemy, x, y, range, pred);
|
||||
if(entity != null){
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return world.indexer().findTile(team, x, y, range, pred);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -271,7 +265,7 @@ public class Units{
|
||||
* Iterates over all units that are enemies of this team.
|
||||
*/
|
||||
public static void getNearbyEnemies(Team team, Rectangle rect, Consumer<Unit> cons){
|
||||
ObjectSet<Team> targets = state.teams.enemiesOf(team);
|
||||
EnumSet<Team> targets = state.teams.enemiesOf(team);
|
||||
|
||||
for(Team other : targets){
|
||||
EntityGroup<BaseUnit> group = unitGroups[other.ordinal()];
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package io.anuke.mindustry.entities.units;
|
||||
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import com.badlogic.gdx.utils.ObjectSet;
|
||||
import io.anuke.annotations.Annotations.Loc;
|
||||
import io.anuke.annotations.Annotations.Remote;
|
||||
import io.anuke.mindustry.Vars;
|
||||
@@ -15,7 +14,6 @@ import io.anuke.mindustry.entities.traits.ShooterTrait;
|
||||
import io.anuke.mindustry.entities.traits.SpawnerTrait;
|
||||
import io.anuke.mindustry.entities.traits.TargetTrait;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.game.TeamInfo.TeamData;
|
||||
import io.anuke.mindustry.gen.Call;
|
||||
import io.anuke.mindustry.graphics.Palette;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
@@ -188,16 +186,14 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
||||
}
|
||||
|
||||
public TileEntity getClosestEnemyCore(){
|
||||
if(Vars.state.teams.has(team)){
|
||||
ObjectSet<TeamData> datas = Vars.state.teams.enemyDataOf(team);
|
||||
|
||||
for(TeamData data : datas){
|
||||
Tile tile = Geometry.findClosest(x, y, data.cores);
|
||||
if(tile != null){
|
||||
return tile.entity;
|
||||
}
|
||||
for(Team enemy : Vars.state.teams.enemiesOf(team)){
|
||||
Tile tile = Geometry.findClosest(x, y, Vars.state.teams.get(enemy).cores);
|
||||
if(tile != null){
|
||||
return tile.entity;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -241,8 +241,18 @@ public abstract class GroundUnit extends BaseUnit{
|
||||
}
|
||||
|
||||
protected void moveAwayFromCore(){
|
||||
Team enemy = null;
|
||||
for(Team team : Vars.state.teams.enemiesOf(team)){
|
||||
if(Vars.state.teams.isActive(team)){
|
||||
enemy = team;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(enemy == null) return;
|
||||
|
||||
Tile tile = world.tileWorld(x, y);
|
||||
Tile targetTile = world.pathfinder().getTargetTile(Vars.state.teams.enemiesOf(team).first(), tile);
|
||||
Tile targetTile = world.pathfinder().getTargetTile(enemy, tile);
|
||||
TileEntity core = getClosestCore();
|
||||
|
||||
if(tile == targetTile || core == null || distanceTo(core) < 90f) return;
|
||||
|
||||
Reference in New Issue
Block a user