Add .X=*Y (property copy) feature

This commit is contained in:
Kurt 2022-03-04 22:35:04 -08:00
parent d0f2b6eeb5
commit 3ebf5279cc

View File

@ -65,6 +65,7 @@ public static class BatchEditing
internal const string CONST_SHINY = "$shiny";
internal const string CONST_SUGGEST = "$suggest";
private const string CONST_BYTES = "$[]";
private const string CONST_POINTER = "*";
internal const string PROP_LEGAL = "Legal";
internal const string PROP_TYPENAME = "ObjectType";
@ -360,7 +361,14 @@ private static ModifyResult SetPKMProperty(StringInstruction cmd, BatchInfo info
if (!pi.CanWrite)
return ModifyResult.Error;
object val = cmd.Random ? cmd.RandomValue : cmd.PropertyValue;
object val;
if (cmd.Random)
val = cmd.RandomValue;
else if (cmd.PropertyValue.StartsWith(CONST_POINTER) && props.TryGetValue(cmd.PropertyValue[1..], out var opi))
val = opi.GetValue(pk);
else
val = cmd.PropertyValue;
ReflectUtil.SetValue(pi, pk, val);
return ModifyResult.Modified;
}