diff --git a/EXILED/Exiled.API/Features/Toys/AdminToy.cs b/EXILED/Exiled.API/Features/Toys/AdminToy.cs index 15cbc0ab7..6f8fe5555 100644 --- a/EXILED/Exiled.API/Features/Toys/AdminToy.cs +++ b/EXILED/Exiled.API/Features/Toys/AdminToy.cs @@ -101,7 +101,33 @@ public Quaternion Rotation } /// - /// Gets or sets the scale of the toy. + /// Gets or sets the local position of the toy relative to its parent. + /// + public Vector3 LocalPosition + { + get => Transform.localPosition; + set + { + Transform.localPosition = value; + AdminToyBase.NetworkPosition = value; + } + } + + /// + /// Gets or sets the local rotation of the toy relative to its parent. + /// + public Quaternion LocalRotation + { + get => Transform.localRotation; + set + { + Transform.localRotation = value; + AdminToyBase.NetworkRotation = value; + } + } + + /// + /// Gets or sets the local scale of the toy. /// public Vector3 Scale { diff --git a/EXILED/Exiled.API/Features/Toys/CameraToy.cs b/EXILED/Exiled.API/Features/Toys/CameraToy.cs index 85727a176..13384f91f 100644 --- a/EXILED/Exiled.API/Features/Toys/CameraToy.cs +++ b/EXILED/Exiled.API/Features/Toys/CameraToy.cs @@ -156,12 +156,11 @@ public static CameraToy Create(Transform parent = null, CameraType type = Camera CameraToy toy = new(Object.Instantiate(prefab, parent)) { Name = name, + LocalPosition = position ?? Vector3.zero, + LocalRotation = rotation ?? Quaternion.identity, + Scale = scale ?? Vector3.one, }; - toy.Transform.localPosition = position ?? Vector3.zero; - toy.Transform.localRotation = rotation ?? Quaternion.identity; - toy.Transform.localScale = scale ?? Vector3.one; - if (verticalConstraint.HasValue) toy.VerticalConstraint = verticalConstraint.Value; diff --git a/EXILED/Exiled.API/Features/Toys/Capybara.cs b/EXILED/Exiled.API/Features/Toys/Capybara.cs index d615b25a1..664282901 100644 --- a/EXILED/Exiled.API/Features/Toys/Capybara.cs +++ b/EXILED/Exiled.API/Features/Toys/Capybara.cs @@ -83,12 +83,11 @@ public static Capybara Create(Transform parent = null, Vector3? position = null, Capybara toy = new(Object.Instantiate(Prefab, parent)) { Collidable = collidable, + LocalPosition = position ?? Vector3.zero, + LocalRotation = rotation ?? Quaternion.identity, + Scale = scale ?? Vector3.one, }; - toy.Transform.localPosition = position ?? Vector3.zero; - toy.Transform.localRotation = rotation ?? Quaternion.identity; - toy.Transform.localScale = scale ?? Vector3.one; - if (spawn) toy.Spawn(); diff --git a/EXILED/Exiled.API/Features/Toys/InteractableToy.cs b/EXILED/Exiled.API/Features/Toys/InteractableToy.cs index 1653e69b7..cb9b7b4e9 100644 --- a/EXILED/Exiled.API/Features/Toys/InteractableToy.cs +++ b/EXILED/Exiled.API/Features/Toys/InteractableToy.cs @@ -120,12 +120,11 @@ public static InteractableToy Create(Transform parent = null, Vector3? position Shape = shape, IsLocked = isLocked, InteractionDuration = interactionDuration, + LocalPosition = position ?? Vector3.zero, + LocalRotation = rotation ?? Quaternion.identity, + Scale = scale ?? Vector3.one, }; - toy.Transform.localPosition = position ?? Vector3.zero; - toy.Transform.localRotation = rotation ?? Quaternion.identity; - toy.Transform.localScale = scale ?? Vector3.one; - if (spawn) toy.Spawn(); diff --git a/EXILED/Exiled.API/Features/Toys/Text.cs b/EXILED/Exiled.API/Features/Toys/Text.cs index 055993e4a..bfb310186 100644 --- a/EXILED/Exiled.API/Features/Toys/Text.cs +++ b/EXILED/Exiled.API/Features/Toys/Text.cs @@ -105,12 +105,11 @@ public static Text Create(Vector3? position = null, Quaternion? rotation = null, { TextFormat = text, DisplaySize = displaySize ?? new Vector3(50, 50), + LocalPosition = position ?? Vector3.zero, + LocalRotation = rotation ?? Quaternion.identity, + Scale = scale ?? Vector3.one, }; - textToy.Transform.localPosition = position ?? Vector3.zero; - textToy.Transform.localRotation = rotation ?? Quaternion.identity; - textToy.Transform.localScale = scale ?? Vector3.one; - if (spawn) textToy.Spawn(); diff --git a/EXILED/Exiled.API/Features/Toys/Waypoint.cs b/EXILED/Exiled.API/Features/Toys/Waypoint.cs index 0de33936a..635894b83 100644 --- a/EXILED/Exiled.API/Features/Toys/Waypoint.cs +++ b/EXILED/Exiled.API/Features/Toys/Waypoint.cs @@ -111,11 +111,10 @@ public static Waypoint Create(Transform parent = null, Vector3? position = null, Priority = priority, BoundsSize = scale ?? Vector3.one * 255.9961f, VisualizeBounds = visualizeBounds, + LocalPosition = position ?? Vector3.zero, + LocalRotation = rotation ?? Quaternion.identity, }; - toy.Transform.localPosition = position ?? Vector3.zero; - toy.Transform.localRotation = rotation ?? Quaternion.identity; - if (spawn) toy.Spawn();