Wall-hugging ground patrol / Core storage changed to set
This commit is contained in:
@@ -6,6 +6,7 @@ import com.badlogic.gdx.math.Rectangle;
|
|||||||
import com.badlogic.gdx.math.Vector2;
|
import com.badlogic.gdx.math.Vector2;
|
||||||
import com.badlogic.gdx.utils.Array;
|
import com.badlogic.gdx.utils.Array;
|
||||||
import com.badlogic.gdx.utils.IntMap;
|
import com.badlogic.gdx.utils.IntMap;
|
||||||
|
import com.badlogic.gdx.utils.ObjectSet;
|
||||||
import com.badlogic.gdx.utils.TimeUtils;
|
import com.badlogic.gdx.utils.TimeUtils;
|
||||||
import io.anuke.annotations.Annotations.Loc;
|
import io.anuke.annotations.Annotations.Loc;
|
||||||
import io.anuke.annotations.Annotations.Remote;
|
import io.anuke.annotations.Annotations.Remote;
|
||||||
@@ -473,7 +474,7 @@ public class NetServer extends Module{
|
|||||||
dataStream.writeFloat(state.wavetime);
|
dataStream.writeFloat(state.wavetime);
|
||||||
dataStream.writeInt(state.wave);
|
dataStream.writeInt(state.wave);
|
||||||
|
|
||||||
Array<Tile> cores = state.teams.get(player.getTeam()).cores;
|
ObjectSet<Tile> cores = state.teams.get(player.getTeam()).cores;
|
||||||
|
|
||||||
dataStream.writeByte(cores.size);
|
dataStream.writeByte(cores.size);
|
||||||
|
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
|||||||
|
|
||||||
public boolean targetHasFlag(BlockFlag flag){
|
public boolean targetHasFlag(BlockFlag flag){
|
||||||
return target instanceof TileEntity && ((TileEntity) target).tile.block().flags != null &&
|
return target instanceof TileEntity && ((TileEntity) target).tile.block().flags != null &&
|
||||||
((TileEntity) target).tile.block().flags.contains(flag);
|
((TileEntity) target).tile.block().flags.contains(flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateRespawning(){
|
public void updateRespawning(){
|
||||||
@@ -167,16 +167,14 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**Only runs when the unit has a target.*/
|
||||||
* Only runs when the unit has a target.
|
|
||||||
*/
|
|
||||||
public void behavior(){
|
public void behavior(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateTargeting(){
|
public void updateTargeting(){
|
||||||
if(target == null || (target instanceof Unit && (target.isDead() || target.getTeam() == team))
|
if(target == null || (target instanceof Unit && (target.isDead() || target.getTeam() == team))
|
||||||
|| (target instanceof TileEntity && ((TileEntity) target).tile.entity == null)){
|
|| (target instanceof TileEntity && ((TileEntity) target).tile.entity == null)){
|
||||||
target = null;
|
target = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -221,9 +219,9 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
|||||||
float angT = i == 0 ? 0 : Mathf.randomSeedRange(i + 2, 60f);
|
float angT = i == 0 ? 0 : Mathf.randomSeedRange(i + 2, 60f);
|
||||||
float lenT = i == 0 ? 0 : Mathf.randomSeedRange(i + 3, 1f) - 1f;
|
float lenT = i == 0 ? 0 : Mathf.randomSeedRange(i + 3, 1f) - 1f;
|
||||||
Draw.rect(stack.item.region,
|
Draw.rect(stack.item.region,
|
||||||
x + Angles.trnsx(rotation + 180f + angT, backTrns + lenT),
|
x + Angles.trnsx(rotation + 180f + angT, backTrns + lenT),
|
||||||
y + Angles.trnsy(rotation + 180f + angT, backTrns + lenT),
|
y + Angles.trnsy(rotation + 180f + angT, backTrns + lenT),
|
||||||
itemSize, itemSize, rotation);
|
itemSize, itemSize, rotation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ public abstract class GroundUnit extends BaseUnit{
|
|||||||
public void update(){
|
public void update(){
|
||||||
target = getClosestCore();
|
target = getClosestCore();
|
||||||
if(target != null){
|
if(target != null){
|
||||||
//circle(60f + Mathf.absin(Timers.time() + id*23525, 70f, 1200f));
|
circle(60f + Mathf.absin(Timers.time() + id*23525, 70f, 1200f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -138,7 +138,7 @@ public abstract class GroundUnit extends BaseUnit{
|
|||||||
public void update(){
|
public void update(){
|
||||||
super.update();
|
super.update();
|
||||||
|
|
||||||
if(!velocity.isZero(0.0001f) && (target == null || (distanceTo(target) > getWeapon().getAmmo().getRange()))){
|
if(!velocity.isZero(0.0001f) && (Units.invalidateTarget(target, this) || (distanceTo(target) > getWeapon().getAmmo().getRange()))){
|
||||||
rotation = Mathf.slerpDelta(rotation, velocity.angle(), 0.2f);
|
rotation = Mathf.slerpDelta(rotation, velocity.angle(), 0.2f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -236,6 +236,20 @@ public abstract class GroundUnit extends BaseUnit{
|
|||||||
super.readSave(stream);
|
super.readSave(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void circle(float circleLength){
|
||||||
|
if(target == null) return;
|
||||||
|
|
||||||
|
vec.set(target.getX() - x, target.getY() - y);
|
||||||
|
|
||||||
|
if(vec.len() < circleLength){
|
||||||
|
vec.rotate((circleLength - vec.len()) / circleLength * 180f);
|
||||||
|
}
|
||||||
|
|
||||||
|
vec.setLength(type.speed * Timers.delta());
|
||||||
|
|
||||||
|
velocity.add(vec);
|
||||||
|
}
|
||||||
|
|
||||||
protected void moveToCore(){
|
protected void moveToCore(){
|
||||||
Tile tile = world.tileWorld(x, y);
|
Tile tile = world.tileWorld(x, y);
|
||||||
if(tile == null) return;
|
if(tile == null) return;
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package io.anuke.mindustry.game;
|
package io.anuke.mindustry.game;
|
||||||
|
|
||||||
import com.badlogic.gdx.utils.Array;
|
import com.badlogic.gdx.utils.ObjectSet;
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.ucore.util.EnumSet;
|
import io.anuke.ucore.util.EnumSet;
|
||||||
import io.anuke.ucore.util.ThreadArray;
|
import io.anuke.ucore.util.ThreadSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class for various team-based utilities.
|
* Class for various team-based utilities.
|
||||||
@@ -54,7 +54,7 @@ public class Teams{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public class TeamData{
|
public class TeamData{
|
||||||
public final Array<Tile> cores = new ThreadArray<>();
|
public final ObjectSet<Tile> cores = new ThreadSet<>();
|
||||||
public final EnumSet<Team> enemies;
|
public final EnumSet<Team> enemies;
|
||||||
public final Team team;
|
public final Team team;
|
||||||
|
|
||||||
|
|||||||
@@ -163,9 +163,7 @@ public class TutorialSector{
|
|||||||
//world.tile(x + 1, y - 2).block().handleStack(Items.copper, 1, world.tile(x + 1, y - 2), null);
|
//world.tile(x + 1, y - 2).block().handleStack(Items.copper, 1, world.tile(x + 1, y - 2), null);
|
||||||
|
|
||||||
//since placed() is not called here, add core manually
|
//since placed() is not called here, add core manually
|
||||||
if(!state.teams.get(waveTeam).cores.contains(world.tile(x, y), true)){
|
state.teams.get(waveTeam).cores.add(world.tile(x, y));
|
||||||
state.teams.get(waveTeam).cores.add(world.tile(x, y));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class MarkerBlockMission extends BlockLocMission{
|
private static class MarkerBlockMission extends BlockLocMission{
|
||||||
|
|||||||
@@ -83,9 +83,7 @@ public class CoreBlock extends StorageBlock{
|
|||||||
@Override
|
@Override
|
||||||
public void onProximityUpdate(Tile tile) {
|
public void onProximityUpdate(Tile tile) {
|
||||||
//add cores
|
//add cores
|
||||||
if(!state.teams.get(tile.getTeam()).cores.contains(tile, true)){
|
state.teams.get(tile.getTeam()).cores.add(tile);
|
||||||
state.teams.get(tile.getTeam()).cores.add(tile);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -95,7 +93,7 @@ public class CoreBlock extends StorageBlock{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removed(Tile tile){
|
public void removed(Tile tile){
|
||||||
state.teams.get(tile.getTeam()).cores.removeValue(tile, true);
|
state.teams.get(tile.getTeam()).cores.remove(tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user