Skip to content

Commit

Permalink
improved Scp1499
Browse files Browse the repository at this point in the history
  • Loading branch information
GrafDimenzio committed Jan 10, 2021
1 parent 9e5ab92 commit 4a48388
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 14 deletions.
7 changes: 7 additions & 0 deletions MoreWeapons/Configs/Scp1499Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
44 changes: 39 additions & 5 deletions MoreWeapons/Handlers/Scp1499Handler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<Scp1499PlayerScript>().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<Interactables.Interobjects.DoorUtils.DoorVariant>().ServerChangeLock(Interactables.Interobjects.DoorUtils.DoorLockReason.SpecialDoorFeature, true);
}
}

private void OnSetClass(Synapse.Api.Events.SynapseEventArguments.PlayerSetClassEventArgs ev)
Expand All @@ -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<Scp1499PlayerScript>().Use1499();
if (ev.Player.GetComponent<Scp1499PlayerScript>().Use1499())
{
ev.Player.VanillaInventory._cawi.usableCooldowns[3] = PluginClass.Scp1499Config.Cooldown;
ev.Player.VanillaInventory._cawi.RpcSetCooldown(3, PluginClass.Scp1499Config.Cooldown);
}
ev.Allow = false;
}
}
Expand All @@ -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)
Expand All @@ -74,6 +101,7 @@ public void Use1499()
IsInDimension = false;

Timing.KillCoroutines(kickcoroutine.ToArray());
return true;
}
else
{
Expand All @@ -83,6 +111,7 @@ public void Use1499()

KickOut(PluginClass.Scp1499Config.Scp1499ResidenceTime);
IsInDimension = true;
return false;
}
}

Expand All @@ -98,7 +127,12 @@ private IEnumerator<float> 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);
}
}
}
}
19 changes: 11 additions & 8 deletions MoreWeapons/MoreWeapons.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,37 +37,40 @@
<HintPath>..\packages\Lib.Harmony.2.0.4\lib\net472\0Harmony.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SynapseSL.2.3.0\lib\net472\Assembly-CSharp.dll</HintPath>
<HintPath>..\packages\SynapseSL.2.4.2\lib\net472\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp-firstpass, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SynapseSL.2.3.0\lib\net472\Assembly-CSharp-firstpass.dll</HintPath>
<HintPath>..\packages\SynapseSL.2.4.2\lib\net472\Assembly-CSharp-firstpass.dll</HintPath>
</Reference>
<Reference Include="LiteDB, Version=5.0.9.0, Culture=neutral, PublicKeyToken=4ee40123013c9f27, processorArchitecture=MSIL">
<HintPath>..\packages\LiteDB.5.0.9\lib\net45\LiteDB.dll</HintPath>
</Reference>
<Reference Include="Mirror, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SynapseSL.2.3.0\lib\net472\Mirror.dll</HintPath>
<HintPath>..\packages\SynapseSL.2.4.2\lib\net472\Mirror.dll</HintPath>
</Reference>
<Reference Include="Synapse, Version=2.3.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SynapseSL.2.3.0\lib\net472\Synapse.dll</HintPath>
<Reference Include="Synapse, Version=2.4.2.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SynapseSL.2.4.2\lib\net472\Synapse.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Runtime" />
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SynapseSL.2.3.0\lib\net472\UnityEngine.dll</HintPath>
<HintPath>..\packages\SynapseSL.2.4.2\lib\net472\UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SynapseSL.2.3.0\lib\net472\UnityEngine.CoreModule.dll</HintPath>
<HintPath>..\packages\SynapseSL.2.4.2\lib\net472\UnityEngine.CoreModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.PhysicsModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SynapseSL.2.3.0\lib\net472\UnityEngine.PhysicsModule.dll</HintPath>
<HintPath>..\packages\SynapseSL.2.4.2\lib\net472\UnityEngine.PhysicsModule.dll</HintPath>
</Reference>
<Reference Include="YamlDotNet, Version=8.0.0.0, Culture=neutral, PublicKeyToken=ec19458f3c15af5e, processorArchitecture=MSIL">
<HintPath>..\packages\YamlDotNet.8.1.2\lib\net45\YamlDotNet.dll</HintPath>
Expand Down
3 changes: 2 additions & 1 deletion MoreWeapons/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<packages>
<package id="Lib.Harmony" version="2.0.4" targetFramework="net472" />
<package id="LiteDB" version="5.0.9" targetFramework="net472" />
<package id="SynapseSL" version="2.3.0" targetFramework="net472" />
<package id="SynapseSL" version="2.4.2" targetFramework="net472" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.2" targetFramework="net472" />
<package id="YamlDotNet" version="8.1.2" targetFramework="net472" />
</packages>

0 comments on commit 4a48388

Please sign in to comment.