diff --git a/EXILED/Exiled.API/Features/Room.cs b/EXILED/Exiled.API/Features/Room.cs index f0440ad64..4efae3acd 100644 --- a/EXILED/Exiled.API/Features/Room.cs +++ b/EXILED/Exiled.API/Features/Room.cs @@ -517,8 +517,6 @@ private void InternalCreate() Log.Error($"[ROOMTYPE UNKNOWN] {this} Name : {gameObject?.name} Shape : {Identifier?.Shape}"); #endif - RoomLightControllersValue.AddRange(gameObject.GetComponentsInChildren()); - RoomLightControllers = RoomLightControllersValue.AsReadOnly(); GetComponentsInChildren().ForEach(component => diff --git a/EXILED/Exiled.Events/Patches/Generic/RoomLightControllersList.cs b/EXILED/Exiled.Events/Patches/Generic/RoomLightControllersList.cs new file mode 100644 index 000000000..129585e26 --- /dev/null +++ b/EXILED/Exiled.Events/Patches/Generic/RoomLightControllersList.cs @@ -0,0 +1,39 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) ExMod Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.Patches.Generic +{ + using Exiled.API.Features; +#pragma warning disable SA1313 +#pragma warning disable SA1402 + + using HarmonyLib; + + /// + /// Patch for adding to list. + /// + [HarmonyPatch(typeof(RoomLightController), nameof(RoomLightController.Start))] + internal class RoomLightControllersList + { + private static void Postfix(RoomLightController __instance) + { + Room.Get(__instance.Room).RoomLightControllersValue.Add(__instance); + } + } + + /// + /// Patch for removing to list. + /// + [HarmonyPatch(typeof(RoomLightController), nameof(RoomLightController.OnDestroy))] + internal class RoomLightControllersList2 + { + private static void Postfix(RoomLightController __instance) + { + Room.Get(__instance.Room).RoomLightControllersValue.Remove(__instance); + } + } +} \ No newline at end of file