mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2024-11-26 17:02:53 +08:00
Merge pull request #56 from PichotM/patch-1
codewalkercore/archetype: portals objects deletion
This commit is contained in:
commit
834cb6bde2
@ -1,4 +1,4 @@
|
|||||||
using SharpDX;
|
using SharpDX;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@ -247,15 +247,39 @@ namespace CodeWalker.GameFiles
|
|||||||
if (ymapEntityDef != null) ymapEntityDef.Index = index;
|
if (ymapEntityDef != null) ymapEntityDef.Index = index;
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
entities = newentities;
|
entities = newentities;
|
||||||
|
|
||||||
if (didDel) FixRoomIndexes(delIndex);
|
if (didDel)
|
||||||
|
{
|
||||||
|
FixRoomIndexes(delIndex);
|
||||||
|
FixPortalIndexes(delIndex);
|
||||||
|
}
|
||||||
return didDel;
|
return didDel;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void FixPortalIndexes(int deletedIndex)
|
||||||
|
{
|
||||||
|
foreach (var portal in portals)
|
||||||
|
{
|
||||||
|
List<uint> newAttachedObjects = new List<uint>();
|
||||||
|
if (portal.AttachedObjects == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
foreach(var objIndex in portal.AttachedObjects)
|
||||||
|
{
|
||||||
|
if (objIndex == deletedIndex) continue;
|
||||||
|
if (objIndex > deletedIndex)
|
||||||
|
newAttachedObjects.Add(objIndex - 1); // move the index back so it matches the index in the entitiy array.
|
||||||
|
else newAttachedObjects.Add(objIndex); // else just add the index to the attached objects.
|
||||||
|
}
|
||||||
|
portal.AttachedObjects = newAttachedObjects.ToArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void FixRoomIndexes(int deletedIndex)
|
private void FixRoomIndexes(int deletedIndex)
|
||||||
{
|
{
|
||||||
foreach (var room in rooms)
|
foreach (var room in rooms)
|
||||||
|
Loading…
Reference in New Issue
Block a user