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 selection classes #8212
Added selection classes #8212
Conversation
ae228b1
to
7f2b92c
Compare
The class ought to default to the actor's type name IMO. |
9a9971f
to
36b6db4
Compare
Done that @phrohdoh. Simplified stuff a lot. |
That means you can remove the redundant yaml lines. |
Not sure what you mean... Defaulting selection class to actor name only simplified the code. Hasn't changed anything for what is needed in YAMLs. Did you mean defaulting on the Tooltip.Name instead of the actor name? |
@@ -22,11 +22,16 @@ public class SelectableInfo : ITraitInfo | |||
public readonly int[] Bounds = null; | |||
[VoiceReference] public readonly string Voice = null; | |||
|
|||
[Desc("All units having the same selection class specified will be selected with select-by-type commands (e.g. double-click).")] |
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.
You should mention that it defaults to the actor's name.
YAML changes for D2k vehicles will be needed. I'm not sure about others (the RA cases you added), though. |
I'll remove those. So guys, opinions on using Tooltip.Name as default and actor name as fallback in case actor doesn't implement Tooltip or doesn't define Tooltip.Name? That way even those YAML entries for d2k would be rendered unnecessary. Although wouldn't be the cleanest of solutions... |
Just stick with the actor type as the default. This isn't exposed to the player so doesn't need to be (and shouldn't be coupled with) something as 'pretty' as the tooltip name. |
@@ -21,7 +21,6 @@ trike.starport: | |||
Inherits: trike | |||
Buildable: | |||
Queue: Starport | |||
Prerequisites: starport |
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 out of place in this PR?
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.
Yes. Must make a separate PR?
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 don't understand why you're removing it to begin with.
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 is redundant. Compare with the other entries - if they're purchasable in the Starport queue, which is only activated once you actually build the Starport, there is no need to put starport in the prerequisites.
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.
Oh, OK, sorry, I see your point. You can keep it here then.
If I understand the whole idea correctly, the |
Edit: Never mind. |
8ba05d8
to
25df78e
Compare
OK, I have no idea why you added those classes in RA, but they seem redundant. |
The |
Ah, good thinking with the inheritance, although that makes it quite implicit. |
I can add a note about this to the description of the |
No, it's good. I just forgot that the starport actors inherit from those. I guess only thing left is to test ingame now. |
var newSelection2 = SelectActorsInBox(World, worldRenderer.Viewport.TopLeft, worldRenderer.Viewport.BottomRight, | ||
a => a.Owner == unit.Owner && a.Info.Name == unit.Info.Name); | ||
var newSelection = SelectActorsInBox(World, worldRenderer.Viewport.TopLeft, worldRenderer.Viewport.BottomRight, | ||
a => a.Owner == unit.Owner && a.Trait<Selectable>().Class == unit.Trait<Selectable>().Class); |
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.
Repeated trait lookups is not the best thing to do, so add a var class = unit.Trait<Selectable>().Class;
above and check against that here.
We may even want a GetSelectionClass()
actor extention, because this is heavily abused.
Fixed commented code @penev92. |
.Where(x => x.Owner == player) | ||
.Select(a => a.Info); | ||
.Select(a => a.Trait<Selectable>().Class); |
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.
.ToHashSet()
please
@penev92, after we talked in IRC, I felt more comfortable changing other things that seem that could use some housekeeping. Could you check if this is more to your liking? |
// sc == null means that units, that meet all other criteria, get selected | ||
return s != null && s.Info.Selectable && (sc == null || sc.Contains(s.Class)); | ||
}); | ||
} |
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 can probably change something with the above three functions, but too tired right now to think clearly.
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.
Can sc
really be null
here?
Looks like worst-case it can be empty, but even that shouldn't be possible.
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.
Think caryalls in d2k.
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.
Can we get better variable names please?
42442ed
to
e019d55
Compare
Code looks good, and it works ingame 👍 |
e019d55
to
ceacdeb
Compare
Squashed. |
Needs a rebase. |
ceacdeb
to
c201a76
Compare
Changed variable names as @phrohdoh suggested. Rebased. |
@@ -33,6 +38,10 @@ public Selectable(Actor self, SelectableInfo info) | |||
{ | |||
this.self = self; | |||
Info = info; | |||
if (string.IsNullOrEmpty(info.Class)) |
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 could become ternary, but that doesn't change the actual logic so it isn't necessary.
Please squash the |
b89b6a4
to
e965a0d
Compare
Squashed. |
Looks also good to me. 👍 / ✅ |
Option 3 from #7469 that would support the type of functionality proposed by @MustaphaTR:
http://ares-developers.github.io/Ares-docs/new/typeselect.html
Basically whenever the standard select-by-type functionality is supposed to be extended to select any custom class of selectable actors, these custom classes can be defined using the Class property of the Selectable trait.
If the basic idea is fine, I'd define any remaining selection classes in the YAMLs.