Ludeon Forums

RimWorld => Mods => Help => Topic started by: Lord Fappington on January 25, 2015, 12:05:52 AM

Title: Is there a cmd to allow only player selected pawns to do a workgiver?
Post by: Lord Fappington on January 25, 2015, 12:05:52 AM
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
Title: Re: Is there a cmd to allow only player selected pawns to do a workgiver?
Post by: 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 :)
Title: Re: Is there a cmd to allow only player selected pawns to do a workgiver?
Post by: Lord Fappington on January 25, 2015, 10:27:56 AM
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))
Title: Re: Is there a cmd to allow only player selected pawns to do a workgiver?
Post by: Haplo on January 25, 2015, 12:24:46 PM
Maybe you could do this:

if (!Find.Selector.IsSelected(myPawn))
    return null;
Title: Re: Is there a cmd to allow only player selected pawns to do a workgiver?
Post by: Lord Fappington on January 25, 2015, 01:35:50 PM
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 :)