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
Added buildradius checkbox to lobby options #14209
Conversation
sorry about dune2k commits, I do not know alot about it |
@@ -164,7 +164,7 @@ public Actor FindBaseProvider(World world, Player p, CPos topLeft) | |||
|
|||
// Range is counted from the center of the actor, not from each cell. | |||
var target = Target.FromPos(bp.Actor.CenterPosition); | |||
if (target.IsInRange(center, bp.Trait.Info.Range)) | |||
if (target.IsInRange(center, bp.Trait.Info.Range) || !world.WorldActor.Trait<MapBuildRadius>().BuildRadiusEnabled) |
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.
We already query the MapBuildRadius
trait above and should 'cache' it therefore, imho.
I.e. something like:
public Actor FindBaseProvider(World world, Player p, CPos topLeft)
{
var center = world.Map.CenterOfCell(topLeft) + CenterOffset(world);
var mapBuildRadius = world.WorldActor.Trait<MapBuildRadius>();
var allyBuildEnabled = mapBuildRadius.AllyBuildRadiusEnabled;
foreach (var bp in world.ActorsWithTrait<BaseProvider>())
{
[...]
if (mapBuildRadius.BuildRadiusEnabled || target.IsInRange(center, bp.Trait.Info.Range))
return bp.Actor;
}
return null;
}
@@ -45,6 +54,8 @@ void INotifyCreated.Created(Actor self) | |||
{ | |||
AllyBuildRadiusEnabled = self.World.LobbyInfo.GlobalSettings | |||
.OptionOrDefault("allybuild", info.AllyBuildRadiusEnabled); | |||
BuildRadiusEnabled = self.World.LobbyInfo.GlobalSettings | |||
.OptionOrDefault("buildradius", info.BuildRadiusEnabled); |
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.
Those spaces should be replaced by tabs.
@@ -80,7 +80,7 @@ bool ValidRenderPlayer() | |||
public IEnumerable<IRenderable> RangeCircleRenderables(WorldRenderer wr) | |||
{ | |||
// Visible to player and allies | |||
if (!ValidRenderPlayer()) | |||
if (!ValidRenderPlayer() || !wr.World.WorldActor.Trait<MapBuildRadius>().BuildRadiusEnabled) |
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.
I think we should cache BuildRadiusEnabled
here as well as AllyBuildEnabled
is already. (Also see the comment below.)
Don't worry. ^^ Just squash the commits together later on. |
This is fundamentally wrong and suffers from tunnel vision - the ticket would be the perfect case to be resolved akin with a mutator, since you're now propagating a trait used in a single mod to be disabled in every shipped and thirdparty one (you can't really disable lobby checkboxes). |
is tarvis-ci failing at getting mono usual? |
No, this appears to be an upstream issue. I assume that they should fix it within a day or two. |
@@ -48,6 +48,11 @@ Background@LOBBY_OPTIONS_BIN: | |||
Width: 150 | |||
Height: 20 | |||
Text: Debug Menu | |||
Checkbox@BUILDRADIUS_CHECKBOX: |
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.
Tiberian Sun doesn't include the base radius, so can you please duplicate the lobby-options.yaml
into mods/ts/chrome
and adjust its mod.yaml
to use it, the same way d2k does?
mods/cnc/chrome/lobby-options.yaml
Outdated
Width: 150 | ||
Height: 20 | ||
Font: Regular | ||
Text: Build Radius |
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.
"Build Radius" isn't a very obvious name. Can we change this to something like "Limit ConYard Area"?
@@ -46,6 +47,7 @@ public BaseProvider(Actor self, BaseProviderInfo info) | |||
devMode = self.Owner.PlayerActor.Trait<DeveloperMode>(); | |||
progress = total = info.InitialDelay; | |||
allyBuildEnabled = self.World.WorldActor.Trait<MapBuildRadius>().AllyBuildRadiusEnabled; | |||
buildRadiusEnabled = self.World.WorldActor.Trait<MapBuildRadius>().BuildRadiusEnabled; |
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.
Space indentation.
@@ -154,7 +154,9 @@ public WVec CenterOffset(World w) | |||
public Actor FindBaseProvider(World world, Player p, CPos topLeft) | |||
{ | |||
var center = world.Map.CenterOfCell(topLeft) + CenterOffset(world); | |||
var allyBuildEnabled = world.WorldActor.Trait<MapBuildRadius>().AllyBuildRadiusEnabled; | |||
var mapBuildRadius = world.WorldActor.Trait<MapBuildRadius>(); |
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.
Space indentation.
@@ -45,6 +54,8 @@ void INotifyCreated.Created(Actor self) | |||
{ | |||
AllyBuildRadiusEnabled = self.World.LobbyInfo.GlobalSettings | |||
.OptionOrDefault("allybuild", info.AllyBuildRadiusEnabled); | |||
BuildRadiusEnabled = self.World.LobbyInfo.GlobalSettings | |||
.OptionOrDefault("buildradius", info.BuildRadiusEnabled); |
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.
Space indentation.
Looks good to me, otherwise. |
fixing in few moments, there are no spacing problems on my local files |
Sorry for the about face, but can you please duplicate the options yaml for ra instead of ts and keep the common copy unmodified? As @GraionDilach mentioned this probably doesnt want to be forced on downstream mods |
@pchote done and working |
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 better, thanks. There are a couple more minor changes you can do to improve performance:
@@ -46,6 +47,7 @@ public BaseProvider(Actor self, BaseProviderInfo info) | |||
devMode = self.Owner.PlayerActor.Trait<DeveloperMode>(); | |||
progress = total = info.InitialDelay; | |||
allyBuildEnabled = self.World.WorldActor.Trait<MapBuildRadius>().AllyBuildRadiusEnabled; | |||
buildRadiusEnabled = self.World.WorldActor.Trait<MapBuildRadius>().BuildRadiusEnabled; |
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.
Nit: can you please define a var mapBuildRadius = self.World.WorldActor.Trait<MapBuildRadius>();
instead of doing two trait lookups?
@@ -80,7 +82,7 @@ bool ValidRenderPlayer() | |||
public IEnumerable<IRenderable> RangeCircleRenderables(WorldRenderer wr) | |||
{ | |||
// Visible to player and allies | |||
if (!ValidRenderPlayer()) | |||
if (!ValidRenderPlayer() || !buildRadiusEnabled) |
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 better to put this in ValidRenderPlayer
so that it also applies to the selection bar.
@@ -164,7 +166,7 @@ public Actor FindBaseProvider(World world, Player p, CPos topLeft) | |||
|
|||
// Range is counted from the center of the actor, not from each cell. | |||
var target = Target.FromPos(bp.Actor.CenterPosition); | |||
if (target.IsInRange(center, bp.Trait.Info.Range)) | |||
if (target.IsInRange(center, bp.Trait.Info.Range) || !buildRadiusEnabled) |
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.
Please change this to return null before the loop if !buildRadiusEnabled
, and then:
- Query
MapBuildRadius
in theBuilding
constructor and store the result in areadonly bool buildRadiusEnabled
. - Check that value in
IsCloseEnoughToBase
to avoid calling this method entirely.
@@ -74,7 +78,7 @@ public bool Ready() | |||
|
|||
bool ValidRenderPlayer() | |||
{ | |||
return self.Owner == self.World.RenderPlayer || (allyBuildEnabled && self.Owner.IsAlliedWith(self.World.RenderPlayer)); | |||
return buildRadiusEnabled ? self.Owner == self.World.RenderPlayer || (allyBuildEnabled && self.Owner.IsAlliedWith(self.World.RenderPlayer)) : false; |
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.
I think this can be simplified to return buildRadiusEnabled && (self.Owner == self.World.RenderPlayer || (allyBuildEnabled && self.Owner.IsAlliedWith(self.World.RenderPlayer)));
.
@@ -38,14 +39,17 @@ public class BaseProvider : ITick, INotifyCreated, IRenderAboveShroudWhenSelecte | |||
int total; | |||
int progress; | |||
bool allyBuildEnabled; | |||
bool buildRadiusEnabled; |
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.
Is there a reason why this is not readonly
?
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.
Its not because allyBuildEnabled is not
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.
Hm, I think you should make both readonly
then. ^^
(They only get a value assigned in the constructor.)
Is this better? |
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.
Is this better?
Yes, just some more minor things and I hope we're done with changing the code back and forth. (Sorry for the hassle, btw...)
|
||
public BaseProvider(Actor self, BaseProviderInfo info) | ||
{ | ||
Info = info; | ||
this.self = self; | ||
devMode = self.Owner.PlayerActor.Trait<DeveloperMode>(); | ||
progress = total = info.InitialDelay; | ||
allyBuildEnabled = self.World.WorldActor.Trait<MapBuildRadius>().AllyBuildRadiusEnabled; | ||
mapBuildRadius = self.World.WorldActor.Trait<MapBuildRadius>(); |
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.
Actually, we only use this in the constructor. So I'd suggest you make this a local var
and drop the readonly MapBuildRadius mapBuildRadius;
.
return self.Owner == self.World.RenderPlayer || (allyBuildEnabled && self.Owner.IsAlliedWith(self.World.RenderPlayer)); | ||
} | ||
return buildRadiusEnabled && (self.Owner == self.World.RenderPlayer || (allyBuildEnabled && self.Owner.IsAlliedWith(self.World.RenderPlayer))); | ||
} |
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.
Somehow spaces sneaked in here again. Please change them to tabs.
@abcdefg30 done, I hope there is nothing else (expecially spaces) |
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 aside from one last minor nit:
@@ -154,7 +154,8 @@ public WVec CenterOffset(World w) | |||
public Actor FindBaseProvider(World world, Player p, CPos topLeft) | |||
{ | |||
var center = world.Map.CenterOfCell(topLeft) + CenterOffset(world); | |||
var allyBuildEnabled = world.WorldActor.Trait<MapBuildRadius>().AllyBuildRadiusEnabled; | |||
var mapBuildRadius = world.WorldActor.Trait<MapBuildRadius>(); | |||
var allyBuildEnabled = mapBuildRadius.AllyBuildRadiusEnabled; |
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.
Please add an
if (!mapBuildRadius)
return null;
as there are no base providers if the build radius is disabled.
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.
will do
@pchote is this good? |
var mapBuildRadius = world.WorldActor.Trait<MapBuildRadius>(); | ||
var allyBuildEnabled = mapBuildRadius.AllyBuildRadiusEnabled; | ||
|
||
if (!mapBuildRadius.BuildRadiusEnabled) |
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.
These lines are now indented using spaces. Please replace them with tabs.
https://github.com/OpenRA/OpenRA/wiki/Coding-Standard includes a guide on how to configure Visual Studio to use tabs.
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.
but I use linux
well great |
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.
Not a fan of this new row while there is just one item, but this works as advertised. LGTM
There are two other long thought about checkboxes that could be implemented by somebody to fill in the gaps (but certainly not in this PR!):
|
Yeah, got it. Maybe @kosti1 can create separate pr for those, so in playtest we would have full row. Either way this is good as it is |
will look in to it |
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 👍
Congratulations to everyone for creating the worst precedent in regarding to customized lobby checkboxes! @pchote, since you were interested on the other day why I believe taht modder feedback is ignored in eaxact cases - here is one. The CnCNetv5 client used by many TS/RA2 mods apply a rules edit behind the checkbox between the main rules and the map edits. That system should have been used here, not expanding the system with made-up arbitrary stuff. |
@GraionDilach: I don't really understand your hostility towards this. This PR doesn't set a precident; it follows our conventions that were established in #11364 and prerequisite PRs. Asking a new contributor to implement a new low-level engine feature that completely changes our lobby options conventions doesn't make sense. |
What does this PR does in effect on RA rules? Let me sum it up with two lines.
Where this PR does set a precedent is that lousy hardcoded lobby checkboxes which should have been implemented via custom rules are acceptable as C# code fragments and encouraged to do so. This precedent is already utilized at #14245. There wasn't a need to completely change the lobby options besides providing a secondary method. #9422 was filed exactly for lobby options causing this level of YAML edits. Ignoring it is convenient, blowing it to out-of-proportion levels is even more convenient - especially when one decides to ignore how CnCNet TS/YR is able to utilize said system for years now. |
OK, as for the help/feedback/attitude:
I checked - all you said prior to merge is "this is bad". That's all the feedback. Now, as for the suggested implementation:From what I've read that method sounds utterly unsupportable for more than 1 or 2 very simple mutators.
or you have these yamls in your rules folder along with all the others:
with each of those potentially having a 2-line entry (at best) for every actor in the mod. In conclusion,
So how about we all do something constructive for a change and try to come up with an actually good approach together? |
Sorry, but i can't. I agree with @GraionDilach that Mutators as CnCNet has would be way better alternative to this. I see no problem with having 20 mutator files, probably under rules/mutators folder not directly rules. CnCNet aside even original RA2 had a similar logic, called Game Types. Only difference ypu can only appy one of those. Plus we already have stuff like |
I left a comment somewhere at @kosti1's repo on a commit weeks ago explaining this exact same thing I'm atm pissed on but apparently it was lost in a rebase. |
Implements #14203