-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change LowPowerSlowdown to LowPowerModifier #14664
Conversation
29ec0f3
to
8873dbc
Compare
This, along with ProductionQueue->BuildDurationModifier should probably be ripped out to a separate conditional QueueSpeedModifier traits by this point. |
8873dbc
to
ef4033a
Compare
@@ -508,7 +508,7 @@ public void Tick(PlayerResources pr) | |||
if (pm.PowerState != PowerState.Normal) | |||
{ | |||
if (--Slowdown <= 0) | |||
Slowdown = Queue.Info.LowPowerSlowdown; | |||
Slowdown = Queue.Info.LowPowerModifier; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This means that the slowdown is now multiplied by 100. Every tick, the Slowdown will go down by 1, so it will now take 300 ticks to do one build tick on low power. Allowing modifiers that aren't effectively multiple of 100 will require careful work to allow for fractional build ticks. I think it may be possible to do by replacing --Slowdown
with Slowdown -= 100
, but I'm not 100% sure.
You asked on IRC about the interaction with #14702; I have nothing in principle against allowing a modifier to speed up the build queue (values less than 100). That would require the logic here to allow the build to tick multiple times per game tick.
ef4033a
to
8666bcf
Compare
8666bcf
to
28f6d3c
Compare
There's currently no ETA for this, and the upgrade rule for this PR should be simple (rename and multiply value by 100). Also needs a rebase. |
28f6d3c
to
fd62250
Compare
Rebased and added a upgrade rule. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me otherwise. Needs a rebase though.
@@ -508,8 +508,8 @@ public void Tick(PlayerResources pr) | |||
|
|||
if (pm.PowerState != PowerState.Normal) | |||
{ | |||
if (--Slowdown <= 0) | |||
Slowdown = Queue.Info.LowPowerSlowdown; | |||
if ((Slowdown -= 100) <= 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks weird, why didn't you use just if (Slowdown - 100 <= 0)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, i haven't answered, because i wasn't sure. But looks like -=
is correct. Slowdown needs to tick down, otherwise unit won't be built.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be cleaner to split this onto two lines:
Slowdown -= 100;
if (SlowDown < 0)
...
1e35557
to
31cf5c0
Compare
Rebased. Moved the update rule to the new system, but did not test it. |
NTM: Looks like this needs rebase again. |
Ping @MustaphaTR. |
31cf5c0
to
1044564
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few thoughts:
@@ -80,8 +80,8 @@ public class ProductionQueueInfo : ITraitInfo | |||
|
|||
public void RulesetLoaded(Ruleset rules, ActorInfo ai) | |||
{ | |||
if (LowPowerSlowdown <= 0) | |||
throw new YamlException("Production queue must have LowPowerSlowdown of at least 1."); | |||
if (LowPowerModifier < 100) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The previous check was needed because 0 or negative values would break the calculation. IMO there is no reason not to disallow modifiers between 1 and 100 (implying a speed up on low power) here.
@@ -508,8 +508,8 @@ public void Tick(PlayerResources pr) | |||
|
|||
if (pm.PowerState != PowerState.Normal) | |||
{ | |||
if (--Slowdown <= 0) | |||
Slowdown = Queue.Info.LowPowerSlowdown; | |||
if ((Slowdown -= 100) <= 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be cleaner to split this onto two lines:
Slowdown -= 100;
if (SlowDown < 0)
...
[Desc("The build time is multiplied with this value on low power.")] | ||
public readonly int LowPowerSlowdown = 3; | ||
[Desc("The build time is multiplied with this percentage on low power.")] | ||
public readonly int LowPowerModifier = 300; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may make sense to take this chance to reset the default to 100? a 3x slowdown is quite arbitrary, and specific to the default C&C mods.
b25c03c
to
7697753
Compare
Updated. |
7697753
to
ea81202
Compare
I suspect the issue is that |
ea81202
to
089868a
Compare
Yeah, that was the issue. Updated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me now. Needs a rebase however.
089868a
to
fbf91ea
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM and looks fine ingame.
Just one tidy in the update rule, which I will push myself shortly to save you from yet another update cycle.
foreach (var q in actorNode.ChildrenMatching(trait)) | ||
queues.Add(q); | ||
|
||
foreach (var queue in queues) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can simplify to
foreach (var queue in queueTraits.SelectMany(q => actorNode.ChildrenMatching(q)))
and then the code above removed.
fbf91ea
to
9084209
Compare
Also removed
LowPowerSlowdown:
s that were already equal to default value.Didn't write a upgrade rule, not sure if wanted, as we are gonna rewrite them anyway.