per-team toggles for core no-build radius / placement range check (#11448)

* per-team toggles for core no-build radius / placement range check

* oops

* fair enough
This commit is contained in:
WMF
2025-12-20 11:16:28 -05:00
committed by GitHub
parent 85b69d3afd
commit a1b47b1188
7 changed files with 39 additions and 11 deletions
+17 -3
View File
@@ -248,7 +248,7 @@ public class Rules{
}
public float buildRadius(Team team){
return enemyCoreBuildRadius + teams.get(team).extraCoreBuildRadius;
return !teams.get(team).protectCores ? 0f : enemyCoreBuildRadius + teams.get(team).extraCoreBuildRadius;
}
public float unitBuildSpeed(Team team){
@@ -299,6 +299,10 @@ public class Rules{
public static class TeamRule{
/** Whether, when AI is enabled, ships should be spawned from the core. TODO remove / unnecessary? */
public boolean aiCoreSpawn = true;
/** Whether the core no-build radius/polygonal protection applies to this team, unprotected teams are ignored by team assigner */
public boolean protectCores = true;
/** Whether the placeRangeCheck applies to this team */
public boolean checkPlacement = true;
/** If true, blocks don't require power or resources. */
public boolean cheat;
/** If true, the core is always filled to capacity with all items. */
@@ -345,8 +349,18 @@ public class Rules{
/** Extra spacing added to the no-build zone around the core. */
public float extraCoreBuildRadius = 0f;
//build cost disabled due to technical complexity
//for reading from json
public TeamRule(){
}
public TeamRule(Team team){
if(team == Team.derelict){
protectCores = false;
checkPlacement = false;
}
}
}
/** A simple map for storing TeamRules in an efficient way without hashing. */
@@ -355,7 +369,7 @@ public class Rules{
public TeamRule get(Team team){
TeamRule out = values[team.id];
return out == null ? (values[team.id] = new TeamRule()) : out;
return out == null ? (values[team.id] = new TeamRule(team)) : out;
}
@Override
+2 -2
View File
@@ -58,7 +58,7 @@ public class Teams{
public boolean anyEnemyCoresWithinBuildRadius(Team team, float x, float y){
for(TeamData data : active){
if(team != data.team){
if(team != data.team && data.team.rules().protectCores){
for(CoreBuild tile : data.cores){
if(tile.within(x, y, state.rules.buildRadius(tile.team) + tilesize)){
return true;
@@ -71,7 +71,7 @@ public class Teams{
public boolean anyEnemyCoresWithin(Team team, float x, float y, float radius){
for(TeamData data : active){
if(team != data.team){
if(team != data.team && data.team.rules().protectCores){
for(CoreBuild tile : data.cores){
if(tile.within(x, y, radius)){
return true;