Is there a cmd to allow only player selected pawns to do a workgiver?

Started by Lord Fappington, January 25, 2015, 12:05:52 AM

Previous topic - Next topic

Lord Fappington

As the title says.  Aside from a floatmenu approach, I'd like to know if there was a way in RimWorld c# to specify only the pawn actively selected by the game's player.

I looked at the selector class but didn't have any luck implementing it.

Basically in my lovemaking mod it's working great, the only caveat is without player direction everyone does there own thing, with idlers tending to go on fapping binges.

Jokes aside, this method instead of floatmenus wil allow me to have a lot more easier flexibility in updating the code down the road

mipen

In the workgiver you could put a line at the top to test if the potential pawn is selected. If it is, carry on. If it isn't, return null.
The function you want is in Find.Selector, either SingleSelectedThing or SelectedObjects. Just check if the pawn is in one of those and you should be good :)

Lord Fappington

Quote from: mipen on January 25, 2015, 06:26:38 AM
In the workgiver you could put a line at the top to test if the potential pawn is selected. If it is, carry on. If it isn't, return null.
The function you want is in Find.Selector, either SingleSelectedThing or SelectedObjects. Just check if the pawn is in one of those and you should be good :)
Thanks for the advice mate, I'll give that a go today and let us know how it turns out.

Would it be something like:


If (mypawn = find.selector.selectedobjects)
//Or
If (mypawn = find.selector.selectedobjects(obj))

Haplo

Maybe you could do this:

if (!Find.Selector.IsSelected(myPawn))
    return null;

Lord Fappington

Quote from: Haplo on January 25, 2015, 12:24:46 PM
Maybe you could do this:

if (!Find.Selector.IsSelected(myPawn))
    return null;

That worked like a charm!

Thank you both Mipen & Haplo :)