diff --git a/LuaScript.Runtime/Anchor/AnchorSupport.cs b/LuaScript.Runtime/Anchor/AnchorSupport.cs index fc689a5..f6100e7 100644 --- a/LuaScript.Runtime/Anchor/AnchorSupport.cs +++ b/LuaScript.Runtime/Anchor/AnchorSupport.cs @@ -9,6 +9,13 @@ namespace LuaScript.Anchor public static int ClampCount(int count) => Math.Clamp(count, 0, MaxAnchors); + public static int NormalizeCount(string group, int count) + { + if (count <= 0 && string.Equals(group, TrackGroup, StringComparison.Ordinal)) + return 1; + return ClampCount(count); + } + public static void ApplyOption(string option, ref AnchorConnection connection, ref bool is3D) { switch (option) @@ -52,6 +59,35 @@ namespace LuaScript.Anchor z = 0d; } + public static ImmutableList SetPosition( + ImmutableList source, string group, int index, double x, double y, double z) + { + for (int i = 0; i < source.Count; i++) + { + var a = source[i]; + if (a.Index == index && string.Equals(a.Group, group, StringComparison.Ordinal)) + { + return source.SetItem(i, new LuaAnchorPoint + { + Group = group, + Index = index, + X = x, + Y = y, + Z = z, + }); + } + } + + return source.Add(new LuaAnchorPoint + { + Group = group, + Index = index, + X = x, + Y = y, + Z = z, + }); + } + public static ImmutableList ApplyDrag( ImmutableList source, string group, int index, double dx, double dy, double dz) {