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

fix: RoomLightControllersValue Fix #346

Merged
merged 2 commits into from
Dec 26, 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
2 changes: 0 additions & 2 deletions EXILED/Exiled.API/Features/Room.cs
Original file line number Diff line number Diff line change
Expand Up @@ -517,8 +517,6 @@ private void InternalCreate()
Log.Error($"[ROOMTYPE UNKNOWN] {this} Name : {gameObject?.name} Shape : {Identifier?.Shape}");
#endif

RoomLightControllersValue.AddRange(gameObject.GetComponentsInChildren<RoomLightController>());

RoomLightControllers = RoomLightControllersValue.AsReadOnly();

GetComponentsInChildren<BreakableWindow>().ForEach(component =>
Expand Down
39 changes: 39 additions & 0 deletions EXILED/Exiled.Events/Patches/Generic/RoomLightControllersList.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// -----------------------------------------------------------------------
// <copyright file="RoomLightControllersList.cs" company="ExMod Team">
// Copyright (c) ExMod Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
// </copyright>
// -----------------------------------------------------------------------

namespace Exiled.Events.Patches.Generic
{
using Exiled.API.Features;
#pragma warning disable SA1313
#pragma warning disable SA1402

using HarmonyLib;

/// <summary>
/// Patch for adding <see cref="RoomLightController"/> to list.
/// </summary>
[HarmonyPatch(typeof(RoomLightController), nameof(RoomLightController.Start))]
internal class RoomLightControllersList
{
private static void Postfix(RoomLightController __instance)
{
Room.Get(__instance.Room).RoomLightControllersValue.Add(__instance);
}
}

/// <summary>
/// Patch for removing <see cref="RoomLightController"/> to list.
/// </summary>
[HarmonyPatch(typeof(RoomLightController), nameof(RoomLightController.OnDestroy))]
internal class RoomLightControllersList2
{
private static void Postfix(RoomLightController __instance)
{
Room.Get(__instance.Room).RoomLightControllersValue.Remove(__instance);
}
}
}
Loading