Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions AttributeList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
3 changes: 1 addition & 2 deletions ICodec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,11 @@ public static bool TryConstructCustomElement(Dictionary<string, Type> 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;
Expand Down
8 changes: 7 additions & 1 deletion Tests/ValveMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
{
Expand Down