mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-03-09 20:29:06 +07:00
Fixed packet spam on sector capture
This commit is contained in:
parent
20a0afd280
commit
304ad74084
@ -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");
|
||||
|
@ -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
|
||||
@ -326,21 +330,7 @@ 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. */
|
||||
/** Make all buildings within this range derelict/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){
|
||||
|
@ -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;
|
||||
|
@ -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());
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user