Skip to content

Commit

Permalink
Setting variable on entity instance now looks to Entity's variable fo…
Browse files Browse the repository at this point in the history
…r the type

fixes #1302
  • Loading branch information
vchelaru committed Jan 9, 2024
1 parent 092799b commit 0d1e4d9
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions FRBDK/Glue/Glue/SaveClasses/NamedObjectSaveExtensionMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -510,8 +510,20 @@ public static void SetVariable(this NamedObjectSave instance, string variableNam
}
else
{
var type = value?.GetType();
instruction = instance.AddNewGenericInstructionFor(variableName, type);
// If it comes from an entity, try to assign the type from the entity. This is needed if the variable
// is an Entity.Type property
var nosEntity = ObjectFinder.Self.GetEntitySave(instance);
var variable = nosEntity?.GetCustomVariableRecursively(variableName);

if(variable != null)
{
instruction = instance.AddInstruction(variableName, variable.Type);
}
else
{
var type = value?.GetType();
instruction = instance.AddNewGenericInstructionFor(variableName, type);
}
}
}

Expand Down

0 comments on commit 0d1e4d9

Please sign in to comment.