Skip to content

Commit

Permalink
fix: RoomLightControllersValue Fix (#346)
Browse files Browse the repository at this point in the history
* RoomLightControllersValue Fix

* remove non used using
  • Loading branch information
louis1706 authored Dec 26, 2024
1 parent d513ff1 commit b1920da
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
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);
}
}
}

0 comments on commit b1920da

Please sign in to comment.