public static bool CreateIfNeededGlobalEvent(string globalEventName)
    {
        FsmEvent _event = FsmEvent.GetFsmEvent(globalEventName);

        bool result = false;

        if (!FsmEvent.IsEventGlobal(globalEventName))
        {
            if (_event == null)
            {
                _event = new FsmEvent(globalEventName)
                {
                    IsGlobal = true
                };
                FsmEvent.AddFsmEvent(_event);
                if (!FsmEvent.globalEvents.Contains(globalEventName))
                {
                    FsmEvent.globalEvents.Add(globalEventName);
                }
            }

            result = true;
        }

        return(result);
    }
    public bool DoesTargetImplementsEvent()
    {
        string eventName = GetEventString();

        if (fsmEventSetup.target == PlayMakerProxyEventTarget.BroadCastAll)
        {
            return(FsmEvent.IsEventGlobal(eventName));
        }

        if (fsmEventSetup.target == PlayMakerProxyEventTarget.FsmComponent)
        {
            return(PlayMakerUtils.DoesFsmImplementsEvent(fsmEventSetup.fsmComponent, eventName));
        }

        if (fsmEventSetup.target == PlayMakerProxyEventTarget.GameObject)
        {
            return(PlayMakerUtils.DoesGameObjectImplementsEvent(fsmEventSetup.gameObject, eventName, fsmEventSetup.sendtoChildren));
        }

        if (fsmEventSetup.target == PlayMakerProxyEventTarget.Owner)
        {
            return(PlayMakerUtils.DoesGameObjectImplementsEvent(this.gameObject, eventName, fsmEventSetup.sendtoChildren));
        }

        return(false);
    }
    /// <summary>
    /// Add if necessary a list of Global events to the PlayMaker Globals resources to be available in the global events list
    /// </summary>
    /// <param name="events"></param>
    public static void CreateGlobalEventsIfNeeded(string[] events)
    {
        bool _isDirty = false;


        foreach (string _eventName in events)
        {
            if (!FsmEvent.IsEventGlobal(_eventName))
            {
                PlayMakerGlobals.AddGlobalEvent(_eventName);
                //	Debug.Log("Adding global event: "+_eventName);
                _isDirty = true;
            }
        }

        if (_isDirty)
        {
            FsmEditor.SaveGlobals();
            for (int index = 0; index < FsmEvent.globalEvents.Count; ++index)
            {
                new FsmEvent(FsmEvent.globalEvents[index]).IsGlobal = true;
            }


            FsmEventsWindow.ResetView();
        }
    }
 void CreateGlobalEvent(string globalEventName)
 {
     if (!FsmEvent.IsEventGlobal(globalEventName))
     {
         FsmEvent _event = new FsmEvent(globalEventName);
         _event.IsGlobal = true;
         FsmEvent.AddFsmEvent(_event);
     }
 }
Exemple #5
0
 public static void CreateIfNeededGlobalEvent(string globalEventName)
 {
     if (!FsmEvent.IsEventGlobal(globalEventName))
     {
         // Setup global events
         FsmEvent _event = new FsmEvent(globalEventName);
         _event.IsGlobal = true;
         FsmEvent.AddFsmEvent(_event);
     }
 }
    public static bool DoesTargetImplementsEvent(FsmEventTarget target, string eventName)
    {
        if (target.target == FsmEventTarget.EventTarget.BroadcastAll)
        {
            return(FsmEvent.IsEventGlobal(eventName));
        }

        if (target.target == FsmEventTarget.EventTarget.FSMComponent)
        {
            return(DoesFsmImplementsEvent(target.fsmComponent, eventName));
        }

        if (target.target == FsmEventTarget.EventTarget.GameObject)
        {
            return(DoesGameObjectImplementsEvent(target.gameObject.GameObject.Value, eventName));
        }

        if (target.target == FsmEventTarget.EventTarget.GameObjectFSM)
        {
            return(DoesGameObjectImplementsEvent(target.gameObject.GameObject.Value, target.fsmName.Value, eventName));
        }

        if (target.target == FsmEventTarget.EventTarget.Self)
        {
            Debug.LogError("Self target not supported yet");
        }

        if (target.target == FsmEventTarget.EventTarget.SubFSMs)
        {
            Debug.LogError("subFsms target not supported yet");
        }

        if (target.target == FsmEventTarget.EventTarget.HostFSM)
        {
            Debug.LogError("HostFSM target not supported yet");
        }

        return(false);
    }