private EventHandlerJob <T_Job, T_Event> GetJobSystem <T_Job, T_Event>() where T_Job : struct, IJobForEvent <T_Event> where T_Event : struct { Type jobType = typeof(T_Job); if (jobType == _cachedJobSystemType) { return((EventHandlerJob <T_Job, T_Event>)_cachedJobSystem); } IEventSystem system; if (!_jobSystemsCache.TryGetValue(typeof(T_Job), out system)) { system = new EventHandlerJob <T_Job, T_Event>(); _systems.Add(system); _jobSystemsCache[typeof(T_Job)] = system; } _cachedJobSystemType = jobType; _cachedJobSystem = system; return((EventHandlerJob <T_Job, T_Event>)system); }
/// <summary> /// Unsubscribe a job that processed during from an event. /// </summary> /// <param name="target">The target to unsubscribe from.</param> /// <param name="onComplete">The callback that is invoked when the job has finished.</param> /// <typeparam name="T_Job">The job type.</typeparam> /// <typeparam name="T_Event">The event type.</typeparam> public void UnsubscribeWithJob <T_Job, T_Event>(EventTarget target, Action <T_Job> onComplete) where T_Job : struct, IJobForEvent <T_Event> where T_Event : struct { EventHandlerJob <T_Job, T_Event> handler = GetJobSystem <T_Job, T_Event>(); handler.Unsubscribe(target, onComplete); }