Skip to content

Commit 9df4edf

Browse files
committed
Fix dyanmic spawned entities id duplicating #32
1 parent ffd000c commit 9df4edf

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/Scripts/Game/EPF_PersistentRootEntityCollection.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,8 @@ class EPF_PersistentRootEntityCollection : EPF_MetaDataDbEntity
1515
{
1616
if (EPF_BitFlags.CheckFlags(persistenceComponent.GetFlags(), EPF_EPersistenceFlags.BAKED))
1717
{
18-
// TODO refactor to use https://feedback.bistudio.com/T172042 when patched
19-
int idx = m_aRemovedBackedRootEntities.Find(persistentId);
20-
if (idx != -1)
21-
{
22-
m_aRemovedBackedRootEntities.Remove(idx);
18+
if (m_aRemovedBackedRootEntities.RemoveItem(persistentId))
2319
return;
24-
}
2520
}
2621

2722
EPF_PersistenceComponentClass settings = EPF_ComponentData<EPF_PersistenceComponentClass>.Get(persistenceComponent);
@@ -37,11 +32,13 @@ class EPF_PersistentRootEntityCollection : EPF_MetaDataDbEntity
3732
array<string> ids = m_mSelfSpawnDynamicEntities.Get(settings.m_tSaveDataType);
3833
if (!ids)
3934
{
40-
ids = {};
35+
ids = {persistentId};
4136
m_mSelfSpawnDynamicEntities.Set(settings.m_tSaveDataType, ids);
37+
return;
4238
}
43-
44-
ids.Insert(persistentId);
39+
40+
if (!ids.Contains(persistentId))
41+
ids.Insert(persistentId);
4542
}
4643

4744
//------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)