From 1f28546043ec640fe7fd057bafdbc20afeac927e Mon Sep 17 00:00:00 2001 From: IkaOverride <36999341+IkaOverride@users.noreply.github.com> Date: Sat, 7 Dec 2024 22:14:35 +0100 Subject: [PATCH] v2.4.1 (SCP SL 14) --- ShootingInteractions/EventsHandler.cs | 38 +++---------------- ShootingInteractions/Plugin.cs | 6 +-- .../ShootingInteractions.csproj | 14 +++---- 3 files changed, 14 insertions(+), 44 deletions(-) diff --git a/ShootingInteractions/EventsHandler.cs b/ShootingInteractions/EventsHandler.cs index 73a7e90..faec493 100644 --- a/ShootingInteractions/EventsHandler.cs +++ b/ShootingInteractions/EventsHandler.cs @@ -37,35 +37,14 @@ internal sealed class EventsHandler /// public static List BlacklistedObjects = new(); - public void OnShooting(ShootingEventArgs args) - { - if (Config.AccurateBullets) - return; - - // Check what's the player shooting at with a raycast, and return if the raycast doesn't hit something within 70 distance (maximum realistic distance) - if (!Physics.Raycast(args.Player.CameraTransform.position, args.Player.CameraTransform.forward, out RaycastHit raycastHit, 70f, ~(1 << 1 | 1 << 13 | 1 << 16 | 1 << 28))) - return; - - // Interact and check the interaction with the player that's shooting, and the GameObject associated to the raycast - if (Interact(args.Player, raycastHit.transform.gameObject)) - { - // Add the GameObject in the blacklist for a server tick - BlacklistedObjects.Add(raycastHit.transform.gameObject); - Timing.CallDelayed(0.02f, () => BlacklistedObjects.Remove(raycastHit.transform.gameObject)); - } - } - /// /// The shot event. Used for accurate shooting interaction. /// /// The . public void OnShot(ShotEventArgs args) { - if (!Config.AccurateBullets) - return; - // Check what's the player shooting at with a raycast, and return if the raycast doesn't hit something within 70 distance (maximum realistic distance) - if (!Physics.Raycast(args.Player.CameraTransform.position, (args.RaycastHit.point - args.Player.CameraTransform.position).normalized, out RaycastHit raycastHit, 70f, ~(1 << 1 | 1 << 13 | 1 << 16 | 1 << 28))) + if (!Physics.Raycast(args.Player.CameraTransform.position, Config.AccurateBullets ? (args.RaycastHit.point - args.Player.CameraTransform.position).normalized : args.Player.CameraTransform.forward, out RaycastHit raycastHit, 70f, ~(1 << 1 | 1 << 13 | 1 << 16 | 1 << 28))) return; // Interact and check the interaction with the player that's shooting, and the GameObject associated to the raycast @@ -162,7 +141,6 @@ public static bool Interact(Player player, GameObject gameObject) if (!door.IsLocked && doorBreak && doorInteraction.MoveBeforeBreaking) Timing.CallDelayed(cooldown, () => { - door.ChangeLock(DoorLockType.SpecialDoorFeature); if (doorInteraction.ButtonsBreakTime > 0) @@ -208,10 +186,10 @@ public static bool Interact(Player player, GameObject gameObject) else if (gameObject.GetComponentInParent() is ElevatorPanel panel && Config.Elevators.IsEnabled) { // Get the elevator associated to the button - Lift elevator = Lift.Get(panel.AssignedChamber); + Lift elevator = Lift.Get(panel._assignedChamber); // Return if there's no elevator associated to the button, it's moving, it's locked and the player doesn't have bypass mode enabled, or it can't get its doors - if (elevator is null || elevator.IsMoving || !elevator.IsOperative || (elevator.IsLocked && !player.IsBypassModeEnabled) || !ElevatorDoor.AllElevatorDoors.TryGetValue(panel.AssignedChamber.AssignedGroup, out List list)) + if (elevator is null || elevator.IsMoving || !elevator.IsOperative || (elevator.IsLocked && !player.IsBypassModeEnabled) || !ElevatorDoor.AllElevatorDoors.TryGetValue(panel._assignedChamber.AssignedGroup, out List list)) return true; // Should the buttons break ? (Generate a number from 1 to 100 then check if it's lesser than config percentage) @@ -221,13 +199,10 @@ public static bool Interact(Player player, GameObject gameObject) if (!elevator.IsLocked && elevatorBreak && !Config.Elevators.MoveBeforeBreaking) { foreach (ElevatorDoor door in list) - { door.ServerChangeLock(DoorLockReason.SpecialDoorFeature, true); - elevator.Base.RefreshLocks(elevator.Group, door); - } if (Config.Elevators.ButtonsBreakTime > 0) - Timing.CallDelayed(Config.Elevators.ButtonsBreakTime + elevator.MoveTime, () => + Timing.CallDelayed(Config.Elevators.ButtonsBreakTime, () => { foreach (ElevatorDoor door in list) { @@ -242,7 +217,7 @@ public static bool Interact(Player player, GameObject gameObject) } // Move the elevator to the next level - int nextLevel = panel.AssignedChamber.CurrentLevel + 1; + int nextLevel = panel._assignedChamber.DestinationLevel + 1; if (nextLevel >= list.Count) nextLevel = 0; @@ -252,10 +227,7 @@ public static bool Interact(Player player, GameObject gameObject) if (!elevator.IsLocked && elevatorBreak && Config.Elevators.MoveBeforeBreaking) { foreach (ElevatorDoor door in list) - { door.ServerChangeLock(DoorLockReason.SpecialDoorFeature, true); - elevator.Base.RefreshLocks(elevator.Group, door); - } if (Config.Elevators.ButtonsBreakTime > 0) Timing.CallDelayed(Config.Elevators.ButtonsBreakTime + elevator.MoveTime, () => diff --git a/ShootingInteractions/Plugin.cs b/ShootingInteractions/Plugin.cs index 356a478..f9aadf7 100644 --- a/ShootingInteractions/Plugin.cs +++ b/ShootingInteractions/Plugin.cs @@ -17,9 +17,9 @@ public class Plugin : Plugin { public override string Author => "Ika"; - public override Version RequiredExiledVersion => new(8, 8, 0); + public override Version RequiredExiledVersion => new(9, 0, 0); - public override Version Version => new(2, 4, 0); + public override Version Version => new(2, 4, 1); public override PluginPriority Priority => PluginPriority.First; @@ -57,12 +57,10 @@ public override void OnDisabled() { public void RegisterEvents() { eventsHandler = new EventsHandler(); - PlayerEvent.Shooting += eventsHandler.OnShooting; PlayerEvent.Shot += eventsHandler.OnShot; } public void UnregisterEvents() { - PlayerEvent.Shooting -= eventsHandler.OnShooting; PlayerEvent.Shot -= eventsHandler.OnShot; eventsHandler = null; diff --git a/ShootingInteractions/ShootingInteractions.csproj b/ShootingInteractions/ShootingInteractions.csproj index 4a20649..091af3b 100644 --- a/ShootingInteractions/ShootingInteractions.csproj +++ b/ShootingInteractions/ShootingInteractions.csproj @@ -37,11 +37,11 @@ False - ..\..\..\..\..\Packages\SCP SL 13.5\Assembly-CSharp-firstpass.dll + ..\..\..\Packages\SCP SL 14\Assembly-CSharp-firstpass.dll False - ..\..\..\..\..\Packages\SCP SL 13.5\Mirror.dll + ..\..\..\Packages\SCP SL 14\Mirror.dll @@ -53,15 +53,15 @@ False - ..\..\..\..\..\Packages\SCP SL 13.5\UnityEngine.AudioModule.dll + ..\..\..\Packages\SCP SL 14\UnityEngine.AudioModule.dll False - ..\..\..\..\..\Packages\SCP SL 13.5\UnityEngine.CoreModule.dll + ..\..\..\Packages\SCP SL 14\UnityEngine.CoreModule.dll False - ..\..\..\..\..\Packages\SCP SL 13.5\UnityEngine.PhysicsModule.dll + ..\..\..\Packages\SCP SL 14\UnityEngine.PhysicsModule.dll @@ -77,8 +77,8 @@ - - 8.11.0 + + 9.0.0-alpha.4