Skip to content

Commit

Permalink
- Fixed assert warning about loading prefabs without extension
Browse files Browse the repository at this point in the history
- Fixed hitzones in hierachy not saving at all and not unique identifiying slots anymorre
  • Loading branch information
Arkensor committed Jan 9, 2025
1 parent bf3803c commit d1667ec
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
24 changes: 12 additions & 12 deletions src/Scripts/Game/Components/EPF_HitZoneContainerComponentSaveData.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class EPF_HitZoneContainerComponentSaveDataClass : EPF_ComponentSaveDataClass
{
[Attribute(desc: "If set, only the explictly selected hitzones are persisted.")]
ref array<string> m_aHitzoneFilter;
};
}

[EDF_DbName.Automatic()]
class EPF_HitZoneContainerComponentSaveData : EPF_ComponentSaveData
Expand All @@ -19,12 +19,12 @@ class EPF_HitZoneContainerComponentSaveData : EPF_ComponentSaveData
m_aHitzones = {};

array<HitZone> outHitZones();
hitZoneContainer.GetAllHitZones(outHitZones);
hitZoneContainer.GetAllHitZonesInHierarchy(outHitZones);

foreach (HitZone hitZone : outHitZones)
foreach (int idx, HitZone hitZone : outHitZones)
{
EPF_PersistentHitZone persistentHitZone();
persistentHitZone.m_sName = hitZone.GetName();
persistentHitZone.m_sName = string.Format("z%1_%2", idx, hitZone.GetName());
persistentHitZone.m_fHealth = hitZone.GetHealthScaled();

if (settings.m_bTrimDefaults && float.AlmostEqual(persistentHitZone.m_fHealth, 1.0)) continue;
Expand All @@ -44,7 +44,7 @@ class EPF_HitZoneContainerComponentSaveData : EPF_ComponentSaveData

array<HitZone> outHitZones();
HitZoneContainerComponent hitZoneContainer = HitZoneContainerComponent.Cast(component);
hitZoneContainer.GetAllHitZones(outHitZones);
hitZoneContainer.GetAllHitZonesInHierarchy(outHitZones);

bool tryIdxAcces = outHitZones.Count() >= m_aHitzones.Count();

Expand All @@ -56,16 +56,16 @@ class EPF_HitZoneContainerComponentSaveData : EPF_ComponentSaveData
if (tryIdxAcces)
{
HitZone idxHitZone = outHitZones.Get(idx);

if (idxHitZone.GetName() == persistentHitZone.m_sName) hitZone = idxHitZone;
if (string.Format("z%1_%2", idx, idxHitZone.GetName()) == persistentHitZone.m_sName)
hitZone = idxHitZone;
}

// Iterate all hitzones to hopefully find the right one
if (!hitZone)
{
foreach (HitZone findHitZone : outHitZones)
foreach (int hitIdx, HitZone findHitZone : outHitZones)
{
if (findHitZone.GetName() == persistentHitZone.m_sName)
if (string.Format("z%1_%2", hitIdx, findHitZone.GetName()) == persistentHitZone.m_sName)
{
hitZone = findHitZone;
break;
Expand All @@ -75,7 +75,7 @@ class EPF_HitZoneContainerComponentSaveData : EPF_ComponentSaveData

if (!hitZone)
{
Debug.Error(string.Format("'%1' unable to find hitZone with name '%2'. Ignored.", component, persistentHitZone.m_sName));
Debug.Error(string.Format("'%1' unable to find hitZone '%2'. Ignored.", component, persistentHitZone.m_sName));
continue;
}

Expand Down Expand Up @@ -118,7 +118,7 @@ class EPF_HitZoneContainerComponentSaveData : EPF_ComponentSaveData

return true;
}
};
}

class EPF_PersistentHitZone
{
Expand All @@ -130,4 +130,4 @@ class EPF_PersistentHitZone
{
return m_sName == other.m_sName && float.AlmostEqual(m_fHealth, other.m_fHealth);
}
};
}
2 changes: 1 addition & 1 deletion src/Scripts/Game/EPF_EntitySaveData.c
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ class EPF_EntitySaveData : EPF_MetaDataDbEntity
string prefabString;
loadContext.ReadValue("m_rPrefab", prefabString);
if (prefabString && prefabString.Get(0) != "{")
prefabString = string.Format("{%1}", prefabString);
prefabString = string.Format("{%1}.et", prefabString);

m_rPrefab = prefabString;

Expand Down

0 comments on commit d1667ec

Please sign in to comment.