Skip to content
This repository has been archived by the owner on Jan 17, 2024. It is now read-only.

Commit

Permalink
Bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Maticzpl committed Mar 20, 2021
1 parent 19c8e8b commit c7d51c2
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 6 deletions.
1 change: 0 additions & 1 deletion MoreHazards/MoreHazards/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public class Config : IConfig

public class ElevatorsConfig
{
[Description("EVENT: Elevators will sometimes breakdown and stop working")]
public bool Enabled { get; set; } = false;

[Description("List of all the elevators that can break down. AVAILABLE: LczA LczB Nuke Scp049 GateA GateB")]
Expand Down
26 changes: 23 additions & 3 deletions MoreHazards/MoreHazards/Doors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Interactables.Interobjects.DoorUtils;
using MEC;
using Warhead = Exiled.Events.Handlers.Warhead;
using Player = Exiled.Events.Handlers.Player;

namespace MoreHazards
{
Expand All @@ -20,22 +21,28 @@ class DoorLogicManager : LogicManager
private static CoroutineHandle FullBreakdownHandle;
private static readonly DoorConfig MalfunctionConfig = MoreHazards.Instance.Config.DoorMalfunction;
private static readonly DoorSystemBreakdownConfig BreakdownConfig = MoreHazards.Instance.Config.DoorSystemBreakdown;

private static bool scp079Exists = false;
public DoorLogicManager()
{
Warhead.Detonated += TerminateCoroutines;
Player.ChangingRole += OnRoleChange;
}

public override void Dispose()
{
base.Dispose();
Warhead.Detonated -= TerminateCoroutines;
Player.ChangingRole -= OnRoleChange;
}

public override void OnRoundStart()
{
if(MalfunctionConfig.Enabled)
if (MalfunctionConfig.Enabled
&&
!(scp079Exists && MalfunctionConfig.DisableIf079Exists))
{
RandomMalfunctionHandle = Timing.RunCoroutine(RandomDoorMalfunction());
}

if (BreakdownConfig.Enabled)
FullBreakdownHandle = Timing.RunCoroutine(FullDoorBreakdown());
Expand All @@ -44,6 +51,19 @@ public override void OnRoundEnd(RoundEndedEventArgs ev)
{
TerminateCoroutines();
}

public void OnRoleChange(ChangingRoleEventArgs ev)
{
if (!MalfunctionConfig.DisableIf079Exists)
return;

if (ev.NewRole == RoleType.Scp079)
{
scp079Exists = true;
Timing.KillCoroutines(RandomMalfunctionHandle);
Log.Debug("Door Malfunctions disabled, SCP079 exists",MoreHazards.Instance.Config.Debug);
}
}
public void TerminateCoroutines()
{
Timing.KillCoroutines(RandomMalfunctionHandle);
Expand All @@ -56,7 +76,7 @@ public IEnumerator<float> RandomDoorMalfunction()
while (Round.IsStarted)
{
yield return Timing.WaitForSeconds(MalfunctionConfig.RandomDoorMalfunctionTiming.GetInterval());
foreach (var player in Player.List)
foreach (var player in Exiled.API.Features.Player.List)
{
if (MalfunctionConfig.IgnoredRoles.Contains(player.Role))
continue;
Expand Down
2 changes: 1 addition & 1 deletion MoreHazards/MoreHazards/MoreHazards.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class MoreHazards : Plugin<Config>

public override string Author { get; } = "Maticzpl";
public override string Name { get; } = "More Hazards";
public override Version Version { get; } = new Version(0, 2, 0);
public override Version Version { get; } = new Version(0, 2, 1);
public override Version RequiredExiledVersion { get; } = new Version(2, 9, 0);

private MoreHazards()
Expand Down
3 changes: 3 additions & 0 deletions MoreHazards/MoreHazards/TeslaGates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ public void SetTeslaEnabled(TeslaGate tesla,bool state)

public void DisableRandomGates(short ChancePerGate, short MaxDisabledGates, short GatesRequired)
{
if (!Config.DisablingTeslas)
return;

if (Map.TeslaGates.Count < GatesRequired)
return;

Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ more_hazards:
tesla_gate_disable_chance: 33
# Elevators Module - Once in a while an elevator can breakdown.
elevators:
# EVENT: Elevators will sometimes breakdown and stop working
enabled: false
# List of all the elevators that can break down. AVAILABLE: LczA LczB Nuke Scp049 GateA GateB
breakable_elevators:
Expand Down

0 comments on commit c7d51c2

Please sign in to comment.