Skip to content

Commit 9bed865

Browse files
authored
exiled 9.0 working
1 parent 6da13a8 commit 9bed865

File tree

11 files changed

+182
-127
lines changed

11 files changed

+182
-127
lines changed

EffectDisplay/Components/UserEffectDisplayer.cs

+50-36
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,65 @@
44
using Exiled.API.Extensions;
55
using Exiled.API.Features;
66
using MEC;
7-
using System;
87
using System.Collections.Generic;
98
using System.Linq;
109
using System.Text;
11-
using System.Threading.Tasks;
1210
using UnityEngine;
1311

1412
namespace EffectDisplay.Components
1513
{
1614
public class UserEffectDisplayer: MonoBehaviour
1715
{
1816
private Player player;
17+
/// <summary>
18+
/// Stores the current process for future stopping
19+
/// </summary>
20+
private CoroutineHandle Current;
21+
22+
private bool Enabled = true;
23+
/// <summary>
24+
/// Will the display of effects be enabled?
25+
/// </summary>
26+
public bool IsEnabled
27+
{
28+
get
29+
{
30+
return Enabled;
31+
}
32+
set
33+
{
34+
Enabled = value;
35+
Timing.KillCoroutines(Current);
36+
if (value)
37+
{
38+
Current = Timing.RunCoroutine(PlayerEffectShower(player));
39+
}
40+
}
41+
}
1942

2043
private string Category(EffectType effectType)
2144
{
2245
if (effectType == EffectType.Scp207 | effectType == EffectType.AntiScp207)
2346
{
24-
return Plugin.Instance.Config.MixedEffect;
47+
return Plugin.Instance.Config.EffectLine["Mixed"];
2548
}
2649

2750
if (effectType.IsHarmful() || effectType.IsNegative())
2851
{
29-
return Plugin.Instance.Config.BadEffect;
52+
return Plugin.Instance.Config.EffectLine["Negative"];
3053
}
3154
else
3255
{
33-
return Plugin.Instance.Config.GoodEffect;
56+
return Plugin.Instance.Config.EffectLine["Positive"];
3457
}
3558
}
3659

3760
private void Awake()
3861
{
3962
player = Player.Get(gameObject);
40-
if (!player.DataChoise())
63+
if (!player.IsAllow())
4164
{
65+
this.IsEnabled = false;
4266
return;
4367
}
4468
else
@@ -51,41 +75,31 @@ private IEnumerator<float> PlayerEffectShower(Player ply)
5175
{
5276
for (; ; )
5377
{
54-
StringBuilder output = new StringBuilder();
55-
output.Append("\n\n\n\n");
56-
if (ply == null || !ply.IsConnected | !ply.DataChoise())
78+
// check whether it is necessary to calculate active effects for the user at the current moment
79+
if (ply.IsAlive | !Plugin.Instance.Config.IgnoredRoles.Contains(ply.Role.Type) | ply.ActiveEffects.Count() != 0)
5780
{
58-
Destroy(this);
59-
break;
60-
}
61-
else
62-
{
63-
foreach (StatusEffectBase type in ply.ActiveEffects)
81+
// we check whether the effects display has been disabled for the user or whether the player has disconnected
82+
if (ply == null | !ply.IsConnected | !this.Enabled)
6483
{
65-
EffectType effect = type.GetEffectType();
66-
string name = "";
67-
if (Plugin.Instance.Config.EffectTranslation.ContainsKey(effect))
68-
{
69-
name = Plugin.Instance.Config.EffectTranslation[effect];
70-
}
71-
if (!Plugin.Instance.Config.EffectTranslation.ContainsKey(effect))
72-
{
73-
name = effect.ToString();
74-
}
75-
string line = $"{Plugin.Instance.Config.HintLocation}{Plugin.Instance.Config.EffectLineMessage.Replace("%effect%", name)}</align>";
76-
if (type.Duration < 0.1)
77-
{
78-
line = line.Replace("%time%", "inf");
79-
}
80-
if (type.Duration > 0.1)
84+
Destroy(this);
85+
break;
86+
}
87+
else
88+
{
89+
StringBuilder output = new StringBuilder();
90+
output.Append("\n\n\n\n");
91+
foreach (StatusEffectBase type in ply.ActiveEffects)
8192
{
82-
line = line.Replace("%time%", ((int)type.TimeLeft).ToString());
93+
string name = Plugin.Instance.Config.GetTranslation(type.GetEffectType());
94+
string line = Category(type.GetEffectType());
95+
line = type.Duration == 0 ? line.Replace("%time%", "inf") : line.Replace("%time%", ((int)type.TimeLeft).ToString());
96+
line = line.Replace("%intensity%", type.Intensity.ToString());
97+
line = line.Replace("%type%", name);
98+
output.AppendLine(line);
8399
}
84-
line = line.Replace("%type%", Category(effect));
85-
output.AppendLine(line);
100+
Log.Debug($"{nameof(PlayerEffectShower)} Try to show hint for ply {ply.Nickname}");
101+
ply.ShowHint(output.ToString(), 1);
86102
}
87-
Log.Debug($"Try to show hint for ply {ply.Nickname}");
88-
ply.ShowHint(output.ToString(), 1);
89103
}
90104
yield return Timing.WaitForSeconds(0.9f);
91105
}

EffectDisplay/Configs.cs

+30-12
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,65 @@
11
using Exiled.API.Enums;
22
using Exiled.API.Features;
33
using Exiled.API.Interfaces;
4-
using JetBrains.Annotations;
5-
using System;
4+
using PlayerRoles;
65
using System.Collections.Generic;
76
using System.ComponentModel;
87
using System.IO;
9-
using System.Security.Policy;
108

119
namespace EffectDisplay
1210
{
1311
public class Configs: IConfig
1412
{
1513
[Description("will the plugin be active?")]
1614
public bool IsEnabled { get; set; } = true;
15+
1716
[Description("will information be displayed for the developer, will help when errors are detected")]
1817
public bool Debug { get; set; } = false;
18+
1919
[Description("will a database be used")]
2020
public bool IsDatabaseUse { get; set; } = true;
21-
[Description("This message will be displayed on each line")]
22-
public string EffectLineMessage { get; set; } = "<size=12>%effect% is %type% end after %time% second's</size>";
23-
[Description("effects combining harm and benefit and nothing (207 and its anti)")]
24-
public string MixedEffect { get; set; } = "<color=purple>Mixed</color>";
25-
[Description("Only good effect")]
26-
public string GoodEffect { get; set; } = "<color=green>Positive</color>";
27-
[Description("Only bad effect")]
28-
public string BadEffect { get; set; } = "<color=red>Negative</color>";
21+
22+
[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>()
24+
{
25+
{"Mixed", "<size=12>%effect% is <color=\"purple\">%type% end after %time%" },
26+
{"Positive", "<size=12>%effect% is <color=\"green\">%type% end after %time%" },
27+
{"Negative", "<size=12>%effect% is <color=\"red\">%type% end after %time%" }
28+
};
29+
2930
[Description("decomposes the text on the screen to change only to what is processed by align")]
3031
public string HintLocation { get; set; } = "<align=left>";
32+
3133
[Description("defines a list of effects that the player will not see (the effects of the technical process are automatically hidden)")]
3234
public List<EffectType> BlackList { get; set; } = new List<EffectType>()
3335
{
3436
EffectType.InsufficientLighting,
3537
EffectType.SoundtrackMute
3638
};
39+
3740
[Description("https://discord.com/channels/656673194693885975/1172647045237067788/1172647045237067788 determines the name of the effect from the existing list to the one you specify")]
3841
public Dictionary<EffectType, string> EffectTranslation { get; set; } = new Dictionary<EffectType, string>()
3942
{
4043
{ EffectType.Blinded, "Blinded" }
4144
};
45+
4246
[Description("defines the database name in the path (required at the end of .db)")]
4347
public string DatabaseName { get; set; } = "data.db";
48+
4449
[Description("locates the database")]
4550
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)")]
52+
public List<RoleTypeId> IgnoredRoles { get; set; } = new List<RoleTypeId>()
53+
{
54+
55+
};
56+
57+
/// <summary>
58+
/// Return effect name from <see cref="EffectTranslation"/> or <see cref="EffectType"/> as <see cref="string"></see>
59+
/// </summary>
60+
public string GetTranslation(EffectType effectType)
61+
{
62+
return EffectTranslation.ContainsKey(effectType) ? EffectTranslation[effectType] : effectType.ToString();
63+
}
4664
}
47-
}
65+
}

EffectDisplay/EffectDisplay.csproj

+19-20
Original file line numberDiff line numberDiff line change
@@ -53,47 +53,45 @@
5353
<HintPath>..\..\..\..\AppData\Roaming\EXILED\Plugins\dependencies\0Harmony.dll</HintPath>
5454
</Reference>
5555
<Reference Include="Assembly-CSharp">
56-
<HintPath>..\packages\EXILED.8.9.2\lib\net48\Assembly-CSharp-Publicized.dll</HintPath>
56+
<HintPath>..\packages\EXILED.9.0.0-alpha.10\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.2\lib\net48\CommandSystem.Core.dll</HintPath>
63+
<HintPath>..\packages\EXILED.9.0.0-alpha.10\lib\net48\CommandSystem.Core.dll</HintPath>
6464
</Reference>
65-
<Reference Include="Exiled.API, Version=8.9.2.0, Culture=neutral, processorArchitecture=AMD64">
66-
<HintPath>..\packages\EXILED.8.9.2\lib\net48\Exiled.API.dll</HintPath>
65+
<Reference Include="Exiled.API, Version=9.0.0.0, Culture=neutral, processorArchitecture=AMD64">
66+
<HintPath>..\packages\EXILED.9.0.0-alpha.10\lib\net48\Exiled.API.dll</HintPath>
6767
</Reference>
68-
<Reference Include="Exiled.CreditTags, Version=8.9.2.0, Culture=neutral, processorArchitecture=AMD64">
69-
<HintPath>..\packages\EXILED.8.9.2\lib\net48\Exiled.CreditTags.dll</HintPath>
68+
<Reference Include="Exiled.CreditTags, Version=9.0.0.0, Culture=neutral, processorArchitecture=AMD64">
69+
<HintPath>..\packages\EXILED.9.0.0-alpha.10\lib\net48\Exiled.CreditTags.dll</HintPath>
7070
</Reference>
71-
<Reference Include="Exiled.CustomItems, Version=8.9.2.0, Culture=neutral, processorArchitecture=AMD64">
72-
<HintPath>..\packages\EXILED.8.9.2\lib\net48\Exiled.CustomItems.dll</HintPath>
71+
<Reference Include="Exiled.CustomModules, Version=9.0.0.0, Culture=neutral, processorArchitecture=AMD64">
72+
<HintPath>..\packages\EXILED.9.0.0-alpha.10\lib\net48\Exiled.CustomModules.dll</HintPath>
7373
</Reference>
74-
<Reference Include="Exiled.CustomRoles, Version=8.9.2.0, Culture=neutral, processorArchitecture=AMD64">
75-
<HintPath>..\packages\EXILED.8.9.2\lib\net48\Exiled.CustomRoles.dll</HintPath>
74+
<Reference Include="Exiled.Events, Version=9.0.0.0, Culture=neutral, processorArchitecture=AMD64">
75+
<HintPath>..\packages\EXILED.9.0.0-alpha.10\lib\net48\Exiled.Events.dll</HintPath>
7676
</Reference>
77-
<Reference Include="Exiled.Events, Version=8.9.2.0, Culture=neutral, processorArchitecture=AMD64">
78-
<HintPath>..\packages\EXILED.8.9.2\lib\net48\Exiled.Events.dll</HintPath>
77+
<Reference Include="Exiled.Loader, Version=9.0.0.0, Culture=neutral, processorArchitecture=AMD64">
78+
<HintPath>..\packages\EXILED.9.0.0-alpha.10\lib\net48\Exiled.Loader.dll</HintPath>
7979
</Reference>
80-
<Reference Include="Exiled.Loader, Version=8.9.2.0, Culture=neutral, processorArchitecture=AMD64">
81-
<HintPath>..\packages\EXILED.8.9.2\lib\net48\Exiled.Loader.dll</HintPath>
82-
</Reference>
83-
<Reference Include="Exiled.Permissions, Version=8.9.2.0, Culture=neutral, processorArchitecture=AMD64">
84-
<HintPath>..\packages\EXILED.8.9.2\lib\net48\Exiled.Permissions.dll</HintPath>
80+
<Reference Include="Exiled.Permissions, Version=9.0.0.0, Culture=neutral, processorArchitecture=AMD64">
81+
<HintPath>..\packages\EXILED.9.0.0-alpha.10\lib\net48\Exiled.Permissions.dll</HintPath>
8582
</Reference>
8683
<Reference Include="LiteDB, Version=5.0.16.0, Culture=neutral, PublicKeyToken=4ee40123013c9f27, processorArchitecture=MSIL">
8784
<HintPath>..\packages\LiteDB.5.0.16\lib\net45\LiteDB.dll</HintPath>
85+
<EmbedInteropTypes>False</EmbedInteropTypes>
8886
</Reference>
8987
<Reference Include="Mirror">
9088
<HintPath>D:\SteamLibrary\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\Mirror.dll</HintPath>
9189
</Reference>
9290
<Reference Include="NorthwoodLib, Version=1.3.0.0, Culture=neutral, processorArchitecture=MSIL">
93-
<HintPath>..\packages\EXILED.8.9.2\lib\net48\NorthwoodLib.dll</HintPath>
91+
<HintPath>..\packages\EXILED.9.0.0-alpha.10\lib\net48\NorthwoodLib.dll</HintPath>
9492
</Reference>
9593
<Reference Include="PluginAPI, Version=13.1.2.0, Culture=neutral, processorArchitecture=AMD64">
96-
<HintPath>..\packages\EXILED.8.9.2\lib\net48\PluginAPI.dll</HintPath>
94+
<HintPath>..\packages\EXILED.9.0.0-alpha.10\lib\net48\PluginAPI.dll</HintPath>
9795
</Reference>
9896
<Reference Include="System" />
9997
<Reference Include="System.Core" />
@@ -113,7 +111,7 @@
113111
<HintPath>D:\SteamLibrary\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\UnityEngine.PhysicsModule.dll</HintPath>
114112
</Reference>
115113
<Reference Include="YamlDotNet, Version=11.0.0.0, Culture=neutral, PublicKeyToken=ec19458f3c15af5e, processorArchitecture=MSIL">
116-
<HintPath>..\packages\EXILED.8.9.2\lib\net48\YamlDotNet.dll</HintPath>
114+
<HintPath>..\packages\EXILED.9.0.0-alpha.10\lib\net48\YamlDotNet.dll</HintPath>
117115
</Reference>
118116
</ItemGroup>
119117
<ItemGroup>
@@ -128,6 +126,7 @@
128126
<Compile Include="Properties\AssemblyInfo.cs" />
129127
</ItemGroup>
130128
<ItemGroup>
129+
<None Include="app.config" />
131130
<None Include="packages.config" />
132131
</ItemGroup>
133132
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+1-10
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,13 @@
11
using EffectDisplay.Components;
2-
using Exiled.API.Features;
32
using Exiled.Events.EventArgs.Player;
4-
using MEC;
53

64
namespace EffectDisplay.EventHandler
75
{
86
public class PlayerEvent
97
{
108
public void OnVerefied(VerifiedEventArgs e)
119
{
12-
if (e.Player == null | e.Player.GameObject.GetComponent<UserEffectDisplayer>() != null)
13-
{
14-
return;
15-
}
16-
else
17-
{
18-
e.Player.GameObject.AddComponent<UserEffectDisplayer>();
19-
}
10+
e.Player?.GameObject.AddComponent<UserEffectDisplayer>();
2011
}
2112
}
2213
}
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1-
using Exiled.API.Features;
1+
using EffectDisplay.Components;
2+
using Exiled.API.Features;
23

34
namespace EffectDisplay.Extensions
45
{
56
public static class PlayerExtensions
67
{
78
/// <summary>
8-
/// determines the user's choice of displaying effect status
9+
/// Returns the Allow parameter that determines the permission to show the display
910
/// </summary>
1011
/// <param name="player"></param>
11-
/// <returns>true if is allow or false</returns>
12-
public static bool DataChoise(this Player player) => Plugin.data.IsAllow(player.UserId);
13-
12+
public static bool IsAllow(this Player player) => Plugin.data.IsAllow(player.UserId);
13+
/// <summary>
14+
/// Allows you to change the value of the IsAllow parameter
15+
/// </summary>
16+
public static void IsAllow(this Player player, bool IsAllow) => Plugin.data.IsAllow(player.UserId, IsAllow);
1417
}
1518
}

0 commit comments

Comments
 (0)