Skip to content

Commit

Permalink
fixed SCP1499 bug
Browse files Browse the repository at this point in the history
  • Loading branch information
GrafDimenzio committed Feb 18, 2022
1 parent 7807c21 commit d1ed96a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion MoreWeapons/EventHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private void OnItemUse(PlayerItemInteractEventArgs ev)
break;

case (int)CustomItemType.Scp1499 when ev.State == Synapse.Api.Events.SynapseEventArguments.ItemInteractState.Finalizing:
ev.Player.GetComponent<Scp1499PlayerScript>().Use1499();
ev.Player.GetComponent<Scp1499PlayerScript>().Use1499(ev.CurrentItem);
ev.Allow = false;
break;
}
Expand Down
4 changes: 2 additions & 2 deletions MoreWeapons/PluginClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ namespace MoreWeapons
Description = "A Plugin that adds new Weapons & Items to the Game",
LoadPriority = 100,
SynapseMajor = 2,
SynapseMinor = 8,
SynapsePatch = 3,
SynapseMinor = 9,
SynapsePatch = 0,
Version = "1.3.2"
)]
public class PluginClass : AbstractPlugin
Expand Down
15 changes: 8 additions & 7 deletions MoreWeapons/Scripts/Scp1499PlayerScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using MEC;
using Synapse.Api;
using Synapse.Api.Enum;
using Synapse.Api.Items;
using UnityEngine;

namespace MoreWeapons.Scripts
Expand All @@ -17,7 +18,7 @@ public class Scp1499PlayerScript : MonoBehaviour

public bool IsInDimension { get; set; } = false;

public void Use1499()
public void Use1499(SynapseItem scp1499)
{
if (player.Zone == ZoneType.Pocket)
{
Expand All @@ -34,7 +35,7 @@ public void Use1499()

IsInDimension = false;

(player.ItemInHand?.ItemBase as Scp268)?.ServerSetGlobalItemCooldown(PluginClass.Scp1499Config.Cooldown);
(scp1499?.ItemBase as Scp268)?.ServerSetGlobalItemCooldown(PluginClass.Scp1499Config.Cooldown);

Timing.KillCoroutines(kickcoroutine.ToArray());
}
Expand All @@ -44,25 +45,25 @@ public void Use1499()
OldPosition = player.Position;
player.Position = PluginClass.Scp1499Config.Scp1499Dimension.Parse().Position;

KickOut(PluginClass.Scp1499Config.Scp1499ResidenceTime);
KickOut(PluginClass.Scp1499Config.Scp1499ResidenceTime,scp1499);
IsInDimension = true;
}
}

public void KickOut(float delay)
public void KickOut(float delay, SynapseItem scp1499)
{
if (delay < 0f) return;
kickcoroutine.Add(Timing.RunCoroutine(KickOutOfScp1499(delay)));
kickcoroutine.Add(Timing.RunCoroutine(KickOutOfScp1499(delay,scp1499)));
}

private readonly List<CoroutineHandle> kickcoroutine = new List<CoroutineHandle>();

private IEnumerator<float> KickOutOfScp1499(float delay)
private IEnumerator<float> KickOutOfScp1499(float delay, SynapseItem scp1499)
{
yield return Timing.WaitForSeconds(delay);

if (IsInDimension)
Use1499();
Use1499(scp1499);
}
}
}

0 comments on commit d1ed96a

Please sign in to comment.