diff --git a/FRBDK/Glue/GlueCommon/SaveClasses/PropertySave.cs b/FRBDK/Glue/GlueCommon/SaveClasses/PropertySave.cs index 5c37ae232..8cebf9cdc 100644 --- a/FRBDK/Glue/GlueCommon/SaveClasses/PropertySave.cs +++ b/FRBDK/Glue/GlueCommon/SaveClasses/PropertySave.cs @@ -156,35 +156,80 @@ public static void SetValue(this List propertySaveList, string newPropertySave.Name = nameToSearchFor; newPropertySave.Value = value; - if(typeof(T) == typeof(int)) - { - newPropertySave.Type = "int"; - } - else if(typeof(T) == typeof(float)) - { - newPropertySave.Type = "float"; - } - else if (typeof(T) == typeof(decimal)) - { - newPropertySave.Type = "decimal"; - } - else - { - newPropertySave.Type = typeof(T).Name; - } - + AssignTypeOnProperty(newPropertySave); propertySaveList.Add(newPropertySave); } } } - public static void SetValuePersistIfDefault(this List propertySaveList, string nameToSearchFor, object value) + private static void AssignTypeOnProperty(PropertySave newPropertySave) + { + if (typeof(T) == typeof(int)) + { + newPropertySave.Type = "int"; + } + else if(typeof(T) == typeof(int?)) + { + newPropertySave.Type = "int?"; + } + else if (typeof(T) == typeof(long)) + { + newPropertySave.Type = "long"; + } + else if (typeof(T) == typeof(long?)) + { + newPropertySave.Type = "long?"; + } + else if (typeof(T) == typeof(float)) + { + newPropertySave.Type = "float"; + } + else if (typeof(T) == typeof(float?)) + { + newPropertySave.Type = "float?"; + } + else if (typeof(T) == typeof(decimal)) + { + newPropertySave.Type = "decimal"; + } + else if (typeof(T) == typeof(decimal?)) + { + newPropertySave.Type = "decimal?"; + } + + else if (typeof(T) == typeof(bool)) + { + newPropertySave.Type = "bool"; + } + + else if (typeof(T) == typeof(bool?)) + { + newPropertySave.Type = "bool?"; + } + + else if (typeof(T) == typeof(byte)) + { + newPropertySave.Type = "byte"; + } + + else if (typeof(T) == typeof(byte?)) + { + newPropertySave.Type = "byte?"; + } + + else + { + newPropertySave.Type = typeof(T).Name; + } + } + + public static void SetValuePersistIfDefault(this List propertySaveList, string nameToSearchFor, T value) { SetValue(propertySaveList, nameToSearchFor, value, true); } - public static void SetValue(this List propertySaveList, string nameToSearchFor, object value, bool persistIfDefault) + public static void SetValue(this List propertySaveList, string nameToSearchFor, T value, bool persistIfDefault) { var handled = false; if(!persistIfDefault) @@ -211,6 +256,7 @@ public static void SetValue(this List propertySaveList, string nam PropertySave newPropertySave = new PropertySave(); newPropertySave.Name = nameToSearchFor; newPropertySave.Value = value; + AssignTypeOnProperty(newPropertySave); propertySaveList.Add(newPropertySave); } } diff --git a/FRBDK/Glue/OfficialPlugins/CollisionPlugin/ViewModels/RelationshipListCellViewModel.cs b/FRBDK/Glue/OfficialPlugins/CollisionPlugin/ViewModels/RelationshipListCellViewModel.cs index 525f8219a..0c2689329 100644 --- a/FRBDK/Glue/OfficialPlugins/CollisionPlugin/ViewModels/RelationshipListCellViewModel.cs +++ b/FRBDK/Glue/OfficialPlugins/CollisionPlugin/ViewModels/RelationshipListCellViewModel.cs @@ -84,8 +84,21 @@ public string RelationshipPhysicsDetails { if (CollisionRelationshipNamedObject != null) { - var collision = CollisionRelationshipNamedObject.Properties.GetValue( - nameof(CollisionRelationshipViewModel.CollisionType)) as int?; + int? collision = null; + + var collisionTypeAsObject = CollisionRelationshipNamedObject.Properties.GetValue( + nameof(CollisionRelationshipViewModel.CollisionType)); + + if(collisionTypeAsObject is int asInt) + { + collision = asInt; + } + else if(collisionTypeAsObject is long asLong) + { + // There's a bug in FRB where the Type would not get saved properly on a collision property. Let's tolerate that here + // for now. This bug has been fixed in FRB in November 2023, but we'll still add this here for Cranky Chibi Cthulhu + collision = (int)asLong; + } string physicsText = "No Physics";