Exemplo n.º 1
0
 public static void Configure(LogLevel level, EventHandlerDictionary events)
 {
     logger     = new Logger(level, "RPC");
     serializer = new Serializer();
     trigger    = new RpcTrigger(logger, serializer);
     handler    = new ClientHandler(events);
 }
Exemplo n.º 2
0
        public void DispatchEvent(string eventName, Movie m = null, Button b = null)
        {
            if (m == null)
            {
                m = m_rootMovie;
            }
            int eventId = SearchEventId(eventName);

            if (eventId >= 0 && eventId < m_data.events.Length)
            {
                EventHandlerDictionary dict =
                    new EventHandlerDictionary(m_eventHandlers[eventId]);
                foreach (var h in dict)
                {
                    h.Value(m, b);
                }
            }
            else
            {
                EventHandlerDictionary dict = new EventHandlerDictionary(
                    m_genericEventHandlerDictionary[eventName]);
                foreach (var h in dict)
                {
                    h.Value(m, b);
                }
            }
        }
Exemplo n.º 3
0
        public BaseSection(Trainer trainer)
        {
            Trainer       = trainer;
            Config        = trainer.Config;
            EventHandlers = trainer.EventHandlers;

            Trainer.DebugLine($"Loading {this.GetType().Name}.");
        }
Exemplo n.º 4
0
        public Movie(LWF lwf, Movie parent, int objId, int instId, int matrixId = 0,
                     int colorTransformId       = 0, bool attached = false,
                     MovieEventHandlers handler = null, string n   = null)
            : base(lwf, parent,
                   attached ? Type.ATTACHEDMOVIE : Type.MOVIE, objId, instId)
        {
            m_data             = lwf.data.movies[objId];
            m_matrixId         = matrixId;
            m_colorTransformId = colorTransformId;
            m_totalFrames      = m_data.frames;

            if (!String.IsNullOrEmpty(n))
            {
                m_name = n;
            }
            m_instanceHead               = null;
            m_instanceTail               = null;
            m_currentFrameInternal       = -1;
            m_execedFrame                = -1;
            m_animationPlayedFrame       = -1;
            m_lastControlOffset          = -1;
            m_lastControls               = -1;
            m_lastHasButton              = false;
            m_lastControlAnimationOffset = -1;
            m_skipped               = false;
            m_postLoaded            = false;
            m_active                = true;
            m_visible               = true;
            m_playing               = true;
            m_jumped                = false;
            m_overriding            = false;
            m_attachMovieExeced     = false;
            m_attachMoviePostExeced = false;
            m_movieExecCount        = -1;
            m_postExecCount         = -1;

            m_property = new Property(lwf);

            m_matrix0         = new Matrix();
            m_matrix1         = new Matrix();
            m_colorTransform0 = new ColorTransform();
            m_colorTransform1 = new ColorTransform();

            m_displayList = new Object[m_data.depths];

            PlayAnimation(ClipEvent.LOAD);

            m_eventHandlers = new EventHandlerDictionary();
            m_handler       = new MovieEventHandlers();
            m_handler.Add(lwf.GetMovieEventHandlers(this));
            m_handler.Add(handler);
            if (!m_handler.Empty())
            {
                m_handler.Call(EventType.LOAD, this);
            }

            lwf.ExecMovieCommand();
        }
Exemplo n.º 5
0
        public static void Init(EventHandlerDictionary events)
        {
            if (EventHandlers != null)
            {
                return;
            }
            EventHandlers = events;

            EventHandlers.Add("fivelife.database.response", new Action <int, string>(OnDataReceived));
        }
Exemplo n.º 6
0
        public static async Task Init(string resourceName, EventHandlerDictionary eventHandlers)
        {
            await _rootResponder.Init(resourceName);

            RegisterNuiCallbackType("message");
            eventHandlers["__cfx_nui:message"] += new Action <dynamic>(data =>
            {
                Debug.WriteLine(JsonConvert.SerializeObject(data));
                _rootResponder.Handle(data);
            });
        }
Exemplo n.º 7
0
        public void Initialise(EventHandlerDictionary handlers)
        {
            foreach (Service service in this)
            {
                service.Initialise();

                foreach (var e in service.Events)
                {
                    handlers[e.Key] += e.Value;
                }
            }
        }
Exemplo n.º 8
0
 // Token: 0x06000016 RID: 22 RVA: 0x000027B8 File Offset: 0x000009B8
 public void RegisterEventHandler(string name, Delegate action)
 {
     try
     {
         EventHandlerDictionary eventHandlers = base.EventHandlers;
         eventHandlers[name] += action;
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.ToString());
     }
 }
Exemplo n.º 9
0
        public void RemoveEventHandler(int eventId, int id)
        {
            if (eventId < 0 || eventId >= m_data.events.Length)
            {
                return;
            }
            EventHandlerDictionary dict = m_eventHandlers[eventId];

            if (dict == null)
            {
                return;
            }
            dict.Remove(id);
        }
Exemplo n.º 10
0
        public static IEnumerable <Delegate> RegisterEventHandlers(EventHandlerDictionary handlerDictionary, object obj)
        {
            return(obj.GetType().GetMethodsEx(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
                   .Where(method => method.GetCustomAttribute <EventHandlerAttribute>() != null)
                   .Select(method =>
            {
                var eventName = method.GetCustomAttribute <EventHandlerAttribute>().Name;
                var parameters = method.GetParameters().Select(p => p.ParameterType).ToArray();
                var actionType = Expression.GetDelegateType(parameters.Concat(new[] { typeof(void) }).ToArray());

                var @delegate = Delegate.CreateDelegate(actionType, obj, method.Name);
                handlerDictionary[eventName] += @delegate;
                return @delegate;
            })
                   .ToArray());
        }
Exemplo n.º 11
0
        public int AddEventHandler(int eventId, EventHandler eventHandler)
        {
            if (eventId < 0 || eventId >= m_data.events.Length)
            {
                return(-1);
            }
            EventHandlerDictionary dict = m_eventHandlers[eventId];

            if (dict == null)
            {
                dict = new EventHandlerDictionary();
                m_eventHandlers[eventId] = dict;
            }
            int id = GetEventOffset();

            dict.Add(id, eventHandler);
            return(id);
        }
Exemplo n.º 12
0
	public int AddEventHandler(string eventName, EventHandler eventHandler)
	{
		int eventId = SearchEventId(eventName);
		int id;
		if (eventId >= 0 && eventId < m_data.events.Length) {
			id = AddEventHandler(eventId, eventHandler);
		} else {
			EventHandlerDictionary dict;
			if (!m_genericEventHandlerDictionary.TryGetValue(
					eventName, out dict)) {
				dict = new EventHandlerDictionary();
				m_genericEventHandlerDictionary[eventName] = dict;
			}
			id = GetEventOffset();
			dict.Add(id, eventHandler);
		}
		return id;
	}
Exemplo n.º 13
0
        public void RemoveEventHandler(string eventName, int id)
        {
            int eventId = SearchEventId(eventName);

            if (eventId >= 0 && eventId < m_data.events.Length)
            {
                RemoveEventHandler(eventId, id);
            }
            else
            {
                EventHandlerDictionary dict =
                    m_genericEventHandlerDictionary[eventName];
                if (dict == null)
                {
                    return;
                }
                dict.Remove(id);
            }
        }
Exemplo n.º 14
0
        public int AddEventHandler(string eventName, EventHandler eventHandler)
        {
            int eventId = SearchEventId(eventName);
            int id;

            if (eventId >= 0 && eventId < m_data.events.Length)
            {
                id = AddEventHandler(eventId, eventHandler);
            }
            else
            {
                EventHandlerDictionary dict;
                if (!m_genericEventHandlerDictionary.TryGetValue(
                        eventName, out dict))
                {
                    dict = new EventHandlerDictionary();
                    m_genericEventHandlerDictionary[eventName] = dict;
                }
                id = GetEventOffset();
                dict.Add(id, eventHandler);
            }
            return(id);
        }
Exemplo n.º 15
0
 public ServerHandler(EventHandlerDictionary events)
 {
     this.events = events;
 }
Exemplo n.º 16
0
        // Token: 0x0600000C RID: 12 RVA: 0x000025B0 File Offset: 0x000007B0
        public void RegisterEventHandler(string name, Delegate action)
        {
            EventHandlerDictionary eventHandlers = base.EventHandlers;

            eventHandlers[name] += action;
        }
Exemplo n.º 17
0
 public ClientHandler(EventHandlerDictionary events)
 {
     this.events = events;
 }
Exemplo n.º 18
0
        public Movie(LWF lwf, Movie parent, int objId, int instId, int matrixId = 0,
                     int colorTransformId       = 0, bool attached = false,
                     MovieEventHandlers handler = null, string n   = null)
            : base(lwf, parent,
                   attached ? Type.ATTACHEDMOVIE : Type.MOVIE, objId, instId)
        {
            m_data             = lwf.data.movies[objId];
            m_matrixId         = matrixId;
            m_colorTransformId = colorTransformId;
            m_totalFrames      = m_data.frames;

            if (!String.IsNullOrEmpty(n))
            {
                m_name = n;
            }
            m_instanceHead               = null;
            m_instanceTail               = null;
            m_currentFrameInternal       = -1;
            m_execedFrame                = -1;
            m_animationPlayedFrame       = -1;
            m_lastControlOffset          = -1;
            m_lastControls               = -1;
            m_lastHasButton              = false;
            m_lastControlAnimationOffset = -1;
            m_skipped               = false;
            m_postLoaded            = false;
            m_active                = true;
            m_visible               = true;
            m_playing               = true;
            m_jumped                = false;
            m_overriding            = false;
            m_attachMovieExeced     = false;
            m_attachMoviePostExeced = false;
            m_movieExecCount        = -1;
            m_postExecCount         = -1;
            m_blendMode             = (int)Constant.BLEND_MODE_NORMAL;

            m_property = new Property(lwf);

            m_matrix0         = new Matrix();
            m_matrix1         = new Matrix();
            m_colorTransform0 = new ColorTransform();
            m_colorTransform1 = new ColorTransform();

            m_displayList = new Object[m_data.depths];

#if LWF_USE_LUA
            m_isRoot = objId == lwf.data.header.rootMovieId;
            if (m_isRoot)
            {
                lwf.GetFunctionsLua(objId, out m_rootLoadFunc, out m_rootPostLoadFunc,
                                    out m_rootUnloadFunc, out m_rootEnterFrameFunc, true);
            }
            lwf.GetFunctionsLua(objId,
                                out m_loadFunc, out m_postLoadFunc, out m_unloadFunc, out m_enterFrameFunc, false);

            if (m_isRoot && !String.IsNullOrEmpty(m_rootLoadFunc))
            {
                lwf.CallFunctionLua(m_rootLoadFunc, this);
            }
            if (m_loadFunc != String.Empty)
            {
                lwf.CallFunctionLua(m_loadFunc, this);
            }
#endif
            PlayAnimation(ClipEvent.LOAD);

            m_eventHandlers = new EventHandlerDictionary();
            m_handler       = new MovieEventHandlers();
            m_handler.Add(lwf.GetMovieEventHandlers(this));
            m_handler.Add(handler);
            if (!m_handler.Empty())
            {
                m_handler.Call(EventType.LOAD, this);
            }

            lwf.ExecMovieCommand();
        }
Exemplo n.º 19
0
	public Movie(LWF lwf, Movie parent, int objId, int instId, int matrixId = 0,
			int colorTransformId = 0, bool attached = false,
			MovieEventHandlers handler = null, string n = null)
		: base(lwf, parent,
			attached ? Type.ATTACHEDMOVIE : Type.MOVIE, objId, instId)
	{
		m_data = lwf.data.movies[objId];
		m_matrixId = matrixId;
		m_colorTransformId = colorTransformId;
		m_totalFrames = m_data.frames;

		if (!String.IsNullOrEmpty(n))
			m_name = n;
		m_instanceHead = null;
		m_instanceTail = null;
		m_currentFrameInternal = -1;
		m_execedFrame = -1;
		m_animationPlayedFrame = -1;
		m_lastControlOffset = -1;
		m_lastControls = -1;
		m_lastHasButton = false;
		m_lastControlAnimationOffset = -1;
		m_skipped = false;
		m_postLoaded = false;
		m_active = true;
		m_visible = true;
		m_playing = true;
		m_jumped = false;
		m_overriding = false;
		m_attachMovieExeced = false;
		m_attachMoviePostExeced = false;
		m_movieExecCount = -1;
		m_postExecCount = -1;
		m_blendMode = (int)Constant.BLEND_MODE_NORMAL;

		m_property = new Property(lwf);

		m_matrix0 = new Matrix();
		m_matrix1 = new Matrix();
		m_colorTransform0 = new ColorTransform();
		m_colorTransform1 = new ColorTransform();

		m_displayList = new Object[m_data.depths];

#if LWF_USE_LUA
		m_isRoot = objId == lwf.data.header.rootMovieId;
		if (m_isRoot) {
			lwf.GetFunctionsLua(objId, out m_rootLoadFunc, out m_rootPostLoadFunc,
				out m_rootUnloadFunc, out m_rootEnterFrameFunc, true);
		}
		lwf.GetFunctionsLua(objId,
			out m_loadFunc, out m_postLoadFunc, out m_unloadFunc, out m_enterFrameFunc, false);

		if (m_isRoot && !String.IsNullOrEmpty(m_rootLoadFunc))
			lwf.CallFunctionLua(m_rootLoadFunc, this);
		if (m_loadFunc != String.Empty)
			lwf.CallFunctionLua(m_loadFunc, this);
#endif
		PlayAnimation(ClipEvent.LOAD);

		m_eventHandlers = new EventHandlerDictionary();
		m_handler = new MovieEventHandlers();
		m_handler.Add(lwf.GetMovieEventHandlers(this));
		m_handler.Add(handler);
		if (!m_handler.Empty())
			m_handler.Call(EventType.LOAD, this);

		lwf.ExecMovieCommand();
	}
Exemplo n.º 20
0
	public void DispatchEvent(string eventName)
	{
		switch (eventName) {
		case "load":
			m_handler.Call(EventType.LOAD, this);
			break;
		case "postLoad":
			m_handler.Call(EventType.POSTLOAD, this);
			break;
		case "unload":
			m_handler.Call(EventType.UNLOAD, this);
			break;
		case "enterFrame":
			m_handler.Call(EventType.ENTERFRAME, this);
			break;
		case "update":
			m_handler.Call(EventType.UPDATE, this);
			break;
		case "render":
			m_handler.Call(EventType.RENDER, this);
			break;
		default:
			{
				EventHandlerDictionary dict;
				if (m_eventHandlers.TryGetValue(eventName, out dict)) {
					dict = new EventHandlerDictionary(dict);
					foreach (var h in dict)
						h.Value();
				}
			}
			break;
		}
	}
Exemplo n.º 21
0
 internal static void Configure(LogLevel level, EventHandlerDictionary eventHandler, PlayerList playerList)
 {
     logger  = new Logger(level, "RPC");
     events  = eventHandler;
     players = playerList;
 }
Exemplo n.º 22
0
	public int AddEventHandler(int eventId, EventHandler eventHandler)
	{
		if (eventId < 0 || eventId >= m_data.events.Length)
			return -1;
		EventHandlerDictionary dict = m_eventHandlers[eventId];
		if (dict == null) {
			dict = new EventHandlerDictionary();
			m_eventHandlers[eventId] = dict;
		}
		int id = GetEventOffset();
		dict.Add(id, eventHandler);
		return id;
	}
Exemplo n.º 23
0
 internal static void Configure(EventHandlerDictionary eventHandler)
 {
     _events = eventHandler;
 }
Exemplo n.º 24
0
 public static void Configure(LogLevel level, EventHandlerDictionary eventHandler, PlayerList playerList)
 {
     _logger  = new FivemCommunicationsLogger(level, "RPC");
     _events  = eventHandler;
     _players = playerList;
 }
Exemplo n.º 25
0
 public void RegisterPlayerManagerNetworkEvents(EventHandlerDictionary ev)
 {
     ev["playerDropped"] += new Action <CitizenFX.Core.Player, string>(OnPlayerDropped);
 }
Exemplo n.º 26
0
	public void DispatchEvent(string eventName, Movie m = null, Button b = null)
	{
		if (m == null)
			m = m_rootMovie;
		int eventId = SearchEventId(eventName);
		if (eventId >= 0 && eventId < m_data.events.Length) {
			EventHandlerDictionary dict =
				new EventHandlerDictionary(m_eventHandlers[eventId]);
			foreach (var h in dict)
				h.Value(m, b);
		} else {
			EventHandlerDictionary dict = new EventHandlerDictionary(
				m_genericEventHandlerDictionary[eventName]);
			foreach (var h in dict)
				h.Value(m, b);
		}
	}
Exemplo n.º 27
0
 public NuiManager(EventHandlerDictionary events)
 {
     this.events = events;
 }
Exemplo n.º 28
0
 public static void Configure(EventHandlerDictionary events)
 {
     handler = new ServerHandler(events);
 }
Exemplo n.º 29
0
 public void Init(string cs, dynamic esx, EventHandlerDictionary ev)
 {
     ConnectionString = cs;
     ESX = esx;
     ev["onResourceStop"] += new Action <string>(OnResourceStop);
 }
Exemplo n.º 30
0
 public RemoteCallService(EventHandlerDictionary eventHandlerDictionary, IEnumerable <IRemote> remotes) : base(remotes)
 {
     _eventHandlerDictionary = eventHandlerDictionary;
 }
Exemplo n.º 31
0
	public void PlayAnimation(
		int animationId, Movie movie, Button button = null)
	{
		int i = 0;
		int[] animations = m_data.animations[animationId];
		Movie target = movie;

		for (;;) {
			switch ((Animation)animations[i++]) {
			case Animation.END:
				return;

			case Animation.PLAY:
				target.Play();
				break;

			case Animation.STOP:
				target.Stop();
				break;

			case Animation.NEXTFRAME:
				target.NextFrame();
				break;

			case Animation.PREVFRAME:
				target.PrevFrame();
				break;

			case Animation.GOTOFRAME:
				target.GotoFrameInternal(animations[i++]);
				break;

			case Animation.GOTOLABEL:
				target.GotoFrame(SearchFrame(target, animations[i++]));
				break;

			case Animation.SETTARGET:
				{
					target = movie;

					int count = animations[i++];
					if (count == 0)
						break;

					for (int j = 0; j < count; ++j) {
						int instId = animations[i++];

						switch ((Animation)instId) {
						case Animation.INSTANCE_TARGET_ROOT:
							target = m_rootMovie;
							break;

						case Animation.INSTANCE_TARGET_PARENT:
							target = target.parent;
							if (target == null)
								target = m_rootMovie;
							break;

						default:
							{
								target = target.SearchMovieInstanceByInstanceId(
									instId, false);
								if (target == null)
									target = movie;
								break;
							}
						}
					}
				}
				break;

			case Animation.EVENT:
				{
					int eventId = animations[i++];
#if LWF_USE_LUA
					CallEventFunctionLua(eventId, movie, button);
#endif
					if (m_eventHandlers[eventId] != null) {
						var handlers = new EventHandlerDictionary(
							m_eventHandlers[eventId]);
						foreach (var h in handlers)
							h.Value(movie, button);
					}
				}
				break;

			case Animation.CALL:
#if LWF_USE_LUA
				{
					int stringId = animations[i++];
					if (stringId < 0 || stringId >= data.strings.Length)
						break;
					CallFunctionLua(data.strings[stringId], target);
				}
#else
				i++;
#endif
				break;
			}
		}
	}
Exemplo n.º 32
0
 public BaseScriptProxy(EventHandlerDictionary eventHandlers, ExportDictionary exports, PlayerList players)
 {
     this.EventHandlers = eventHandlers;
     this.Exports       = exports;
     this.Players       = players;
 }
Exemplo n.º 33
0
	public int AddEventHandler(string eventName, EventHandler eventHandler)
	{
		int id = m_lwf.GetEventOffset();
		EventHandlerDictionary dict;
		if (!m_eventHandlers.TryGetValue(eventName, out dict)) {
			dict = new EventHandlerDictionary();
			m_eventHandlers[eventName] = dict;
		}
		dict.Add(id, eventHandler);

		return id;
	}
Exemplo n.º 34
0
        public void PlayAnimation(
            int animationId, Movie movie, Button button = null)
        {
            int i = 0;

            int[] animations = m_data.animations[animationId];
            Movie target     = movie;

            for (;;)
            {
                switch ((Animation)animations[i++])
                {
                case Animation.END:
                    return;

                case Animation.PLAY:
                    target.Play();
                    break;

                case Animation.STOP:
                    target.Stop();
                    break;

                case Animation.NEXTFRAME:
                    target.NextFrame();
                    break;

                case Animation.PREVFRAME:
                    target.PrevFrame();
                    break;

                case Animation.GOTOFRAME:
                    target.GotoFrameInternal(animations[i++]);
                    break;

                case Animation.GOTOLABEL:
                    target.GotoFrame(SearchFrame(target, animations[i++]));
                    break;

                case Animation.SETTARGET:
                {
                    target = movie;

                    int count = animations[i++];
                    if (count == 0)
                    {
                        break;
                    }

                    for (int j = 0; j < count; ++j)
                    {
                        int instId = animations[i++];

                        switch ((Animation)instId)
                        {
                        case Animation.INSTANCE_TARGET_ROOT:
                            target = m_rootMovie;
                            break;

                        case Animation.INSTANCE_TARGET_PARENT:
                            target = target.parent;
                            if (target == null)
                            {
                                target = m_rootMovie;
                            }
                            break;

                        default:
                        {
                            target = target.SearchMovieInstanceByInstanceId(
                                instId, false);
                            if (target == null)
                            {
                                target = movie;
                            }
                            break;
                        }
                        }
                    }
                }
                break;

                case Animation.EVENT:
                {
                    int eventId = animations[i++];
#if LWF_USE_LUA
                    CallEventFunctionLua(eventId, movie, button);
#endif
                    if (m_eventHandlers[eventId] != null)
                    {
                        var handlers = new EventHandlerDictionary(
                            m_eventHandlers[eventId]);
                        foreach (var h in handlers)
                        {
                            h.Value(movie, button);
                        }
                    }
                }
                break;

                case Animation.CALL:
#if LWF_USE_LUA
                {
                    int stringId = animations[i++];
                    if (stringId < 0 || stringId >= data.strings.Length)
                    {
                        break;
                    }
                    CallFunctionLua(data.strings[stringId], target);
                }
#else
                    i++;
#endif
                    break;
                }
            }
        }
 public RemoteCallService(EventHandlerDictionary eventHandlerDictionary, IRemote[] remotes) : base(remotes)
 {
     _eventHandlerDictionary = eventHandlerDictionary;
 }