public static void InitNodePopup(NodeBase node, NodeGraph graph) { currentNodePopupWindow = (NodeGraphPopupWindow)EditorWindow.GetWindow<NodeGraphPopupWindow>(); currentNodePopupWindow.node = node; currentNodePopupWindow.graph = graph; currentNodePopupWindow.title = "Create a new GraphNode"; }
public EventNode(EventWrapper evt, SetMemberNode node, bool isSubscription) { _Event = evt; _IsSubscription = isSubscription; _Node = node; _Callback = Expr.CastTransparent(node.Value, _Event.EventHandlerType); }
private RuleNode getLastRuleNode(NodeBase current) { if (!current.HasChild) { if (current is RuleNode) { return current as RuleNode; } else { return null; } } else { if (current.ChildNode is GroupNode) { return getLastRuleNode(((GroupNode)current.ChildNode).GroupRoot); } else { return getLastRuleNode(current.ChildNode); } } }
public virtual bool Connected(int i, NodeBase target) { return joints.Count != 0 && i > 0 && i < joints.Count && joints[i].TargetId == target.Id; }
public override IEnumerable<NodeBase> Expand(Context ctx, NodeBase expression, Label nextStatement) { foreach (var rule in KeyRule.Expand(ctx, Expr.GetMember(expression, "Key"), nextStatement)) yield return rule; foreach (var rule in ValueRule.Expand(ctx, Expr.GetMember(expression, "Value"), nextStatement)) yield return rule; }
public static New New2(BlockBase parent, string type, NodeBase length) { var ret = new New(); ret.Parent = parent; ret.type = TypeReference.New(Types.GetType(parent, type), true); ret.Length = length; return ret; }
public NodeUpdatedEvent(IAcSession acSession, NodeBase source, INodeUpdateIo output) : base(acSession, source) { if (output == null) { throw new System.ArgumentNullException("output"); } this.Output = output; }
public NodeJointPoint(Rect actionRect, Vector2 offset, NodeDrawableBase parent, NodeBase target = null) { ActionRect = actionRect; Offset = offset; Target = target != null ? target.FirstJoint : null; TargetId = target != null ? target.Id : NodeDrawableBase.NothingId; ParentId = parent.Id; //Debug.Log("in " + parent + ", ID=" + parent.ElementName); }
public override IEnumerable<NodeBase> Expand(Context ctx, NodeBase expression, Label nextStatement) { yield return Expr.If( Expr.NotEqual(Literal as NodeBase, expression), Expr.Block( Expr.JumpTo(nextStatement) ) ); }
public void FlashNode(NodeBase node) { if (node == null) return; this.flashNode = node; this.flashDuration = 0.0f; this.timerFlashItem.Enabled = true; this.folderView.EnsureVisible(this.folderView.FindNode(this.folderModel.GetPath(this.flashNode))); }
public NodeCursorEventArgs(NodeBase source, string command, object tag, int X, int Y, int ClickCount, GameUI.MouseButtons Button, GameUI.MouseClicks ClickType) : base(source, command, tag) { this.x = X; this.y = Y; this.clicks = ClickCount; this.button = Button; this.clicktype = ClickType; }
private NodeBase getEndNode(NodeBase current) { if (!current.HasChild) { return current; } else { return getEndNode(current.ChildNode); } }
/// <summary> /// Which joint is connected to that target. /// If fail, returns <code>IndexOfNothing</code>. /// </summary> /// <param name="target">target to check conection with</param> /// <returns><code>IndexOfNothing</code> if no such target at all, otherwise index of corresponding joint</returns> public virtual int Connected(NodeBase target) { for (var i = 0; i < joints.Count; ++i) { if (Connected(i, target)) { return i; } } return IndexOfNothing; }
private Call ConvertToCall(NodeBase v) { if (v is Call) return v as Call; if (v is Variant) return Call.NewName(parent, (v as Variant).Name); if (!(v is Member)) return Call.NewV(parent, v, null, null); var mem = v as Member; return Call.New(parent, mem.GetName(), mem.GetTarget(), null); }
private NodeBase ReadIndex(NodeBase target) { var t = Read(); if (t == "]" && target is Variant) return TypeOf.New(parent, Variant.NewName(parent, (target as Variant).Name + "[]")); else if (t != null) Rewind(); var ret = Index.New(parent, target, ReadExpression()); Check("配列", "]"); return ret; }
public void Test() { var tc = new TestClass(); var etc = new List<TestClass>(); var otc = new List<object>(); var nodeBase = new NodeBase(null, null); nodeBase.Register(otc); nodeBase.Get<IEnumerable<TestClass>>(); //TODO: this is the case needed by my immediate code }
public override IEnumerable<NodeBase> Expand(Context ctx, NodeBase expression, Label nextStatement) { for (var idx = 0; idx < ElementRules.Count; idx++) { var fieldName = string.Format("Item{0}", idx + 1); var rules = ElementRules[idx].Expand(ctx, Expr.GetMember(expression, fieldName), nextStatement); foreach (var rule in rules) yield return rule; } }
public override IEnumerable<NodeBase> Expand(Context ctx, NodeBase expression, Label nextStatement) { yield return Expr.If( Expr.Or( Expr.Less(expression, RangeStartRule.Literal as NodeBase), Expr.Greater(expression, RangeEndRule.Literal as NodeBase) ), Expr.Block( Expr.JumpTo(nextStatement) ) ); }
private static NodeBase CreateNode(Type nodeType, Type[] typeParameters, NodeBase targetNode, params object[] arguments) { var closedType = nodeType.MakeGenericType(typeParameters); var constructorArguments = new object[] {targetNode}.Union(arguments).ToArray(); var constructorArgumentTypes = constructorArguments.Select(x => x.GetType()).ToArray(); var constructor = closedType.GetConstructor(constructorArgumentTypes); if (constructor == null) throw new InvalidOperationException(); return (NodeBase) constructor.Invoke(constructorArguments); }
///// <summary>Create a catch node that will be associated with this try node ///// and will handle the given exception. A set of block node are to be bound ///// to the newly created catch node.</summary> ///// <param name="blocks">A collection of one or more blocks whose associated ///// instructions should be added to the new catch block.</param> ///// <param name="caughtException">An optional string that is the name of the class ///// of the caucght exception. A null reference denotes a catch-all block.</param> ///// <returns>The newly created node.</returns> ///// <remarks>The catch block creation order is meaningfull. Moreover once a ///// catch all block has been bound to the current instance no new catch block ///// could be associated with this instance.</remarks> //internal CatchNode AddCatch(ICollection<BlockNode> blocks, string caughtException = null) //{ // if (_catchAllAdded) { throw new InvalidOperationException(); } // if (null == caughtException) { _catchAllAdded = true; } // CatchNode result = new CatchNode(this); // GetRoot().MoveLeaves(result, blocks); // return result; //} /// <summary>TODO : Assert this method uselessness and remove.</summary> /// <param name="root"></param> /// <param name="wrappedNodes"></param> private static ICollection<NodeBase<AstNode>> BuildMoveList(NodeBase<AstNode> root, ICollection<NodeBase<AstNode>> wrappedNodes) { if (null == root) { throw new ArgumentNullException(); } if (null == wrappedNodes) { throw new ArgumentNullException(); } // The root node must not appear in the wrapped nodes list. if (wrappedNodes.Contains(root)) { throw new ArgumentException(); } List<NodeBase<AstNode>> result = new List<NodeBase<AstNode>>(); List<NodeBase<AstNode>> coveredNodes = new List<NodeBase<AstNode>>(); root.Walk(delegate(NodeBase<AstNode> scannedNode, WalkTraversal traversal, object context) { // Ignore root node which is not expected to be in the collection. if (scannedNode == root) { return WalkContinuation.Normal; } switch (traversal) { case WalkTraversal.CurrentNode: case WalkTraversal.BeforeTransit: if (object.ReferenceEquals(scannedNode.Parent, root)) { result.Add(scannedNode); } break; default: break; } try { // All encountered leaf nodes MUST be in the collection if (scannedNode.IsLeafNode) { if (!wrappedNodes.Contains(scannedNode)) { throw new ApplicationException(); } return WalkContinuation.Normal; } // An intermediate node that belongs to the collection implicitly // encompass all of is direct and indirect sons. Those don't need // to be in the collection. if (wrappedNodes.Contains(scannedNode)) { return WalkContinuation.SkipSons; } return WalkContinuation.Normal; } finally { if (!coveredNodes.Contains(scannedNode)) { coveredNodes.Add(scannedNode); } } }, WalkMode.TransitBeforeAndAfter); if (coveredNodes.Count != wrappedNodes.Count) { throw new ApplicationException(); } return result; }
private NodeBase AutoDelegate(Function f) { if (f == null) return null; var autoArgs = f.GetAutoArgs(); if (autoArgs == null) return f; var args = new NodeBase[autoArgs.Length]; for (int i = 0; i < args.Length; i++) args[i] = Var.NewName(parent, autoArgs[i].Name); var ret = DelgFunc.New(parent, f.CallType, args, f); ret.Auto = true; return ret; }
/* * AddNode */ public void AddNode(NodeBase nodeToAdd) { if (nodeToAdd == null) { throw new ArgumentNullException("nodeToAdd"); } nodeToAdd.ContainingProgram = this; /* If we are adding an input node, we need to set its index starting at 1 because of the on/off node. */ Int32 inputCount = 1; ProgramInput programInput = nodeToAdd as ProgramInput; if (programInput != null) { for (Int32 i = 0; i < _nodes.Count; i++) { if (_nodes[i] is ProgramInput) { inputCount++; } } programInput.InputIndex = inputCount; } /* If we are adding an output node, we need to set its index. */ Int32 outputCount = 0; ProgramOutput programOutput = nodeToAdd as ProgramOutput; if (programOutput != null) { for (Int32 i = 0; i < _nodes.Count; i++) { if (_nodes[i] is ProgramOutput) { outputCount++; } } programOutput.OutputIndex = outputCount; } _nodes.Add(nodeToAdd); UpdateParentNode(); }
public void CanSerializeNodesRecursively() { var sut = new NodeToFolderSerializer(new SystemIoFileSystem()); string rootPath = Path.GetFullPath("temp"); var node = new NodeBase {Name = "Root", Uri = new Uri("http://root")}; node.Children.Add(new TestNode { Name = "Barn", Uri = new Uri("http://root/barn"), HeadLine = "Mjallo", BirthDay = DateTime.Today}); sut.Serialize(rootPath, node, recursive: true); string nodePath = Path.Combine(rootPath, "Root"); File.Exists(Path.Combine(nodePath, "Properties.txt")).Should().BeTrue(); Directory.EnumerateFiles(nodePath).Count().Should().Be(1); Directory.EnumerateDirectories(nodePath).Count().Should().Be(1); string barnPath = Path.Combine(nodePath, "Barn"); Directory.EnumerateFiles(barnPath).Count().Should().Be(3); }
public override IEnumerable<NodeBase> Expand(Context ctx, NodeBase expression, Label nextStatement) { if (Type != null) { yield return Expr.If( Expr.Not(Expr.Is(expression, Type)), Expr.Block( Expr.JumpTo(nextStatement) ) ); } if (!IsWildcard) { yield return Expr.Set(Name, expression); } }
public override IEnumerable<NodeBase> Expand(Context ctx, NodeBase expression, Label nextStatement) { yield return MakeJumpIf( nextStatement, Expr.Not(Expr.Is(expression, Type)) ); foreach (var fieldRule in FieldRules) { var rules = fieldRule.Rule.Expand( ctx, Expr.GetMember(Expr.Cast(expression, Type), fieldRule.Name.FullSignature), nextStatement ); foreach(var rule in rules) yield return rule; } }
private NodeBase ReadCall(NodeBase target) { var fn = "call"; if (target is NodeBase) { var nb = target as NodeBase; fn = nb.Name; } var args = Arguments(",", ")", false); if (args == null) throw Abort("{0}: 引数が不完全です。", fn); if (target is Variant) return Call.New(parent, fn, null, args); if (target is Member) { var mem = target as Member; return Call.New(parent, "", mem, args); } return Call.NewV(parent, target, null, args); }
/// <summary> /// Expands the current rule into a block of checks. /// </summary> public CodeBlockNode ExpandRules(Context ctx, NodeBase expression, Label expressionLabel) { var block = new CodeBlockNode(); // rule is never true: do not emit its code at all if (Condition != null && Condition.IsConstant && Condition.ConstantValue == false) return block; // declare variables foreach (var binding in _BindingSet) block.Add(Expr.Var(binding.Name, binding.Type.FullName)); foreach (var rule in MatchRules) { // current and next labels for each rule var ruleLabels = ParentNode.GetRuleLabels(rule); block.Add(Expr.JumpLabel(ruleLabels.CurrentRule)); block.AddRange(rule.Expand(ctx, expression, ruleLabels.NextRule)); if (Condition != null) { block.Add( Expr.If( Expr.Not(Condition), Expr.Block(Expr.JumpTo(ruleLabels.NextRule)) ) ); } block.Add(Expr.JumpTo(expressionLabel)); } block.AddRange( Expr.JumpLabel(expressionLabel), Expression, Expr.JumpTo(ParentNode.EndLabel) ); return block; }
private NodeBase ReadMember(NodeBase target) { var mem = target as Member; var t2 = Read(); if (!Tokenizer.IsWord(t2)) { //Rewind(); throw Abort("名前が不適切です: {0}", t2); } var t2m = Member.New(parent, t2); if (mem != null) { mem.Append(t2m); return mem; } if (target is Variant) t2m.TargetType = (target as Variant).Name; else t2m.Target = target; return t2m; }
public override IEnumerable<NodeBase> Expand(Context ctx, NodeBase expression, Label nextStatement) { // no need for temporary variable: field access is idempotent yield return MakeJumpIf( nextStatement, Expr.Not( Expr.Is(expression, Type) ) ); var rules = LabelRule.Expand( ctx, Expr.GetMember( Expr.Cast(expression, Type), "Tag" ), nextStatement ); foreach (var rule in rules) yield return rule; }
/// <summary> /// Resolves the method if the expression was a member getter (obj.field or type::field). /// </summary> private void ResolveGetMember(Context ctx, GetMemberNode node) { _invocationSource = node.Expression; var type = _invocationSource != null ? _invocationSource.Resolve(ctx) : ctx.ResolveType(node.StaticType); CheckTypeInSafeMode(ctx, type); if (node.TypeHints != null && node.TypeHints.Count > 0) { _typeHints = node.TypeHints.Select(x => ctx.ResolveType(x, true)).ToArray(); } try { // resolve a normal method try { _method = ctx.ResolveMethod( type, node.MemberName, ArgTypes, _typeHints, (idx, types) => ctx.ResolveLambda(Arguments[idx] as LambdaNode, types) ); if (_method.IsStatic) { _invocationSource = null; } return; } catch (KeyNotFoundException) { if (_invocationSource == null) { throw; } } // resolve a callable field try { ctx.ResolveField(type, node.MemberName); ResolveExpression(ctx, node); return; } catch (KeyNotFoundException) { } // resolve a callable property try { ctx.ResolveProperty(type, node.MemberName); ResolveExpression(ctx, node); return; } catch (KeyNotFoundException) { } Arguments = (Arguments[0] is UnitNode) ? new List <NodeBase> { _invocationSource } : new[] { _invocationSource }.Union(Arguments).ToList(); var oldArgTypes = ArgTypes; ArgTypes = Arguments.Select(a => a.Resolve(ctx)).ToArray(); _invocationSource = null; try { // resolve a local function that is implicitly used as an extension method _method = ctx.ResolveMethod( ctx.MainType.TypeInfo, node.MemberName, ArgTypes, resolver: (idx, types) => ctx.ResolveLambda(Arguments[idx] as LambdaNode, types) ); return; } catch (KeyNotFoundException) { } // resolve a declared extension method // most time-consuming operation, therefore is last checked try { if (!ctx.Options.AllowExtensionMethods) { throw new KeyNotFoundException(); } _method = ctx.ResolveExtensionMethod( type, node.MemberName, oldArgTypes, _typeHints, (idx, types) => ctx.ResolveLambda(Arguments[idx] as LambdaNode, types) ); } catch (KeyNotFoundException) { var msg = node.StaticType != null ? CompilerMessages.TypeStaticMethodNotFound : CompilerMessages.TypeMethodNotFound; Error(msg, type, node.MemberName); } } catch (AmbiguousMatchException) { Error(CompilerMessages.TypeMethodInvocationAmbiguous, type, node.MemberName); } }
private void OnCurrentDialogueNodeChanged(NodeBase before, NodeBase after) { FireEvent("OnCurrentDialogueNodeChanged", (int)after.index); }
public bool CanConnectEdgeFromNode(NodeBase node) { return(true); }
public void OpenExecute(string openFileName, bool readOnly) { if (dirty) { // give the user a chance to save DialogResult result = messagingService.Value.ShowDialog( Resources.Strings.Solution_Confirm_DoYouWantToSave, Resources.Strings.Solution_Confirm_DoYouWantToSave_Title, MessageBoxButtons.YesNoCancel); if (result == DialogResult.Cancel) { return; } else if (result == DialogResult.Yes) { SaveExecute(); } } bool addExtension = true; bool checkFileExists = true; bool checkPathExists = true; string fileName; if (openFileName == null) { fileName = fileDialogService.Value.OpenFileDialog( SOLUTION_EXTENSION, @"c:\", m_filters, Resources.Strings.Solution_OpenFileDialog_Title, addExtension, checkFileExists, checkPathExists); } else { fileName = openFileName; } if (fileName != null) { try { using (Stream src = File.OpenRead(fileName)) { using (Stream dest = new MemoryStream()) { try { Decompress(src, dest); dest.Seek(0, SeekOrigin.Begin); // after Decompress, pointer is at the end using (StreamReader reader = new StreamReader(dest, Encoding.Unicode)) { string xml = reader.ReadToEnd(); NodeSolution readSolution = NodeBase.NodeFromXML(xml, null) as NodeSolution; setSolution(readSolution, false, true); if (!readOnly) { SolutionFileName = fileName; } else { SolutionFileName = null; } layoutManager.Value.ShowPad(this); SolutionLoaded(this, new EventArgs()); layoutManager.Value.RestoreLayout(readSolution.Layout.ToString()); } } catch (InvalidDataException) { messagingService.Value.ShowMessage( Resources.Strings.Solution_Open_InvalidDataException, Resources.Strings.Solution_Open_InvalidDataException_Title); } } } } catch (PathTooLongException) { messagingService.Value.ShowMessage( Resources.Strings.Solution_Open_PathTooLongException, Resources.Strings.Solution_Open_PathTooLongException_Title); } catch (DirectoryNotFoundException) { messagingService.Value.ShowMessage( Resources.Strings.Solution_Open_DirectoryNotFoundException, Resources.Strings.Solution_Open_DirectoryNotFoundException_Title); } catch (UnauthorizedAccessException) { messagingService.Value.ShowMessage( Resources.Strings.Solution_Open_UnauthorizedAccessException, Resources.Strings.Solution_Open_UnauthorizedAccessException_Title); } catch (FileNotFoundException) { messagingService.Value.ShowMessage( Resources.Strings.Solution_Open_FileNotFoundException, Resources.Strings.Solution_Open_FileNotFoundException_Title); } } }
public ShortAssignmentNode(LexemType opType, NodeBase expr) { _operatorType = opType; _assignmentOperator = OperatorLookups[opType]; Expression = expr; }
//public void OnScrollWheel(float ratio, float gridSize) //{ // _ratio = ratio; // _gridSize = gridSize; // for (int i = 0; i < _nodeList.Count; i++) // { // _nodeList[i].OnScollWheel(ratio, gridSize, _window.WindowCenter); // } //} void ProcessEvent(Event e) { switch (e.type) { case EventType.MouseDown: for (int i = _nodeList.Count - 1; i >= 0; i--) { //如果点击到Node执行以下逻辑 if (_nodeList[i].ClickThisNode(e.mousePosition)) { //判断是否处于连线状态,如果处于连线状态,只处理连线的逻辑 if (_isConnecting) { _isConnecting = false; if (CurNode != _nodeList[i]) { CreateLine(CurNode, _nodeList[i]); } return; } //左键点击事件和右键点击事件 CurNode = _nodeList[i]; if (e.button == 0) { _isDrag = true; } else if (e.button == 1) { OnRightClick(e.mousePosition); } e.Use(); _isConnecting = false; return; } } _isDrag = false; CurNode = null; _isConnecting = false; break; case EventType.MouseDrag: if (_isDrag) { if (CurNode != null) { CurNode.OnDrag(e.delta); } e.Use(); } break; case EventType.MouseUp: if (_isDrag) { CurNode.SetNodePosition(_window.GetPosition(_window.GetXYCount(CurNode.Position))); _isDrag = false; _window.Repaint(); } break; case EventType.KeyDown: if (e.keyCode == KeyCode.Delete || e.keyCode == KeyCode.Backspace) { DestroyNode(CurNode); } break; //case EventType.ScrollWheel: // break; } }
// Links the first right-clicked node with the second-right clicked node, taking the connector type (next/firstBody) into consideration. public void LinkCurrentlySelectedObjects() { linkingNodes = false; // Stop here if we're linking nodes that are already connected the same way if (linkingNodeMode == LinkingMode.NextNode) { if (linkingNodesObjects[0].GetComponent <NodeBase>().NextNodeObject == linkingNodesObjects[1]) { linkingNodesObjects[0] = linkingNodesObjects[1] = null; return; } } else if (linkingNodeMode == LinkingMode.FirstBodyNode) { /*NodeBase prevNode = (NodeBase)(linkingNodesObjects[1].GetComponent<NodeBase>().prevNode); * if (prevNode != null && prevNode == linkingNodesObjects[1].GetComponent<LogicalBlock>()) * { * linkingNodesObjects[0] = linkingNodesObjects[1] = null; * return; * }*/ } // Cancel linking by linking the same node: removes nextNode from obj0 (watch out for ProgramEnd as that won't have a NextNodeObject) if (linkingNodesObjects[0] == linkingNodesObjects[1] && !linkingNodesObjects[0].GetComponent <ProgramEnd>()) { if (linkingNodeMode == LinkingMode.NextNode) { if (linkingNodesObjects[0].GetComponent <NodeBase>().NextNodeObject) { linkingNodesObjects[0].GetComponent <NodeBase>().NextNodeObject.GetComponent <NodeBase>().PrevNodeObject = null; linkingNodesObjects[0].GetComponent <NodeBase>().NextNodeObject.GetComponent <NodeBase>().prevNode = null; } linkingNodesObjects[0].GetComponent <NodeBase>().NextNodeObject = null; linkingNodesObjects[0].GetComponent <NodeBase>().nextNode = null; } else { if (linkingNodesObjects[0].GetComponent <CodeBlock>().FirstBodyNodeObject) { linkingNodesObjects[0].GetComponent <CodeBlock>().FirstBodyNodeObject.GetComponent <NodeBase>().PrevNodeObject = null; linkingNodesObjects[0].GetComponent <CodeBlock>().FirstBodyNodeObject.GetComponent <NodeBase>().prevNode = null; linkingNodesObjects[0].GetComponent <CodeBlock>().FirstBodyNodeObject.GetComponent <NodeBase>().ownerLoop = null; } linkingNodesObjects[0].GetComponent <CodeBlock>().FirstBodyNodeObject = null; linkingNodesObjects[0].GetComponent <CodeBlock>().firstBodyNode = null; } linkingNodesObjects[0] = linkingNodesObjects[1] = null; return; } // Prevent ProgramEnd being used as a prevNode and ProgramStart being used as nextNode if (linkingNodesObjects[0].GetComponent <ProgramEnd>() || linkingNodesObjects[1].GetComponent <ProgramStart>()) { linkingNodesObjects[0] = linkingNodesObjects[1] = null; return; } if (linkingNodeMode == LinkingMode.NextNode) { // Prevent connecting to nextNode that's also the prevNode if (linkingNodesObjects[1] == linkingNodesObjects[0].GetComponent <NodeBase>().PrevNodeObject) { linkingNodesObjects[0] = linkingNodesObjects[1] = null; return; } GameObject nextObj = linkingNodesObjects[0].GetComponent <NodeBase>().NextNodeObject; NodeBase nextObjNode = null; if (nextObj != null) { nextObjNode = nextObj.GetComponent <NodeBase>(); } // obj0 is no longer its former nextNode's prevNode if (nextObjNode != null && nextObjNode.PrevNodeObject != null && nextObjNode.PrevNodeObject == linkingNodesObjects[0]) { nextObjNode.PrevNodeObject.GetComponent <NodeBase>().NextNodeObject = null; nextObjNode.PrevNodeObject.GetComponent <NodeBase>().nextNode = null; nextObjNode.PrevNodeObject = null; } nextObj = linkingNodesObjects[1]; nextObjNode = nextObj.GetComponent <NodeBase>(); // assign obj0 as obj1's prevNode, unassigning obj1's former prevNode if (nextObjNode != null && nextObjNode.PrevNodeObject != null && nextObjNode.PrevNodeObject != linkingNodesObjects[0]) { nextObjNode.PrevNodeObject.GetComponent <NodeBase>().NextNodeObject = null; nextObjNode.PrevNodeObject.GetComponent <NodeBase>().nextNode = null; nextObjNode.PrevNodeObject = linkingNodesObjects[0]; linkingNodesObjects[0].GetComponent <NodeBase>().NextNodeObject = linkingNodesObjects[1]; } nextObjNode.GetComponent <NodeBase>().PrevNodeObject = linkingNodesObjects[0]; nextObjNode.GetComponent <NodeBase>().PrevNodeObject.GetComponent <NodeBase>().NextNodeObject = linkingNodesObjects[1]; } else if (linkingNodeMode == LinkingMode.FirstBodyNode) { // failsafe if (linkingNodesObjects[0].GetComponent <CodeBlock>() == null) { linkingNodes = false; linkingNodesObjects[0] = linkingNodesObjects[1] = null; return; } else { GameObject nextObj = linkingNodesObjects[0].GetComponent <NodeBase>().NextNodeObject; NodeBase nextObjNode = null; if (nextObj != null) { nextObjNode = nextObj.GetComponent <NodeBase>(); } // obj0 is no longer its former nextNode's prevNode if (nextObjNode != null && nextObjNode.PrevNodeObject != null && nextObjNode.PrevNodeObject == linkingNodesObjects[0]) { nextObjNode.PrevNodeObject.GetComponent <NodeBase>().NextNodeObject = null; nextObjNode.PrevNodeObject.GetComponent <NodeBase>().nextNode = null; nextObjNode.PrevNodeObject = null; } nextObj = linkingNodesObjects[1]; nextObjNode = nextObj.GetComponent <NodeBase>(); // assign obj0 as obj1's prevNode, unassigning obj1's former prevNode if (nextObjNode != null && nextObjNode.PrevNodeObject != null && nextObjNode.PrevNodeObject != linkingNodesObjects[0]) { nextObjNode.PrevNodeObject.GetComponent <NodeBase>().NextNodeObject = null; nextObjNode.PrevNodeObject.GetComponent <NodeBase>().nextNode = null; nextObjNode.PrevNodeObject = linkingNodesObjects[0]; } linkingNodesObjects[0].GetComponent <CodeBlock>().FirstBodyNodeObject = linkingNodesObjects[1]; linkingNodesObjects[1].GetComponent <NodeBase>().PrevNodeObject = linkingNodesObjects[0]; } } if (linkingNodesObjects[1].GetComponent <NodeBase>()) { if (linkingNodeMode == LinkingMode.NextNode) { linkingNodesObjects[0].GetComponent <NodeBase>().nextNode = linkingNodesObjects[1].GetComponent <NodeBase>(); linkingNodesObjects[1].GetComponent <NodeBase>().prevNode = linkingNodesObjects[0].GetComponent <NodeBase>(); } else if (linkingNodeMode == LinkingMode.FirstBodyNode) { linkingNodesObjects[0].GetComponent <CodeBlock>().firstBodyNode = linkingNodesObjects[1].GetComponent <NodeBase>(); linkingNodesObjects[1].GetComponent <NodeBase>().prevNode = linkingNodesObjects[0].GetComponent <NodeBase>(); } // Assign firstbody loop/logicalblock ownership if (linkingNodesObjects[0].GetComponent <LogicalBlock>() != null && linkingNodeMode == LinkingMode.FirstBodyNode) { linkingNodesObjects[1].GetComponent <NodeBase>().ownerLoop = linkingNodesObjects[0].GetComponent <LogicalBlock>(); } // Propagate loop/logicalblock ownership if (linkingNodesObjects[0].GetComponent <NodeBase>().ownerLoop != null && linkingNodeMode == LinkingMode.NextNode) { linkingNodesObjects[1].GetComponent <NodeBase>().ownerLoop = linkingNodesObjects[0].GetComponent <NodeBase>().ownerLoop; } } linkingNodesObjects[0] = linkingNodesObjects[1] = null; }
public void RegisterNode(string nodeType, NodeBase node) { this.nodeTypes.Add(nodeType, node); }
protected override BinaryOperatorNodeBase RecreateSelfWithArgs(NodeBase left, NodeBase right) { return(new DivideOperatorNode { LeftOperand = left, RightOperand = right }); }
protected void BindSyncBase(NodeBase nb) { syncedNode = nb; Sync(); }
void rootSolutionItem_Edited(INodeWrapper sender, NodeBase oldNode, NodeBase newNode) { dirty = true; m_CloseEnabled.SetCondition(true); }
protected override NodeBase Move(NodeBase toBeMovedNode, DirectoryNode targetDirectory) { throw new NotImplementedException(); }
protected override NodeTimeInfo GetTimeInfo(NodeBase node) { return(_store[node].TimeInfo); }
public Sequence(NodeBase parent) : base(parent) { }
protected override IEnumerable <NodeChild> GetChildren() { yield return(new NodeChild(Expression, x => Expression = x)); }
public FunctionNodeLength(NodeBase parameter) : base(parameter) { }
public Action(NodeBase parent) : base(parent) { }
public MSNode(Vector3 pos, bool isWall, float nodeSize) : base(pos) { m_isWall = isWall; right = new NodeBase(m_position + Vector3.right * nodeSize / 2.0f); top = new NodeBase(m_position + Vector3.up * nodeSize / 2.0f); }
public float Result(NodeBase node1, NodeBase node2) { return(Math.Max( Math.Abs(node1.Position.X - node2.Position.X), Math.Abs(node1.Position.Y - node2.Position.Y))); }
//public static void DeleteNode(NodeBase node) { // AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(node)); // //AssetDatabase.SaveAssets(); // //AssetDatabase.Refresh(); //} /// <summary> /// creates a new generic node in the passed graph /// </summary> /// <param name="graph"></param> /// <param name="type"></param> /// <param name="var"></param> /// <param name="pos"></param> /// <returns></returns> public static NodeBase CreateNode(NodeGraph graph, NodeType type, object var, Vector2 pos) { NodeBase res = null; if (graph != null) { switch (type) { case NodeType.Control: switch ((ControlNode.ControlType)var) { case ControlNode.ControlType.Branch: res = ScriptableObject.CreateInstance <BranchNode>(); break; case ControlNode.ControlType.Choice: res = ScriptableObject.CreateInstance <ChoiceNode>(); break; case ControlNode.ControlType.Custom: res = ScriptableObject.CreateInstance <CustomNode>(); break; case ControlNode.ControlType.Delay: res = ScriptableObject.CreateInstance <DelayNode>(); break; case ControlNode.ControlType.Dialogue: res = ScriptableObject.CreateInstance <DialogueNode>(); break; case ControlNode.ControlType.ForLoop: res = ScriptableObject.CreateInstance <ForLoopNode>(); break; case ControlNode.ControlType.Music: res = ScriptableObject.CreateInstance <MusicNode>(); break; case ControlNode.ControlType.PlaySound: res = ScriptableObject.CreateInstance <PlaySoundNode>(); break; case ControlNode.ControlType.Print: res = ScriptableObject.CreateInstance <PrintNode>(); break; case ControlNode.ControlType.Quest: res = ScriptableObject.CreateInstance <QuestNode>(); break; case ControlNode.ControlType.Sequence: res = ScriptableObject.CreateInstance <SequenceNode>(); break; case ControlNode.ControlType.SetDialogueScript: res = ScriptableObject.CreateInstance <SetDialogueScriptNode>(); break; case ControlNode.ControlType.SetSubStart: res = ScriptableObject.CreateInstance <SetSubStartNode>(); break; } res.Initialize(); ((ControlNode)res).Construct(); break; case NodeType.Event: int i = 1; if (var as string != null) { res = ScriptableObject.CreateInstance <SubStartNode>(); i = 2; } else { if ((bool)var) { res = ScriptableObject.CreateInstance <EndNode>(); i = 3; } else { res = ScriptableObject.CreateInstance <StartNode>(); } } res.Initialize(); switch (i) { case 1: ((StartNode)res).Construct(); break; case 2: ((SubStartNode)res).Construct(); break; case 3: ((EndNode)res).Construct(); break; } break; } InitNode(res, graph, pos); } return(res); }
public List <string> Visit(NodeBase root) { return(root.Accept(this, null)); }
/// <summary> /// Initializes a new instance of the <see cref="FunctionNodeHyperbolicSine" /> class. /// </summary> /// <param name="parameter">The parameter.</param> public FunctionNodeHyperbolicSine(NodeBase parameter) : base(parameter) { }
protected override IEnumerable <NodeChild> GetChildren() { if (Expression is GetMemberNode) { // epic kludge: had to reset previously cached InvocationSource if it is expanded var getMbr = Expression as GetMemberNode; if (getMbr.Expression != null) { yield return(new NodeChild(getMbr.Expression, x => getMbr.Expression = _invocationSource = x)); } } else if (!(Expression is GetIdentifierNode)) { yield return(new NodeChild(Expression, x => Expression = x)); } foreach (var curr in base.GetChildren()) { yield return(curr); } }
void DrawNodeLinks() { List <GameObject> elements = new List <GameObject>(); for (int childIndex = 0; childIndex < transform.Find("Canvas").Find("Elements").childCount; childIndex++) { elements.Add(transform.Find("Canvas").Find("Elements").GetChild(childIndex).gameObject); } // Names of valid link GameObjects List <string> validLinks = new List <string>(); // First, render the next-node links foreach (GameObject element in elements) { NodeBase potentialNode = element.GetComponent <NodeBase>(); GameObject potentialNextNodeObj = potentialNode ? potentialNode.NextNodeObject : null; if (linkingNodes && linkingNodeMode == LinkingMode.NextNode && element.name == linkingNodesObjects[0].name) { potentialNextNodeObj = linkingPreviewNode; //Logger.Log("Found preview node"); } if (potentialNode && potentialNextNodeObj) { GameObject currentLink = null; LineRenderer currentRenderer = null; Transform linkTransform = lineCanvas.transform.Find($"nextNode:{potentialNode.name}->{potentialNextNodeObj.name}"); if (linkTransform) { currentLink = linkTransform.gameObject; currentRenderer = currentLink.GetComponent <LineRenderer>(); currentLink.GetComponent <LinkDescriptor>().prev = potentialNode.gameObject; currentLink.GetComponent <LinkDescriptor>().next = potentialNextNodeObj; } else { currentLink = new GameObject($"nextNode:{potentialNode.name}->{potentialNextNodeObj.name}"); currentLink.transform.SetParent(lineCanvas.transform, false); currentRenderer = currentLink.AddComponent <LineRenderer>(); currentRenderer.material = lineMaterial; currentRenderer.useWorldSpace = false; currentLink.AddComponent <LinkDescriptor>(); currentLink.GetComponent <LinkDescriptor>().prev = potentialNode.gameObject; currentLink.GetComponent <LinkDescriptor>().next = potentialNextNodeObj; } // This is to prevent culling from other 3D elements in the scene currentRenderer.gameObject.layer = LayerMask.NameToLayer("CodeEditor"); Rect thisRect = potentialNode.GetComponent <RectTransform>().rect, nextRect = potentialNextNodeObj.GetComponent <RectTransform>().rect; Vector2 thisPos = new Vector2(potentialNode.GetComponent <RectTransform>().localPosition.x + thisRect.width / 2, potentialNode.GetComponent <RectTransform>().localPosition.y); Vector2 nextPos = new Vector2(potentialNextNodeObj.GetComponent <RectTransform>().localPosition.x - nextRect.width / 2, potentialNextNodeObj.GetComponent <RectTransform>().localPosition.y); // If we're rendering link preview, make it point to the rect center so that it aligns with the cursor if (potentialNextNodeObj.name == "previewNode") { nextPos.x += nextRect.width / 2.0f; } currentRenderer.positionCount = 2; currentRenderer.SetPositions(new Vector3[] { thisPos, nextPos }); validLinks.Add(currentLink.name); } } // Now create separate LineRenderers for FirstBodyNodeObjects foreach (GameObject element in elements) { CodeBlock potentialCodeBlock = element.GetComponent <CodeBlock>(); GameObject potentialFirstBodyObj = potentialCodeBlock ? potentialCodeBlock.FirstBodyNodeObject : null; if (linkingNodes && linkingNodeMode == LinkingMode.FirstBodyNode && element.name == linkingNodesObjects[0].name) { potentialFirstBodyObj = linkingPreviewNode; } if (potentialCodeBlock && potentialFirstBodyObj) { GameObject currentLink = null; LineRenderer currentRenderer = null; Transform linkTransform = lineCanvas.transform.Find($"firstBody:{potentialCodeBlock.name}->{potentialFirstBodyObj.name}"); if (linkTransform) { currentLink = linkTransform.gameObject; currentRenderer = currentLink.GetComponent <LineRenderer>(); currentLink.GetComponent <LinkDescriptor>().prev = potentialCodeBlock.gameObject; currentLink.GetComponent <LinkDescriptor>().next = potentialFirstBodyObj; } else { currentLink = new GameObject($"firstBody:{potentialCodeBlock.name}->{potentialFirstBodyObj.name}"); currentLink.transform.SetParent(lineCanvas.transform, false); currentRenderer = currentLink.AddComponent <LineRenderer>(); currentRenderer.material = lineMaterial; currentRenderer.useWorldSpace = false; currentLink.AddComponent <LinkDescriptor>(); currentLink.GetComponent <LinkDescriptor>().prev = potentialCodeBlock.gameObject; currentLink.GetComponent <LinkDescriptor>().next = potentialFirstBodyObj; } currentRenderer.positionCount = 2; currentRenderer.SetPositions(new Vector3[] { potentialCodeBlock.GetComponent <RectTransform>().localPosition + new Vector3(.0f, potentialCodeBlock.GetComponent <RectTransform>().rect.height / -2.0f), potentialFirstBodyObj.GetComponent <RectTransform>().localPosition + new Vector3(potentialFirstBodyObj.GetComponent <RectTransform>().rect.width / -2.0f, 0.0f) }); // If we're rendering link preview, make it point to the rect center so that it aligns with the cursor if (potentialFirstBodyObj.name == "previewNode") { currentRenderer.SetPosition(1, potentialFirstBodyObj.GetComponent <RectTransform>().localPosition); } // This is to prevent culling from other 3D elements in the scene currentRenderer.gameObject.layer = LayerMask.NameToLayer("CodeEditor"); validLinks.Add(currentLink.name); } } // Lastly, remove any lines that are not needed (e.g after deleting a node) Transform[] allLines = lineCanvas.GetComponentsInChildren <Transform>(); foreach (Transform line in allLines) { if (!validLinks.Contains(line.name) && line.name != "LineCanvas" && !line.name.Contains("previewNode")) { Destroy(line.gameObject); } } FixLines(); }
public static grpc::ServerServiceDefinition BindService(NodeBase serviceImpl) { return(grpc::ServerServiceDefinition.CreateBuilder() .AddMethod(__Method_MessageLoop, serviceImpl.MessageLoop).Build()); }
protected override NodeBase SetAttributes(NodeBase node, NodeAttributes attributes) { _store[node].Attributes = attributes; return(node); }
/// <summary> /// Initializes a new instance of the <see cref="FunctionNodeTrim" /> class. /// </summary> /// <param name="parameter">The parameter.</param> public FunctionNodeTrim(NodeBase parameter) : base(parameter) { }
public static void BindService(grpc::ServiceBinderBase serviceBinder, NodeBase serviceImpl) { serviceBinder.AddMethod(__Method_MessageLoop, serviceImpl == null ? null : new grpc::DuplexStreamingServerMethod <global::Pbx.ClientMsg, global::Pbx.ServerMsg>(serviceImpl.MessageLoop)); }
protected override NodeBase SetTimeInfo(NodeBase node, NodeTimeInfo newTimeInfo) { _store[node].TimeInfo = newTimeInfo; return(node); }
public NotificationEvent(NodeBase source, string command, object tag) { this.source = source; this.command = command; this.tag = tag; }
private void CheckEditorSelectedNodes(Pipeline pipeline, TimelineWindow timeline, NodeBase node, bool valueChanged) { //Most data types are stored via tag so ignore null types if (node.Tag == null) { return; } //Check for active changes for functions that load only once on click if (valueChanged) { if (node.Tag is Toolbox.Core.Animations.STAnimation) { var anim = (Toolbox.Core.Animations.STAnimation)node.Tag; timeline.AddAnimation(anim, false); timeline.SetFrame(0); } if (node.Tag is CameraAnimation) { pipeline.AddCameraAnimation(node.Tag as CameraAnimation); } //Container to batch play multiple animations at once if (node.Tag is IAnimationContainer) { timeline.ClearAnimations(); foreach (var anim in ((IAnimationContainer)node.Tag).AnimationList) { timeline.AddAnimation(anim, false); } timeline.SetFrame(0); } } //Keep track of the selected bone index for debug shading (view assigned bone weights) if (node.Tag is STBone) { Runtime.SelectedBoneIndex = ((STBone)node.Tag).Index; } }