PR #51 but updated, also PR #252

This commit is contained in:
dexy 2024-07-12 11:39:52 +10:00
parent 6cf72c4b74
commit e5dc63f429
3 changed files with 314 additions and 397 deletions

View File

@ -706,7 +706,6 @@ namespace CodeWalker.World
{
var xDir = Math.Min(1, Math.Max(-1, desiredX - ynd.CellX));
var yDir = Math.Min(1, Math.Max(-1, desiredY - ynd.CellY));
var x = desiredX;
var y = desiredY;
@ -718,11 +717,9 @@ namespace CodeWalker.World
{
break;
}
x += xDir;
}
}
if (yDir != 0)
{
while (y >= 0 && y <= 31)
@ -731,16 +728,61 @@ namespace CodeWalker.World
{
break;
}
y += yDir;
}
}
var dx = x - ynd.CellX;
var dy = y - ynd.CellY;
var areaId = y * 32 + x;
var areaIdorig = ynd.AreaID;
var changed = ynd.AreaID != areaId;
ynd.CellX = x;
ynd.CellY = y;
var areaId = y * 32 + x;
ynd.AreaID = areaId;
ynd.Name = $"nodes{areaId}";
if (changed)
{
var nodes = ynd.Nodes;
if (nodes != null)
{
for (int i = 0; i < nodes.Length; i++)
{
var node = nodes[i];
node.SetPosition(node.Position + new Vector3(512 * dx, 512 * dy, 0));
if (node.AreaID == areaIdorig)
{
node.AreaID = (ushort)areaId;
}
}
}
var links = ynd.Links;
if (links != null)
{
for (int i = 0; i < links.Length; i++)
{
var link = links[i];
if (link._RawData.AreaID == areaIdorig)
{
link._RawData.AreaID = (ushort)areaId;
}
}
}
var juncs = ynd.Junctions;
if (juncs != null)
{
for (int i = 0; i < juncs.Length; i++)
{
var junc = juncs[i];
junc.PositionX += (short)(512 * dx);
junc.PositionY += (short)(512 * dy);
}
}
ynd.UpdateAllNodePositions();
ynd.UpdateBoundingBox();
ynd.UpdateTriangleVertices(null);
ynd.BuildStructs();
}
NodeGrid.UpdateYnd(ynd);
}

File diff suppressed because it is too large Load Diff

View File

@ -103,11 +103,12 @@ namespace CodeWalker.Project.Panels
{
if (ProjectForm.WorldForm == null)
{
MessageBox.Show("You can only do this while in full CodeWalker", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show("You can only do this while the Project Window is open.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
ProjectForm.WorldForm.Space.MoveYndArea(Ynd, x, y);
ProjectForm.WorldForm.UpdatePathYndGraphics(Ynd, true);
ProjectForm.SetYndHasChanged(Ynd, true);
// Take the updated information