private static ActionView ReadActionView(StageElement ave, QualifierView parent) { var connectorType = ave.AttributeValueOrDefault <string>(AttributeName.ConnectorType, null); ActionView av; if (connectorType == ConnectorType.Selector) { av = new SelectorActionView(); } else if (connectorType == ConnectorType.AILink) { av = new AILinkActionView(); } else if (connectorType == ConnectorType.Composite) { av = new CompositeActionView(); } else { av = new ActionView(); } av.name = ave.ValueOrDefault <string>(ElementName.Name, null); av.description = ave.ValueOrDefault <string>(ElementName.Description, null); av.parent = parent; return(av); }
internal bool Connect(QualifierView qv, TopLevelView targetView) { ActionView av = null; var sv = targetView as SelectorView; if (sv != null) { if (sv.selector.IsConnectedTo(qv.parent.selector)) { EditorUtility.DisplayDialog("Invalid Action", "Circular connections are not allowed.", "Ok"); return(false); } //Composite actions may also act as selectors as the last step var cav = qv.actionView as CompositeActionView; if (cav != null) { var ca = (CompositeAction)cav.action; var newConnector = new SelectorAction(sv.selector); _undoRedo.Do(new ConnectCompositeOperation(cav, ca.connectorAction, newConnector)); ca.connectorAction = newConnector; cav.targetView = null; return(true); } av = new SelectorActionView { targetSelector = sv, action = new SelectorAction(sv.selector), parent = qv }; } var lv = targetView as AILinkView; if (lv != null) { var cav = qv.actionView as CompositeActionView; if (cav != null) { var ca = (CompositeAction)cav.action; var newConnector = new AILinkAction(lv.aiId); _undoRedo.Do(new ConnectCompositeOperation(cav, ca.connectorAction, newConnector)); ca.connectorAction = newConnector; cav.targetView = null; return(true); } av = new AILinkActionView { targetAI = lv, action = new AILinkAction(lv.aiId), parent = qv }; } if (av != null) { SetAction(av, qv); return(true); } return(false); }