From 4d34f1edd1508ada2ad64cd7ea04a03dd666186d Mon Sep 17 00:00:00 2001 From: Lumi Date: Wed, 15 Jan 2025 19:58:23 +0000 Subject: [PATCH] feat: add transform create --- EXILED/Exiled.API/Features/Toys/Speaker.cs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/EXILED/Exiled.API/Features/Toys/Speaker.cs b/EXILED/Exiled.API/Features/Toys/Speaker.cs index 2ca0b29071..859a8f2055 100644 --- a/EXILED/Exiled.API/Features/Toys/Speaker.cs +++ b/EXILED/Exiled.API/Features/Toys/Speaker.cs @@ -122,6 +122,28 @@ public static Speaker Create(Vector3? position, Vector3? rotation, Vector3? scal return speaker; } + /// + /// Creates a new . + /// + /// The transform to create this on. + /// Whether the should be initially spawned. + /// Whether the should keep the same world position. + /// The new . + 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; + } + /// /// Plays audio through this speaker. ///