Skip to content

Commit 8e34aa4

Browse files
committed
Blackout changes
* It is now possible to make it so that if the SCP-575 disappears before the end of the blackout, the blackout will end.
1 parent 13f0a15 commit 8e34aa4

File tree

4 files changed

+29
-3
lines changed

4 files changed

+29
-3
lines changed

SCP575/Config.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ public class BlackoutConfig
7878
[Description("The minimum duration of a delay after a blackout")]
7979
public int MaxDelay { get; set; } = 400;
8080

81+
[Description("If the SCP-575 disappears before the duration of the blackout should the blackout end?")]
82+
public bool EndBlackoutWhenDisappearing { get; set; } = true;
83+
8184
[Description("Before starting the blackout Cassie will say this message")]
8285
public string CassieMessage { get; set; } =
8386
"facility power system failure in 3 . pitch_.80 2 . pitch_.60 1 . pitch_.49 . .g1 pitch_.42 .g2 pitch_.31 .g5";
@@ -198,6 +201,6 @@ public class ResponseCommandConfig
198201
public string Spawning { get; set; } = "Spawning a SCP-575 to hunt {0} for {1} seconds";
199202

200203
[YamlMember(ScalarStyle = YamlDotNet.Core.ScalarStyle.DoubleQuoted)]
201-
public string HelpResponse { get; set; } = "Correct use of the command {0}\nPlayer ID | It is a numerical ID that changes with each new round and each time someone connects to the server again.\nDuration | The time (in seconds) that the SCP-575 will hunt someone";
204+
public string HelpResponse { get; set; } = "Correct use of the command {0}\nPlayer ID | It is a numerical ID that changes with each new round and each time someone connects to the server again.\nDuration | The time (in seconds) that the SCP-575 will hunt someone\n\nNote that this command does not turn off the lights, so if the SCP-575 is in a lit room for more than 5 seconds it will disappear.";
202205
}
203206
}

SCP575/Resources/Components/Scp575Component.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ private IEnumerator<float> Checks()
181181
/// </summary>
182182
private void OnDestroy()
183183
{
184+
if (Scp575.Instance.Config.BlackOut.EndBlackoutWhenDisappearing)
185+
Extensions.EndBlackout();
186+
184187
var dummyPlayer = Dummies.DummiesPlayers.FirstOrDefault(d => d.ReferenceHub == ReferenceHub);
185188

186189
dummyPlayer?.StopAudio();

SCP575/Resources/Extensions.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
using MapGeneration;
22
using Mirror;
33
using PluginAPI.Core;
4+
using RemoteAdmin;
45
using System;
6+
using System.Collections.Generic;
57
using System.IO;
68
using System.Linq;
79
using System.Reflection;
@@ -11,6 +13,7 @@ namespace SCP575.Resources
1113
{
1214
public static class Extensions
1315
{
16+
private static List<RoomLightController> _roomLightsAffected = new();
1417
/// <summary>
1518
/// Checks for .ogg files in the sounds folder
1619
/// </summary>
@@ -60,9 +63,10 @@ public static bool IsDummy(ReferenceHub hub)
6063
/// Turns off the lights in the specified zone, for a period of time.
6164
/// </summary>
6265
/// <param name="duration">The duration in seconds of the blackout</param>
63-
public static void FlickerLights(float duration, bool antiScp173 = false)
66+
public static void StartBlackout(float duration, bool antiScp173 = false)
6467
{
6568
var roomLightControllers = RoomLightController.Instances;
69+
_roomLightsAffected.Clear();
6670

6771
if (Scp575.Instance.Config.ActiveInHeavy)
6872
{
@@ -71,7 +75,9 @@ public static void FlickerLights(float duration, bool antiScp173 = false)
7175
if (controller.Room.Zone != FacilityZone.HeavyContainment ||
7276
Scp575.Instance.Config.BlackOut.BlackListRooms.Count > 0 &&
7377
Scp575.Instance.Config.BlackOut.BlackListRooms.Contains(controller.Room.Name)) continue;
78+
7479
controller.ServerFlickerLights(duration);
80+
_roomLightsAffected.Add(controller);
7581
}
7682
}
7783

@@ -85,6 +91,7 @@ public static void FlickerLights(float duration, bool antiScp173 = false)
8591
Scp575.Instance.Config.BlackOut.BlackListRooms.Count > 0 &&
8692
Scp575.Instance.Config.BlackOut.BlackListRooms.Contains(controller.Room.Name)) continue;
8793
controller.ServerFlickerLights(duration);
94+
_roomLightsAffected.Add(controller);
8895
}
8996
}
9097
}
@@ -97,10 +104,22 @@ public static void FlickerLights(float duration, bool antiScp173 = false)
97104
Scp575.Instance.Config.BlackOut.BlackListRooms.Count > 0 &&
98105
Scp575.Instance.Config.BlackOut.BlackListRooms.Contains(controller.Room.Name)) continue;
99106
controller.ServerFlickerLights(duration);
107+
_roomLightsAffected.Add(controller);
100108
}
101109
}
102110
}
103111

112+
/// <summary>
113+
/// End current blackout.
114+
/// </summary>
115+
public static void EndBlackout()
116+
{
117+
foreach(var roomLight in _roomLightsAffected)
118+
{
119+
roomLight.ServerFlickerLights(0);
120+
}
121+
}
122+
104123
/// <summary>
105124
/// Check if the current room is with the lights on.
106125
/// </summary>

SCP575/Scp575.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ private IEnumerator<float> Blackout()
167167
}
168168

169169
// Turn off the lights in the area
170-
Extensions.FlickerLights(blackoutDuration, antiScp173);
170+
Extensions.StartBlackout(blackoutDuration, antiScp173);
171171

172172
// Decide the delay by calculating between the minimum and the maximum value.
173173
yield return Timing.WaitForSeconds(_rng.Next(Config.BlackOut.MinDelay, Config.BlackOut.MaxDelay) +
@@ -349,6 +349,7 @@ private bool GetScp173()
349349
if (player.Role == RoleTypeId.Scp173)
350350
{
351351
value = true;
352+
break;
352353
}
353354
}
354355

0 commit comments

Comments
 (0)