Пример #1
0
 public static void InvokeAction <T>(System.Action <T> action, T parameter)
 {
     if (action != null && action.GetInvocationList().Length > 0)
     {
         action(parameter);
     }
 }
Пример #2
0
 public static void InvokeAction(System.Action <object[]> action, params object[] parameters)
 {
     if (action != null && action.GetInvocationList().Length > 0)
     {
         action(parameters);
     }
 }
Пример #3
0
    public void TriggerEvent(GameEventsList.PlayerEvents EventType, PlayerEventParams playerEventParams)
    {
        EventIds eventIds = m_EventIdMapper.Find(x => x._eventType == EventType);

        if (eventIds != null)
        {
            InvokeRelevantListeners(eventIds._ids, GameEventHandlers.GetInvocationList(), playerEventParams);
        }
        else
        {
            //Debug.Log("Key Not Found!");
        }
    }
Пример #4
0
    static int set_OnUpdate(IntPtr L)
    {
        try
        {
            EventObject arg0 = null;

            if (LuaDLL.lua_isuserdata(L, 2) != 0)
            {
                arg0 = (EventObject)ToLua.ToObject(L, 2);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "The event 'SceneLoader.OnUpdate' can only appear on the left hand side of += or -= when used outside of the type 'SceneLoader'"));
            }

            if (arg0.op == EventOp.Add)
            {
                System.Action <float> ev = (System.Action <float>)DelegateFactory.CreateDelegate(typeof(System.Action <float>), arg0.func);
                SceneLoader.OnUpdate += ev;
            }
            else if (arg0.op == EventOp.Sub)
            {
                System.Action <float> ev = (System.Action <float>)LuaMisc.GetEventHandler(null, typeof(SceneLoader), "OnUpdate");
                Delegate[]            ds = ev.GetInvocationList();
                LuaState state           = LuaState.Get(L);

                for (int i = 0; i < ds.Length; i++)
                {
                    ev = (System.Action <float>)ds[i];
                    LuaDelegate ld = ev.Target as LuaDelegate;

                    if (ld != null && ld.func == arg0.func)
                    {
                        SceneLoader.OnUpdate -= ev;
                        state.DelayDispose(ld.func);
                        break;
                    }
                }

                arg0.func.Dispose();
            }

            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }