diff --git a/MoreWeapons/Configs/Scp1499Config.cs b/MoreWeapons/Configs/Scp1499Config.cs index c092e53..3078263 100644 --- a/MoreWeapons/Configs/Scp1499Config.cs +++ b/MoreWeapons/Configs/Scp1499Config.cs @@ -8,6 +8,13 @@ public class Scp1499Config : AbstractConfigSection [Description("Where a player lands using Scp1499")] public SerializedMapPoint Scp1499Dimension = new Synapse.Config.SerializedMapPoint("HCZ_049", -13f, 266f, 0f); + [Description("Spawns a Door at the default spawn so that the Player can't see in the void")] + public bool SpawnDoor = true; + + [Description("The time after which the Player gets forced out of Scp1499")] public float Scp1499ResidenceTime = -1f; + + [Description("The Cooldown that Scp1499 gives")] + public float Cooldown = 5f; } } diff --git a/MoreWeapons/Handlers/Scp1499Handler.cs b/MoreWeapons/Handlers/Scp1499Handler.cs index 1be8ae1..c4564a6 100644 --- a/MoreWeapons/Handlers/Scp1499Handler.cs +++ b/MoreWeapons/Handlers/Scp1499Handler.cs @@ -2,11 +2,14 @@ using Synapse; using MEC; using UnityEngine; +using Synapse.Config; namespace MoreWeapons.Handlers { public class Scp1499Handler { + private readonly SerializedMapPoint doorSpawn = new SerializedMapPoint("HCZ_049", -6.683522f, 264.0f, 24.09575f); + public Scp1499Handler() { Server.Get.ItemManager.RegisterCustomItem(new Synapse.Api.Items.CustomItemInformation @@ -16,10 +19,30 @@ public Scp1499Handler() Name = "Scp1499" }); + Server.Get.Events.Player.PlayerDropItemEvent += Drop; Server.Get.Events.Player.PlayerPickUpItemEvent += OnPickup; Server.Get.Events.Player.PlayerItemUseEvent += OnUse; Server.Get.Events.Player.LoadComponentsEvent += OnLoad; Server.Get.Events.Player.PlayerSetClassEvent += OnSetClass; + Server.Get.Events.Round.WaitingForPlayersEvent += Waiting; + } + + private void Drop(Synapse.Api.Events.SynapseEventArguments.PlayerDropItemEventArgs ev) + { + if (ev.Player.GetComponent().IsInDimension && ev.Item?.ID == (int)CustomItemType.Scp1499) + { + ev.Allow = false; + ev.Player.GiveTextHint("You can't currently drop Scp1499"); + } + } + + private void Waiting() + { + if (PluginClass.Scp1499Config.SpawnDoor) + { + var door = Synapse.Api.Map.Get.SpawnDoorVariant(doorSpawn.Parse().Position, Synapse.Api.Map.Get.GetRoom(RoomInformation.RoomType.HCZ_049).GameObject.transform.rotation); + door.GameObject.GetComponent().ServerChangeLock(Interactables.Interobjects.DoorUtils.DoorLockReason.SpecialDoorFeature, true); + } } private void OnSetClass(Synapse.Api.Events.SynapseEventArguments.PlayerSetClassEventArgs ev) @@ -33,9 +56,13 @@ private void OnLoad(Synapse.Api.Events.SynapseEventArguments.LoadComponentEventA private void OnUse(Synapse.Api.Events.SynapseEventArguments.PlayerItemInteractEventArgs ev) { - if(ev.CurrentItem != null && ev.CurrentItem.ID == (int)CustomItemType.Scp1499 && ev.State == Synapse.Api.Events.SynapseEventArguments.ItemInteractState.Finalizing) + if(ev.CurrentItem?.ID == (int)CustomItemType.Scp1499 && ev.State == Synapse.Api.Events.SynapseEventArguments.ItemInteractState.Finalizing) { - ev.Player.GetComponent().Use1499(); + if (ev.Player.GetComponent().Use1499()) + { + ev.Player.VanillaInventory._cawi.usableCooldowns[3] = PluginClass.Scp1499Config.Cooldown; + ev.Player.VanillaInventory._cawi.RpcSetCooldown(3, PluginClass.Scp1499Config.Cooldown); + } ev.Allow = false; } } @@ -58,12 +85,12 @@ public class Scp1499PlayerScript : MonoBehaviour public bool IsInDimension { get; set; } = false; - public void Use1499() + public bool Use1499() { if(player.Zone == Synapse.Api.Enum.ZoneType.Pocket) { player.GiveTextHint("You can't use it right now"); - return; + return false; } if (IsInDimension) @@ -74,6 +101,7 @@ public void Use1499() IsInDimension = false; Timing.KillCoroutines(kickcoroutine.ToArray()); + return true; } else { @@ -83,6 +111,7 @@ public void Use1499() KickOut(PluginClass.Scp1499Config.Scp1499ResidenceTime); IsInDimension = true; + return false; } } @@ -98,7 +127,12 @@ private IEnumerator KickOutOfScp1499(float delay) { yield return Timing.WaitForSeconds(delay); - if (IsInDimension) Use1499(); + if (IsInDimension) + { + Use1499(); + player.VanillaInventory._cawi.usableCooldowns[3] = PluginClass.Scp1499Config.Cooldown; + player.VanillaInventory._cawi.RpcSetCooldown(3, PluginClass.Scp1499Config.Cooldown); + } } } } diff --git a/MoreWeapons/MoreWeapons.csproj b/MoreWeapons/MoreWeapons.csproj index 1851e9f..8becfee 100644 --- a/MoreWeapons/MoreWeapons.csproj +++ b/MoreWeapons/MoreWeapons.csproj @@ -37,23 +37,26 @@ ..\packages\Lib.Harmony.2.0.4\lib\net472\0Harmony.dll - ..\packages\SynapseSL.2.3.0\lib\net472\Assembly-CSharp.dll + ..\packages\SynapseSL.2.4.2\lib\net472\Assembly-CSharp.dll - ..\packages\SynapseSL.2.3.0\lib\net472\Assembly-CSharp-firstpass.dll + ..\packages\SynapseSL.2.4.2\lib\net472\Assembly-CSharp-firstpass.dll ..\packages\LiteDB.5.0.9\lib\net45\LiteDB.dll - ..\packages\SynapseSL.2.3.0\lib\net472\Mirror.dll + ..\packages\SynapseSL.2.4.2\lib\net472\Mirror.dll - - ..\packages\SynapseSL.2.3.0\lib\net472\Synapse.dll + + ..\packages\SynapseSL.2.4.2\lib\net472\Synapse.dll + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll + @@ -61,13 +64,13 @@ - ..\packages\SynapseSL.2.3.0\lib\net472\UnityEngine.dll + ..\packages\SynapseSL.2.4.2\lib\net472\UnityEngine.dll - ..\packages\SynapseSL.2.3.0\lib\net472\UnityEngine.CoreModule.dll + ..\packages\SynapseSL.2.4.2\lib\net472\UnityEngine.CoreModule.dll - ..\packages\SynapseSL.2.3.0\lib\net472\UnityEngine.PhysicsModule.dll + ..\packages\SynapseSL.2.4.2\lib\net472\UnityEngine.PhysicsModule.dll ..\packages\YamlDotNet.8.1.2\lib\net45\YamlDotNet.dll diff --git a/MoreWeapons/packages.config b/MoreWeapons/packages.config index 699d113..a605a3f 100644 --- a/MoreWeapons/packages.config +++ b/MoreWeapons/packages.config @@ -2,6 +2,7 @@ - + + \ No newline at end of file