Minor building optimization

This commit is contained in:
Anuken
2024-01-28 15:50:05 -05:00
parent 8aa7e8b930
commit eddcd8fc6d
2 changed files with 11 additions and 12 deletions

View File

@@ -86,9 +86,9 @@ abstract class BuilderComp implements Posc, Statusc, Teamc, Rotc{
buildAlpha = Mathf.lerpDelta(buildAlpha, activelyBuilding() ? 1f : 0f, 0.15f); buildAlpha = Mathf.lerpDelta(buildAlpha, activelyBuilding() ? 1f : 0f, 0.15f);
} }
//validate regardless of whether building is enabled.
if(!updateBuilding || !canBuild()){
validatePlans(); validatePlans();
if(!updateBuilding || !canBuild()){
return; return;
} }
@@ -99,18 +99,17 @@ abstract class BuilderComp implements Posc, Statusc, Teamc, Rotc{
if(Float.isNaN(buildCounter) || Float.isInfinite(buildCounter)) buildCounter = 0f; if(Float.isNaN(buildCounter) || Float.isInfinite(buildCounter)) buildCounter = 0f;
buildCounter = Math.min(buildCounter, 10f); buildCounter = Math.min(buildCounter, 10f);
boolean instant = state.rules.instantBuild && state.rules.infiniteResources;
//random attempt to fix a freeze that only occurs on Android //random attempt to fix a freeze that only occurs on Android
int maxPerFrame = state.rules.instantBuild ? plans.size : 10, count = 0; int maxPerFrame = instant ? plans.size : 10, count = 0;
while((buildCounter >= 1 || state.rules.instantBuild) && count++ < maxPerFrame){
buildCounter -= 1f;
validatePlans();
var core = core(); var core = core();
//nothing to build, or core doesn't exist if((core == null && !infinite)) return;
if(buildPlan() == null || (core == null && !infinite)) return;
while((buildCounter >= 1 || instant) && count++ < maxPerFrame && plans.size > 0){
buildCounter -= 1f;
//find the next build plan //find the next build plan
if(plans.size > 1){ if(plans.size > 1){

View File

@@ -25,4 +25,4 @@ org.gradle.caching=true
#used for slow jitpack builds; TODO see if this actually works #used for slow jitpack builds; TODO see if this actually works
org.gradle.internal.http.socketTimeout=100000 org.gradle.internal.http.socketTimeout=100000
org.gradle.internal.http.connectionTimeout=100000 org.gradle.internal.http.connectionTimeout=100000
archash=137d14855f archash=008e73aa33