Skip to content
Merged
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
22 changes: 22 additions & 0 deletions EXILED/Exiled.API/Features/Toys/Speaker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,28 @@ public static Speaker Create(Vector3? position, Vector3? rotation, Vector3? scal
return speaker;
}

/// <summary>
/// Creates a new <see cref="Speaker"/>.
/// </summary>
/// <param name="transform">The transform to create this <see cref="Speaker"/> on.</param>
/// <param name="spawn">Whether the <see cref="Speaker"/> should be initially spawned.</param>
/// <param name="worldPositionStays">Whether the <see cref="Speaker"/> should keep the same world position.</param>
/// <returns>The new <see cref="Speaker"/>.</returns>
public static Speaker Create(Transform transform, bool spawn, bool worldPositionStays = true)
{
Speaker speaker = new(Object.Instantiate(Prefab, transform, worldPositionStays))
{
Position = transform.position,
Rotation = transform.rotation,
Scale = transform.localScale.normalized,
};

if(spawn)
speaker.Spawn();

return speaker;
}

/// <summary>
/// Plays audio through this speaker.
/// </summary>
Expand Down
Loading