Skip to content

Commit 17f9a19

Browse files
committed
修复部分功能
1 parent 1d084f2 commit 17f9a19

15 files changed

+143
-113
lines changed

Commands/MessageCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace YongAnFrame.Commands
1111
/// 发送消息指令
1212
/// </summary>
1313
[CommandHandler(typeof(RemoteAdminCommandHandler))]
14-
public class MessageCommand : CommandPlus
14+
public sealed class MessageCommand : CommandPlus
1515
{
1616
public override string Command => "message";
1717

Commands/SkillCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace YongAnFrame.Commands
88
/// 未完成请勿乱用
99
/// </summary>
1010
[CommandHandler(typeof(ClientCommandHandler))]
11-
public class SkillsCommand : CommandPlus
11+
public sealed class SkillsCommand : CommandPlus
1212
{
1313
public override string Command => "skills";
1414

Components/CapacityList.cs

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
using Exiled.API.Features;
2+
using System;
3+
using System.Collections;
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
using System.Text;
7+
using System.Threading.Tasks;
8+
9+
namespace YongAnFrame.Components
10+
{
11+
public class CapacityList<T>(int capacity) : IList<T>, ICollection<T>, IEnumerable<T>, IEnumerable
12+
{
13+
private readonly List<T> list = new(capacity);
14+
public int Capacity { get; set; } = capacity;
15+
16+
public int Count => list.Count;
17+
18+
public bool IsReadOnly => ((ICollection<T>)list).IsReadOnly;
19+
20+
public T this[int index]
21+
{
22+
get => list[index];
23+
set => list[index] = value;
24+
}
25+
26+
public int IndexOf(T item)
27+
{
28+
return list.IndexOf(item);
29+
}
30+
31+
public void Insert(int index, T item)
32+
{
33+
list.Insert(index, item);
34+
}
35+
36+
public void RemoveAt(int index)
37+
{
38+
list.RemoveAt(index);
39+
}
40+
41+
public void Add(T item)
42+
{
43+
if (Capacity <= list.Count)
44+
{
45+
list.Add(item);
46+
}
47+
else
48+
{
49+
list.RemoveAt(0);
50+
list.Add(item);
51+
}
52+
}
53+
54+
public void Clear()
55+
{
56+
list.Clear();
57+
}
58+
59+
public bool Contains(T item)
60+
{
61+
return list.Contains(item);
62+
}
63+
64+
public void CopyTo(T[] array, int arrayIndex)
65+
{
66+
list.CopyTo(array, arrayIndex);
67+
}
68+
69+
public bool Remove(T item)
70+
{
71+
return list.Remove(item);
72+
}
73+
74+
IEnumerator IEnumerable.GetEnumerator()
75+
{
76+
return list.GetEnumerator();
77+
}
78+
79+
IEnumerator<T> IEnumerable<T>.GetEnumerator()
80+
{
81+
return ((IEnumerable<T>)list).GetEnumerator();
82+
}
83+
}
84+
}

Events/EventArgs/FramePlayer/FramePlayerCreatedEventArgs.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace YongAnFrame.Events.EventArgs.FramePlayer
55
/// <summary>
66
/// FramePlayer被创建时的事件数据
77
/// </summary>
8-
public class FramePlayerCreatedEventArgs(Players.FramePlayer fPlayer) : IExiledEvent
8+
public sealed class FramePlayerCreatedEventArgs(Players.FramePlayer fPlayer) : IExiledEvent
99
{
1010
public Players.FramePlayer FPlayer { get; } = fPlayer;
1111
}

Events/EventArgs/FramePlayer/FramePlayerInvalidingEventArgs.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace YongAnFrame.Events.EventArgs.FramePlayer
55
/// <summary>
66
/// FramePlayer被无效时的事件数据
77
/// </summary>
8-
public class FramePlayerInvalidatingEventArgs : IExiledEvent
8+
public sealed class FramePlayerInvalidatingEventArgs : IExiledEvent
99
{
1010
public Players.FramePlayer FPlayer { get; }
1111

Events/Handlers/FramePlayer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
namespace YongAnFrame.Events.Handlers
55
{
6-
public class FramePlayer
6+
public sealed class FramePlayer
77
{
88
/// <summary>
99
/// FramePlayer被创建时的事件

Players/FramePlayer.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
namespace YongAnFrame.Players
1111
{
12-
public class FramePlayer
12+
public sealed class FramePlayer
1313
{
1414
private PlayerTitle usingTitles = null;
1515
private PlayerTitle usingRankTitles = null;
@@ -121,7 +121,7 @@ internal void UpdateShowInfoList()
121121
if (usingRankTitles.DynamicCommand != null)
122122
{
123123
Timing.KillCoroutines(coroutines[0]);
124-
coroutines[0] = Timing.RunCoroutine(DynamicProTitlesShow(CustomRolePlus.NameColor));
124+
coroutines[0] = Timing.RunCoroutine(DynamicRankTitlesShow());
125125
}
126126
else
127127
{
@@ -173,25 +173,22 @@ internal void UpdateShowInfoList()
173173
if (CustomRolePlus != null)
174174
{
175175
ExPlayer.RankName = CustomRolePlus.Name;
176-
}
177-
if (CustomRolePlus != null)
178-
{
179176
ExPlayer.RankColor = CustomRolePlus.NameColor;
180177
}
181178
}
182179

183180
if (usingTitles == null) ExPlayer.CustomName = $"[LV:{Level}]{ExPlayer.Nickname}";
184181
}
185182

186-
private IEnumerator<float> DynamicProTitlesShow(string name = null)
183+
private IEnumerator<float> DynamicRankTitlesShow()
187184
{
188185
while (true)
189186
{
190187
foreach (var command in usingRankTitles.DynamicCommand)
191188
{
192-
if (name != null)
189+
if (CustomRolePlus != null)
193190
{
194-
ExPlayer.RankName = $"{name} *{command[0]}*";
191+
ExPlayer.RankName = $"{CustomRolePlus.Name} *{command[0]}*";
195192
}
196193
else
197194
{

Players/HintManager.cs

Lines changed: 14 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
using MEC;
22
using System.Collections.Generic;
33
using System.Reflection;
4+
using YongAnFrame.Components;
45

56
namespace YongAnFrame.Players
67
{
78
/// <summary>
89
/// 提示系统管理器
910
/// </summary>
10-
public class HintManager
11+
public sealed class HintManager
1112
{
1213
/// <summary>
1314
/// 拥有该实例的框架玩家
@@ -17,11 +18,9 @@ public class HintManager
1718
private readonly CoroutineHandle coroutine;
1819

1920

20-
public Text[] CustomText1 = new Text[10];
21-
public Text[] CustomText2 = new Text[20];
22-
public List<Text> RoleText { get; } = [];
23-
public List<Text> MessageTexts { get; } = [];
24-
public List<Text> ChatTexts { get; } = [];
21+
public Text[] CustomText = new Text[20];
22+
public CapacityList<Text> MessageTexts { get; } = new(7);
23+
public CapacityList<Text> ChatTexts { get; } = new(6);
2524
public HintManager(FramePlayer player)
2625
{
2726
fPlayer = player;
@@ -37,25 +36,9 @@ public IEnumerator<float> Update()
3736
int usedMex = text.Length - 1;
3837
int used = 0;
3938
text[used] = $"YongAnFrame 1.0.0-alpha6";
40-
used++;
39+
used = 1;
4140
text[used] = "<align=left>";
42-
used++;
43-
foreach (string data in CustomText1)
44-
{
45-
text[used] = data ?? string.Empty;
46-
used++;
47-
}
48-
used++;
4941

50-
if (ChatTexts.Count > 28 - used)
51-
{
52-
for (int i = 0; i < ChatTexts.Count - (28 - used); i++)
53-
{
54-
ChatTexts.Remove(ChatTexts[i]);
55-
}
56-
}
57-
58-
used = 22;
5942
for (int i = 0; i < ChatTexts.Count; i++)
6043
{
6144
Text textData = ChatTexts[i];
@@ -71,16 +54,13 @@ public IEnumerator<float> Update()
7154
}
7255
}
7356

74-
used = 29;
75-
76-
if (usedMex - RoleText.Count < used + MessageTexts.Count + 1)
57+
foreach (Text data in CustomText)
7758
{
78-
for (int i = 0; i < usedMex - RoleText.Count - (used + MessageTexts.Count + 1); i++)
79-
{
80-
MessageTexts.Remove(MessageTexts[i]);
81-
}
59+
text[used] = data ?? string.Empty;
60+
used++;
8261
}
8362

63+
8464
for (int i = 0; i < MessageTexts.Count; i++)
8565
{
8666
Text messageText = MessageTexts[i];
@@ -94,22 +74,14 @@ public IEnumerator<float> Update()
9474
}
9575
}
9676

97-
used = usedMex - RoleText.Count;
9877
text[used] += "</align>";
9978

100-
foreach (Text roleText in RoleText)
79+
if (fPlayer.CustomRolePlus != null)
10180
{
102-
text[used] += roleText;
103-
used++;
104-
}
105-
106-
for (int i = 0; i < usedMex; i++)
107-
{
108-
if (string.IsNullOrEmpty(text[i]))
109-
{
110-
text[i] = "<color=#00000000>占</color>";
111-
}
81+
text[34] = fPlayer.CustomRolePlus.Name;
82+
text[35] = fPlayer.CustomRolePlus.Description;
11283
}
84+
11385
fPlayer.ExPlayer.ShowHint($"<size=20>{string.Join("\n", text)}\n\n\n\n\n\n\n\n\n\n\n\n\n\n</size>", 2f);
11486
yield return Timing.WaitForSeconds(1f);
11587
}
@@ -144,19 +116,5 @@ public static implicit operator Text(string text)
144116
return new Text(text, -1);
145117
}
146118
}
147-
public struct Registry
148-
{
149-
public Assembly Assembly { get; }
150-
public int StartLineNum { get; }
151-
public int EndLineNum { get; }
152-
public int LineNum => EndLineNum - StartLineNum + 1;
153-
154-
public Registry(Assembly assembly, int startLineNum, int endLineNum)
155-
{
156-
Assembly = assembly;
157-
StartLineNum = startLineNum;
158-
EndLineNum = endLineNum;
159-
}
160-
}
161119
}
162120
}

Players/PlayerTitle.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace YongAnFrame.Players
55
/// <summary>
66
/// 玩家称号
77
/// </summary>
8-
public class PlayerTitle
8+
public sealed class PlayerTitle
99
{
1010
public uint Id { get; set; }
1111
public string Name { get; set; }

0 commit comments

Comments
 (0)