Skip to content

自动化 #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ jobs:

- name: Build
run: dotnet build --no-restore

- name: Test
run: dotnet test --no-build --verbosity normal

- name: Generate NuGet packages
run: nuget pack

- name: Upload NuGet package
uses: actions/upload-artifact@v4
with:
path: YongAnFrame.*.nupkg
9 changes: 7 additions & 2 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ jobs:
- name: Build
run: dotnet build --no-restore

- name: Test
run: dotnet test --no-build --verbosity normal
- name: Generate NuGet packages
run: nuget pack

- name: Upload NuGet package
uses: actions/upload-artifact@v4
with:
path: YongAnFrame.*.nupkg

3 changes: 2 additions & 1 deletion Commands/ExpCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,25 @@
using Exiled.API.Features;
using Exiled.Permissions.Extensions;
using System;
using System.Linq;

namespace YongAnFrame.Commands
{
[CommandHandler(typeof(RemoteAdminCommandHandler))]
public class ExpCommand : ICommand

Check warning on line 10 in Commands/ExpCommand.cs

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'ExpCommand'
{
public string Command => "pexperience";

Check warning on line 12 in Commands/ExpCommand.cs

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'ExpCommand.Command'

public string[] Aliases => ["pexp"];

Check warning on line 14 in Commands/ExpCommand.cs

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'ExpCommand.Aliases'

public string Description => "用于经验的设置";

Check warning on line 16 in Commands/ExpCommand.cs

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'ExpCommand.Description'

public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response)

Check warning on line 18 in Commands/ExpCommand.cs

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'ExpCommand.Execute(ArraySegment<string>, ICommandSender, out string)'
{
response = "NO";
if (sender.CheckPermission("yongan404.level.add"))
{
if (arguments.Array.Length > 2)
if (arguments.Count >= 1)
{
Player.Get(arguments.Array[1]).ToFPlayer().Level += ulong.Parse(arguments.Array[2]);
response = "OK";
Expand Down
8 changes: 4 additions & 4 deletions Commands/MessageCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out s
List<FramePlayer> choicePlayer = [];
if (arguments.Count < 3)
{
response = "不允许的格式,格式应该是int string int";
response = "不允许的格式,格式应该是 int string int";
return false;
}
switch (arguments.Array[1])
{
case "all":
if (!sender.CheckPermission("yongan404.message.choice.all"))
{
response = "请保证你有yongan404.message.choice.all权限";
response = "请保证你有 yongan404.message.choice.all 权限";
return false;
}
foreach (Player player in Player.List)
Expand All @@ -46,7 +46,7 @@ public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out s
{
if (idStringArray.Length > 1 && !sender.CheckPermission("yongan404.message.choice.multiple"))
{
response = "请保证你有yongan404.message.choice.multiple权限";
response = "请保证你有 yongan404.message.choice.multiple 权限";
return false;
}

Expand All @@ -73,7 +73,7 @@ public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out s
{
if (duration > 10 && !sender.CheckPermission("yongan404.message.send.large_duration"))
{
response = "请保证你有yongan404.message.send.large_duration权限";
response = "请保证你有 yongan404.message.send.large_duration 权限";
return false;
}

Expand Down
15 changes: 7 additions & 8 deletions Commands/PlayerCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,30 @@
namespace YongAnFrame.Commands
{
[CommandHandler(typeof(ClientCommandHandler))]
public class PlayerCommand : ICommand

Check warning on line 9 in Commands/PlayerCommand.cs

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'PlayerCommand'
{
public string Command => "hPlayer";

Check warning on line 11 in Commands/PlayerCommand.cs

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'PlayerCommand.Command'

public string[] Aliases => ["hPlay", "hp", "h"];

Check warning on line 13 in Commands/PlayerCommand.cs

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'PlayerCommand.Aliases'

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

Check warning on line 15 in Commands/PlayerCommand.cs

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'PlayerCommand.Description'

public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response)

Check warning on line 17 in Commands/PlayerCommand.cs

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'PlayerCommand.Execute(ArraySegment<string>, ICommandSender, out string)'
{
response = "NULL";
if (arguments.Count < 2)
if (arguments.Count >= 1 && Player.TryGet(sender, out Player player))
{
FramePlayer fPlayer = FramePlayer.Get(player);
switch (arguments.Array[1])
{
case "BDNT":
if (Player.TryGet(sender, out Player player))
{
FramePlayer fPlayer = FramePlayer.Get(player);
fPlayer.HintManager.Clean();
fPlayer.ExPlayer.ShowHint($"<size=20>{YongAnFramePlugin.Instance.Translation.BypassDoNotTrack.Split('\n')}</size>", 10000f);
}
fPlayer.HintManager.Clean();
fPlayer.ExPlayer.ShowHint($"<size=20>{YongAnFramePlugin.Instance.Translation.BypassDoNotTrack.Split('\n')}</size>", 10000f);
return true;
case "INFO":

return true;
}

}
return false;
}
Expand Down
19 changes: 15 additions & 4 deletions Commands/SkillCommand.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using CommandSystem;
using Exiled.API.Features;
using System;
using YongAnFrame.Players;
using YongAnFrame.Roles;
using YongAnFrame.Roles.Properties;

namespace YongAnFrame.Commands
{
Expand All @@ -20,12 +23,20 @@ public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out s
{
response = "NO";

if (arguments.Array.Length > 1 && int.TryParse(arguments.Array[1], out int num) && Player.TryGet(sender, out Player player))
if (arguments.Count >= 1 && int.TryParse(arguments.Array[1], out int num) && Player.TryGet(sender, out Player player))
{
//TODO
return true;
FramePlayer fPlayer = FramePlayer.Get(player);

if (fPlayer.CustomRolePlus != null && fPlayer.CustomRolePlus.Check(fPlayer, out CustomRolePlusProperties data))
{
SkillManager skillManager = data.SkillManagers[num];
skillManager.Run();
fPlayer.HintManager.MessageTexts.Add(new HintManager.Text($"技能[{skillManager.SkillProperties.Name}:{fPlayer.CustomRolePlus.GetType().GUID.ToString() + 10000}]已经发动,持续时间:{skillManager.SkillProperties.ActiveMaxTime}", skillManager.SkillProperties.ActiveMaxTime));
response = "OK";
return true;
}
return false;
}

return false;
}
}
Expand Down
4 changes: 2 additions & 2 deletions Players/FramePlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ private IEnumerator<float> DynamicRankTitlesShow()
}
if (usingRankTitles == null)
{
RankColor = command[1] != "null" ? command[1] : RankColor;
RankColor = command[1];
}
yield return Timing.WaitForSeconds(float.Parse(command[2]));
}
Expand All @@ -327,7 +327,7 @@ private IEnumerator<float> DynamicTitlesShow()
CustomName = $"[LV:{Level}][{command[0]}]{ExPlayer.Nickname}";
if (usingRankTitles == null)
{
RankColor = command[1] != "null" ? command[1] : RankColor;
RankColor = command[1];
}
yield return Timing.WaitForSeconds(float.Parse(command[2]));
}
Expand Down
3 changes: 1 addition & 2 deletions Players/HintManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ private IEnumerator<float> Update()
string[] text = new string[36];

int used = 0;
text[used] = $"YongAnFrame 1.0.0-Beta4";
text[used] = $"YongAnFrame 1.0.0-Beta5";

if (fPlayer.ExPlayer.DoNotTrack && !fPlayer.IsBDNT)
{
Expand Down Expand Up @@ -91,7 +91,6 @@ private IEnumerator<float> Update()

if (fPlayer.CustomRolePlus != null)
{

text[34] += $"<color=\"{fPlayer.CustomRolePlus.NameColor}\">{fPlayer.CustomRolePlus.Name}</color>";
text[35] = fPlayer.CustomRolePlus.Description;
}
Expand Down
6 changes: 3 additions & 3 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
[assembly: AssemblyProduct("YongAnFrame")]
[assembly: AssemblyCopyright("Copyright © YongAn404")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: AssemblyCulture("zh-cn")]

// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
Expand All @@ -31,5 +31,5 @@
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.12")]
[assembly: AssemblyFileVersion("1.0.0.12")]
[assembly: AssemblyVersion("1.0.0.13")]
[assembly: AssemblyFileVersion("1.0.0.13")]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

## 联系我们 ##
QQ:3489728203<br>
Mail:3489728203@qq.com<br>
E-Mail:yongandevelopers@163.com
Bug反馈或有疑问欢迎提交issue(请附带错误日志/截图,以及问题的详细描述)


Expand Down
9 changes: 7 additions & 2 deletions Roles/CustomRolePlus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@
using PlayerRoles;
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.InteropServices;
using YongAnFrame.Players;
using YongAnFrame.Roles.Enums;
using YongAnFrame.Roles.Interfaces;
using YongAnFrame.Roles.Properties;

namespace YongAnFrame.Roles
{
[Guid("913613e0-c6e7-4511-a079-bacc7bc0089c")]
public abstract class CustomRolePlus : CustomRole
{
/// <summary>
Expand All @@ -30,7 +33,7 @@ public abstract class CustomRolePlus : CustomRole
/// <summary>
/// 获取或设置自定义角色是否开启生成
/// </summary>
public bool IsStaetSpawn { get; set; } = true;
public bool IsStartSpawn { get; set; } = true;
internal Dictionary<FramePlayer, CustomRolePlusProperties> BaseData { get; } = [];
/// <summary>
/// 获取或设置自定义角色的更多属性
Expand Down Expand Up @@ -242,7 +245,7 @@ private void OnStaticRestartingRound()
private void OnSpawning(SpawningEventArgs args)
{
FramePlayer fPlayer = args.Player.ToFPlayer();
if (IsStaetSpawn && (OldRole != RoleTypeId.None && args.Player.Role.Type == OldRole) || (OldRole == RoleTypeId.None && args.Player.Role.Type == Role))
if (IsStartSpawn && (OldRole != RoleTypeId.None && args.Player.Role.Type == OldRole) || (OldRole == RoleTypeId.None && args.Player.Role.Type == Role))
{
switch (SpawnProperties.RefreshTeam)
{
Expand Down Expand Up @@ -281,6 +284,7 @@ private void OnDroppingItem(DroppingItemEventArgs args)
else
{
skillsManager.Run();
fPlayer.HintManager.MessageTexts.Add(new HintManager.Text($"技能[{skillsManager.SkillProperties.Name}]已经发动,持续时间:{skillsManager.SkillProperties.ActiveMaxTime}", skillsManager.SkillProperties.ActiveMaxTime));
}
args.IsAllowed = false;
}
Expand Down Expand Up @@ -402,6 +406,7 @@ protected override void ShowMessage(Player player)
}

}
[Guid("913613e0-c6e7-4511-a079-bacc7bc9000c")]
public abstract class CustomRolePlus<T> : CustomRolePlus where T : CustomRolePlusProperties, new()
{
/// <summary>
Expand Down
39 changes: 25 additions & 14 deletions Roles/MusicManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ public sealed class MusicManager
private static readonly MusicManager instance = new();

private int num = 1;
/// <summary>
/// 获取<seealso cref="MusicManager"/>单例
/// </summary>
public static MusicManager Instance => instance;
/// <summary>
/// 获取或设置放音频的玩家(NPC)
Expand Down Expand Up @@ -90,7 +93,7 @@ public AudioPlayerBase Play(string musicFile, string npcName, FramePlayer source
/// <param name="npcName">NPC名称</param>
/// <param name="source">指定玩家</param>
/// <returns></returns>
public AudioPlayerBase Play(string musicFile, string npcName, Player source)
public AudioPlayerBase Play(string musicFile, string npcName, FramePlayer source)
{
return Play(musicFile, npcName, new TrackEvent(), source, [], false, 80, false);
}
Expand All @@ -99,20 +102,24 @@ public AudioPlayerBase Play(string musicFile, string npcName, Player source)
/// </summary>
/// <param name="musicFile">音频文件</param>
/// <param name="npcName">NPC名称</param>
/// <param name="trackEvent">播放事件</param>
/// <param name="source">传播距离检测源头玩家</param>
/// <param name="distance">传播距离</param>
/// <param name="extraPlay">额外可接收音频的玩家</param>
/// <param name="trackEvent">播放事件,可以是 null</param>
/// <param name="source">传播距离检测源头玩家,如果是 null 所有人都将听到</param>
/// <param name="distance">传播距离(源头玩家为 null 将无效)</param>
/// <param name="extraPlay">额外可接收音频的玩家,可以是 null</param>
/// <param name="isSole">是否覆盖播放</param>
/// <param name="volume">音量大小</param>
/// <param name="isLoop">是否循环</param>
/// <returns></returns>
public AudioPlayerBase Play(string musicFile, string npcName, TrackEvent trackEvent, FramePlayer source, float distance, FramePlayer[] extraPlay, bool isSole = false, float volume = 80, bool isLoop = false)
public AudioPlayerBase Play(string musicFile, string npcName, TrackEvent? trackEvent, FramePlayer source, float distance, FramePlayer[] extraPlay, bool isSole = false, float volume = 80, bool isLoop = false)
{
AudioPlayerBase audioPlayerBase = null;
try
{
OnTrackLoaded += trackEvent.TrackLoaded;
if (trackEvent.HasValue)
{
OnTrackLoaded += trackEvent.Value.TrackLoaded;
}

if (!MusicNpc.TryGetValue(npcName, out ReferenceHub npc))
{
npc = CreateMusicNpc(npcName);
Expand All @@ -129,17 +136,21 @@ public AudioPlayerBase Play(string musicFile, string npcName, TrackEvent trackEv
}
}

if (extraPlay != null)

if (source != null)
{
audioPlayerBase.AudioToPlay = extraPlay.Select((s) => { return s.ExPlayer.UserId; }).ToList();
audioPlayerBase.AudioToPlay = FramePlayer.List.Where(p => Vector3.Distance(p.ExPlayer.Position, source.ExPlayer.Position) <= distance).Select((s) => s.ExPlayer.UserId).ToList();
}
else
{
audioPlayerBase.AudioToPlay = FramePlayer.List.Select((s) => s.ExPlayer.UserId).ToList();
}

if (distance != 0)
if (extraPlay != null)
{
audioPlayerBase.AudioToPlay ??= [];
foreach (var player in Player.List.Where(p => Vector3.Distance(p.Position, source.ExPlayer.Position) <= distance))
foreach (var player in extraPlay)
{
audioPlayerBase.AudioToPlay.Add(player.UserId);
audioPlayerBase.AudioToPlay.Add(player.ExPlayer.UserId);
}
}

Expand Down Expand Up @@ -193,7 +204,7 @@ public AudioPlayerBase Play(string musicFile, string npcName, TrackEvent trackEv
audioPlayerBase.AudioToPlay = extraPlay.Select((s) => { return s.ExPlayer.UserId; }).ToList();
}

audioPlayerBase.AudioToPlay.Add(source.UserId);
audioPlayerBase.AudioToPlay.Add(source.ExPlayer.UserId);

audioPlayerBase.Enqueue($"{Paths.Plugins}/{Server.Port}/YongAnPluginData/{musicFile}.ogg", 0);
audioPlayerBase.Volume = volume;
Expand Down
3 changes: 3 additions & 0 deletions Roles/SkillManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ private ISkillBurialEnd SkillBurialEnd
return null;
}
}
/// <summary>
/// 获取技能的属性
/// </summary>
public SkillProperties SkillProperties { get => skill.SkillProperties[Id]; }

/// <summary>
Expand Down
4 changes: 3 additions & 1 deletion YongAnFrame.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Debug\YongAnFrame.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand Down Expand Up @@ -133,8 +134,9 @@
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
<None Include="README.md" />
<None Include="YongAnFrame.nuspec" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>
Expand Down
8 changes: 4 additions & 4 deletions YongAnFrame.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
<package >
<metadata>
<id>$id$</id>
<version>1.0.0-beta4</version>
<version>1.0.0-beta5</version>
<title>$title$</title>
<authors>$author$</authors>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<license type="expression">LGPL-3.0-only</license>
<!-- <icon>icon.png</icon> -->
<readme>docs\README.md</readme>
<readme>docs\README.md</readme>
<projectUrl>https://github.com/SCP-SL-Plugin-YongAnTeam/YongAnFrame</projectUrl>
<description>$description$</description>
<releaseNotes>$version$</releaseNotes>
<copyright>$copyright$</copyright>
<tags>EXILED SCPSL</tags>
<tags>EXILED SCPSL SCP:SL</tags>
</metadata>
<files>
<file src="README.md" target="docs\" />
<file src="README.md" target="docs\" />
<file src="lib\net48\SCPSLAudioApi.dll" target="lib/net48/SCPSLAudioApi.dll" />
</files>
</package>
Loading