public void AddListener <T>(Entity condition, ProvenceDelegate <T> del, int stage = 0) where T : ARGTYPE { if (condition == null) { Debug.Log("Missing Condition"); return; } if (!conditionalDelegates.ContainsKey(condition)) { conditionalDelegates[condition] = new Dictionary <int, Dictionary <Type, Delegate> >(); } if (!conditionalDelegates[condition].ContainsKey(stage)) { conditionalDelegates[condition][stage] = new Dictionary <Type, Delegate>(); } if (conditionalDelegates[condition][stage].ContainsKey(typeof(T))) { Delegate tempDel = conditionalDelegates[condition][stage][typeof(T)]; conditionalDelegates[condition][stage][typeof(T)] = Delegate.Combine(tempDel, del); } else { conditionalDelegates[condition][stage][typeof(T)] = del; } conditionalDelegates[condition] = conditionalDelegates[condition].OrderBy(d => d.Key).ToDictionary(d => d.Key, d => d.Value); }
public void AddWorld(World world, ProvenceDelegate <WorldRegistrationComplete> regEvent = null) { if (!worlds.ContainsKey(world.id)) { worlds[world.id] = world; if (regEvent != null) { world.eventManager.AddListener <WorldRegistrationComplete>(regEvent, 10); } if (UnityHelpers.IsCurrentScene(world.worldName)) { world.Initialize(); } else { if (UnityHelpers.SceneExists(world.worldName)) { //load async then init. UnityHelpers.LoadSceneAsync(world.worldName, () => { Debug.Log("async load: " + world.worldName); world.Initialize(); }); } else { world.Initialize(); } } } }
public static void Open(World world, ProvenceDelegate <MainframeKeySelection <Entity> > callback) { EntitySelector.Close <EntitySelector>(); EntitySelector window = MainframeSelectorWindow <Entity> .Open <EntitySelector>("Entity Selector", callback); window.eventManager.Raise <SetSelectorParameters <World> >(new SetSelectorParameters <World>(world)); }
public static void Open(TypeSelectorParameters args, ProvenceDelegate <MainframeKeySelection <Type> > callback) { TypeSelector.Close <TypeSelector>(); TypeSelector window = MainframeSelectorWindow <Type> .Open <TypeSelector>("Type Selector", callback); window.eventManager.Raise <SetSelectorParameters <TypeSelectorParameters> >(new SetSelectorParameters <TypeSelectorParameters>(args)); }
public static M Open <M>(string title, ProvenceDelegate <MainframeKeySelection <T> > callback) where M : MainframeSelectorWindow <T> { M window = GetWindow <M>(); window.titleContent = new GUIContent(title); window.eventManager.AddListener <MainframeKeySelection <T> >(callback); return(window); }
public World AddWorld(string id, ProvenceDelegate <WorldRegistrationComplete> regEvent = null) { if (string.IsNullOrEmpty(id)) { return(null); } World current = Helpers.LoadFromSerializedFile <World>(ProvenceCollection <AssetData> .dataPath + "/Worlds/" + id + ".meglo"); if (current.id == id) { AddWorld(current, regEvent); return(current); } return(null); }
public void AddListener <T> (ProvenceDelegate <T> del, int stage = 0) where T : ARGTYPE { if (!delegates.ContainsKey(stage)) { delegates[stage] = new Dictionary <Type, Delegate>(); } if (delegates[stage].ContainsKey(typeof(T))) { Delegate tempDel = delegates[stage][typeof(T)]; delegates[stage][typeof(T)] = Delegate.Combine(tempDel, del); } else { delegates[stage][typeof(T)] = del; } delegates = delegates.OrderBy(d => d.Key).ToDictionary(d => d.Key, d => d.Value); }
public void RemoveListener <T> (ProvenceDelegate <T> del) where T : ARGTYPE { foreach (Dictionary <Type, Delegate> dict in delegates.Values) { if (dict.ContainsKey(typeof(T))) { var currentDel = Delegate.Remove(dict[typeof(T)], del); if (currentDel == null) { dict.Remove(typeof(T)); } else { dict[typeof(T)] = currentDel; } } } }
public void RemoveListener <T>(Entity condition, ProvenceDelegate <T> del) where T : ARGTYPE { if (!conditionalDelegates.ContainsKey(condition)) { return; } foreach (Dictionary <Type, Delegate> dict in conditionalDelegates[condition].Values) { if (dict.ContainsKey(typeof(T))) { var currentDel = Delegate.Remove(dict[typeof(T)], del); if (currentDel == null) { dict.Remove(typeof(T)); } else { dict[typeof(T)] = currentDel; } } } }
public static void Open(ProvenceDelegate <MainframeKeySelection <int> > callback, int highestIndex = -1) { IndexSelector window = MainframeSelectorWindow <int> .Open <IndexSelector>("Index Selection", callback); window.highestIndex = highestIndex; }