Skip to content

Commit

Permalink
Add SCP035 support (requested)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasjosif committed Sep 18, 2020
1 parent 7b70e9d commit c9006c4
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
27 changes: 27 additions & 0 deletions UltimateAFK/AFKComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using MEC;
using System;
using System.Collections.Generic;
using scp035.API;

namespace UltimateAFK
{
Expand All @@ -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);
Expand All @@ -52,6 +56,7 @@ private void AFKChecker()
if (this.ply.Team != Team.RIP)
{
bool isScp079 = false;

if (this.ply.Role == RoleType.Scp079)
isScp079 = true;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion UltimateAFK/MainClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class MainClass : Plugin<Config>
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;

Expand Down
3 changes: 3 additions & 0 deletions UltimateAFK/UltimateAFK.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\References\Mirror.dll</HintPath>
</Reference>
<Reference Include="scp035">
<HintPath>..\..\References\scp035.dll</HintPath>
</Reference>
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.ComponentModel.Composition.Registration" />
<Reference Include="System.ComponentModel.DataAnnotations" />
Expand Down

0 comments on commit c9006c4

Please sign in to comment.