Skip to content
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

Merged
merged 1 commit into from Jun 12, 2015
Merged

Conversation

matija-hustic
Copy link
Contributor

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.

@phrohdoh
Copy link
Member

The class ought to default to the actor's type name IMO.

@matija-hustic matija-hustic force-pushed the selectable_classes branch 4 times, most recently from 9a9971f to 36b6db4 Compare May 22, 2015 23:04
@matija-hustic
Copy link
Contributor Author

Done that @phrohdoh. Simplified stuff a lot.

@phrohdoh
Copy link
Member

That means you can remove the redundant yaml lines.

@matija-hustic
Copy link
Contributor Author

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).")]
Copy link
Member

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.

@penev92
Copy link
Member

penev92 commented May 23, 2015

YAML changes for D2k vehicles will be needed. I'm not sure about others (the RA cases you added), though.

@matija-hustic
Copy link
Contributor Author

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...

@phrohdoh
Copy link
Member

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
Copy link
Member

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?

Copy link
Contributor Author

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?

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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.

@penev92
Copy link
Member

penev92 commented May 23, 2015

If I understand the whole idea correctly, the Selectable: Class: should go on the startport actors for this to work and maybe on the normal ones for clarity.

@matija-hustic
Copy link
Contributor Author

@phrohdoh
Copy link
Member

You can use a Defaults entry or a parent definition if necessary. This is at the yaml level now though.

Above I was referring to engine plumbing.

Edit: Never mind.

@matija-hustic matija-hustic force-pushed the selectable_classes branch 3 times, most recently from 8ba05d8 to 25df78e Compare May 26, 2015 22:12
@penev92
Copy link
Member

penev92 commented May 31, 2015

OK, I have no idea why you added those classes in RA, but they seem redundant.
Also D2k needs them on the actor definitions in starport.yaml, not the ones in vehicles.yaml.

@matija-hustic
Copy link
Contributor Author

The Selectable trait gets inherited and so does the Class property when explicitly defined. That way, anyone who inherits from e.g. trike will inherit and share the same Selectable.Class thus making them equivalent as far as selectability is concerned.
I've added this thing for the civilians in order for them all to be in the same class. Try making and selling a couple of Tech Labs and see how fun it is when you get all kinds of different civilians and no quick way to select them all.

@penev92
Copy link
Member

penev92 commented May 31, 2015

Ah, good thinking with the inheritance, although that makes it quite implicit.

@matija-hustic
Copy link
Contributor Author

I can add a note about this to the description of the Class property?

@penev92
Copy link
Member

penev92 commented May 31, 2015

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);
Copy link
Member

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.

@matija-hustic
Copy link
Contributor Author

Fixed commented code @penev92.

.Where(x => x.Owner == player)
.Select(a => a.Info);
.Select(a => a.Trait<Selectable>().Class);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.ToHashSet() please

@matija-hustic
Copy link
Contributor Author

@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));
});
}
Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think caryalls in d2k.

Copy link
Member

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?

@penev92
Copy link
Member

penev92 commented Jun 1, 2015

Code looks good, and it works ingame 👍
You should squash the commits now.

@matija-hustic
Copy link
Contributor Author

Squashed.

@Mailaender
Copy link
Member

Needs a rebase.

@matija-hustic
Copy link
Contributor Author

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))
Copy link
Member

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.

@phrohdoh
Copy link
Member

phrohdoh commented Jun 8, 2015

Please squash the Typos commit so this can be tested.

@matija-hustic
Copy link
Contributor Author

Squashed.

@abcdefg30
Copy link
Member

Looks also good to me. 👍 / ✅

abcdefg30 added a commit that referenced this pull request Jun 12, 2015
@abcdefg30 abcdefg30 merged commit b98d98c into OpenRA:bleed Jun 12, 2015
@abcdefg30
Copy link
Member

Changelog

@penev92
Copy link
Member

penev92 commented Jun 13, 2015

Changelog #2

@matija-hustic matija-hustic deleted the selectable_classes branch June 26, 2015 00:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants