Auto-destruction of enemies after attack sector capture
This commit is contained in:
@@ -56,18 +56,7 @@ public class BlockIndexer{
|
|||||||
|
|
||||||
public BlockIndexer(){
|
public BlockIndexer(){
|
||||||
Events.on(TileChangeEvent.class, event -> {
|
Events.on(TileChangeEvent.class, event -> {
|
||||||
if(typeMap.get(event.tile.pos()) != null){
|
updateIndices(event.tile);
|
||||||
TileIndex index = typeMap.get(event.tile.pos());
|
|
||||||
for(BlockFlag flag : index.flags){
|
|
||||||
getFlagged(index.team)[flag.ordinal()].remove(event.tile);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(index.flags.contains(BlockFlag.unitModifier)){
|
|
||||||
updateCap(index.team);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
process(event.tile);
|
|
||||||
updateQuadrant(event.tile);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Events.on(WorldLoadEvent.class, event -> {
|
Events.on(WorldLoadEvent.class, event -> {
|
||||||
@@ -111,6 +100,21 @@ public class BlockIndexer{
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateIndices(Tile tile){
|
||||||
|
if(typeMap.get(tile.pos()) != null){
|
||||||
|
TileIndex index = typeMap.get(tile.pos());
|
||||||
|
for(BlockFlag flag : index.flags){
|
||||||
|
getFlagged(index.team)[flag.ordinal()].remove(tile);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(index.flags.contains(BlockFlag.unitModifier)){
|
||||||
|
updateCap(index.team);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
process(tile);
|
||||||
|
updateQuadrant(tile);
|
||||||
|
}
|
||||||
|
|
||||||
private TileArray[] getFlagged(Team team){
|
private TileArray[] getFlagged(Team team){
|
||||||
return flagMap[team.id];
|
return flagMap[team.id];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,6 +121,30 @@ public class Logic implements ApplicationListener{
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Events.on(SectorCaptureEvent.class, e -> {
|
||||||
|
if(!net.client()){
|
||||||
|
for(Tile tile : world.tiles){
|
||||||
|
//convert all blocks to neutral, randomly killing them
|
||||||
|
if(tile.isCenter() && tile.build != null && tile.build.team == state.rules.waveTeam){
|
||||||
|
Building b = tile.build;
|
||||||
|
Time.run(Mathf.random(0f, 60f * 6f), () -> {
|
||||||
|
Call.setTeam(b, Team.derelict);
|
||||||
|
if(Mathf.chance(0.25)){
|
||||||
|
b.kill();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//kill all units
|
||||||
|
Groups.unit.each(u -> {
|
||||||
|
if(u.team == state.rules.waveTeam){
|
||||||
|
Time.run(Mathf.random(0f, 60f * 5f), u::kill);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Adds starting items, resets wave time, and sets state to playing. */
|
/** Adds starting items, resets wave time, and sets state to playing. */
|
||||||
|
|||||||
@@ -15,9 +15,7 @@ import static mindustry.Vars.*;
|
|||||||
|
|
||||||
public class AIController implements UnitController{
|
public class AIController implements UnitController{
|
||||||
protected static final Vec2 vec = new Vec2();
|
protected static final Vec2 vec = new Vec2();
|
||||||
protected static final int timerTarget = 0;
|
protected static final int timerTarget = 0, timerTarget2 = 1, timerTarget3 = 2;
|
||||||
protected static final int timerTarget2 = 1;
|
|
||||||
protected static final int timerTarget3 = 2;
|
|
||||||
|
|
||||||
protected Unit unit;
|
protected Unit unit;
|
||||||
protected Interval timer = new Interval(4);
|
protected Interval timer = new Interval(4);
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ public class Sector{
|
|||||||
|
|
||||||
/** @return whether the enemy has a generated base here. */
|
/** @return whether the enemy has a generated base here. */
|
||||||
public boolean hasEnemyBase(){
|
public boolean hasEnemyBase(){
|
||||||
return generateEnemyBase && (save == null || info.waves);
|
return generateEnemyBase && (save == null || info.attack);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBeingPlayed(){
|
public boolean isBeingPlayed(){
|
||||||
|
|||||||
@@ -602,6 +602,14 @@ public class Tile implements Position, QuadTreeObject, Displayable{
|
|||||||
tile.setBlock(block, team, rotation);
|
tile.setBlock(block, team, rotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Remote(called = Loc.server)
|
||||||
|
public static void setTeam(Building build, Team team){
|
||||||
|
if(build != null){
|
||||||
|
build.team = team;
|
||||||
|
indexer.updateIndices(build.tile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Remote(called = Loc.server, unreliable = true)
|
@Remote(called = Loc.server, unreliable = true)
|
||||||
public static void tileDamage(Building build, float health){
|
public static void tileDamage(Building build, float health){
|
||||||
if(build == null) return;
|
if(build == null) return;
|
||||||
|
|||||||
Reference in New Issue
Block a user