ItemComponent properties that are editable in the editor are always saved

This commit is contained in:
Regalis
2016-05-26 16:10:24 +03:00
parent 7aa1b44cae
commit 6a3572e1d2

View File

@@ -255,18 +255,22 @@ namespace Barotrauma
object value = property.GetValue();
if (value == null) continue;
//only save if the value has been changed from the default value and the attribute is saveable
bool dontSave = true;
//only save
// - if the attribute is saveable
// - and it's different from the default value or can be changed in the editor
bool save = false;
foreach (var attribute in property.Attributes.OfType<HasDefaultValue>())
{
if (attribute.isSaveable && !attribute.defaultValue.Equals(value))
if (!attribute.isSaveable) continue;
if (!attribute.defaultValue.Equals(value) || property.Attributes.OfType<Editable>().Any())
{
dontSave = false;
save = true;
break;
}
}
if (dontSave) continue;
if (!save) continue;
string stringValue;
if (value is float)