Per-team infinite building resources

This commit is contained in:
Anuken 2020-06-15 15:33:14 -04:00
parent 7001ad09cb
commit 405d6cf33f
4 changed files with 9 additions and 7 deletions

View File

@ -44,6 +44,8 @@ abstract class BuilderComp implements Unitc{
float finalPlaceDst = state.rules.infiniteResources ? Float.MAX_VALUE : buildingRange;
boolean infinite = state.rules.infiniteResources || team().rules().infiniteResources;
Iterator<BuildPlan> it = plans.iterator();
while(it.hasNext()){
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)){
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);
}else{
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((core == null && !state.rules.infiniteResources) || !(tile.entity instanceof BuildEntity)){
if((core == null && !infinite) || !(tile.entity instanceof BuildEntity)){
return;
}
@ -148,7 +150,7 @@ abstract class BuilderComp implements Unitc{
/** @return whether this request should be skipped, in favor of the next one. */
boolean shouldSkip(BuildPlan request, @Nullable Tilec core){
//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
return (request.stuck && !core.items().has(request.block.requirements)) || (Structs.contains(request.block.requirements, i -> !core.items().has(i.item)) && !request.initialized);
}

View File

@ -16,7 +16,7 @@ import mindustry.world.*;
* Does not store game state, just configuration.
*/
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;
/** Team-specific rules. */
public TeamRules teams = new TeamRules();

View File

@ -200,7 +200,7 @@ public class BuildBlock extends Block{
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++){
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);
}
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);
builderID = builder.id();

View File

@ -1,3 +1,3 @@
org.gradle.daemon=true
org.gradle.jvmargs=-Xms256m -Xmx1024m
archash=5c3e9ec21d1b541f3b0e6ecde5f4d468b92efc25
archash=8560f9a35cde90ef4e0fd600419e5761ae51494a