mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2024-11-26 00:43:00 +08:00
Auto update room portal counts when adding/editing portals
This commit is contained in:
parent
8ac37258c3
commit
958c6def5b
@ -315,6 +315,8 @@ namespace CodeWalker.GameFiles
|
|||||||
{
|
{
|
||||||
rooms[i].Index = i;
|
rooms[i].Index = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UpdatePortalCounts();//portal room indices probably would need to be updated anyway
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddPortal(MCMloPortalDef portal)
|
public void AddPortal(MCMloPortalDef portal)
|
||||||
@ -327,6 +329,8 @@ namespace CodeWalker.GameFiles
|
|||||||
var newportals = portals?.ToList() ?? new List<MCMloPortalDef>();
|
var newportals = portals?.ToList() ?? new List<MCMloPortalDef>();
|
||||||
newportals.Add(portal);
|
newportals.Add(portal);
|
||||||
portals = newportals.ToArray();
|
portals = newportals.ToArray();
|
||||||
|
|
||||||
|
UpdatePortalCounts();
|
||||||
}
|
}
|
||||||
public void RemovePortal(MCMloPortalDef portal)
|
public void RemovePortal(MCMloPortalDef portal)
|
||||||
{
|
{
|
||||||
@ -340,6 +344,8 @@ namespace CodeWalker.GameFiles
|
|||||||
{
|
{
|
||||||
portals[i].Index = i;
|
portals[i].Index = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UpdatePortalCounts();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddEntitySet(MCMloEntitySet set)
|
public void AddEntitySet(MCMloEntitySet set)
|
||||||
@ -432,6 +438,26 @@ namespace CodeWalker.GameFiles
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UpdatePortalCounts()
|
||||||
|
{
|
||||||
|
if ((rooms == null) || (portals == null)) return;
|
||||||
|
|
||||||
|
foreach (var room in rooms)
|
||||||
|
{
|
||||||
|
uint count = 0;
|
||||||
|
foreach (var portal in portals)
|
||||||
|
{
|
||||||
|
if ((portal._Data.roomFrom == room.Index) || (portal._Data.roomTo == room.Index))
|
||||||
|
{
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
room._Data.portalCount = count;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void LoadChildren(Meta meta)
|
public void LoadChildren(Meta meta)
|
||||||
{
|
{
|
||||||
var centities = MetaTypes.ConvertDataArray<CEntityDef>(meta, MetaName.CEntityDef, _MloArchetypeDefData.entities);
|
var centities = MetaTypes.ConvertDataArray<CEntityDef>(meta, MetaName.CEntityDef, _MloArchetypeDefData.entities);
|
||||||
|
@ -103,6 +103,7 @@ namespace CodeWalker.Project.Panels
|
|||||||
if (CurrentPortal._Data.roomFrom != u)
|
if (CurrentPortal._Data.roomFrom != u)
|
||||||
{
|
{
|
||||||
CurrentPortal._Data.roomFrom = u;
|
CurrentPortal._Data.roomFrom = u;
|
||||||
|
CurrentPortal.OwnerMlo?.UpdatePortalCounts();
|
||||||
ProjectForm.SetYtypHasChanged(true);
|
ProjectForm.SetYtypHasChanged(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -123,6 +124,7 @@ namespace CodeWalker.Project.Panels
|
|||||||
if (CurrentPortal._Data.roomTo != u)
|
if (CurrentPortal._Data.roomTo != u)
|
||||||
{
|
{
|
||||||
CurrentPortal._Data.roomTo = u;
|
CurrentPortal._Data.roomTo = u;
|
||||||
|
CurrentPortal.OwnerMlo?.UpdatePortalCounts();
|
||||||
ProjectForm.SetYtypHasChanged(true);
|
ProjectForm.SetYtypHasChanged(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user