private void NodeDragMoved(IDraggable sender, DragEventArgs args, Event nativeEvent) { if (sender is BehaviorNodeControl) { BehaviorNodeControl node = sender as BehaviorNodeControl; switch (nativeEvent.button) { case 0: { Vector2 newPos = node.Position + args.delta; if (newPos.x >= 0.0f && newPos.y >= 0.0f) { node.SetPosition(newPos); } } break; case 2: { Vector2 newPos = node.Position + args.delta; if (newPos.x >= 0.0f && newPos.y >= 0.0f) { DragHierarchy(node, args.delta); } } break; } } }
private void DragHierarchy(BehaviorNodeControl c, Vector2 delta) { c.SetPosition(c.Position + delta); foreach (BehaviorNodeControl o in c.m_outputs) { if (o != null) { DragHierarchy(o, delta); } } }
private BehaviorNodeControl DeserializeNode(XmlNode xml, EditorNodeTypeCache typeCache, out string nodeId, out List <string> childIds) { childIds = new List <string>(); nodeId = xml.Attributes["id"].InnerText; string type = xml.Attributes["type"].InnerText; string[] posStr = xml.Attributes["position"].InnerText.Split(','); Vector2 position = new Vector2(float.Parse(posStr[0]), float.Parse(posStr[1])); if (xml.Attributes["outputs"] != null) { childIds.AddRange(xml.Attributes["outputs"].InnerText.Split(',')); } bool found = false; EditorCachedNode data = default(EditorCachedNode); foreach (EditorCachedNode cachedType in typeCache.Cache) { if (cachedType.type.ToString() == type) { found = true; data = cachedType; break; } } if (!found) { return(null); } BehaviorNodeControl control = new BehaviorNodeControl(data); control.SetPosition(position); DeserializeFields(xml, data, control); return(control); }
private void DragHierarchy( BehaviorNodeControl c, Vector2 delta ) { c.SetPosition( c.Position + delta ); foreach( BehaviorNodeControl o in c.m_outputs ) { if ( o != null ) { DragHierarchy( o, delta ); } } }
private BehaviorNodeControl DeserializeNode( XmlNode xml, EditorNodeTypeCache typeCache, out string nodeId, out List<string> childIds ) { childIds = new List<string>(); nodeId = xml.Attributes[ "id" ].InnerText; string type = xml.Attributes[ "type" ].InnerText; string[] posStr = xml.Attributes[ "position" ].InnerText.Split(','); Vector2 position = new Vector2( float.Parse( posStr[ 0 ] ), float.Parse( posStr[ 1 ] ) ); if ( xml.Attributes[ "outputs" ] != null ) { childIds.AddRange( xml.Attributes[ "outputs" ].InnerText.Split( ',' ) ); } bool found = false; EditorCachedNode data = default(EditorCachedNode); foreach( EditorCachedNode cachedType in typeCache.Cache ) { if ( cachedType.type.ToString() == type ) { found = true; data = cachedType; break; } } if ( !found ) { return null; } BehaviorNodeControl control = new BehaviorNodeControl( data ); control.SetPosition( position ); DeserializeFields( xml, data, control ); return control; }