public static void SubscribeToEvent(AObject subscriber, AObject sender, string eventType, AtomicEventDelegate function) { var eventTypeID = Atomic.StringToStringHash(eventType); Dictionary <uint, Subscription> subs; if (!subscriptions.TryGetValue(subscriber.RefID, out subs)) { subs = new Dictionary <uint, Subscription> (); subscriptions [subscriber.RefID] = subs; } Subscription sub; if (!subs.TryGetValue(eventTypeID, out sub)) { sub = new Subscription(); subs [eventTypeID] = sub; } sub.SenderRefID = sender == null ? 0 : sender.RefID; sub.Handler = function; List <uint> subscribers; if (!eventSubscribers.TryGetValue(eventTypeID, out subscribers)) { subscribers = new List <uint> (); eventSubscribers [eventTypeID] = subscribers; } if (!subscribers.Contains(subscriber.RefID)) { subscribers.Add(subscriber.RefID); } }
public static void Run() { while (Atomic.RunFrame()) { } }