Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Resonance] Update toys #2746

Merged
merged 2 commits into from
Jul 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions Exiled.API/Features/Toys/AdminToy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ public Footprint Footprint
public Vector3 Position
{
get => Transform.position;
set => Transform.position = value;
set
{
Transform.position = value;
AdminToyBase.NetworkPosition = value;
}
}

/// <summary>
Expand All @@ -91,7 +95,11 @@ public Vector3 Position
public Quaternion Rotation
{
get => Transform.rotation;
set => Transform.rotation = value;
set
{
Transform.rotation = value;
AdminToyBase.NetworkRotation = new(value);
}
}

/// <summary>
Expand All @@ -100,7 +108,11 @@ public Quaternion Rotation
public Vector3 Scale
{
get => Transform.localScale;
set => Transform.localScale = value;
set
{
Transform.localScale = value;
AdminToyBase.NetworkScale = value;
}
}

/// <summary>
Expand All @@ -122,7 +134,7 @@ public byte MovementSmoothing
public bool IsStatic
{
get => AdminToyBase.IsStatic;
set => AdminToyBase.IsStatic = value;
set => AdminToyBase.NetworkIsStatic = value;
}

/// <summary>
Expand Down
25 changes: 12 additions & 13 deletions Exiled.API/Features/Toys/Light.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,31 +80,30 @@ public bool ShadowEmission
{
get => Base.NetworkLightShadows;
set => Base.NetworkLightShadows = value;
}
}

/// <summary>
/// Creates a new <see cref="Light"/>.
/// </summary>
/// <param name="position">The position of the <see cref="Light"/>.</param>
/// <param name="rotation">The rotation of the <see cref="Light"/>.</param>
/// <param name="scale">The scale of the <see cref="Light"/>.</param>
/// <param name="scale">The scale of the <see cref="Light"/>.</param>
/// <param name="color">The color of the <see cref="Light"/>.</param>
/// <param name="spawn">Whether the <see cref="Light"/> should be initially spawned.</param>
/// <param name="color">The color of the <see cref="Light"/>.</param>
/// <returns>The new <see cref="Light"/>.</returns>
public static Light Create(Vector3? position = null, Vector3? rotation = null, Vector3? scale = null, bool spawn = true, Color? color = null)
public static Light Create(Vector3? position = null, Quaternion? rotation = null, Vector3? scale = null, Color? color = null, bool spawn = true)
{
Light light = new(Object.Instantiate(PrefabObject.GetComponent<LightSourceToy>()));

Transform transform = light.Base.transform;
transform.position = position ?? Vector3.zero;
transform.eulerAngles = rotation ?? Vector3.zero;
transform.localScale = scale ?? Vector3.one;
Light light = new(Object.Instantiate(PrefabObject.GetComponent<LightSourceToy>()))
{
Position = position ?? Vector3.zero,
Rotation = rotation ?? Quaternion.identity,
Scale = scale ?? Vector3.one,
Color = color ?? Color.gray,
};

if (spawn)
light.Spawn();

light.Color = color ?? Color.gray;

return light;
}

Expand Down
9 changes: 4 additions & 5 deletions Exiled.API/Features/Toys/ShootingTargetToy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public bool IsSynced
/// <param name="scale">The scale of the <see cref="ShootingTargetToy"/>.</param>
/// <param name="spawn">Whether the <see cref="ShootingTargetToy"/> should be initially spawned.</param>
/// <returns>The new <see cref="ShootingTargetToy"/>.</returns>
public static ShootingTargetToy Create(ShootingTargetType type, Vector3? position = null, Vector3? rotation = null, Vector3? scale = null, bool spawn = true)
public static ShootingTargetToy Create(ShootingTargetType type, Vector3? position = null, Quaternion? rotation = null, Vector3? scale = null, bool spawn = true)
{
ShootingTargetToy shootingTargetToy = type switch
{
Expand All @@ -191,10 +191,9 @@ public static ShootingTargetToy Create(ShootingTargetType type, Vector3? positio
_ => new ShootingTargetToy(Object.Instantiate(SportTargetPrefabObject.GetComponent<ShootingTarget>()))
};

Transform transform = shootingTargetToy.Base.transform;
transform.position = position ?? Vector3.zero;
transform.eulerAngles = rotation ?? Vector3.zero;
transform.localScale = scale ?? Vector3.one;
shootingTargetToy.Position = position ?? Vector3.zero;
shootingTargetToy.Rotation = rotation ?? Quaternion.identity;
shootingTargetToy.Scale = scale ?? Vector3.one;

if (spawn)
shootingTargetToy.Spawn();
Expand Down
Loading