diff --git a/AttributeList.cs b/AttributeList.cs index 1761300..d0648aa 100644 --- a/AttributeList.cs +++ b/AttributeList.cs @@ -273,8 +273,8 @@ public virtual object? this[string name] { var valueType = value.GetType(); - // type must be equal, or a superclass - if (prop.PropertyType != valueType && valueType.IsSubclassOf(prop.PropertyType)) + // types must be equal, or a superclass + if (prop.PropertyType != typeof(Element) && valueType.IsSubclassOf(prop.PropertyType)) { throw new InvalidDataException($"class property '{prop.Name}' with type '{prop.PropertyType}' does not match the type '{valueType}' of the value being set, this is likely a mismatch between the real class and the class from the datamodel"); } diff --git a/ICodec.cs b/ICodec.cs index 0c6ff35..cef6071 100644 --- a/ICodec.cs +++ b/ICodec.cs @@ -256,12 +256,11 @@ public static bool TryConstructCustomElement(Dictionary types, Dat object uninitializedObject = RuntimeHelpers.GetUninitializedObject(derivedType); - elementConstructor.Invoke(uninitializedObject, [dataModel, elem_name, elem_id, elem_class]); - // this will initialize values such as // public Datamodel.ElementArray Children { get; } = []; customClassInitializer.Invoke(uninitializedObject, []); + elementConstructor.Invoke(uninitializedObject, [dataModel, elem_name, elem_id, elem_class]); elem = (Element?)uninitializedObject; return true; diff --git a/Tests/ValveMap.cs b/Tests/ValveMap.cs index f8fe7e5..8ce70c5 100644 --- a/Tests/ValveMap.cs +++ b/Tests/ValveMap.cs @@ -180,7 +180,7 @@ internal class CMapSelectionSet : DMElement { public Datamodel.ElementArray Children { get; } = []; public string SelectionSetName { get; set; } = string.Empty; - public CObjectSelectionSetDataElement SelectionSetData { get; set; } = []; + public DMElement SelectionSetData { get; set; } = []; public CMapSelectionSet() { } public CMapSelectionSet(string name) @@ -195,6 +195,12 @@ internal class CObjectSelectionSetDataElement : DMElement public Datamodel.ElementArray selectedObjects { get; set; } = []; } +internal class CFaceSelectionSetDataElement : DMElement +{ + public Datamodel.IntArray faces { get; set; } = []; + public Datamodel.ElementArray meshes { get; set; } = []; +} + internal class CMapEntity : BaseEntity {