mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-12-06 02:40:23 -08:00
Limit build progress per frame gamerule
This commit is contained in:
parent
5397d8426c
commit
b312fe8b20
4 changed files with 10 additions and 2 deletions
|
|
@ -1495,6 +1495,7 @@ rules.initialwavespacing = Initial Wave Spacing:[lightgray] (sec)
|
||||||
rules.buildcostmultiplier = Build Cost Multiplier
|
rules.buildcostmultiplier = Build Cost Multiplier
|
||||||
rules.buildspeedmultiplier = Build Speed Multiplier
|
rules.buildspeedmultiplier = Build Speed Multiplier
|
||||||
rules.deconstructrefundmultiplier = Deconstruct Refund Multiplier
|
rules.deconstructrefundmultiplier = Deconstruct Refund Multiplier
|
||||||
|
rules.limitbuildprogress = Limit Build Progress
|
||||||
rules.waitForWaveToEnd = Waves Wait for Enemies
|
rules.waitForWaveToEnd = Waves Wait for Enemies
|
||||||
rules.wavelimit = Map Ends After Wave
|
rules.wavelimit = Map Ends After Wave
|
||||||
rules.dropzoneradius = Drop Zone Radius:[lightgray] (tiles)
|
rules.dropzoneradius = Drop Zone Radius:[lightgray] (tiles)
|
||||||
|
|
|
||||||
|
|
@ -104,6 +104,8 @@ public class Rules{
|
||||||
public float buildCostMultiplier = 1f;
|
public float buildCostMultiplier = 1f;
|
||||||
/** Multiplier for building speed. */
|
/** Multiplier for building speed. */
|
||||||
public float buildSpeedMultiplier = 1f;
|
public float buildSpeedMultiplier = 1f;
|
||||||
|
/** Maximum block build progress that can be built per frame */
|
||||||
|
public float limitBuildProgress = Float.MAX_VALUE;
|
||||||
/** Multiplier for percentage of materials refunded when deconstructing. */
|
/** Multiplier for percentage of materials refunded when deconstructing. */
|
||||||
public float deconstructRefundMultiplier = 0.5f;
|
public float deconstructRefundMultiplier = 0.5f;
|
||||||
/** Multiplier for time in timer objectives. */
|
/** Multiplier for time in timer objectives. */
|
||||||
|
|
@ -285,6 +287,10 @@ public class Rules{
|
||||||
return buildSpeedMultiplier * teams.get(team).buildSpeedMultiplier;
|
return buildSpeedMultiplier * teams.get(team).buildSpeedMultiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public float limitBuildProgress(Team team){
|
||||||
|
return instantBuild ? Float.MAX_VALUE : limitBuildProgress / 60f;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isBanned(Block block){
|
public boolean isBanned(Block block){
|
||||||
return blockWhitelist != bannedBlocks.contains(block);
|
return blockWhitelist != bannedBlocks.contains(block);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -170,6 +170,7 @@ public class CustomRulesDialog extends BaseDialog{
|
||||||
check("@rules.disableworldprocessors", b -> rules.disableWorldProcessors = b, () -> rules.disableWorldProcessors);
|
check("@rules.disableworldprocessors", b -> rules.disableWorldProcessors = b, () -> rules.disableWorldProcessors);
|
||||||
number("@rules.buildcostmultiplier", false, f -> rules.buildCostMultiplier = f, () -> rules.buildCostMultiplier, () -> !rules.infiniteResources);
|
number("@rules.buildcostmultiplier", false, f -> rules.buildCostMultiplier = f, () -> rules.buildCostMultiplier, () -> !rules.infiniteResources);
|
||||||
number("@rules.buildspeedmultiplier", f -> rules.buildSpeedMultiplier = f, () -> rules.buildSpeedMultiplier, 0.001f, 50f);
|
number("@rules.buildspeedmultiplier", f -> rules.buildSpeedMultiplier = f, () -> rules.buildSpeedMultiplier, 0.001f, 50f);
|
||||||
|
number("@rules.limitbuildprogress", f -> rules.limitBuildProgress = f, () -> rules.limitBuildProgress, 0f, Float.MAX_VALUE);
|
||||||
number("@rules.deconstructrefundmultiplier", false, f -> rules.deconstructRefundMultiplier = f, () -> rules.deconstructRefundMultiplier, () -> !rules.infiniteResources, 0f, 1f);
|
number("@rules.deconstructrefundmultiplier", false, f -> rules.deconstructRefundMultiplier = f, () -> rules.deconstructRefundMultiplier, () -> !rules.infiniteResources, 0f, 1f);
|
||||||
number("@rules.blockhealthmultiplier", f -> rules.blockHealthMultiplier = f, () -> rules.blockHealthMultiplier);
|
number("@rules.blockhealthmultiplier", f -> rules.blockHealthMultiplier = f, () -> rules.blockHealthMultiplier);
|
||||||
number("@rules.blockdamagemultiplier", f -> rules.blockDamageMultiplier = f, () -> rules.blockDamageMultiplier);
|
number("@rules.blockdamagemultiplier", f -> rules.blockDamageMultiplier = f, () -> rules.blockDamageMultiplier);
|
||||||
|
|
|
||||||
|
|
@ -288,7 +288,7 @@ public class ConstructBlock extends Block{
|
||||||
|
|
||||||
maxProgress = core == null || team.rules().infiniteResources ? 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 + Math.min(maxProgress, state.rules.limitBuildProgress * amount));
|
||||||
|
|
||||||
if(progress >= 1f || state.rules.infiniteResources){
|
if(progress >= 1f || state.rules.infiniteResources){
|
||||||
boolean canFinish = true;
|
boolean canFinish = true;
|
||||||
|
|
@ -362,7 +362,7 @@ public class ConstructBlock extends Block{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
progress = Mathf.clamp(progress - amount);
|
progress = Mathf.clamp(progress - Math.min(amount, state.rules.limitBuildProgress * amount));
|
||||||
|
|
||||||
if(progress <= current.deconstructThreshold || state.rules.infiniteResources){
|
if(progress <= current.deconstructThreshold || state.rules.infiniteResources){
|
||||||
//add any leftover items that weren't obtained due to rounding errors
|
//add any leftover items that weren't obtained due to rounding errors
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue