public void AttachInput(string sceneName, string inputMethod, string parameter, float executionDelay, SignalProcessor localProcessor) { var l = new OutputEventListener() { targetProcessorName = sceneName, method = inputMethod, param = parameter, delay = executionDelay }; l.FindTargetProcessors(localProcessor); registeredListeners.Add(l); }
private Dictionary<string, string[]> inputMapping; // must be arrays because they are used from the unity GUI which does not work on lists #endregion Fields #region Constructors public SignalDataCache(SignalProcessor localProcessor, OutputEventListener listener) { // Generates data. // This is a more or lesss expensive task which is why the results are stored for later re-use. listener.matchedProcessors.Clear(); // expensive but it's not used THAT often Dictionary<string, List<string>> inputMap = new Dictionary<string, List<string>>(); if (!string.IsNullOrEmpty(listener.targetProcessorName)) { // check if target processor name is okay // Here come some exceptions. We can reference !self as target which means target is local processor if (listener.targetProcessorName == "!self") { listener.matchedProcessors.Add(localProcessor); } else { var hits = UnityEngine.Object.FindObjectsOfType<SignalProcessor>(); for (int i = 0; i < hits.Length; ++i) { if (!hits[i].name.StartsWith(listener.targetProcessorName, StringComparison.Ordinal)) { continue; } listener.matchedProcessors.Add(hits[i]); if (hits[i].InputFuncs.Count == 0) { UnityEngine.Debug.LogError("No inputfunc components on processor " + hits[i].name); } foreach (var kvp in hits[i].InputFuncs) { if (!inputMap.ContainsKey(kvp.Key)) { inputMap.Add(kvp.Key, new List<string>()); } for (int j = 0; j < kvp.Value.Count; ++j) { inputMap[kvp.Key].Add(kvp.Value[j].Name); } } } } } this.inputMapping = new Dictionary<string, string[]>(inputMap.Count); componentList = new string[inputMap.Count]; int k = 0; // This is a bit of a waste but apparently it has to happen, after all. // Unitys popup elements don't support lists foreach (var kvp in inputMap) { inputMapping.Add(kvp.Key, kvp.Value.ToArray()); componentList[k] = kvp.Key; ++k; } }
public void GenerateCacheData(SignalProcessor localProcessor, OutputEventListener l) { cache = new SignalDataCache(localProcessor, l); }