From c9006c4491469d7d110ad698355693d94bd122f4 Mon Sep 17 00:00:00 2001 From: Thomasjosif Date: Thu, 17 Sep 2020 22:51:53 -0400 Subject: [PATCH] Add SCP035 support (requested) --- UltimateAFK/AFKComponent.cs | 27 +++++++++++++++++++++++++++ UltimateAFK/MainClass.cs | 2 +- UltimateAFK/UltimateAFK.csproj | 3 +++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/UltimateAFK/AFKComponent.cs b/UltimateAFK/AFKComponent.cs index 9f09c52..1acd074 100644 --- a/UltimateAFK/AFKComponent.cs +++ b/UltimateAFK/AFKComponent.cs @@ -6,6 +6,7 @@ using MEC; using System; using System.Collections.Generic; +using scp035.API; namespace UltimateAFK { @@ -26,6 +27,9 @@ public class AFKComponent : MonoBehaviour // Do not change this delay. It will screw up the detection public float delay = 1.0f; + private Player TryGet035() => Scp035Data.GetScp035(); + private void TrySpawn035(Player player) => Scp035Data.Spawn035(player); + void Awake() { ply = Player.Get(gameObject); @@ -52,6 +56,7 @@ private void AFKChecker() if (this.ply.Team != Team.RIP) { bool isScp079 = false; + if (this.ply.Role == RoleType.Scp079) isScp079 = true; @@ -87,6 +92,17 @@ private void AFKChecker() { if (plugin.Config.TryReplace && !this.past_replace_time()) { + // SCP035 Support (Credit DCReplace) + bool is035 = false; + try + { + is035 = this.ply.Id == TryGet035()?.Id; + } + catch (Exception e) + { + Log.Debug($"SCP-035 is not installed, skipping method call: {e}"); + } + // Credit: DCReplace :) // I mean at this point 90% of this has been rewritten lol... Inventory.SyncListItemInfo items = this.ply.Inventory.items; @@ -119,6 +135,17 @@ private void AFKChecker() player.SetRole(role); Timing.CallDelayed(0.3f, () => { + if (is035) + { + try + { + TrySpawn035(player); + } + catch (Exception e) + { + Log.Debug($"SCP-035 is not installed, skipping method call: {e}"); + } + } player.Position = pos; player.Inventory.Clear(); diff --git a/UltimateAFK/MainClass.cs b/UltimateAFK/MainClass.cs index c61b817..e1d8d26 100644 --- a/UltimateAFK/MainClass.cs +++ b/UltimateAFK/MainClass.cs @@ -58,7 +58,7 @@ public class MainClass : Plugin public override string Author { get; } = "Thomasjosif"; public override string Name { get; } = "Ultimate AFK"; public override string Prefix { get; } = "uAFK"; - public override Version Version { get; } = new Version(3, 0, 1); + public override Version Version { get; } = new Version(3, 0, 2); public override Version RequiredExiledVersion { get; } = new Version(2, 0, 0); public PlayerEvents PlayerEvents; diff --git a/UltimateAFK/UltimateAFK.csproj b/UltimateAFK/UltimateAFK.csproj index 7ec6fee..681781d 100644 --- a/UltimateAFK/UltimateAFK.csproj +++ b/UltimateAFK/UltimateAFK.csproj @@ -69,6 +69,9 @@ False ..\..\References\Mirror.dll + + ..\..\References\scp035.dll +