playMaker

Author Topic: [SOLVED] Custom variable type in custom action  (Read 5691 times)

DARK_ETERNAL

  • Full Member
  • ***
  • Posts: 110
[SOLVED] Custom variable type in custom action
« on: October 24, 2012, 01:13:53 PM »
Greetings.

I'm learning how to write my own custom actions for usage in Playmaker editor. But, since one of my goals is to integrate some EZGUI components, I was wondering how can I specify a variable type (for instance, EZGUI UIPanel)? As I understand, I'd think that I have to inherit from the basic variable type (FsmVariables, I guess?) and to create a new data type, but, in order to make the proper setup, I'd have to do something like assigning value to the actual object I wanna use (for instance, the UIPanel)

Anyone has made something like this before? Any pointers? Any suggestion will be well received.

Thanks in advance.

[Update Oct 24]

I have come with a solution for this, although I still want to know how to change a variable type to Fsm (as Int goes FsmInt and so on).

Actually, to integrate components from 3rd-party plugins, it seems to be enough to write a custom action that receives as public parameter an object from that plugin (for instance, if I want to operate an EZGUI UIPanel, my custom action will ask for a public UIPanel parameter, and the OnEnter() event will execute, say, a BringIn animation), then call the Finish() function to indicate that action has been completed.

But, in order to achieve a simpler design (to be easier to maintain that integration), I made a static class that executes all the object possible operations, so my custom action only needs to call that intermediate layer class desired operation. It's unavoidable to write a single action for each possible operation (in my case for EZGUI UIPanel, an action for BringIn a panel, another for Dismiss it, and so on).

Hope this helps whoever might want to do something like this. I'm checking this as 'SOLVED' since my issue is no longer a problem, yet still my question remains unanswered: How to convert my own variable types to Fsm variables, if possible?.
« Last Edit: October 24, 2012, 06:43:21 PM by DARK_ETERNAL »
Check out our new game: Nitro Chimp. Now live in App Store!

Trailer:
Download: https://itunes.apple.com/app/nitro-chimp/id557150450?l=en&mt=8

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: [SOLVED] Custom variable type in custom action
« Reply #1 on: October 26, 2012, 02:21:05 AM »
Hi,

 Instead of willing to create your own FSMxxx variable, I think the best approach is compositing. Simply write a proxy between your variable and the available set of playmaker Fsm variables. since anyway, I don't really see the point since the whole PlayMaker interface will not digest your newly created Fsmxxx class.

 Could you give an example of what you would like to achieve? then I can provide the solution I would use to do that. I have been porting mayn framework ( some very very difficult to port) and it always worked one way or the other, either via proxies, or with simple custom actions, but composition was always the key.

bye,

 Jean

DARK_ETERNAL

  • Full Member
  • ***
  • Posts: 110
Re: [SOLVED] Custom variable type in custom action
« Reply #2 on: October 26, 2012, 11:44:26 AM »
That's just the solution I've come with, and thus solved my question and marked this post as solved. For the sake of illustrating, what I did with EZGUI basic operations is this:

Code: [Select]
using UnityEngine;
using System.Collections;

public static class PlaymakerEZGUIManager {

// ******** UIPanel functions support *********

/// <summary>
/// Plays UIPanel BringIn animation
/// </summary>
/// <param name='panel'>
/// Panel.
/// </param>

public static void BringIn(UIPanel panel){
panel.BringIn();
}

/// <summary>
/// Dismiss the specified panel.
/// </summary>
/// <param name='panel'>
/// Panel.
/// </param>

public static void Dismiss(UIPanel panel){
panel.Dismiss();
}

// ******** UIPanel functions support *********
}

Then, my custom action for playing a panel BringIn animation, for instance, will call this script, and not the panel itself, like this.

Code: [Select]
using UnityEngine;
using System.Collections;

namespace HutongGames.PlayMaker.Actions{

[ActionCategory("EZGUI Custom Actions")]
[Tooltip("Plays BringInForward animation on supplied UIPanel")]

public class PanelBringIn : FsmStateAction {

[Tooltip("UIPanel to bring in")]
public UIPanel panel;

public override void OnEnter(){
PlaymakerEZGUIManager.BringIn(panel);
Finish();
}
}
}

This approach seems to be enough for my purposes, and, as you say, jeanfabre, it actually renders pointless to create a custom Fsm variable type.

However, I hope this might help someone wanting to do something alike, and, if there are any other approaches, I hope whoever thinks about it might share it with us. Thank you very much for your attention.
Check out our new game: Nitro Chimp. Now live in App Store!

Trailer:
Download: https://itunes.apple.com/app/nitro-chimp/id557150450?l=en&mt=8

Aislin

  • Playmaker Newbie
  • *
  • Posts: 6
Re: [SOLVED] Custom variable type in custom action
« Reply #3 on: December 21, 2017, 08:22:12 AM »
Hello! I had a question on this topic. Jean, what exactly do you mean by "creating a proxy" between my variable and an FSM one?

In my application, I have a custom class "Enemy" that does not inherent from anything. In my BattleTrigger FSM, I want to store an array of Enemy[]. However, since "Enemy" isn't an "Object", I don't see how this is possible. "Enemy" has various fields such as "CharacterType" "StartingHealth" "Skeleton" etc. When the player hits the trigger, I want the BattleTrigger FSM to send the Enemy[] variable to the BattleManager, who then initiates the battle.

Just trying to figure out the best way of doing it via FSMs instead of scripting.

Thanks!







jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: [SOLVED] Custom variable type in custom action
« Reply #4 on: January 19, 2018, 01:55:45 AM »
Hi,

 Sorry for the delay, only spotted your question now...

 a proxy is a class or a component that bridge two context together because theyr are otherwise incompatible. It's a like when you install a driver on your computer for your new printer or device. Your device doesn't know your computer, your computer doesn't know your device, the driver is here to bind the two and mitigate communication between the two.

 this is the same for a proxy. I use this name, it may be obscur and I am sorry.. could not find a better name that did not clash with other known vocabulary.

 Bye,

 Jean