Skip to content
Open
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
4 changes: 2 additions & 2 deletions EXILED/Exiled.API/Features/Toys/AdminToy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public Vector3 Scale
/// </summary>
public byte MovementSmoothing
{
get => AdminToyBase.MovementSmoothing;
get => AdminToyBase.NetworkMovementSmoothing;
set => AdminToyBase.NetworkMovementSmoothing = value;
}

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

Expand Down
11 changes: 5 additions & 6 deletions EXILED/Exiled.API/Features/Toys/CameraToy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,18 +124,18 @@ public string Name
/// Creates a new <see cref="CameraToy"/>.
/// </summary>
/// <param name="parent">The transform to create this <see cref="CameraToy"/> on.</param>
/// <param name="type">The <see cref="CameraType"/> of the camera.</param>
/// <param name="position">The local position of the camera.</param>
/// <param name="rotation">The local rotation of the camera.</param>
/// <param name="scale">The local scale of the camera.</param>
/// <param name="type">The <see cref="CameraType"/> of the camera.</param>
/// <param name="name">The name (label) of the camera.</param>
/// <param name="room">The room associated with this camera.</param>
/// <param name="verticalConstraint">The vertical limits. Leave null to use prefab default.</param>
/// <param name="horizontalConstraint">The horizontal limits. Leave null to use prefab default.</param>
/// <param name="zoomConstraint">The zoom limits. Leave null to use prefab default.</param>
/// <param name="spawn">Whether the camera should be initially spawned.</param>
/// <returns>The new <see cref="CameraToy"/>.</returns>
public static CameraToy Create(Transform parent = null, CameraType type = CameraType.EzArmCameraToy, Vector3? position = null, Quaternion? rotation = null, Vector3? scale = null, string name = "New Camera", Room room = null, Vector2? verticalConstraint = null, Vector2? horizontalConstraint = null, Vector2? zoomConstraint = null, bool spawn = true)
public static CameraToy Create(Transform parent = null, Vector3? position = null, Quaternion? rotation = null, Vector3? scale = null, CameraType type = CameraType.EzArmCameraToy, string name = "New Camera", Room room = null, Vector2? verticalConstraint = null, Vector2? horizontalConstraint = null, Vector2? zoomConstraint = null, bool spawn = true)
{
Scp079CameraToy prefab = type switch
{
Expand All @@ -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;

Expand Down
7 changes: 3 additions & 4 deletions EXILED/Exiled.API/Features/Toys/Capybara.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
32 changes: 8 additions & 24 deletions EXILED/Exiled.API/Features/Toys/InteractableToy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,7 @@ public bool IsLocked
}

/// <summary>
/// Creates a new <see cref="InteractableToy"/> at the specified position.
/// </summary>
/// <param name="position">The local position of the <see cref="InteractableToy"/>.</param>
/// <returns>The new <see cref="InteractableToy"/>.</returns>
public static InteractableToy Create(Vector3 position) => Create(position: position, spawn: true);

/// <summary>
/// Creates a new <see cref="InteractableToy"/> with a specific position and shape.
/// </summary>
/// <param name="position">The local position of the <see cref="InteractableToy"/>.</param>
/// <param name="shape">The shape of the collider.</param>
/// <returns>The new <see cref="InteractableToy"/>.</returns>
public static InteractableToy Create(Vector3 position, ColliderShape shape) => Create(position: position, shape: shape, spawn: true);

/// <summary>
/// Creates a new <see cref="InteractableToy"/> with a specific position, shape, and interaction duration.
/// Creates a new <see cref="InteractableToy"/>.
/// </summary>
/// <param name="position">The local position of the <see cref="InteractableToy"/>.</param>
/// <param name="shape">The shape of the collider.</param>
Expand All @@ -90,16 +75,16 @@ public bool IsLocked
public static InteractableToy Create(Vector3 position, ColliderShape shape, float duration) => Create(position: position, shape: shape, interactionDuration: duration, spawn: true);

/// <summary>
/// Creates a new <see cref="InteractableToy"/> from a Transform.
/// Creates a new <see cref="InteractableToy"/>.
/// </summary>
/// <param name="transform">The transform to create this <see cref="InteractableToy"/> on.</param>
/// <param name="position">The local position of the <see cref="InteractableToy"/>.</param>
/// <param name="shape">The shape of the collider.</param>
/// <param name="interactionDuration">How long the interaction takes.</param>
/// <param name="isLocked">Whether the object is locked.</param>
/// <param name="spawn">Whether the <see cref="InteractableToy"/> should be initially spawned.</param>
/// <returns>The new <see cref="InteractableToy"/>.</returns>
public static InteractableToy Create(Transform transform, ColliderShape shape = ColliderShape.Sphere, float interactionDuration = 1f, bool isLocked = false, bool spawn = true)
=> Create(parent: transform, shape: shape, interactionDuration: interactionDuration, isLocked: isLocked, spawn: spawn);
public static InteractableToy Create(Vector3 position, ColliderShape shape = ColliderShape.Sphere, float interactionDuration = 1f, bool isLocked = false, bool spawn = true)
=> Create(position: position, shape: shape, interactionDuration: interactionDuration, isLocked: isLocked, spawn: spawn);

/// <summary>
/// Creates a new <see cref="InteractableToy"/>.
Expand All @@ -120,12 +105,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();

Expand Down
58 changes: 43 additions & 15 deletions EXILED/Exiled.API/Features/Toys/Light.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ namespace Exiled.API.Features.Toys

using UnityEngine;

using Object = UnityEngine.Object;

/// <summary>
/// A wrapper class for <see cref="LightSourceToy"/>.
/// </summary>
Expand Down Expand Up @@ -129,36 +131,62 @@ public LightShadows ShadowType
/// 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="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)
=> Create(position, rotation, scale, spawn, null);
public static Light Create(Vector3 position, Color color) => Create(position: position, color: color, spawn: true);

/// <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="parent">The transform to create this <see cref="Light"/> on.</param>
/// <param name="position">The local position of the <see cref="Light"/>.</param>
/// <param name="rotation">The local rotation of the <see cref="Light"/>.</param>
/// <param name="scale">The scale 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>
/// <param name="intensity">The intensity of the light.</param>
/// <param name="range">The range of the light.</param>
/// <param name="spotAngle">The angle of the light.</param>
/// <param name="innerSpotAngle">The inner angle of the light.</param>
/// <param name="shadowStrength">The shadow strength of the light.</param>
/// <param name="lightType">The type of light the Light emits.</param>
/// <param name="shadowType">The type of shadows the light casts.</param>
/// <param name="spawn">Whether the <see cref="Light"/> should be initially spawned.</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(Transform parent = null, Vector3? position = null, Quaternion? rotation = null, Vector3? scale = null, Color? color = null, float? intensity = null, float? range = null, float? spotAngle = null, float? innerSpotAngle = null, float? shadowStrength = null, LightType? lightType = null, LightShadows? shadowType = null, bool spawn = true)
{
Light light = new(UnityEngine.Object.Instantiate(Prefab))
Light toy = new(Object.Instantiate(Prefab, parent))
{
Position = position ?? Vector3.zero,
Rotation = Quaternion.Euler(rotation ?? Vector3.zero),
LocalPosition = position ?? Vector3.zero,
LocalRotation = rotation ?? Quaternion.identity,
Scale = scale ?? Vector3.one,
Color = color ?? Color.gray,
Color = color ?? Color.white,
};

if (intensity.HasValue)
toy.Intensity = intensity.Value;

if (range.HasValue)
toy.Range = range.Value;

if (spotAngle.HasValue)
toy.SpotAngle = spotAngle.Value;

if (innerSpotAngle.HasValue)
toy.InnerSpotAngle = innerSpotAngle.Value;

if (shadowStrength.HasValue)
toy.ShadowStrength = shadowStrength.Value;

if (lightType.HasValue)
toy.LightType = lightType.Value;

if (shadowType.HasValue)
toy.ShadowType = shadowType.Value;

if (spawn)
light.Spawn();
toy.Spawn();

return light;
return toy;
}

/// <summary>
Expand Down
Loading
Loading