예제 #1
0
 /// <summary>
 /// Registers with the given selector's listeners.
 /// </summary>
 private void RegisterSelector(SmartObjectSelector selector, int index)
 {
     selectors.Add(selector);
     selector.OnObjectChanged += (SmartObject o, SmartObject n) => Replace(involvedObjects, o, n);
     if (selector.IsParticipant)
     {
         selector.OnObjectChanged += (SmartObject o, SmartObject n) => Replace(participants, o, n);
     }
     selector.OnObjectChanged += (SmartObject o, SmartObject n) => OnSelect(o, n, index);
 }
예제 #2
0
 public ParticipantConnector(int index, EventStub eventStub, MainWindow window)
 {
     this.index = index;
     this.eventStub = eventStub;
     this.window = window;
     this.selector = eventStub.GetSelectorForIndex(index);
     this.compatibleSmartObjects = new List<ContentRectangle<SmartObject>>();
     this.leftOffset = CalculateLeftOffset();
 }
예제 #3
0
 /// <summary>
 /// Analyze the signatures to create the necessary selectors.
 /// </summary>
 /// <param name="signatures">The list of signatures for this event.</param>
 private void AnalyzeSignatures(IList<EventSignature> signatures)
 {
     Type[] types = signatures.First().RequiredTypes;
     NonParticipantAttribute[] attrs = signatures.First().GetAttributes<NonParticipantAttribute>();
     NonParticipantAttribute attribute = (attrs.Length > 0) ? attrs[0] : new NonParticipantAttribute();
     //The maximal index still shown in the GUI.
     int maxShownIndex = signatures.Min((EventSignature sig) => sig.ParameterCount);
     IsImplicitAttribute[] maxIndex = signatures.First().GetAttributes<IsImplicitAttribute>();
     maxShownIndex = (maxIndex.Length > 0) ? 
         Mathf.Min(maxIndex[0].FirstImplicitIndex, maxShownIndex) : maxShownIndex;
     for (int index = 0; index < maxShownIndex; index++)
     {
         Type type = types[index];
         //We only allow SmartObject parameters.
         if (typeof(SmartObject).IsAssignableFrom(type))
         {
             List<IList<StateName>> roles = new List<IList<StateName>>();
             for (int i = 0; i < signatures.Count; i++)
             {
                 roles.Add(ExtractRoles(signatures[i].StateReqs.
                     Where((StateCondition s) => s.Index == index)));
             }
             SmartObjectSelector selector = new SmartObjectSelector(type, roles.ToArray(), !attribute.Indices.Contains(index));
             RegisterSelector(selector, index);
         }
         else
         {
             Debug.LogError("Unrecognized type " + type.Name + " in Event signature " + Signature.Name);
             throw new Exception();
         }
     }
 }