diff --git a/MoreHazards/MoreHazards/Doors.cs b/MoreHazards/MoreHazards/Doors.cs index a2470a0..f73d582 100644 --- a/MoreHazards/MoreHazards/Doors.cs +++ b/MoreHazards/MoreHazards/Doors.cs @@ -14,12 +14,12 @@ namespace MoreHazards { - class DoorEventManager : EventManager + class DoorLogicManager : LogicManager { private static CoroutineHandle CoroutineHandle; private static readonly DoorConfig Config = MoreHazards.Instance.Config.Doors; - public DoorEventManager() + public DoorLogicManager() { Warhead.Detonated += OnDetonated; } @@ -30,7 +30,7 @@ public override void Dispose() Warhead.Detonated -= OnDetonated; } - public override void OnRoundStart() + public override void OnRoundStart() { if (!Config.Enabled) return; @@ -58,8 +58,9 @@ public IEnumerator Timer() //random door of the room the player is inside var door = CollectionUtils.GetRandomElement((Map.FindParentRoom(player.GameObject).Doors)); - + door.NetworkTargetState = false; + Debug.Log("Door closed on player:"+player.Nickname); } } } diff --git a/MoreHazards/MoreHazards/Elevators.cs b/MoreHazards/MoreHazards/Elevators.cs index 4cf9362..b916005 100644 --- a/MoreHazards/MoreHazards/Elevators.cs +++ b/MoreHazards/MoreHazards/Elevators.cs @@ -14,7 +14,7 @@ namespace MoreHazards { - public class ElevatorEventManager : EventManager + public class ElevatorLogicManager : LogicManager { private CoroutineHandle CoroutineHandle; private readonly ElevatorsConfig Config = MoreHazards.Instance.Config.Elevators; @@ -30,7 +30,7 @@ public class ElevatorEventManager : EventManager [ElevatorType.GateB] = (RoomType.EzGateB, RoomType.Unknown) }; - public ElevatorEventManager() + public ElevatorLogicManager() { Warhead.Detonated += OnDetonated; } @@ -88,6 +88,8 @@ public void LiftBreakdown(int duration) lift.operative = false; + Debug.Log($"Elevator {lift.Type()} disabled for {duration}"); + if (Config.BlackoutRoom) { var lower = ElevatorToRoomsLookup[lift.Type()].lower; diff --git a/MoreHazards/MoreHazards/EventManager.cs b/MoreHazards/MoreHazards/LogicManager.cs similarity index 90% rename from MoreHazards/MoreHazards/EventManager.cs rename to MoreHazards/MoreHazards/LogicManager.cs index 8701689..70f0652 100644 --- a/MoreHazards/MoreHazards/EventManager.cs +++ b/MoreHazards/MoreHazards/LogicManager.cs @@ -10,9 +10,9 @@ namespace MoreHazards { - public class EventManager : IDisposable + public class LogicManager : IDisposable { - public EventManager() + public LogicManager() { Handlers.Server.RoundStarted += OnRoundStart; Handlers.Server.RoundEnded += OnRoundEnd; diff --git a/MoreHazards/MoreHazards/MoreHazards.cs b/MoreHazards/MoreHazards/MoreHazards.cs index 22878ac..1ba15c1 100644 --- a/MoreHazards/MoreHazards/MoreHazards.cs +++ b/MoreHazards/MoreHazards/MoreHazards.cs @@ -4,6 +4,7 @@ using System.Runtime.CompilerServices; using System.Text; using System.Threading.Tasks; +using CustomPlayerEffects; using Discord; using Exiled.API.Enums; using Exiled.API.Features; @@ -23,14 +24,14 @@ public class MoreHazards : Plugin public override string Author { get; } = "Maticzpl"; public override string Name { get; } = "More Hazards"; - public override Version Version { get; } = new Version(1, 0, 0); + public override Version Version { get; } = new Version(0, 1, 0); public override Version RequiredExiledVersion { get; } = new Version(2, 9, 0); private MoreHazards() { } - private static List EventHandlers = new List(); + private static List LogicHandlers = new List(); public static MoreHazards Instance => singleton; public override PluginPriority Priority { get; } = PluginPriority.Medium; @@ -40,9 +41,9 @@ public override void OnEnabled() { base.OnEnabled(); - EventHandlers.Add(new TeslaGateManager()); - EventHandlers.Add(new ElevatorEventManager()); - EventHandlers.Add(new DoorEventManager()); + LogicHandlers.Add(new TeslaGateManager()); + LogicHandlers.Add(new ElevatorLogicManager()); + LogicHandlers.Add(new DoorLogicManager()); } @@ -50,7 +51,7 @@ public override void OnDisabled() { base.OnDisabled(); - EventHandlers.Clear(); + LogicHandlers.Clear(); } } diff --git a/MoreHazards/MoreHazards/MoreHazards.csproj b/MoreHazards/MoreHazards/MoreHazards.csproj index 48a157e..ecbce2b 100644 --- a/MoreHazards/MoreHazards/MoreHazards.csproj +++ b/MoreHazards/MoreHazards/MoreHazards.csproj @@ -84,7 +84,7 @@ - + diff --git a/MoreHazards/MoreHazards/TeslaGates.cs b/MoreHazards/MoreHazards/TeslaGates.cs index dd7842c..f05fe21 100644 --- a/MoreHazards/MoreHazards/TeslaGates.cs +++ b/MoreHazards/MoreHazards/TeslaGates.cs @@ -16,7 +16,7 @@ namespace MoreHazards { - public class TeslaGateManager : EventManager + public class TeslaGateManager : LogicManager { private Dictionary TeslaStates = new Dictionary(); public List IgnoredByTesla { get; } = new List(); @@ -27,6 +27,7 @@ public void LoadRolesFromConfig(Config config) IgnoredByTesla.Clear(); foreach (var role in config.Tesla.IgnoredRoles) { + Debug.Log($"Tesla ignore role: {role}"); IgnoredByTesla.Add(role); } } @@ -59,6 +60,8 @@ public void DisableRandomGates(short ChancePerGate, short MaxDisabledGates, shor SetTeslaEnabled(tesla, false); } + Debug.Log($"Disabled {DisabledGates} tesla gates"); + } public TeslaGateManager() @@ -75,7 +78,6 @@ public override void Dispose() public override void OnRoundStart() { - DisableRandomGates( Config.TeslaGateDisableChance, Config.MaxDisabledTeslaGates, @@ -98,6 +100,7 @@ public void OnTeslaTrigger(TriggeringTeslaEventArgs ev) if (IgnoredByTesla.Contains(ev.Player.Role)) { ev.IsTriggerable = false; + Debug.Log($"Tesla ignored by player role"); return; } @@ -115,6 +118,7 @@ public void OnTeslaTrigger(TriggeringTeslaEventArgs ev) if (Vector3.Distance(ev.Player.Position, tesla.Key) < 7) { ev.IsTriggerable = false; + Debug.Log($"Player crossed disabled tesla"); return; } } diff --git a/MoreHazards/MoreHazards/utils.cs b/MoreHazards/MoreHazards/utils.cs index 8c67d8e..9c7ecf7 100644 --- a/MoreHazards/MoreHazards/utils.cs +++ b/MoreHazards/MoreHazards/utils.cs @@ -90,14 +90,18 @@ public void Speak() Cassie.GlitchyMessage(Text, Glitches, Jams); } } - public class CollectionUtils { - public static TValue GetRandomElement(ICollection collection) + /* public static TValue GetRandomElement(IReadOnlyCollection collection) { int index = UnityEngine.Random.Range(0,collection.Count-1); return collection.ElementAt(index); } + public static TValue GetRandomElement(List collection) + { + int index = UnityEngine.Random.Range(0, collection.Count - 1); + return collection[index]; + }*/ public static TValue GetRandomElement(IEnumerable enumerable) { var collection = (enumerable as IReadOnlyList) ?? enumerable.ToArray(); @@ -105,4 +109,15 @@ public static TValue GetRandomElement(IEnumerable enumerable) return collection[index]; } } + + public class Debug + { + public static void Log(object msg) + { + if (MoreHazards.Instance.Config.Debug) + { + Exiled.API.Features.Log.Debug(msg); + } + } + } }