playMaker

Author Topic: OnCreate() and OnDestroy() Action Methods  (Read 2028 times)

LoftyTheMetroid

  • Playmaker Newbie
  • *
  • Posts: 11
    • View Profile
OnCreate() and OnDestroy() Action Methods
« on: January 07, 2015, 01:18:12 PM »
Would it be possible to create CustomAction methods or callbacks for when an Action is either created (as in, a new Action was instantiated and added to a state) or destroyed (as in, an Action was removed from a state and destroyed)? If not during runtime, could this be implemented for use in the editor?

When making tools for the designers on my team, I've found several use cases where it would have been useful to have been notified that certain Actions were being added to or removed from an FSM in a scene in order to update metadata about certain scenes or data objects. For example, I'd like to maintain a list of scenes that have certain Actions accessing or manipulating a particular type of data object, but I can only do that if I am notified when these Actions are being added or removed. I've had workarounds, but even those have edge-case scenarios that break the functionality.

I know where I could add this code myself if I had the source, but seeing as how PlayMaker doesn't provide that, I was wondering if this could be added in the future? Thanks!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15072
  • Official Playmaker Support
    • View Profile
Re: OnCreate() and OnDestroy() Action Methods
« Reply #1 on: January 13, 2015, 12:37:04 AM »
Hi,

 Yeah... I SOO would like a full set of events and delegates to catch PlayMaker activity, during editing and runtime! like listening to events from c#, and indeed like you said, listening to author activity, when creating, editing states and actions.

I think you can kind of hack it, because you have access to the following for sure:

-- the current edited fsm
-- the current active state
-- the list of actions in that state

So you could be watching the number of actions and keep references to detect what's changed. It's ugly, but would get the job done.

 I would go further on this and also request ( I did, but if you feel it would be useful, make yourself heard) for being able to edit fsm, states and actions without requiring the user to use the playmaker various editors. typicall to add an action to a state ( in the ecosystem browser, I haven't found yet a way to add an action to a state without having the user to use the action browser itself).

Bye

 Jean
 

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15072
  • Official Playmaker Support
    • View Profile
Re: OnCreate() and OnDestroy() Action Methods
« Reply #2 on: January 13, 2015, 12:37:44 AM »
Hi,

 also, if you are not part of the beta and feel you could be of help, get in touch with the playmaker support.

 Bye,

 Jean

LoftyTheMetroid

  • Playmaker Newbie
  • *
  • Posts: 11
    • View Profile
Re: OnCreate() and OnDestroy() Action Methods
« Reply #3 on: January 20, 2015, 12:17:20 AM »
Yeah, I agree, I think it'd be great if there were more event/data tools in general. And for editing Fsms, States, and Actions, you mean without Editor tools like FsmBuilder or ActionUtility? Yeah, I think that's also be nice.

I'm not sure I'd be much help in the beta at the moment, I'm too tied up in several projects right now. But really, for my needs, as far as I can tell this could be done with just a simple virtual method for Actions, something like OnCreate()/OnAdd(). In FsmBuilder, methods like InsertAction() and AddAction() already call Init() and Reset(), so you'd think it'd be as easy as nestling OnCreate()/OnAdd() right in there. Same thing with something like OnDestroy()/OnRemove()/OnDelete(). At that point, developers can just override those methods in their derived Actions and implement their custom logic (such as updating metadata).