Fixed packet spam on sector capture

This commit is contained in:
Anuken 2024-10-06 10:05:51 -04:00
parent 20a0afd280
commit 304ad74084
6 changed files with 38 additions and 23 deletions

View File

@ -145,6 +145,7 @@ public class Planets{
r.waveTeam = Team.crux;
r.placeRangeCheck = false;
r.showSpawns = false;
r.coreDestroyClear = true;
};
iconColor = Color.valueOf("7d4dff");
atmosphereColor = Color.valueOf("3c1b8f");

View File

@ -240,6 +240,8 @@ public class Teams{
}
public static class TeamData{
private static final IntSeq derelictBuffer = new IntSeq();
public final Team team;
/** Handles building ""bases"". */
@ -317,6 +319,8 @@ public class Teams{
}
}
finishScheduleDerelict();
//kill all units randomly
units.each(u -> Time.run(Mathf.random(0f, 60f * 5f), () -> {
//ensure unit hasn't switched teams for whatever reason
@ -327,20 +331,6 @@ public class Teams{
}
/** Make all buildings within this range derelict/explode. */
public void makeDerelict(float x, float y, float range){
var builds = new Seq<Building>();
if(buildingTree != null){
buildingTree.intersect(x - range, y - range, range * 2f, range * 2f, builds);
}
for(var build : builds){
if(build.within(x, y, range) && !build.block.privileged){
scheduleDerelict(build);
}
}
}
/** Make all buildings within this range explode. */
public void timeDestroy(float x, float y, float range){
var builds = new Seq<Building>();
if(buildingTree != null){
@ -348,27 +338,31 @@ public class Teams{
}
for(var build : builds){
if(build.within(x, y, range) && !cores.contains(c -> c.within(build, range))){
//TODO GPU driver bugs?
build.kill();
//Time.run(Mathf.random(0f, 60f * 6f), build::kill);
if(!build.block.privileged && build.within(x, y, range) && !cores.contains(c -> c.within(build, range))){
scheduleDerelict(build);
}
}
finishScheduleDerelict();
}
private void scheduleDerelict(Building build){
//TODO this may cause a lot of packet spam, optimize?
Call.setTeam(build, Team.derelict);
//queue block to be handled later, avoid packet spam
derelictBuffer.add(build.pos());
if(build.getPayload() instanceof UnitPayload){
Call.destroyPayload(build);
}
if(Mathf.chance(0.25)){
if(Mathf.chance(0.2)){
Time.run(Mathf.random(0f, 60f * 6f), build::kill);
}
}
private void finishScheduleDerelict(){
derelictBuffer.chunked(1000, values -> Call.setTeams(values, Team.derelict));
derelictBuffer.clear();
}
//this is just an alias for consistency
@Nullable
public Seq<Unit> getUnits(UnitType type){

View File

@ -755,6 +755,17 @@ public class Tile implements Position, QuadTreeObject, Displayable{
}
}
@Remote(called = Loc.server)
public static void setTeams(int[] positions, Team team){
if(positions == null) return;
for(int pos : positions){
Tile tile = world.tile(pos);
if(tile != null && tile.build != null){
tile.build.changeTeam(team);
}
}
}
@Remote(called = Loc.server)
public static void buildDestroyed(Building build){
if(build == null) return;

View File

@ -2,6 +2,7 @@ package mindustry.world.blocks.environment;
import arc.graphics.g2d.*;
import arc.math.*;
import mindustry.game.*;
import mindustry.world.*;
/**A type of floor that is overlaid on top of other floors.*/
@ -12,6 +13,11 @@ public class OverlayFloor extends Floor{
useColor = false;
}
@Override
public boolean canPlaceOn(Tile tile, Team team, int rotation){
return !wallOre || tile.block().solid;
}
@Override
public void drawBase(Tile tile){
Draw.rect(variantRegions[Mathf.randomSeed(tile.pos(), 0, Math.max(0, variantRegions.length - 1))], tile.worldx(), tile.worldy());

View File

@ -45,6 +45,9 @@ public class RemoveWall extends Block{
@Override
public void placeEnded(Tile tile, @Nullable Unit builder){
tile.setBlock(Blocks.air);
if(tile.overlay().wallOre){
tile.setOverlay(Blocks.air);
}
}
}

View File

@ -26,4 +26,4 @@ org.gradle.caching=true
org.gradle.internal.http.socketTimeout=100000
org.gradle.internal.http.connectionTimeout=100000
android.enableR8.fullMode=false
archash=e2aba22b1f
archash=89c7f1aee6