Skip to content

Commit

Permalink
1.0.0-alpha.8 (#8)
Browse files Browse the repository at this point in the history
* 音频系统的小改,部分注释补充

* 注释补充

* 问题的修复 (#6)

* add BDNT(Bypass Do Not Track)

* add GetAllProperties

* 修复功能

* 修复错版 (#10)
  • Loading branch information
YongAn404 authored Oct 7, 2024
1 parent d927248 commit d8d869b
Show file tree
Hide file tree
Showing 7 changed files with 147 additions and 91 deletions.
45 changes: 45 additions & 0 deletions Commands/PlayerCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using CommandSystem;
using Exiled.API.Features;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YongAnFrame.Players;

namespace YongAnFrame.Commands
{
[CommandHandler(typeof(ClientCommandHandler))]
public class PlayerCommand : ICommand
{
public string Command => "player";

public string[] Aliases => ["play", "pl", "pr"];

public string Description => "用于管理自己的用户";

public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response)
{
response = "NULL";
if (arguments.Count < 2)
{
switch (arguments.Array[1])
{
case "BDNT":
if (Player.TryGet(sender, out Player player))
{
FramePlayer fPlayer = FramePlayer.Get(player);
fPlayer.HintManager.Clean();
string[] text = new string[36];

fPlayer.ExPlayer.ShowHint($"<size=20>{string.Join("\n", text)}\n\n\n\n\n\n\n\n\n\n\n\n\n\n</size>", 10000f);
}

return true;
}

}
return false;
}
}
}
59 changes: 14 additions & 45 deletions Components/CapacityList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,33 @@

namespace YongAnFrame.Components
{
public class CapacityList<T>(int capacity) : IList<T>, ICollection<T>, IEnumerable<T>, IEnumerable
public class CapacityList<T>(int capacity)
{
private readonly List<T> list = new(capacity);

public int Capacity { get; set; } = capacity;

public int Count => list.Count;

public bool IsReadOnly => ((ICollection<T>)list).IsReadOnly;

public T this[int index]
{
get => list[index];
set => list[index] = value;
}

public int IndexOf(T item)
{
return list.IndexOf(item);
}

public void Insert(int index, T item)
{
list.Insert(index, item);
}
get
{
if (Count > index)
{
return list[index];
}
return default;
}
set
{

public void RemoveAt(int index)
{
list.RemoveAt(index);
}
}

public void Add(T item)
{
if (Capacity <= list.Count)
if (Capacity > list.Count)
{
list.Add(item);
}
Expand All @@ -51,34 +45,9 @@ public void Add(T item)
}
}

public void Clear()
{
list.Clear();
}

public bool Contains(T item)
{
return list.Contains(item);
}

public void CopyTo(T[] array, int arrayIndex)
{
list.CopyTo(array, arrayIndex);
}

public bool Remove(T item)
{
return list.Remove(item);
}

IEnumerator IEnumerable.GetEnumerator()
{
return list.GetEnumerator();
}

IEnumerator<T> IEnumerable<T>.GetEnumerator()
{
return ((IEnumerable<T>)list).GetEnumerator();
}
}
}
25 changes: 22 additions & 3 deletions Players/FramePlayer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Exiled.API.Features;
using Exiled.CustomRoles.API;
using Exiled.Events.EventArgs.Player;
using Exiled.Events.Features;
using MEC;
Expand Down Expand Up @@ -30,7 +31,16 @@ public sealed class FramePlayer
/// <summary>
/// 实例拥有的自定义角色
/// </summary>
public CustomRolePlus CustomRolePlus { get; internal set; }
public CustomRolePlus CustomRolePlus {
get
{
if (ExPlayer.GetCustomRoles().Count != 0)
{
return (CustomRolePlus)ExPlayer.GetCustomRoles()[0];
}
return null;
}
}
/// <summary>
/// 提示系统管理器
/// </summary>
Expand All @@ -39,7 +49,10 @@ public sealed class FramePlayer
/// 玩家等级
/// </summary>
public ulong Level { get; set; }

/// <summary>
/// 玩家批准绕过DNT
/// </summary>
public bool IsBDNT { get; set; }
/// <summary>
/// 正在使用的名称称号
/// </summary>
Expand Down Expand Up @@ -72,7 +85,8 @@ private static void OnStaticVerified(VerifiedEventArgs args)
}
private static void OnStaticDestroying(DestroyingEventArgs args)
{
args.Player.ToFPlayer().Invalid();
FramePlayer fPlayer = args.Player.ToFPlayer();
fPlayer.Invalid();
}
//private static void OnStaticWaitingForPlayers()
//{
Expand Down Expand Up @@ -175,6 +189,11 @@ internal void UpdateShowInfoList()
ExPlayer.RankName = CustomRolePlus.Name;
ExPlayer.RankColor = CustomRolePlus.NameColor;
}
else
{
ExPlayer.RankName = string.Empty;
ExPlayer.RankColor = string.Empty;
}
}

if (usingTitles == null) ExPlayer.CustomName = $"[LV:{Level}]{ExPlayer.Nickname}";
Expand Down
63 changes: 40 additions & 23 deletions Players/HintManager.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using MEC;
using Exiled.API.Features;
using MEC;
using System.Collections.Generic;
using System.Reflection;
using YongAnFrame.Components;
Expand All @@ -17,7 +18,6 @@ public sealed class HintManager

private readonly CoroutineHandle coroutine;


public Text[] CustomText = new Text[20];
public CapacityList<Text> MessageTexts { get; } = new(7);
public CapacityList<Text> ChatTexts { get; } = new(6);
Expand All @@ -33,25 +33,36 @@ public IEnumerator<float> Update()
{
string[] text = new string[36];

int usedMex = text.Length - 1;
int used = 0;
text[used] = $"YongAnFrame 1.0.0-alpha7";

if (fPlayer.ExPlayer.DoNotTrack && !fPlayer.IsBDNT)
{
text[used] = "[注意]已开启DoNotTrack(DNT),游戏数据不会被保存,想保存数据请控制台输入pl BDNT查看详情";
}

used = 1;
text[used] = "<align=left>";

for (int i = 0; i < ChatTexts.Count; i++)
for (int i = 0; i < ChatTexts.Capacity; i++)
{
Text textData = ChatTexts[i];

text[used] += textData;
used++;

textData.Duration--;
if (textData.Duration <= 0)
Text chatText = ChatTexts[i];
if(chatText != null)
{
text[used] += chatText;
chatText.Duration--;

if (chatText.Duration <= 0)
{
ChatTexts.Remove(chatText);
i--;
}
}
else
{
ChatTexts.Remove(textData);
i--;
text[used] = string.Empty;
}
used++;
}

foreach (Text data in CustomText)
Expand All @@ -60,28 +71,34 @@ public IEnumerator<float> Update()
used++;
}


for (int i = 0; i < MessageTexts.Count; i++)
for (int i = 0; i < MessageTexts.Capacity; i++)
{
Text messageText = MessageTexts[i];
text[used] = $"[{messageText.Duration}]{messageText}";

messageText.Duration--;
if (messageText.Duration <= 0)
if (messageText != null)
{
text[used] = $"[{messageText.Duration}]{messageText}";

messageText.Duration--;
if (messageText.Duration <= 0)
{
MessageTexts.Remove(messageText);
i--;
}
}
else
{
MessageTexts.Remove(messageText);
i--;
text[used] = string.Empty;
}
used++;
}

text[used] += "</align>";

if (fPlayer.CustomRolePlus != null)
{
text[34] = fPlayer.CustomRolePlus.Name;
text[35] = fPlayer.CustomRolePlus.Description;
}

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);
yield return Timing.WaitForSeconds(1f);
}
Expand Down
Loading

0 comments on commit d8d869b

Please sign in to comment.