idk
This commit is contained in:
@@ -0,0 +1,96 @@
|
||||
using HintServiceMeow.Core.Enum;
|
||||
using HintServiceMeow.Core.Models.Hints;
|
||||
using HintServiceMeow.Core.Utilities;
|
||||
using LabApi.Events.Arguments.PlayerEvents;
|
||||
using LabApi.Events.Handlers;
|
||||
using LabApi.Features;
|
||||
using LabApi.Features.Console;
|
||||
using LabApi.Features.Wrappers;
|
||||
using PlayerRoles;
|
||||
using PlayerRoles.PlayableScps.Scp096;
|
||||
using Timer = System.Timers.Timer;
|
||||
|
||||
namespace SCPTeamHint
|
||||
{
|
||||
public class Plugin : LabApi.Loader.Features.Plugins.Plugin
|
||||
{
|
||||
public override string Name => "SCPTeamHint";
|
||||
public override string Author => "HoherGeist, Code002Lover";
|
||||
public override Version Version { get; } = new(1, 0, 0);
|
||||
public override string Description => "Displays information about your SCP Teammates";
|
||||
public override Version RequiredApiVersion { get; } = new(LabApiProperties.CompiledVersion);
|
||||
|
||||
private Timer _timer;
|
||||
private readonly Dictionary<Player,Hint> _spectatorHints = new();
|
||||
|
||||
public override void Enable()
|
||||
{
|
||||
Logger.Debug("Apple juice");
|
||||
PlayerEvents.Joined += OnJoin;
|
||||
|
||||
_timer = new Timer(1000);
|
||||
_timer.Elapsed += (_,_) => UpdateHints();
|
||||
_timer.Start();
|
||||
}
|
||||
|
||||
public override void Disable()
|
||||
{
|
||||
PlayerEvents.Joined -= OnJoin;
|
||||
_timer.Stop();
|
||||
}
|
||||
|
||||
private void UpdateHints()
|
||||
{
|
||||
var hintTexts = new List<string>();
|
||||
|
||||
foreach (var player in Player.List)
|
||||
{
|
||||
if (!player.IsSCP) continue;
|
||||
|
||||
var text = $"{player.RoleBase.RoleName} | {player.HumeShield} | {player.Health} | {player.Zone}";
|
||||
|
||||
if (player.RoleBase is Scp096Role scp)
|
||||
{
|
||||
text += "\n";
|
||||
|
||||
scp.SubroutineModule.TryGetSubroutine(out Scp096TargetsTracker tracker);
|
||||
|
||||
text += $"Targets: {tracker.Targets.Count}";
|
||||
}
|
||||
|
||||
hintTexts.Add(text);
|
||||
}
|
||||
|
||||
foreach (var player in Player.List.Where(x=>!x.IsHost))
|
||||
{
|
||||
Logger.Debug($"Updating hint for {player.DisplayName}");
|
||||
UpdateHint(player, string.Join("\n", hintTexts));
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateHint(Player player, string hintText)
|
||||
{
|
||||
var hint = _spectatorHints[player];
|
||||
|
||||
Logger.Debug($"Player {player.Nickname} is on team {player.RoleBase.Team} | hide: {player.RoleBase.Team != Team.SCPs}");
|
||||
hint.Hide = player.RoleBase.Team != Team.SCPs;
|
||||
|
||||
hint.Text = hintText;
|
||||
}
|
||||
|
||||
private void OnJoin(PlayerJoinedEventArgs ev)
|
||||
{
|
||||
|
||||
var hint = new Hint
|
||||
{
|
||||
Text = "Apfelsaft", Alignment = HintAlignment.Left, YCoordinate = 300, Hide = true
|
||||
};
|
||||
|
||||
var playerDisplay = PlayerDisplay.Get(ev.Player);
|
||||
playerDisplay.AddHint(hint);
|
||||
|
||||
_spectatorHints[ev.Player] = hint;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net48</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>disable</Nullable>
|
||||
<LangVersion>10</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||
<Optimize>true</Optimize>
|
||||
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
|
||||
<DebugType>full</DebugType>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||
<Optimize>true</Optimize>
|
||||
<CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
|
||||
<DebugType>none</DebugType>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="0Harmony">
|
||||
<HintPath>..\dependencies\0Harmony.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Assembly-CSharp">
|
||||
<HintPath>..\..\.local\share\Steam\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\Assembly-CSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="HintServiceMeow">
|
||||
<HintPath>..\dependencies\HintServiceMeow-LabAPI.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Mirror">
|
||||
<HintPath>..\..\.local\share\Steam\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\Mirror.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Pooling">
|
||||
<HintPath>..\..\.local\share\Steam\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\Pooling.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.CoreModule">
|
||||
<HintPath>..\..\.local\share\Steam\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Northwood.LabAPI" Version="1.0.2" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user