diff --git a/GameFiles/FileTypes/YmapFile.cs b/GameFiles/FileTypes/YmapFile.cs index 1566ad2..897000c 100644 --- a/GameFiles/FileTypes/YmapFile.cs +++ b/GameFiles/FileTypes/YmapFile.cs @@ -1115,6 +1115,7 @@ namespace CodeWalker.GameFiles public bool IsMlo { get; set; } public MloInstanceData MloInstance { get; set; } public YmapEntityDef MloParent { get; set; } + public MCMloEntitySet MloEntitySet { get; set; } public Vector3 MloRefPosition { get; set; } public Quaternion MloRefOrientation { get; set; } public MetaWrapper[] Extensions { get; set; } diff --git a/GameFiles/MetaTypes/MetaTypes.cs b/GameFiles/MetaTypes/MetaTypes.cs index 25e8c8a..bc8d99f 100644 --- a/GameFiles/MetaTypes/MetaTypes.cs +++ b/GameFiles/MetaTypes/MetaTypes.cs @@ -1962,7 +1962,7 @@ namespace CodeWalker.GameFiles public override string ToString() { - return Name; + return Name + ": " + (Entities?.Length ?? 0).ToString() + " entities"; } } diff --git a/GameFiles/Resources/Archetype.cs b/GameFiles/Resources/Archetype.cs index d5c16f5..d048d17 100644 --- a/GameFiles/Resources/Archetype.cs +++ b/GameFiles/Resources/Archetype.cs @@ -212,31 +212,54 @@ namespace CodeWalker.GameFiles if (owner == null) return; if (mloa.entities == null) return; var ec = mloa.entities.Length; - Entities = new YmapEntityDef[ec]; + + var entlist = new List(); for (int i = 0; i < ec; i++) { - MCEntityDef ment = mloa.entities[i]; - YmapEntityDef e = new YmapEntityDef(null, i, ref ment._Data); - e.Extensions = ment.Extensions; - e.MloRefPosition = e.Position; - e.MloRefOrientation = e.Orientation; - e.MloParent = owner; - e.Position = owner.Position + owner.Orientation.Multiply(e.MloRefPosition); - e.Orientation = Quaternion.Multiply(owner.Orientation, e.MloRefOrientation); - e.UpdateWidgetPosition(); - e.UpdateWidgetOrientation(); - Entities[i] = e; + YmapEntityDef e = CreateYmapEntity(owner, mloa.entities[i], i); + entlist.Add(e); } + int lasti = ec; + var entitySets = mloa.entitySets; if (entitySets != null) { - //for (int i = 0; i < entitySets.Length; i++) - //{ - // var entitySet = entitySets[i]; - //} + for (int i = 0; i < entitySets.Length; i++) + { + var entitySet = entitySets[i]; + if (entitySet.Entities != null) + { + for (int j = 0; j < entitySet.Entities.Length; j++) + { + YmapEntityDef e = CreateYmapEntity(owner, entitySet.Entities[j], lasti); + e.MloEntitySet = entitySet; + entlist.Add(e); + lasti++; + } + } + } } + if (defaultEntitySets != null) + { + } + + Entities = entlist.ToArray(); + } + + private YmapEntityDef CreateYmapEntity(YmapEntityDef owner, MCEntityDef ment, int i) + { + YmapEntityDef e = new YmapEntityDef(null, i, ref ment._Data); + e.Extensions = ment.Extensions; + e.MloRefPosition = e.Position; + e.MloRefOrientation = e.Orientation; + e.MloParent = owner; + e.Position = owner.Position + owner.Orientation.Multiply(e.MloRefPosition); + e.Orientation = Quaternion.Multiply(owner.Orientation, e.MloRefOrientation); + e.UpdateWidgetPosition(); + e.UpdateWidgetOrientation(); + return e; }