Skip to content

Commit f6710ae

Browse files
committed
Chrismass Lol
1 parent f3485c2 commit f6710ae

File tree

12 files changed

+385
-131
lines changed

12 files changed

+385
-131
lines changed
Lines changed: 79 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
using CustomPlayerEffects;
2-
using EffectDisplay.Extensions;
3-
using Exiled.API.Enums;
1+
using EffectDisplay.Extensions;
2+
using EffectDisplay.Features;
3+
44
using Exiled.API.Extensions;
55
using Exiled.API.Features;
6+
67
using MEC;
8+
79
using System.Collections.Generic;
810
using System.Linq;
911
using System.Text;
@@ -13,6 +15,7 @@ namespace EffectDisplay.Components
1315
{
1416
public class UserEffectDisplayer: MonoBehaviour
1517
{
18+
private MeowHintManager MeowHintManager;
1619
private Player player;
1720
/// <summary>
1821
/// Stores the current process for future stopping
@@ -31,40 +34,29 @@ public bool IsEnabled
3134
}
3235
set
3336
{
37+
Log.Debug($"{nameof(IsEnabled)}.Set: {Enabled} -> {value}.");
3438
Enabled = value;
3539
Timing.KillCoroutines(Current);
3640
if (value)
3741
{
38-
Current = Timing.RunCoroutine(PlayerEffectShower(player));
42+
Current = Timing.RunCoroutine(PlayerEffectShower());
3943
}
4044
}
4145
}
4246

43-
private string Category(StatusEffectBase statusEffectBase)
44-
{
45-
if (statusEffectBase.Classification == StatusEffectBase.EffectClassification.Mixed)
46-
{
47-
return Plugin.Instance.Config.EffectLine["Mixed"];
48-
}
49-
if (statusEffectBase.Classification == StatusEffectBase.EffectClassification.Negative)
50-
{
51-
return Plugin.Instance.Config.EffectLine["Negative"];
52-
}
53-
else
54-
{
55-
return Plugin.Instance.Config.EffectLine["Positive"];
56-
}
57-
}
58-
5947
private void Awake()
6048
{
61-
Log.Debug($"{nameof(Awake)} Initing component");
49+
Log.Debug($"{nameof(Awake)}: Initing component.");
6250
player = Player.Get(gameObject);
63-
Log.Debug(player);
51+
Log.Debug($"{nameof(Awake)}: {player.Nickname} Awake and adding component handling.");
6452
if (player.IsAllow())
6553
{
66-
Log.Debug("Starting Corountine");
67-
Timing.RunCoroutine(PlayerEffectShower(player));
54+
Log.Debug($"{nameof(Awake)}: Starting Corountine.");
55+
Timing.RunCoroutine(PlayerEffectShower());
56+
}
57+
if (Plugin.HintServiceMeowDetected)
58+
{
59+
MeowHintManager = new MeowHintManager();
6860
}
6961
else
7062
{
@@ -74,41 +66,74 @@ private void Awake()
7466
}
7567
}
7668

77-
private IEnumerator<float> PlayerEffectShower(Player ply)
69+
private IEnumerator<float> PlayerEffectShower()
7870
{
71+
bool showing = false;
7972
for (; ; )
8073
{
81-
// check whether it is necessary to calculate active effects for the user at the current moment
82-
if (ply.IsAlive | !Plugin.Instance.Config.IgnoredRoles.Contains(ply.Role.Type) | ply.ActiveEffects.Count() != 0)
74+
if (player == null)
75+
{
76+
yield break;
77+
}
78+
if (IsEnabled == false)
79+
{
80+
yield break;
81+
}
82+
if (player.IsDead | Plugin.Instance.Config.IgnoredRoles.Contains(player.Role.Type))
83+
{
84+
yield return Timing.WaitForSeconds(2);
85+
continue;
86+
}
87+
if (player.ActiveEffects.Where(x => !Plugin.Instance.Config.BlackList.Contains(x.GetEffectType())).Count() == 0)
88+
{
89+
MeowHintManager.RemoveHint(player, MeowHintManager.GetHintProcessionObject());
90+
showing = false;
91+
yield return Timing.WaitForSeconds(0.1f);
92+
continue;
93+
}
94+
if (Plugin.HintServiceMeowDetected & showing)
95+
{
96+
MeowHintManager.RemoveHint(player, MeowHintManager.GetHintProcessionObject());
97+
showing = false;
98+
}
99+
StringBuilder InfoLine = new StringBuilder();
100+
if (!Plugin.HintServiceMeowDetected)
101+
{
102+
InfoLine.Append("\n\n\n\n");
103+
InfoLine.AppendLine($"<size={Plugin.Instance.Config.NativeHintSettings.FontSize}><align={Plugin.Instance.Config.NativeHintSettings.Aligment.ToLower()}>");
104+
}
105+
foreach (var item in player.ActiveEffects)
106+
{
107+
if (Plugin.Instance.Config.BlackList.Contains(item.GetEffectType())) continue;
108+
string processingline = Plugin.Instance.Config.EffectLine[item.Classification];
109+
if (string.IsNullOrEmpty(processingline)) continue;
110+
processingline = processingline.Replace("%time%", ((int)item.TimeLeft) == 0 ? string.Empty : ((int)item.TimeLeft).ToString());
111+
processingline = processingline.Replace("%duration%", item.Duration == 0 ? "inf" : ((int)item.Duration).ToString());
112+
processingline = processingline.Replace("%effect%", Plugin.Instance.Config.GetName(item.GetEffectType()));
113+
processingline = processingline.Replace("%intensity%", item.Intensity.ToString());
114+
InfoLine.AppendLine(processingline);
115+
}
116+
if (Plugin.HintServiceMeowDetected)
117+
{
118+
MeowHintManager = new MeowHintManager();
119+
MeowHintManager.SetText(InfoLine.ToString());
120+
MeowHintManager.SetId("EffectDisplay");
121+
MeowHintManager.SetFont(Plugin.Instance.Config.MeowHintSettings.FontSize);
122+
MeowHintManager.SetHorizontalAligment(Plugin.Instance.Config.MeowHintSettings.Aligment);
123+
MeowHintManager.SetVerticalAligment(Plugin.Instance.Config.MeowHintSettings.VerticalAligment);
124+
MeowHintManager.SetYCoordinates(Plugin.Instance.Config.MeowHintSettings.YCoordinate);
125+
MeowHintManager.SetXCoordinate(Plugin.Instance.Config.MeowHintSettings.XCoordinate);
126+
MeowHintManager.AddHint(player, MeowHintManager.GetHintProcessionObject());
127+
showing = true;
128+
}
129+
else if (!Plugin.HintServiceMeowDetected)
83130
{
84-
// we check whether the effects display has been disabled for the user or whether the player has disconnected
85-
if (ply == null | !ply.IsConnected | !this.Enabled)
86-
{
87-
Log.Debug("Destroy components");
88-
Destroy(this);
89-
break;
90-
}
91-
else
92-
{
93-
StringBuilder output = new StringBuilder();
94-
output.Append("\n\n\n\n");
95-
foreach (StatusEffectBase type in ply.ActiveEffects)
96-
{
97-
string name = Plugin.Instance.Config.GetTranslation(type.GetEffectType());
98-
string line = $"{Plugin.Instance.Config.HintLocation}{Category(type)}</align>";
99-
// Current end time line
100-
line = type.Duration == 0 ? line.Replace("%time%", "inf") : line.Replace("%time%", ((int)type.TimeLeft).ToString());
101-
// Effect duration total
102-
line = type.Duration == 0 ? line.Replace("%duration%", "inf") : line.Replace("%duration%", type.Duration.ToString());
103-
line = line.Replace("%intensity%", type.Intensity.ToString());
104-
line = line.Replace("%effect%", name);
105-
output.AppendLine(line);
106-
}
107-
ply.ShowHint(output.ToString(), 1);
108-
}
131+
string res = InfoLine.ToString() + "</size></align>";
132+
player.ShowHint(res, (float)Plugin.Instance.Config.UpdateTime);
109133
}
110-
yield return Timing.WaitForSeconds(0.9f);
134+
Log.Debug($"Iteration {player.Nickname}: processed.");
135+
yield return Timing.WaitForSeconds((float)Plugin.Instance.Config.UpdateTime);
111136
}
112137
}
113138
}
114-
}
139+
}

EffectDisplay/Configs.cs

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
using Exiled.API.Enums;
1+
using CustomPlayerEffects;
2+
3+
using EffectDisplay.Features.Sereliazer;
4+
5+
using Exiled.API.Enums;
26
using Exiled.API.Features;
37
using Exiled.API.Interfaces;
48
using PlayerRoles;
@@ -12,53 +16,50 @@ public class Configs: IConfig
1216
{
1317
[Description("will the plugin be active?")]
1418
public bool IsEnabled { get; set; } = true;
15-
1619
[Description("will information be displayed for the developer, will help when errors are detected")]
1720
public bool Debug { get; set; } = false;
18-
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;
1923
[Description("will a database be used")]
2024
public bool IsDatabaseUse { get; set; } = true;
21-
25+
[Description("the time period for which information is updated")]
26+
public double UpdateTime { get; set; } = 0.9;
2227
[Description("these lines will be displayed for each effect type separately, allowing you to customize them")]
23-
public Dictionary<string, string> EffectLine { get; set; } = new Dictionary<string, string>()
28+
public Dictionary<StatusEffectBase.EffectClassification, string> EffectLine { get; set; } = new Dictionary<StatusEffectBase.EffectClassification, string>()
2429
{
25-
{"Mixed", "<size=12>%effect% is <color=\"purple\">Mixed</color> end after %time%|%duration%" },
26-
{"Positive", "<size=12>%effect% is <color=\"green\">Positive</color> end after %time%|%duration%" },
27-
{"Negative", "<size=12>%effect% is <color=\"red\">Negative</color> end after %time%|%duration%" },
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%" }
2833
};
29-
30-
[Description("decomposes the text on the screen to change only to what is processed by align")]
31-
public string HintLocation { get; set; } = "<align=left>";
32-
33-
[Description("defines a list of effects that the player will not see (the effects of the technical process are automatically hidden)")]
34+
[Description("defines a list of effects that the player will not see (the effects of the technical process are hidden)")]
3435
public List<EffectType> BlackList { get; set; } = new List<EffectType>()
3536
{
3637
EffectType.InsufficientLighting,
3738
EffectType.SoundtrackMute
3839
};
39-
4040
[Description("https://discord.com/channels/656673194693885975/1172647045237067788/1172647045237067788 determines the name of the effect from the existing list to the one you specify")]
4141
public Dictionary<EffectType, string> EffectTranslation { get; set; } = new Dictionary<EffectType, string>()
4242
{
4343
{ EffectType.None, "UnkownEffect" }
4444
};
45-
4645
[Description("defines the database name in the path (required at the end of .db)")]
4746
public string DatabaseName { get; set; } = "data.db";
48-
4947
[Description("folder location current database")]
5048
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)")]
49+
[Description("List of roles for which the effects display will not be displayed (the roles of the dead are ignored without configs sets)")]
5250
public List<RoleTypeId> IgnoredRoles { get; set; } = new List<RoleTypeId>()
5351
{
5452
RoleTypeId.None,
5553
RoleTypeId.Spectator
5654
};
57-
55+
[Description("Standard settings for displaying information, used in the absence of any supported Hint providers")]
56+
public NativeHintSettings NativeHintSettings { get; set; } = new NativeHintSettings();
57+
[Description("If you use MeowHintService for Exiled then these settings will be useful for customizing the display")]
58+
public MeowHintSettings MeowHintSettings { get; set; } = new MeowHintSettings();
5859
/// <summary>
5960
/// Return effect name from <see cref="EffectTranslation"/> if not found return <see cref="EffectType"/> as <see cref="string"></see>
6061
/// </summary>
61-
public string GetTranslation(EffectType effectType)
62+
public string GetName(EffectType effectType)
6263
{
6364
return EffectTranslation.ContainsKey(effectType) ? EffectTranslation[effectType] : effectType.ToString();
6465
}

EffectDisplay/EffectDisplay.csproj

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
3434
<DebugSymbols>true</DebugSymbols>
3535
<OutputPath>bin\x64\Debug\</OutputPath>
36-
<DefineConstants>DEBUG;TRACE</DefineConstants>
36+
<DefineConstants>TRACE;DEBUG;HINTSERVICEMEOW</DefineConstants>
3737
<DebugType>full</DebugType>
3838
<PlatformTarget>x64</PlatformTarget>
3939
<LangVersion>7.3</LangVersion>
@@ -53,35 +53,35 @@
5353
<HintPath>..\..\..\..\AppData\Roaming\EXILED\Plugins\dependencies\0Harmony.dll</HintPath>
5454
</Reference>
5555
<Reference Include="Assembly-CSharp">
56-
<HintPath>..\packages\EXILED.8.9.8\lib\net48\Assembly-CSharp-Publicized.dll</HintPath>
56+
<HintPath>..\packages\ExMod.Exiled.9.0.1\lib\net48\Assembly-CSharp-Publicized.dll</HintPath>
5757
<Private>True</Private>
5858
</Reference>
5959
<Reference Include="Assembly-CSharp-firstpass">
6060
<HintPath>D:\SteamLibrary\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath>
6161
</Reference>
6262
<Reference Include="CommandSystem.Core, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
63-
<HintPath>..\packages\EXILED.8.9.8\lib\net48\CommandSystem.Core.dll</HintPath>
63+
<HintPath>..\packages\ExMod.Exiled.9.0.1\lib\net48\CommandSystem.Core.dll</HintPath>
6464
</Reference>
65-
<Reference Include="Exiled.API, Version=8.9.8.0, Culture=neutral, processorArchitecture=AMD64">
66-
<HintPath>..\packages\EXILED.8.9.8\lib\net48\Exiled.API.dll</HintPath>
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>
6767
</Reference>
68-
<Reference Include="Exiled.CreditTags, Version=8.9.8.0, Culture=neutral, processorArchitecture=AMD64">
69-
<HintPath>..\packages\EXILED.8.9.8\lib\net48\Exiled.CreditTags.dll</HintPath>
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>
7070
</Reference>
71-
<Reference Include="Exiled.CustomItems, Version=8.9.8.0, Culture=neutral, processorArchitecture=AMD64">
72-
<HintPath>..\packages\EXILED.8.9.8\lib\net48\Exiled.CustomItems.dll</HintPath>
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>
7373
</Reference>
74-
<Reference Include="Exiled.CustomRoles, Version=8.9.8.0, Culture=neutral, processorArchitecture=AMD64">
75-
<HintPath>..\packages\EXILED.8.9.8\lib\net48\Exiled.CustomRoles.dll</HintPath>
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>
7676
</Reference>
77-
<Reference Include="Exiled.Events, Version=8.9.8.0, Culture=neutral, processorArchitecture=AMD64">
78-
<HintPath>..\packages\EXILED.8.9.8\lib\net48\Exiled.Events.dll</HintPath>
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>
7979
</Reference>
80-
<Reference Include="Exiled.Loader, Version=8.9.8.0, Culture=neutral, processorArchitecture=AMD64">
81-
<HintPath>..\packages\EXILED.8.9.8\lib\net48\Exiled.Loader.dll</HintPath>
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>
8282
</Reference>
83-
<Reference Include="Exiled.Permissions, Version=8.9.8.0, Culture=neutral, processorArchitecture=AMD64">
84-
<HintPath>..\packages\EXILED.8.9.8\lib\net48\Exiled.Permissions.dll</HintPath>
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>
8585
</Reference>
8686
<Reference Include="LiteDB, Version=5.0.16.0, Culture=neutral, PublicKeyToken=4ee40123013c9f27, processorArchitecture=MSIL">
8787
<HintPath>..\packages\LiteDB.5.0.16\lib\net45\LiteDB.dll</HintPath>
@@ -90,11 +90,11 @@
9090
<Reference Include="Mirror">
9191
<HintPath>D:\SteamLibrary\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\Mirror.dll</HintPath>
9292
</Reference>
93-
<Reference Include="NorthwoodLib, Version=1.3.0.0, Culture=neutral, processorArchitecture=MSIL">
94-
<HintPath>..\packages\EXILED.8.9.8\lib\net48\NorthwoodLib.dll</HintPath>
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>
9595
</Reference>
96-
<Reference Include="PluginAPI, Version=13.1.2.0, Culture=neutral, processorArchitecture=AMD64">
97-
<HintPath>..\packages\EXILED.8.9.8\lib\net48\PluginAPI.dll</HintPath>
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>
9898
</Reference>
9999
<Reference Include="System" />
100100
<Reference Include="System.Core" />
@@ -114,7 +114,7 @@
114114
<HintPath>D:\SteamLibrary\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\UnityEngine.PhysicsModule.dll</HintPath>
115115
</Reference>
116116
<Reference Include="YamlDotNet, Version=11.0.0.0, Culture=neutral, PublicKeyToken=ec19458f3c15af5e, processorArchitecture=MSIL">
117-
<HintPath>..\packages\EXILED.8.9.8\lib\net48\YamlDotNet.dll</HintPath>
117+
<HintPath>..\packages\ExMod.Exiled.9.0.1\lib\net48\YamlDotNet.dll</HintPath>
118118
</Reference>
119119
</ItemGroup>
120120
<ItemGroup>
@@ -124,6 +124,9 @@
124124
<Compile Include="EventHandler\PlayerEvent.cs" />
125125
<Compile Include="Extensions\PlayerExtensions.cs" />
126126
<Compile Include="Features\DataBase.cs" />
127+
<Compile Include="Features\MeowHintManager.cs" />
128+
<Compile Include="Features\Sereliazer\MeowHintSettings.cs" />
129+
<Compile Include="Features\Sereliazer\NativeHintSettings.cs" />
127130
<Compile Include="Features\Sereliazer\User.cs" />
128131
<Compile Include="Plugin.cs" />
129132
<Compile Include="Properties\AssemblyInfo.cs" />

0 commit comments

Comments
 (0)