public void RaiseDependant() { var tmpConnectionA = default(PathfinderConnection); if (DependantConnection != null) { return; } if (NodeA.ParentNode != NodeB.ParentNode) { if (NodeA.ParentNode != null && NodeB.ParentNode != null) { tmpConnectionA = NodeA.ParentNode.FindConnection(NodeB.ParentNode); if (tmpConnectionA == null) { DependantConnection = new PathfinderConnection(this); DependantConnection.LinkIncrease(); DependantConnection.RaiseDependant(); } else { DependantConnection = tmpConnectionA; DependantConnection.LinkIncrease(); } } } }
public void UnlinkParentDependants() { if (DependantConnection != null) { var tmpConnection = DependantConnection; DependantConnection = null; tmpConnection.LinkDecrease(); } }
public PathfinderConnection(PathfinderConnection SourceConnection) { NodeA = SourceConnection.NodeA.ParentNode; NodeB = SourceConnection.NodeB.ParentNode; NodeA.Connection_Add(this, ref NodeA_ConnectionNum); NodeB.Connection_Add(this, ref NodeB_ConnectionNum); NodeA.Layer.Connection_Add(this); ValueCalc(); }
public void Connection_Add(PathfinderConnection NewConnection) { if (Connections.GetUpperBound(0) < ConnectionCount) { Array.Resize(ref Connections, (ConnectionCount + 1) * 2); } Connections[ConnectionCount] = NewConnection; Connections[ConnectionCount].Layer_ConnectionNum = ConnectionCount; ConnectionCount++; }
public void Connection_Add(PathfinderConnection Connection, ref int OutputNum) { OutputNum = ConnectionCount; if (Connections.GetUpperBound(0) < ConnectionCount) { Array.Resize(ref Connections, ConnectionCount * 2 + 1 + 1); } Connections[ConnectionCount] = Connection; ConnectionCount++; if (ParentNode == null) { Layer.Network.FindParentNode_Add(this); } }
public void Split() { if (NodeCount != 4) { Debugger.Break(); } float Value = 0; float BestValue = 0; PathfinderNode BestNodeA = null; PathfinderNode BestNodeB = null; PathfinderNode BestNodeC = null; PathfinderNode BestNodeD = null; var A = 0; var B = 0; var tmpNodeA = default(PathfinderNode); var tmpNodeB = default(PathfinderNode); var tmpNodeC = default(PathfinderNode); var tmpNodeD = default(PathfinderNode); PathfinderConnection tmpConnectionA = null; PathfinderConnection tmpConnectionB = null; var C = 0; var D = 0; var Children = new PathfinderNode[NodeCount]; for (A = 0; A <= NodeCount - 1; A++) { Children[A] = Nodes[A]; } var ChildCount = NodeCount; var ThisLayer = Layer; Disband(); BestValue = float.MaxValue; for (A = 0; A <= ChildCount - 1; A++) { tmpNodeA = Children[A]; for (B = A + 1; B <= ChildCount - 1; B++) { tmpNodeB = Children[B]; for (C = 0; C <= ChildCount - 1; C++) { if (Children[C] != tmpNodeA && Children[C] != tmpNodeB) { break; } } tmpNodeC = Children[C]; for (D = C + 1; D <= ChildCount - 1; D++) { if (Children[D] != tmpNodeA && Children[D] != tmpNodeB) { break; } } tmpNodeD = Children[D]; for (C = 0; C <= tmpNodeA.ConnectionCount - 1; C++) { tmpConnectionA = tmpNodeA.Connections[C]; if (tmpConnectionA.GetOtherNode(tmpNodeA) == tmpNodeB) { break; } } for (D = 0; D <= tmpNodeC.ConnectionCount - 1; D++) { tmpConnectionB = tmpNodeC.Connections[D]; if (tmpConnectionB.GetOtherNode(tmpNodeC) == tmpNodeD) { break; } } if (C < tmpNodeA.ConnectionCount & D < tmpNodeC.ConnectionCount) { Value = tmpConnectionA.Value + tmpConnectionB.Value; if (Value < BestValue) { BestValue = Value; BestNodeA = tmpNodeA; BestNodeB = tmpNodeB; BestNodeC = tmpNodeC; BestNodeD = tmpNodeD; } } } } if (BestNodeA != null) { if (ParentNode != null) { tmpNodeA = ParentNode; tmpNodeA.Node_Remove(ParentNode_NodeNum); } else { tmpNodeA = null; } if (tmpNodeA != null) { tmpNodeA.CheckIntegrity(); } var NewNodeA = new PathfinderNode(ThisLayer); var NewNodeB = new PathfinderNode(ThisLayer); NewNodeA.Node_Add(BestNodeA); NewNodeA.Node_Add(BestNodeB); NewNodeA.SpanCalc(); BestNodeA.RaiseConnections(); BestNodeB.RaiseConnections(); NewNodeA.Layer.Network.FindParentNode_Add(NewNodeA); NewNodeB.Node_Add(BestNodeC); NewNodeB.Node_Add(BestNodeD); NewNodeB.SpanCalc(); BestNodeC.RaiseConnections(); BestNodeD.RaiseConnections(); NewNodeB.Layer.Network.FindParentNode_Add(NewNodeB); } else { Debugger.Break(); } }
public void ForceDeallocate() { DependantConnection = null; NodeA = null; NodeB = null; }