Skip to content

Commit 4f2b899

Browse files
authored
Add files via upload
1 parent 74f95fc commit 4f2b899

File tree

14 files changed

+1058
-0
lines changed

14 files changed

+1058
-0
lines changed

Components/UserEffectDisplayer.cs

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
using EffectDisplay.Extensions;
2+
using EffectDisplay.Features;
3+
4+
using Exiled.API.Extensions;
5+
using Exiled.API.Features;
6+
7+
using MEC;
8+
9+
using System;
10+
using System.Collections.Generic;
11+
using System.Linq;
12+
using System.Linq.Expressions;
13+
using System.Text;
14+
using UnityEngine;
15+
16+
namespace EffectDisplay.Components
17+
{
18+
public class UserEffectDisplayer: MonoBehaviour
19+
{
20+
private MeowHintManager meow;
21+
private Player player;
22+
/// <summary>
23+
/// Stores the current process for future stopping
24+
/// </summary>
25+
private CoroutineHandle Current;
26+
27+
private bool Enabled = true;
28+
/// <summary>
29+
/// Will the display of effects be enabled?
30+
/// </summary>
31+
public bool IsEnabled
32+
{
33+
get
34+
{
35+
return Enabled;
36+
}
37+
set
38+
{
39+
Log.Debug($"{nameof(IsEnabled)}.Set: {Enabled} -> {value}.");
40+
Enabled = value;
41+
Timing.KillCoroutines(Current);
42+
if (value)
43+
{
44+
Current = Timing.RunCoroutine(PlayerEffectShower());
45+
}
46+
}
47+
}
48+
49+
private void Awake()
50+
{
51+
Log.Debug($"{nameof(Awake)}: Initing component.");
52+
player = Player.Get(gameObject);
53+
Log.Debug($"{nameof(Awake)}: {player.Nickname} Awake and adding component handling.");
54+
if (player.IsAllow())
55+
{
56+
Log.Debug($"{nameof(Awake)}: Starting Corountine.");
57+
Timing.RunCoroutine(PlayerEffectShower());
58+
}
59+
else
60+
{
61+
this.IsEnabled = false;
62+
Timing.KillCoroutines(this.Current);
63+
return;
64+
}
65+
}
66+
67+
private void ShowMeowHint(string text)
68+
{
69+
if (meow != null)
70+
{
71+
MeowHintManager.RemoveHint(player, meow.GetHintProcessionObject());
72+
meow = null;
73+
}
74+
meow = new MeowHintManager(text, "EffectDisplay", Plugin.Instance.Config.MeowHintSettings);
75+
MeowHintManager.AddHint(player, meow.GetHintProcessionObject());
76+
}
77+
78+
private IEnumerator<float> PlayerEffectShower()
79+
{
80+
for (; ; )
81+
{
82+
if (player == null)
83+
{
84+
Log.Debug($"{nameof(PlayerEffectShower)}: Player is null break yield");
85+
yield break;
86+
}
87+
if (IsEnabled == false)
88+
{
89+
Log.Debug($"{nameof(PlayerEffectShower)}: IsEnabled - {IsEnabled} disabled, break yield");
90+
yield break;
91+
}
92+
if (player.IsDead | Plugin.Instance.Config.IgnoredRoles.Contains(player.Role.Type))
93+
{
94+
yield return Timing.WaitForSeconds(2);
95+
continue;
96+
}
97+
if (player.ActiveEffects.Where(x => !Plugin.Instance.Config.BlackList.Contains(x.GetEffectType())).Count() == 0)
98+
{
99+
if (meow != null)
100+
{
101+
meow = null;
102+
}
103+
yield return Timing.WaitForSeconds(0.1f);
104+
continue;
105+
}
106+
StringBuilder InfoLine = new StringBuilder();
107+
foreach (var item in player.ActiveEffects)
108+
{
109+
try
110+
{
111+
if (Plugin.Instance.Config.BlackList.Contains(item.GetEffectType())) continue;
112+
try
113+
{
114+
string processingline = Plugin.Instance.Config.EffectLine[item.Classification];
115+
if (string.IsNullOrEmpty(processingline)) continue;
116+
processingline = processingline.Replace("%time%", item.Duration == 0 ? "inf" : ((int)item.TimeLeft).ToString());
117+
processingline = processingline.Replace("%duration%", item.Duration == 0 ? "inf" : item.Duration.ToString());
118+
processingline = processingline.Replace("%effect%", Plugin.Instance.Config.GetName(item.GetEffectType()));
119+
processingline = processingline.Replace("%intensity%", item.Intensity.ToString());
120+
Log.Debug($"{nameof(PlayerEffectShower)}: Line {processingline} created");
121+
InfoLine.AppendLine(processingline);
122+
}
123+
catch (Exception e)
124+
{
125+
Log.Debug($"{nameof(PlayerEffectShower)}: Exception {e.Message}");
126+
}
127+
}
128+
catch (Exception e)
129+
{
130+
Log.Debug($"{nameof(PlayerEffectShower)}: Exception {e.Message}");
131+
}
132+
}
133+
string data = InfoLine.ToString();
134+
Log.Debug(data);
135+
try
136+
{
137+
if (Plugin.HintServiceMeowDetected)
138+
{
139+
ShowMeowHint(data);
140+
}
141+
else
142+
{
143+
data = $"<size={Plugin.Instance.Config.NativeHintSettings.FontSize}><align={Plugin.Instance.Config.NativeHintSettings.Aligment}>" + data + "</size></align>";
144+
player.ShowHint(data, 1 + (player.Ping / 100)); // display a message taking into account the player's ping for a smooth update
145+
}
146+
}
147+
catch (Exception e)
148+
{
149+
Log.Debug($"{nameof(PlayerEffectShower)}: Exception {e.Message}");
150+
}
151+
Log.Debug($"{nameof(PlayerEffectShower)}: Iteration {player.Nickname}: processed.");
152+
yield return Timing.WaitForSeconds(Plugin.Instance.Config.UpdateTime);
153+
}
154+
}
155+
}
156+
}

Configs.cs

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
using CustomPlayerEffects;
2+
3+
using EffectDisplay.Features.Sereliazer;
4+
5+
using Exiled.API.Enums;
6+
using Exiled.API.Features;
7+
using Exiled.API.Interfaces;
8+
using PlayerRoles;
9+
using System.Collections.Generic;
10+
using System.ComponentModel;
11+
using System.IO;
12+
13+
namespace EffectDisplay
14+
{
15+
public class Configs: IConfig
16+
{
17+
[Description("will the plugin be active?")]
18+
public bool IsEnabled { get; set; } = true;
19+
[Description("will information be displayed for the developer, will help when errors are detected")]
20+
public bool Debug { get; set; } = false;
21+
[Description("will merge with other Hint service providers (for example HintServiceMeow) - if they are installed, it will switch itself")]
22+
public bool ThirdParty { get; set; } = true;
23+
[Description("will a database be used")]
24+
public bool IsDatabaseUse { get; set; } = true;
25+
[Description("the time period for which information is updated")]
26+
public float UpdateTime { get; set; } = 0.9f;
27+
[Description("these lines will be displayed for each effect type separately, allowing you to customize them")]
28+
public Dictionary<StatusEffectBase.EffectClassification, string> EffectLine { get; set; } = new Dictionary<StatusEffectBase.EffectClassification, string>()
29+
{
30+
{StatusEffectBase.EffectClassification.Mixed, $"<color=purple>%effect%</color> -> %time%/%duration% LVL: %intensity%" },
31+
{StatusEffectBase.EffectClassification.Positive, $"<color=green>%effect%</color> -> %time%/%duration% LVL: %intensity%" },
32+
{StatusEffectBase.EffectClassification.Negative, $"<color=red>%effect%</color> -> %time%/%duration% LVL: %intensity%" },
33+
{StatusEffectBase.EffectClassification.Technical, " " }
34+
};
35+
[Description("defines a list of effects that the player will not see (the effects of the technical process are hidden)")]
36+
public List<EffectType> BlackList { get; set; } = new List<EffectType>()
37+
{
38+
EffectType.InsufficientLighting,
39+
EffectType.SoundtrackMute,
40+
EffectType.FogControl
41+
};
42+
[Description("https://discord.com/channels/656673194693885975/1172647045237067788/1172647045237067788 determines the name of the effect from the existing list to the one you specify")]
43+
public Dictionary<EffectType, string> EffectTranslation { get; set; } = new Dictionary<EffectType, string>()
44+
{
45+
{ EffectType.None, "UnkownEffect" }
46+
};
47+
[Description("defines the database name in the path (required at the end of .db)")]
48+
public string DatabaseName { get; set; } = "data.db";
49+
[Description("folder location current database")]
50+
public string PathToDataBase { get; set; } = Path.Combine(Paths.Configs, "EffectDisplay");
51+
[Description("List of roles for which the effects display will not be displayed (the roles of the dead are ignored without configs sets)")]
52+
public List<RoleTypeId> IgnoredRoles { get; set; } = new List<RoleTypeId>()
53+
{
54+
RoleTypeId.None,
55+
RoleTypeId.Spectator
56+
};
57+
[Description("Standard settings for displaying information, used in the absence of any supported Hint providers")]
58+
public NativeHintSettings NativeHintSettings { get; set; } = new NativeHintSettings();
59+
[Description("If you use MeowHintService for Exiled then these settings will be useful for customizing the display")]
60+
public MeowHintSettings MeowHintSettings { get; set; } = new MeowHintSettings();
61+
[Description("What text will the user see when hovering over a question mark in the settings?")]
62+
public string EnabledDisplayDescription { get; set; } = "Determines whether the display of enabled effects is enabled, replaces .display in the console";
63+
/// <summary>
64+
/// Return effect name from <see cref="EffectTranslation"/> if not found return <see cref="EffectType"/> as <see cref="string"></see>
65+
/// </summary>
66+
public string GetName(EffectType effectType)
67+
{
68+
return EffectTranslation.ContainsKey(effectType) ? EffectTranslation[effectType] : effectType.ToString();
69+
}
70+
}
71+
}

EffectDisplay.csproj

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{859B2CE7-9C9C-4CDA-B2D1-6AFAB4724063}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>EffectDisplay</RootNamespace>
11+
<AssemblyName>EffectDisplay</AssemblyName>
12+
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
<Deterministic>true</Deterministic>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<DebugSymbols>true</DebugSymbols>
18+
<DebugType>full</DebugType>
19+
<Optimize>false</Optimize>
20+
<OutputPath>bin\Debug\</OutputPath>
21+
<DefineConstants>DEBUG;TRACE</DefineConstants>
22+
<ErrorReport>prompt</ErrorReport>
23+
<WarningLevel>4</WarningLevel>
24+
</PropertyGroup>
25+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26+
<DebugType>pdbonly</DebugType>
27+
<Optimize>true</Optimize>
28+
<OutputPath>bin\Release\</OutputPath>
29+
<DefineConstants>TRACE</DefineConstants>
30+
<ErrorReport>prompt</ErrorReport>
31+
<WarningLevel>4</WarningLevel>
32+
</PropertyGroup>
33+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
34+
<DebugSymbols>true</DebugSymbols>
35+
<OutputPath>bin\x64\Debug\</OutputPath>
36+
<DefineConstants>TRACE</DefineConstants>
37+
<DebugType>full</DebugType>
38+
<PlatformTarget>x64</PlatformTarget>
39+
<LangVersion>7.3</LangVersion>
40+
<ErrorReport>prompt</ErrorReport>
41+
</PropertyGroup>
42+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
43+
<OutputPath>bin\x64\Release\</OutputPath>
44+
<DefineConstants>TRACE</DefineConstants>
45+
<Optimize>true</Optimize>
46+
<DebugType>pdbonly</DebugType>
47+
<PlatformTarget>x64</PlatformTarget>
48+
<LangVersion>7.3</LangVersion>
49+
<ErrorReport>prompt</ErrorReport>
50+
</PropertyGroup>
51+
<ItemGroup>
52+
<Reference Include="0Harmony">
53+
<HintPath>..\..\..\..\AppData\Roaming\EXILED\Plugins\dependencies\0Harmony.dll</HintPath>
54+
</Reference>
55+
<Reference Include="Assembly-CSharp">
56+
<HintPath>..\packages\ExMod.Exiled.9.0.1\lib\net48\Assembly-CSharp-Publicized.dll</HintPath>
57+
<Private>True</Private>
58+
</Reference>
59+
<Reference Include="Assembly-CSharp-firstpass">
60+
<HintPath>D:\SteamLibrary\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath>
61+
</Reference>
62+
<Reference Include="CommandSystem.Core, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
63+
<HintPath>..\packages\ExMod.Exiled.9.0.1\lib\net48\CommandSystem.Core.dll</HintPath>
64+
</Reference>
65+
<Reference Include="Exiled.API, Version=9.0.1.0, Culture=neutral, processorArchitecture=AMD64">
66+
<HintPath>..\packages\ExMod.Exiled.9.0.1\lib\net48\Exiled.API.dll</HintPath>
67+
</Reference>
68+
<Reference Include="Exiled.CreditTags, Version=9.0.1.0, Culture=neutral, processorArchitecture=AMD64">
69+
<HintPath>..\packages\ExMod.Exiled.9.0.1\lib\net48\Exiled.CreditTags.dll</HintPath>
70+
</Reference>
71+
<Reference Include="Exiled.CustomItems, Version=9.0.1.0, Culture=neutral, processorArchitecture=AMD64">
72+
<HintPath>..\packages\ExMod.Exiled.9.0.1\lib\net48\Exiled.CustomItems.dll</HintPath>
73+
</Reference>
74+
<Reference Include="Exiled.CustomRoles, Version=9.0.1.0, Culture=neutral, processorArchitecture=AMD64">
75+
<HintPath>..\packages\ExMod.Exiled.9.0.1\lib\net48\Exiled.CustomRoles.dll</HintPath>
76+
</Reference>
77+
<Reference Include="Exiled.Events, Version=9.0.1.0, Culture=neutral, processorArchitecture=AMD64">
78+
<HintPath>..\packages\ExMod.Exiled.9.0.1\lib\net48\Exiled.Events.dll</HintPath>
79+
</Reference>
80+
<Reference Include="Exiled.Loader, Version=9.0.1.0, Culture=neutral, processorArchitecture=AMD64">
81+
<HintPath>..\packages\ExMod.Exiled.9.0.1\lib\net48\Exiled.Loader.dll</HintPath>
82+
</Reference>
83+
<Reference Include="Exiled.Permissions, Version=9.0.1.0, Culture=neutral, processorArchitecture=AMD64">
84+
<HintPath>..\packages\ExMod.Exiled.9.0.1\lib\net48\Exiled.Permissions.dll</HintPath>
85+
</Reference>
86+
<Reference Include="LiteDB, Version=5.0.16.0, Culture=neutral, PublicKeyToken=4ee40123013c9f27, processorArchitecture=MSIL">
87+
<HintPath>..\packages\LiteDB.5.0.16\lib\net45\LiteDB.dll</HintPath>
88+
<EmbedInteropTypes>False</EmbedInteropTypes>
89+
</Reference>
90+
<Reference Include="Mirror">
91+
<HintPath>D:\SteamLibrary\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\Mirror.dll</HintPath>
92+
</Reference>
93+
<Reference Include="NorthwoodLib, Version=1.3.1.0, Culture=neutral, processorArchitecture=MSIL">
94+
<HintPath>..\packages\ExMod.Exiled.9.0.1\lib\net48\NorthwoodLib.dll</HintPath>
95+
</Reference>
96+
<Reference Include="PluginAPI, Version=13.1.5.0, Culture=neutral, processorArchitecture=AMD64">
97+
<HintPath>..\packages\ExMod.Exiled.9.0.1\lib\net48\PluginAPI.dll</HintPath>
98+
</Reference>
99+
<Reference Include="System" />
100+
<Reference Include="System.Core" />
101+
<Reference Include="System.Xml.Linq" />
102+
<Reference Include="System.Data.DataSetExtensions" />
103+
<Reference Include="Microsoft.CSharp" />
104+
<Reference Include="System.Data" />
105+
<Reference Include="System.Net.Http" />
106+
<Reference Include="System.Xml" />
107+
<Reference Include="UnityEngine">
108+
<HintPath>D:\SteamLibrary\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\UnityEngine.dll</HintPath>
109+
</Reference>
110+
<Reference Include="UnityEngine.CoreModule">
111+
<HintPath>D:\SteamLibrary\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
112+
</Reference>
113+
<Reference Include="UnityEngine.PhysicsModule">
114+
<HintPath>D:\SteamLibrary\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\UnityEngine.PhysicsModule.dll</HintPath>
115+
</Reference>
116+
<Reference Include="YamlDotNet, Version=11.0.0.0, Culture=neutral, PublicKeyToken=ec19458f3c15af5e, processorArchitecture=MSIL">
117+
<HintPath>..\packages\ExMod.Exiled.9.0.1\lib\net48\YamlDotNet.dll</HintPath>
118+
</Reference>
119+
</ItemGroup>
120+
<ItemGroup>
121+
<Compile Include="commands\display.cs" />
122+
<Compile Include="commands\test.cs" />
123+
<Compile Include="Components\UserEffectDisplayer.cs" />
124+
<Compile Include="Configs.cs" />
125+
<Compile Include="EventHandler\PlayerEvent.cs" />
126+
<Compile Include="Extensions\PlayerExtensions.cs" />
127+
<Compile Include="Features\DataBase.cs" />
128+
<Compile Include="Features\MeowHintManager.cs" />
129+
<Compile Include="Features\Sereliazer\MeowHintSettings.cs" />
130+
<Compile Include="Features\Sereliazer\NativeHintSettings.cs" />
131+
<Compile Include="Features\Sereliazer\User.cs" />
132+
<Compile Include="Plugin.cs" />
133+
<Compile Include="Properties\AssemblyInfo.cs" />
134+
</ItemGroup>
135+
<ItemGroup>
136+
<None Include="app.config" />
137+
<None Include="packages.config" />
138+
</ItemGroup>
139+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
140+
</Project>

0 commit comments

Comments
 (0)