playMaker

Author Topic: Make FSM transition when a custom delegate fires?  (Read 1766 times)

elxen

  • Playmaker Newbie
  • *
  • Posts: 6
Make FSM transition when a custom delegate fires?
« on: June 17, 2014, 07:46:53 PM »
Hello,

say I have a simple light bulb with On/Off states. It starts with "Off" and I want it to go "On" when say, an OnPickup delegate gets fired.
Code: [Select]
public class ItemPickup : MonoBehaviour
{
    public Item itemToPickup;
    public Action<Item> OnPickup;
    public void Pickup(GameObject to)
    {
        // ...
        OnPickup(this);
        // ...
    }
}
Now say I have a reference to the bulb's FSM no problem, but I'm not sure how to tell playmaker to make the transition from Off to On when this OnPickup delegate fires as currently the only way I see it is to use an FsmEvent which could either be a global one, or a custom 'trivial' one. I say trivial because I could create an "OnPickup" event from playmaker but it won't accept parameters (in this case an Item object) - and now I would have to re-work all my logic to be around the fact that "OnPickup" now lives in playmaker, and not in ItemPickup.

Thank you.

elxen

  • Playmaker Newbie
  • *
  • Posts: 6
Re: Make FSM transition when a custom delegate fires?
« Reply #1 on: July 05, 2014, 09:18:18 AM »
Bump