Per-team infinite building resources
This commit is contained in:
@@ -44,6 +44,8 @@ abstract class BuilderComp implements Unitc{
|
|||||||
|
|
||||||
float finalPlaceDst = state.rules.infiniteResources ? Float.MAX_VALUE : buildingRange;
|
float finalPlaceDst = state.rules.infiniteResources ? Float.MAX_VALUE : buildingRange;
|
||||||
|
|
||||||
|
boolean infinite = state.rules.infiniteResources || team().rules().infiniteResources;
|
||||||
|
|
||||||
Iterator<BuildPlan> it = plans.iterator();
|
Iterator<BuildPlan> it = plans.iterator();
|
||||||
while(it.hasNext()){
|
while(it.hasNext()){
|
||||||
BuildPlan req = it.next();
|
BuildPlan req = it.next();
|
||||||
@@ -83,7 +85,7 @@ abstract class BuilderComp implements Unitc{
|
|||||||
if(!current.initialized && !current.breaking && Build.validPlace(current.block, team(), current.x, current.y, current.rotation)){
|
if(!current.initialized && !current.breaking && Build.validPlace(current.block, team(), current.x, current.y, current.rotation)){
|
||||||
boolean hasAll = !Structs.contains(current.block.requirements, i -> !core.items().has(i.item));
|
boolean hasAll = !Structs.contains(current.block.requirements, i -> !core.items().has(i.item));
|
||||||
|
|
||||||
if(hasAll || state.rules.infiniteResources){
|
if(hasAll || infinite){
|
||||||
Build.beginPlace(current.block, team(), current.x, current.y, current.rotation);
|
Build.beginPlace(current.block, team(), current.x, current.y, current.rotation);
|
||||||
}else{
|
}else{
|
||||||
current.stuck = true;
|
current.stuck = true;
|
||||||
@@ -105,7 +107,7 @@ abstract class BuilderComp implements Unitc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
//if there is no core to build with or no build entity, stop building!
|
//if there is no core to build with or no build entity, stop building!
|
||||||
if((core == null && !state.rules.infiniteResources) || !(tile.entity instanceof BuildEntity)){
|
if((core == null && !infinite) || !(tile.entity instanceof BuildEntity)){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,7 +150,7 @@ abstract class BuilderComp implements Unitc{
|
|||||||
/** @return whether this request should be skipped, in favor of the next one. */
|
/** @return whether this request should be skipped, in favor of the next one. */
|
||||||
boolean shouldSkip(BuildPlan request, @Nullable Tilec core){
|
boolean shouldSkip(BuildPlan request, @Nullable Tilec core){
|
||||||
//requests that you have at least *started* are considered
|
//requests that you have at least *started* are considered
|
||||||
if(state.rules.infiniteResources || request.breaking || core == null) return false;
|
if(state.rules.infiniteResources || team().rules().infiniteResources || request.breaking || core == null) return false;
|
||||||
//TODO these are bad criteria
|
//TODO these are bad criteria
|
||||||
return (request.stuck && !core.items().has(request.block.requirements)) || (Structs.contains(request.block.requirements, i -> !core.items().has(i.item)) && !request.initialized);
|
return (request.stuck && !core.items().has(request.block.requirements)) || (Structs.contains(request.block.requirements, i -> !core.items().has(i.item)) && !request.initialized);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import mindustry.world.*;
|
|||||||
* Does not store game state, just configuration.
|
* Does not store game state, just configuration.
|
||||||
*/
|
*/
|
||||||
public class Rules{
|
public class Rules{
|
||||||
/** Whether every team has infinite resources and instant build speed. */
|
/** Sandbox mode: Enables infinite resources, build range and build speed. */
|
||||||
public boolean infiniteResources;
|
public boolean infiniteResources;
|
||||||
/** Team-specific rules. */
|
/** Team-specific rules. */
|
||||||
public TeamRules teams = new TeamRules();
|
public TeamRules teams = new TeamRules();
|
||||||
|
|||||||
@@ -200,7 +200,7 @@ public class BuildBlock extends Block{
|
|||||||
setConstruct(previous, cblock);
|
setConstruct(previous, cblock);
|
||||||
}
|
}
|
||||||
|
|
||||||
float maxProgress = core == null ? amount : checkRequired(core.items(), amount, false);
|
float maxProgress = core == null || team.rules().infiniteResources ? amount : checkRequired(core.items(), amount, false);
|
||||||
|
|
||||||
for(int i = 0; i < cblock.requirements.length; i++){
|
for(int i = 0; i < cblock.requirements.length; i++){
|
||||||
int reqamount = Math.round(state.rules.buildCostMultiplier * cblock.requirements[i].amount);
|
int reqamount = Math.round(state.rules.buildCostMultiplier * cblock.requirements[i].amount);
|
||||||
@@ -208,7 +208,7 @@ public class BuildBlock extends Block{
|
|||||||
totalAccumulator[i] = Math.min(totalAccumulator[i] + reqamount * maxProgress, reqamount);
|
totalAccumulator[i] = Math.min(totalAccumulator[i] + reqamount * maxProgress, reqamount);
|
||||||
}
|
}
|
||||||
|
|
||||||
maxProgress = core == null ? maxProgress : checkRequired(core.items(), maxProgress, true);
|
maxProgress = core == null || team.rules().infiniteResources ? maxProgress : checkRequired(core.items(), maxProgress, true);
|
||||||
|
|
||||||
progress = Mathf.clamp(progress + maxProgress);
|
progress = Mathf.clamp(progress + maxProgress);
|
||||||
builderID = builder.id();
|
builderID = builder.id();
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
org.gradle.daemon=true
|
org.gradle.daemon=true
|
||||||
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
||||||
archash=5c3e9ec21d1b541f3b0e6ecde5f4d468b92efc25
|
archash=8560f9a35cde90ef4e0fd600419e5761ae51494a
|
||||||
|
|||||||
Reference in New Issue
Block a user