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.utils.Array;
|
||||
import com.badlogic.gdx.utils.IntMap;
|
||||
import com.badlogic.gdx.utils.ObjectSet;
|
||||
import com.badlogic.gdx.utils.TimeUtils;
|
||||
import io.anuke.annotations.Annotations.Loc;
|
||||
import io.anuke.annotations.Annotations.Remote;
|
||||
@@ -473,7 +474,7 @@ public class NetServer extends Module{
|
||||
dataStream.writeFloat(state.wavetime);
|
||||
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);
|
||||
|
||||
|
||||
@@ -141,7 +141,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
||||
|
||||
public boolean targetHasFlag(BlockFlag flag){
|
||||
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(){
|
||||
@@ -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 updateTargeting(){
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -221,9 +219,9 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
||||
float angT = i == 0 ? 0 : Mathf.randomSeedRange(i + 2, 60f);
|
||||
float lenT = i == 0 ? 0 : Mathf.randomSeedRange(i + 3, 1f) - 1f;
|
||||
Draw.rect(stack.item.region,
|
||||
x + Angles.trnsx(rotation + 180f + angT, backTrns + lenT),
|
||||
y + Angles.trnsy(rotation + 180f + angT, backTrns + lenT),
|
||||
itemSize, itemSize, rotation);
|
||||
x + Angles.trnsx(rotation + 180f + angT, backTrns + lenT),
|
||||
y + Angles.trnsy(rotation + 180f + angT, backTrns + lenT),
|
||||
itemSize, itemSize, rotation);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -426,4 +424,4 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
||||
public void onSuperDeath(){
|
||||
super.onDeath();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -80,7 +80,7 @@ public abstract class GroundUnit extends BaseUnit{
|
||||
public void update(){
|
||||
target = getClosestCore();
|
||||
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(){
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -236,6 +236,20 @@ public abstract class GroundUnit extends BaseUnit{
|
||||
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(){
|
||||
Tile tile = world.tileWorld(x, y);
|
||||
if(tile == null) return;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
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.world.Tile;
|
||||
import io.anuke.ucore.util.EnumSet;
|
||||
import io.anuke.ucore.util.ThreadArray;
|
||||
import io.anuke.ucore.util.ThreadSet;
|
||||
|
||||
/**
|
||||
* Class for various team-based utilities.
|
||||
@@ -54,7 +54,7 @@ public class Teams{
|
||||
}
|
||||
|
||||
public class TeamData{
|
||||
public final Array<Tile> cores = new ThreadArray<>();
|
||||
public final ObjectSet<Tile> cores = new ThreadSet<>();
|
||||
public final EnumSet<Team> enemies;
|
||||
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);
|
||||
|
||||
//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{
|
||||
|
||||
@@ -83,9 +83,7 @@ public class CoreBlock extends StorageBlock{
|
||||
@Override
|
||||
public void onProximityUpdate(Tile tile) {
|
||||
//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
|
||||
@@ -95,7 +93,7 @@ public class CoreBlock extends StorageBlock{
|
||||
|
||||
@Override
|
||||
public void removed(Tile tile){
|
||||
state.teams.get(tile.getTeam()).cores.removeValue(tile, true);
|
||||
state.teams.get(tile.getTeam()).cores.remove(tile);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user