public NavmeshAsset(NavmeshAsset original) : base(original.Name, original.Collection) { this.Position = original.Position; this.Size = original.Size; this.cells = new CellAsset[original.Nodes.Length]; for (int i = 0; i < original.Nodes.Length; i++) // Create new cell assets - based on the nodes of the original { this.cells[i] = new CellAsset(( CellAsset )original.Nodes[i], this); } this.Tags = new int[original.Tags.Length]; for (int i = 0; i < original.Tags.Length; i++) // Copy the tag indexes { this.Tags[i] = original.Tags[i]; } for (int cellIDX = 0; cellIDX < this.cells.Length; cellIDX++) // Create connections going from OUR node at the same index as THEIR node to same - just with to { this.cells[cellIDX].Connections = new ConnectionAsset[original.Nodes[cellIDX].Connections.Length]; for (int connectionIDX = 0; connectionIDX < this.cells[cellIDX].Connections.Length; connectionIDX++) { this.cells[cellIDX].Connections[connectionIDX] = new ConnectionAsset( this.cells[Array.IndexOf(original.Nodes, original.Nodes[cellIDX].Connections[connectionIDX].From)], this.cells[Array.IndexOf(original.Nodes, original.Nodes[cellIDX].Connections[connectionIDX].To)], original.Nodes[cellIDX].Connections[connectionIDX].Width, this.Collection); this.cells[cellIDX].Connections[connectionIDX].Tags = new int[original.Nodes[cellIDX].Connections[connectionIDX].Tags.Length]; for (int tagIDX = 0; tagIDX < original.Nodes[cellIDX].Connections[connectionIDX].Tags.Length; tagIDX++) // Copy the tag indexes { this.cells[cellIDX].Connections[connectionIDX].Tags[tagIDX] = original.Nodes[cellIDX].Connections[connectionIDX].Tags[tagIDX]; } } } }
public NavmeshAsset( NavmeshAsset original ) : base( original.Name, original.Collection ) { this.Position = original.Position; this.Size = original.Size; this.cells = new CellAsset[ original.Nodes.Length ]; for( int i = 0; i < original.Nodes.Length; i++ ) // Create new cell assets - based on the nodes of the original { this.cells[ i ] = new CellAsset( ( CellAsset )original.Nodes[ i ], this ); } this.Tags = new int[ original.Tags.Length ]; for( int i = 0; i < original.Tags.Length; i++ ) // Copy the tag indexes { this.Tags[ i ] = original.Tags[ i ]; } for( int cellIDX = 0; cellIDX < this.cells.Length; cellIDX++ ) // Create connections going from OUR node at the same index as THEIR node to same - just with to { this.cells[ cellIDX ].Connections = new ConnectionAsset[ original.Nodes[ cellIDX ].Connections.Length ]; for( int connectionIDX = 0; connectionIDX < this.cells[ cellIDX ].Connections.Length; connectionIDX++ ) { this.cells[ cellIDX ].Connections[ connectionIDX ] = new ConnectionAsset( this.cells[ Array.IndexOf( original.Nodes, original.Nodes[ cellIDX ].Connections[ connectionIDX ].From ) ], this.cells[ Array.IndexOf( original.Nodes, original.Nodes[ cellIDX ].Connections[ connectionIDX ].To ) ], original.Nodes[ cellIDX ].Connections[ connectionIDX ].Width, this.Collection ); this.cells[ cellIDX ].Connections[ connectionIDX ].Tags = new int[ original.Nodes[ cellIDX ].Connections[ connectionIDX ].Tags.Length ]; for( int tagIDX = 0; tagIDX < original.Nodes[ cellIDX ].Connections[ connectionIDX ].Tags.Length; tagIDX++ ) // Copy the tag indexes { this.cells[ cellIDX ].Connections[ connectionIDX ].Tags[ tagIDX ] = original.Nodes[ cellIDX ].Connections[ connectionIDX ].Tags[ tagIDX ]; } } } }