Skip to content

Commit

Permalink
Unbugification
Browse files Browse the repository at this point in the history
  • Loading branch information
KognitysPlayhouse committed Apr 24, 2021
1 parent 6ecebb1 commit 74f97fa
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
4 changes: 3 additions & 1 deletion CustomSpawner/CustomSpawner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class CustomSpawner : Plugin<Config>
public override string Author { get; } = "Kognity";
public override string Prefix { get; } = "CustomSpawner";
public override Version RequiredExiledVersion { get; } = new Version(2, 8, 0);
public override Version Version { get; } = new Version(1, 1, 0);
public override Version Version { get; } = new Version(1, 2, 0);

public override void OnEnabled()
{
Expand All @@ -25,6 +25,7 @@ public override void OnEnabled()
Exiled.Events.Handlers.Player.Verified += Handler.OnVerified;
Exiled.Events.Handlers.Server.RoundStarted += Handler.OnRoundStart;
Exiled.Events.Handlers.Server.WaitingForPlayers += Handler.OnWaitingForPlayers;
Exiled.Events.Handlers.Player.PickingUpItem += Handler.OnPickingUp;
base.OnEnabled();
}

Expand All @@ -33,6 +34,7 @@ public override void OnDisabled()
Exiled.Events.Handlers.Player.Verified -= Handler.OnVerified;
Exiled.Events.Handlers.Server.RoundStarted -= Handler.OnRoundStart;
Exiled.Events.Handlers.Server.WaitingForPlayers -= Handler.OnWaitingForPlayers;
Exiled.Events.Handlers.Player.PickingUpItem -= Handler.OnPickingUp;

Handler = null;
base.OnDisabled();
Expand Down
23 changes: 20 additions & 3 deletions CustomSpawner/EventHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ public class EventHandler
private static Vector3 GuardPoint = new Vector3(230, 980, 95);
private static Vector3 Tutorial = new Vector3(241, 980, 96);

private List<Team> teamrespawncopy;
private List<Team> teamrespawncopy = new List<Team> { };

private int SCPsToSpawn = 0;
private int ClassDsToSpawn = 0;
private int ScientistsToSpawn = 0;
private int GuardsToSpawn = 0;

private List<Pickup> boll = new List<Pickup> { }; // boll :flushed:

private List<GameObject> Dummies = new List<GameObject> { };
private static Dictionary<RoleType, string> dummiesToSpawn = new Dictionary<RoleType, string>
{
Expand All @@ -53,6 +55,12 @@ public class EventHandler
{ RoleType.FacilityGuard, new KeyValuePair<Vector3, Quaternion>(GuardPoint, new Quaternion(0, 0.9f, 0, 0.4f) ) },
};

public void OnPickingUp(PickingUpItemEventArgs ev)
{
if (boll.Contains(ev.Pickup))
ev.IsAllowed = false;
}

public void OnVerified(VerifiedEventArgs ev)
{
if (!Round.IsStarted && (GameCore.RoundStart.singleton.NetworkTimer > 1 || GameCore.RoundStart.singleton.NetworkTimer == -2))
Expand All @@ -79,6 +87,8 @@ public void OnRoundStart()
UnityEngine.Object.Destroy(thing); // Deleting the dummies and SCP-018 circles
}

RoundSummary.roundTime = 0; // My testing showed that this didn't make a difference lmk if it does I guess.

for (int x = 0; x < Player.List.ToList().Count; x++)
{
switch (teamrespawncopy[x])
Expand Down Expand Up @@ -343,11 +353,17 @@ public void OnRoundStart()

public void OnWaitingForPlayers()
{
teamrespawncopy = CharacterClassManager.ClassTeamQueue.ToList();
if(teamrespawncopy.Count == 0)
teamrespawncopy = CharacterClassManager.ClassTeamQueue.ToList();
CharacterClassManager.ClassTeamQueue.Clear();
Round.IsLocked = true;

GameObject.Find("StartRound").transform.localScale = Vector3.zero;
SCPsToSpawn = 0;
ClassDsToSpawn = 0;
ScientistsToSpawn = 0;
GuardsToSpawn = 0;

GameObject.Find("StartRound").transform.localScale = Vector3.zero;
Timing.RunCoroutine(LobbyTimer());

foreach (var Role in dummiesToSpawn)
Expand All @@ -371,6 +387,7 @@ public void OnWaitingForPlayers()
Dummies.Add(obj);

Pickup pickup = Exiled.API.Extensions.Item.Spawn(ItemType.SCP018, 0, dummySpawnPointsAndRotations[Role.Key].Key);
boll.Add(pickup);
GameObject gameObject = pickup.gameObject;
gameObject.transform.localScale = new Vector3(30f, 0.1f, 30f);
NetworkServer.UnSpawn(gameObject);
Expand Down

0 comments on commit 74f97fa

Please sign in to comment.