Skip to content

Commit

Permalink
Actual fix for (#2716)
Browse files Browse the repository at this point in the history
  • Loading branch information
ITeMbI4 authored Jul 15, 2024
1 parent ee1152a commit 8e333e1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
8 changes: 4 additions & 4 deletions Exiled.API/Features/Toys/AdminToy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,17 @@ public Footprint Footprint
/// </summary>
public new Vector3 Position
{
get => AdminToyBase.Position;
set => AdminToyBase.Position = value;
get => AdminToyBase.transform.position;
set => AdminToyBase.transform.position = value;
}

/// <summary>
/// Gets or sets the scale of the toy.
/// </summary>
public Vector3 Scale
{
get => AdminToyBase.Scale;
set => AdminToyBase.Scale = value;
get => AdminToyBase.transform.localScale;
set => AdminToyBase.transform.localScale = value;
}

/// <summary>
Expand Down
23 changes: 12 additions & 11 deletions Exiled.API/Features/Toys/Primitive.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ public PrimitiveFlags Flags
/// <param name="isStatic">Whether or not the primitive is static.</param>
/// <param name="spawn">Whether or not the primitive should be spawned.</param>
/// <returns>The newly created <see cref="Primitive"/>.</returns>
public static Primitive Create(PrimitiveType primitiveType, PrimitiveFlags flags = default, Color? color = null, Vector3? position = null, Quaternion? rotation = null, Vector3? scale = null, bool isStatic = false, bool spawn = true)
=> Create(new(primitiveType, color, position, flags, rotation, scale, isStatic, spawn));
public static Primitive Create(PrimitiveType primitiveType, PrimitiveFlags flags = PrimitiveFlags.Visible | PrimitiveFlags.Collidable, Color? color = null, Vector3? position = null, Quaternion? rotation = null, Vector3? scale = null, bool isStatic = false, bool spawn = true)
=> Create(new(primitiveType, flags, color, position, rotation, scale, isStatic, spawn));

/// <summary>
/// Creates a new <see cref="Primitive"/>.
Expand All @@ -112,15 +112,16 @@ public static Primitive Create(PrimitiveType primitiveType, PrimitiveFlags flags
/// <returns>The new <see cref="Primitive"/>.</returns>
public static Primitive Create(PrimitiveSettings primitiveSettings)
{
Primitive primitive = new(Object.Instantiate(PrefabObject.GetComponent<PrimitiveObjectToy>()));

primitive.Base.NetworkPrimitiveType = primitiveSettings.PrimitiveType;
primitive.AdminToyBase.transform.position = primitiveSettings.Position;
primitive.AdminToyBase.transform.rotation = primitiveSettings.Rotation;
primitive.AdminToyBase.transform.localScale = primitiveSettings.Scale;
primitive.Flags = primitiveSettings.Flags;
primitive.Color = primitiveSettings.Color;
primitive.IsStatic = primitiveSettings.IsStatic;
Primitive primitive = new(Object.Instantiate(PrefabObject.GetComponent<PrimitiveObjectToy>()))
{
Type = primitiveSettings.PrimitiveType,
Flags = primitiveSettings.Flags,
Color = primitiveSettings.Color,
Position = primitiveSettings.Position,
Rotation = primitiveSettings.Rotation,
Scale = primitiveSettings.Scale,
IsStatic = primitiveSettings.IsStatic,
};

if (primitiveSettings.ShouldSpawn)
primitive.Spawn();
Expand Down
6 changes: 3 additions & 3 deletions Exiled.API/Structs/PrimitiveSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ public struct PrimitiveSettings
/// <param name="scale">The scale of the primitive.</param>
/// <param name="spawn">Whether or not the primitive should be spawned.</param>
/// <param name="isStatic">Whether or not the primitive should be static.</param>
public PrimitiveSettings(PrimitiveType primitiveType, Color? color, Vector3? position, PrimitiveFlags flags = PrimitiveFlags.Visible | PrimitiveFlags.Collidable, Quaternion? rotation = null, Vector3? scale = null, bool isStatic = false, bool spawn = true)
public PrimitiveSettings(PrimitiveType primitiveType, PrimitiveFlags flags = PrimitiveFlags.Visible | PrimitiveFlags.Collidable, Color? color = null, Vector3? position = null, Quaternion? rotation = null, Vector3? scale = null, bool isStatic = false, bool spawn = true)
{
PrimitiveType = primitiveType;
PrimitiveType = primitiveType;
Flags = flags;
Color = color ?? Color.gray;
Position = position ?? Vector3.one;
Flags = flags;
Rotation = rotation ?? Quaternion.identity;
Scale = scale ?? Vector3.one;
IsStatic = isStatic;
Expand Down

0 comments on commit 8e333e1

Please sign in to comment.