-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
266 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.0.32014.148 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScpsInfoDisplay", "ScpsInfoDisplay\ScpsInfoDisplay.csproj", "{8DAA7834-8141-448E-8694-EBE9F4800C66}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{8DAA7834-8141-448E-8694-EBE9F4800C66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{8DAA7834-8141-448E-8694-EBE9F4800C66}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{8DAA7834-8141-448E-8694-EBE9F4800C66}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{8DAA7834-8141-448E-8694-EBE9F4800C66}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {93FC9CD8-3B2D-45A1-AC80-1EFFAA30D6EF} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using Exiled.API.Interfaces; | ||
|
||
namespace ScpsInfoDisplay | ||
{ | ||
public class Config : IConfig | ||
{ | ||
[Description("Is the plugin enabled?")] | ||
public bool IsEnabled { get; set; } = true; | ||
[Description("Display strings. Format: Role, display string.")] | ||
public Dictionary<RoleType, string> DisplayStrings { get; set; } = new Dictionary<RoleType, string>() | ||
{ | ||
{ RoleType.Scp106, "<color=#D51D1D>SCP-106 [%healthpercent%%]</color>" }, | ||
{ RoleType.Scp049, "<color=#D51D1D>SCP-049 [%healthpercent%%]</color>" }, | ||
{ RoleType.Scp079, "<color=#D51D1D>SCP-079 [%generators%%engaging%/3]</color>" }, | ||
{ RoleType.Scp096, "<color=#D51D1D>SCP-096 [%healthpercent%%]</color>" }, | ||
{ RoleType.Scp173, "<color=#D51D1D>SCP-173 [%healthpercent%%]</color>" }, | ||
{ RoleType.Scp93953, "<color=#D51D1D>SCP-939-53 [%healthpercent%%]</color>" }, | ||
{ RoleType.Scp93989, "<color=#D51D1D>SCP-939-89 [%healthpercent%%]</color>" } | ||
}; | ||
[Description("Custom roles integrations. Format: SessionVariable that marks that the player belongs to that role, display string")] | ||
public Dictionary<string, string> CustomRolesIntegrations { get; set; } = new Dictionary<string, string>(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Exiled.API.Extensions; | ||
using Exiled.API.Features; | ||
using Exiled.Events.EventArgs; | ||
using MEC; | ||
using UnityEngine; | ||
|
||
namespace ScpsInfoDisplay | ||
{ | ||
public class EventHandlers | ||
{ | ||
private readonly Dictionary<Player, CoroutineHandle> _allDisplays = new Dictionary<Player, CoroutineHandle>(); | ||
|
||
public void OnRoundRestart() | ||
{ | ||
foreach (KeyValuePair<Player, CoroutineHandle> kvp in _allDisplays) | ||
{ | ||
if (kvp.Value.IsRunning) | ||
Timing.KillCoroutines(kvp.Value); | ||
_allDisplays.Remove(kvp.Key); | ||
} | ||
_allDisplays.Clear(); | ||
} | ||
|
||
public void OnPlayerChangingRole(ChangingRoleEventArgs ev) | ||
{ | ||
if (ev.Player != null) | ||
{ | ||
if (_allDisplays.ContainsKey(ev.Player) && !ScpsInfoDisplay.Singleton.Config.DisplayStrings.ContainsKey(ev.NewRole)) | ||
{ | ||
Timing.KillCoroutines(_allDisplays[ev.Player]); | ||
_allDisplays.Remove(ev.Player); | ||
} | ||
else if ((ev.Player.Role.Team != Team.SCP && ev.NewRole.GetTeam() == Team.SCP && ScpsInfoDisplay.Singleton.Config.DisplayStrings.ContainsKey(ev.NewRole)) || ScpsInfoDisplay.Singleton.Config.CustomRolesIntegrations.Keys.Any(key => ev.Player.SessionVariables.ContainsKey(key))) | ||
{ | ||
_allDisplays.Add(ev.Player, Timing.RunCoroutine(_showDisplay(ev.Player))); | ||
} | ||
} | ||
} | ||
|
||
private IEnumerator<float> _showDisplay(Player player) | ||
{ | ||
for (; ; ) | ||
{ | ||
yield return Timing.WaitForSeconds(0.5f); | ||
string text = string.Empty; | ||
sbyte integrations = 0; | ||
foreach (Player scp in Player.List.Where(p => p.Role.Team == Team.SCP)) | ||
{ | ||
text += "<align=right>" + ScpsInfoDisplay.Singleton.Config.DisplayStrings[scp.Role.Type].Replace("%arhealth%", scp.ArtificialHealth > 0 ? scp.ArtificialHealth.ToString() : "").Replace("%healthpercent%", Math.Round((Mathf.Clamp01(scp.Health / (float)scp.MaxHealth) * 100), 0).ToString()).Replace("%health%", Math.Round(scp.Health, 0).ToString()).Replace("%generators%", Generator.List.Count(gen => gen.IsEngaged).ToString()).Replace("%engaging%", Generator.List.Count(gen => gen.IsActivating) > 0 ? $" (+{Generator.List.Count(gen => gen.IsActivating)})" : "") + "</align>\n"; | ||
} | ||
|
||
foreach (KeyValuePair<string, string> integration in ScpsInfoDisplay.Singleton.Config.CustomRolesIntegrations) | ||
{ | ||
foreach (Player any in Player.List) | ||
{ | ||
if (any.SessionVariables.ContainsKey(integration.Key)) | ||
{ | ||
text += "<align=right>" + integration.Value.Replace("%arhealth%", any.ArtificialHealth > 0 ? any.ArtificialHealth.ToString() : "").Replace("%healthpercent%", Math.Round((Mathf.Clamp01(any.Health / (float)any.MaxHealth) * 100), 0).ToString()).Replace("%health%", Math.Round(any.Health, 0).ToString()).Replace("%generators%", Generator.List.Count(gen => gen.IsEngaged).ToString()).Replace("%engaging%", Generator.List.Count(gen => gen.IsActivating) > 0 ? $" (+{Generator.List.Count(gen => gen.IsActivating)})" : "") + "</align>\n"; | ||
integrations++; | ||
} | ||
} | ||
} | ||
text += new string('\n', 31 - Player.List.Count(p => p.Role.Team == Team.SCP) - integrations); | ||
player.ShowHint(text, 1f); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("ScpsInfoDisplay")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("ScpsInfoDisplay")] | ||
[assembly: AssemblyCopyright("Copyright © 2022")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("8daa7834-8141-448e-8694-ebe9f4800c66")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using System; | ||
using Exiled.API.Features; | ||
using Server = Exiled.Events.Handlers.Server; | ||
using Player = Exiled.Events.Handlers.Player; | ||
|
||
namespace ScpsInfoDisplay | ||
{ | ||
internal class ScpsInfoDisplay : Plugin<Config> | ||
{ | ||
public override string Prefix => "scpsinfodisplay"; | ||
public override string Name => "ScpsInfoDisplay"; | ||
public override string Author => "bladuk."; | ||
public override Version Version { get; } = new Version(1, 0, 0); | ||
public override Version RequiredExiledVersion { get; } = new Version(5, 2, 1); | ||
public static ScpsInfoDisplay Singleton = new ScpsInfoDisplay(); | ||
private EventHandlers _eventHandlers; | ||
|
||
public override void OnEnabled() | ||
{ | ||
base.OnEnabled(); | ||
Singleton = this; | ||
_eventHandlers = new EventHandlers(); | ||
RegisterEvents(); | ||
} | ||
|
||
public override void OnDisabled() | ||
{ | ||
base.OnDisabled(); | ||
UnregisterEvents(); | ||
} | ||
|
||
private void RegisterEvents() | ||
{ | ||
Server.RestartingRound += _eventHandlers.OnRoundRestart; | ||
Player.ChangingRole += _eventHandlers.OnPlayerChangingRole; | ||
} | ||
|
||
private void UnregisterEvents() | ||
{ | ||
Server.RestartingRound -= _eventHandlers.OnRoundRestart; | ||
Player.ChangingRole -= _eventHandlers.OnPlayerChangingRole; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{8DAA7834-8141-448E-8694-EBE9F4800C66}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>ScpsInfoDisplay</RootNamespace> | ||
<AssemblyName>ScpsInfoDisplay</AssemblyName> | ||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<Deterministic>true</Deterministic> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="Assembly-CSharp"> | ||
<HintPath>..\..\..\..\Steam\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\Assembly-CSharp.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Assembly-CSharp-firstpass"> | ||
<HintPath>..\..\Assembly-CSharp-firstpass.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Exiled.API"> | ||
<HintPath>..\..\Exiled.API.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Exiled.Events"> | ||
<HintPath>..\..\Exiled.Events.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Xml" /> | ||
<Reference Include="UnityEngine.CoreModule"> | ||
<HintPath>..\..\UnityEngine.CoreModule.dll</HintPath> | ||
</Reference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Config.cs" /> | ||
<Compile Include="EventHandlers.cs" /> | ||
<Compile Include="ScpsInfoDisplay.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
</Project> |