mirror of
https://gitee.com/cssfw/EasyTools.git
synced 2026-03-28 12:01:36 +08:00
feat: 914和电梯使用提示
This commit is contained in:
31
Configs/HUDInfoConfig.cs
Normal file
31
Configs/HUDInfoConfig.cs
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace EasyTools.Configs
|
||||||
|
{
|
||||||
|
public class HUDInfoConfig
|
||||||
|
{
|
||||||
|
[Description("是否显示SCP914提示信息")]
|
||||||
|
public bool info_914 { get; set; } = true;
|
||||||
|
[Description("是否显示电梯提示信息")]
|
||||||
|
public bool info_elevator { get; set; } = true;
|
||||||
|
|
||||||
|
/// /////////////////////////////////////////////////
|
||||||
|
[Description("914显示,X轴坐标(0为正中,-为左,+为右):")]
|
||||||
|
public float _914_x { get; set; } = 0;
|
||||||
|
[Description("914显示,Y轴坐标(屏幕最上端大概100,最下端大概1000):")]
|
||||||
|
public float _914_y { get; set; } = 80;
|
||||||
|
[Description("914显示,字体大小:")]
|
||||||
|
public int _914_font { get; set; } = 20;
|
||||||
|
|
||||||
|
/// /////////////////////////////////////////////////
|
||||||
|
[Description("电梯显示,X轴坐标(0为正中,-为左,+为右):")]
|
||||||
|
public float _elev_x { get; set; } = 0;
|
||||||
|
[Description("电梯显示,Y轴坐标(屏幕最上端大概100,最下端大概1000):")]
|
||||||
|
public float _elev_y { get; set; } = 800;
|
||||||
|
[Description("电梯显示,字体大小:")]
|
||||||
|
public int _elev_font { get; set; } = 20;
|
||||||
|
|
||||||
|
[Description("电梯提示显示可见范围(操作者为中心):")]
|
||||||
|
public float elev_range { get; set; } = 10f;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
using EasyTools.Utils;
|
using EasyTools.Utils;
|
||||||
using PlayerRoles;
|
using PlayerRoles;
|
||||||
|
using Scp914;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
|
||||||
@@ -73,5 +74,21 @@ namespace EasyTools.Configs
|
|||||||
{Team.ChaosInsurgency , "混沌阵营" },
|
{Team.ChaosInsurgency , "混沌阵营" },
|
||||||
{Team.FoundationForces , "九尾狐阵营" },
|
{Team.FoundationForces , "九尾狐阵营" },
|
||||||
};
|
};
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
[Description("电梯显示模板(HEX color写死, {p_operator}表示操作人, 没有的话自动为未知):")]
|
||||||
|
public string elev_template { get; set; } = "[Elevator] 电梯使用者: <color=#B952FA>{p_operator}</color>";
|
||||||
|
[Description("SCP914显示模板(HEX color写死, {mode}表示操作模式, {p_operator}表示操作人, 没有的话自动为未知):")]
|
||||||
|
public string scp914_template { get; set; } = "[Scp914] 已启动! 模式: <color=#F7C73E>{mode}</color>, 操作人: <color=#0080FF>{p_operator}</color>";
|
||||||
|
[Description("SCP914, Rough模式翻译:")]
|
||||||
|
public Dictionary<Scp914KnobSetting, string> scp914_trans { get; set; } = new Dictionary<Scp914KnobSetting, string>()
|
||||||
|
{
|
||||||
|
{ Scp914KnobSetting.Rough, "粗加" },
|
||||||
|
{ Scp914KnobSetting.Coarse, "半粗" },
|
||||||
|
{ Scp914KnobSetting.OneToOne, "1:1" },
|
||||||
|
{ Scp914KnobSetting.Fine, "精加" },
|
||||||
|
{ Scp914KnobSetting.VeryFine, "超精加工" }
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
15
DataBase/Serialization/HintData.cs
Normal file
15
DataBase/Serialization/HintData.cs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
namespace EasyTools.DataBase.Serialization
|
||||||
|
{
|
||||||
|
public struct HintData
|
||||||
|
{
|
||||||
|
public float x, y;
|
||||||
|
public int font;
|
||||||
|
|
||||||
|
public HintData(float x, float y, int font)
|
||||||
|
{
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.font = font;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
64
DataBase/Serialization/PlayerHint.cs
Normal file
64
DataBase/Serialization/PlayerHint.cs
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
using HintServiceMeow.Core.Enum;
|
||||||
|
using HintServiceMeow.Core.Extension;
|
||||||
|
using HintServiceMeow.Core.Models.Hints;
|
||||||
|
using HintServiceMeow.Core.Utilities;
|
||||||
|
using LabApi.Features.Wrappers;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace EasyTools.DataBase.Serialization
|
||||||
|
{
|
||||||
|
public struct PlayerHint : IDisposable
|
||||||
|
{
|
||||||
|
private readonly List<Hint> _hints = new();
|
||||||
|
|
||||||
|
private Hint hint_914;
|
||||||
|
private Hint hint_elevator;
|
||||||
|
|
||||||
|
public PlayerHint(Player player, HintData data_914, HintData data_elevator)
|
||||||
|
{
|
||||||
|
hint_914 = new Hint
|
||||||
|
{
|
||||||
|
Text = "",
|
||||||
|
XCoordinate = data_914.x,
|
||||||
|
YCoordinate = data_914.y,
|
||||||
|
FontSize = data_914.font,
|
||||||
|
YCoordinateAlign = HintVerticalAlign.Bottom
|
||||||
|
};
|
||||||
|
|
||||||
|
hint_elevator = new Hint
|
||||||
|
{
|
||||||
|
Text = "",
|
||||||
|
XCoordinate = data_elevator.x,
|
||||||
|
YCoordinate = data_elevator.y,
|
||||||
|
FontSize = data_elevator.font,
|
||||||
|
YCoordinateAlign = HintVerticalAlign.Bottom
|
||||||
|
};
|
||||||
|
|
||||||
|
var display = PlayerDisplay.Get(player);
|
||||||
|
_hints.AddRange(new[] { hint_914, hint_elevator });
|
||||||
|
_hints.ForEach(display.AddHint);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Show914(string text)
|
||||||
|
{
|
||||||
|
hint_914.Text = text;
|
||||||
|
hint_914.Hide = false;
|
||||||
|
hint_914.HideAfter(15f);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ShowElevator(string text)
|
||||||
|
{
|
||||||
|
hint_elevator.Text = text;
|
||||||
|
hint_elevator.Hide = false;
|
||||||
|
hint_elevator.HideAfter(7f);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Start() { }
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
foreach (var h in _hints) h.Hide = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -130,10 +130,13 @@
|
|||||||
<Compile Include="Configs\Config.cs" />
|
<Compile Include="Configs\Config.cs" />
|
||||||
<Compile Include="Configs\CustomRoleConfig.cs" />
|
<Compile Include="Configs\CustomRoleConfig.cs" />
|
||||||
<Compile Include="Configs\DataBaseConfig.cs" />
|
<Compile Include="Configs\DataBaseConfig.cs" />
|
||||||
|
<Compile Include="Configs\HUDInfoConfig.cs" />
|
||||||
<Compile Include="Configs\TranslateConfig.cs" />
|
<Compile Include="Configs\TranslateConfig.cs" />
|
||||||
<Compile Include="DataBase\DataAPI.cs" />
|
<Compile Include="DataBase\DataAPI.cs" />
|
||||||
<Compile Include="DataBase\InfoExtension.cs" />
|
<Compile Include="DataBase\InfoExtension.cs" />
|
||||||
|
<Compile Include="DataBase\Serialization\HintData.cs" />
|
||||||
<Compile Include="DataBase\Serialization\PlayerData.cs" />
|
<Compile Include="DataBase\Serialization\PlayerData.cs" />
|
||||||
|
<Compile Include="DataBase\Serialization\PlayerHint.cs" />
|
||||||
<Compile Include="Events\CustomEventHandler.cs" />
|
<Compile Include="Events\CustomEventHandler.cs" />
|
||||||
<Compile Include="Plugins.cs" />
|
<Compile Include="Plugins.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
|||||||
@@ -1,11 +1,15 @@
|
|||||||
using EasyTools.BadgeSystem;
|
using EasyTools.BadgeSystem;
|
||||||
using EasyTools.Configs;
|
using EasyTools.Configs;
|
||||||
|
using EasyTools.DataBase.Serialization;
|
||||||
using EasyTools.Utils;
|
using EasyTools.Utils;
|
||||||
|
using Hints;
|
||||||
using InventorySystem.Items;
|
using InventorySystem.Items;
|
||||||
using LabApi.Events.Arguments.PlayerEvents;
|
using LabApi.Events.Arguments.PlayerEvents;
|
||||||
|
using LabApi.Events.Arguments.Scp914Events;
|
||||||
using LabApi.Events.Arguments.ServerEvents;
|
using LabApi.Events.Arguments.ServerEvents;
|
||||||
using LabApi.Events.CustomHandlers;
|
using LabApi.Events.CustomHandlers;
|
||||||
using LabApi.Features.Wrappers;
|
using LabApi.Features.Wrappers;
|
||||||
|
using MapGeneration;
|
||||||
using MEC;
|
using MEC;
|
||||||
using PlayerRoles;
|
using PlayerRoles;
|
||||||
using PlayerStatsSystem;
|
using PlayerStatsSystem;
|
||||||
@@ -30,8 +34,14 @@ namespace EasyTools.Events
|
|||||||
|
|
||||||
public static DataBaseConfig DataBaseConfig;
|
public static DataBaseConfig DataBaseConfig;
|
||||||
|
|
||||||
|
public static HUDInfoConfig HUDInfoConfig;
|
||||||
|
|
||||||
public static CoroutineHandle Badge_Coroutine;
|
public static CoroutineHandle Badge_Coroutine;
|
||||||
|
|
||||||
|
public static readonly Dictionary<Player, PlayerHint> _huds = new();
|
||||||
|
|
||||||
|
public static HintData data_914, data_elevator;
|
||||||
|
|
||||||
public override void OnServerWaitingForPlayers()
|
public override void OnServerWaitingForPlayers()
|
||||||
{
|
{
|
||||||
base.OnServerWaitingForPlayers();
|
base.OnServerWaitingForPlayers();
|
||||||
@@ -58,6 +68,7 @@ namespace EasyTools.Events
|
|||||||
{
|
{
|
||||||
Timing.RunCoroutine(ScpReal.AutoReal());
|
Timing.RunCoroutine(ScpReal.AutoReal());
|
||||||
}
|
}
|
||||||
|
_huds.Values.ToList().ForEach(h => h.Start());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,6 +111,8 @@ namespace EasyTools.Events
|
|||||||
Badge.Handler(player);
|
Badge.Handler(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_huds[player] = new PlayerHint(player, data_914, data_elevator);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnPlayerLeft(PlayerLeftEventArgs ev)
|
public override void OnPlayerLeft(PlayerLeftEventArgs ev)
|
||||||
@@ -122,6 +135,7 @@ namespace EasyTools.Events
|
|||||||
Badge.Remove(player);
|
Badge.Remove(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_huds.ContainsKey(player))
|
||||||
{
|
{
|
||||||
_huds.Remove(player);
|
_huds.Remove(player);
|
||||||
}
|
}
|
||||||
@@ -470,5 +484,41 @@ namespace EasyTools.Events
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void OnScp914Activating(Scp914ActivatingEventArgs ev)
|
||||||
|
{
|
||||||
|
if (HUDInfoConfig.info_914 == false) return;
|
||||||
|
|
||||||
|
Scp914.Scp914KnobSetting knob = ev.KnobSetting;
|
||||||
|
string mode = TranslateConfig.scp914_trans[knob];
|
||||||
|
|
||||||
|
var p_operator = ev.Player.Nickname ?? "未知";
|
||||||
|
|
||||||
|
string msg = TranslateConfig.scp914_template.Replace("{mode}", mode)
|
||||||
|
.Replace("{p_operator}", p_operator);
|
||||||
|
|
||||||
|
foreach (var p in Player.List)
|
||||||
|
{
|
||||||
|
if (p.IsAlive && p != null && p.Room.Name == RoomName.Lcz914)// 检测914附近玩家,然后告诉他们914正在运行
|
||||||
|
{
|
||||||
|
_huds[p].Show914(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnPlayerInteractingElevator(PlayerInteractingElevatorEventArgs ev)
|
||||||
|
{
|
||||||
|
if (HUDInfoConfig.info_elevator == false) return;
|
||||||
|
|
||||||
|
IEnumerable<Player> near = Player.List.Where(p =>
|
||||||
|
Vector3.Distance(p.Position, ev.Player.Position) <= HUDInfoConfig.elev_range);
|
||||||
|
|
||||||
|
var p_operator = ev.Player.Nickname ?? "未知";
|
||||||
|
string text = TranslateConfig.elev_template.Replace("{p_operator}", p_operator);
|
||||||
|
foreach (var p in near)
|
||||||
|
{
|
||||||
|
_huds[p].ShowElevator(text);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
19
Plugins.cs
19
Plugins.cs
@@ -1,4 +1,5 @@
|
|||||||
using EasyTools.Configs;
|
using EasyTools.Configs;
|
||||||
|
using EasyTools.DataBase.Serialization;
|
||||||
using EasyTools.Events;
|
using EasyTools.Events;
|
||||||
using LabApi.Events.CustomHandlers;
|
using LabApi.Events.CustomHandlers;
|
||||||
using LabApi.Features;
|
using LabApi.Features;
|
||||||
@@ -20,6 +21,21 @@ namespace EasyTools
|
|||||||
CustomEventHandler.BadgeConfig = this.LoadConfig<BadgeConfig>("badgeConfig.yml");
|
CustomEventHandler.BadgeConfig = this.LoadConfig<BadgeConfig>("badgeConfig.yml");
|
||||||
CustomEventHandler.CustomRoleConfig = this.LoadConfig<CustomRoleConfig>("customRoleConfig.yml");
|
CustomEventHandler.CustomRoleConfig = this.LoadConfig<CustomRoleConfig>("customRoleConfig.yml");
|
||||||
CustomEventHandler.DataBaseConfig = this.LoadConfig<DataBaseConfig>("dataBaseConfig.yml");
|
CustomEventHandler.DataBaseConfig = this.LoadConfig<DataBaseConfig>("dataBaseConfig.yml");
|
||||||
|
CustomEventHandler.HUDInfoConfig = this.LoadConfig<HUDInfoConfig>("HUDInfoConfig.yml");
|
||||||
|
|
||||||
|
CustomEventHandler.data_914 = new HintData
|
||||||
|
(
|
||||||
|
CustomEventHandler.HUDInfoConfig._914_x,
|
||||||
|
CustomEventHandler.HUDInfoConfig._914_y,
|
||||||
|
CustomEventHandler.HUDInfoConfig._914_font
|
||||||
|
);
|
||||||
|
|
||||||
|
CustomEventHandler.data_elevator = new HintData
|
||||||
|
(
|
||||||
|
CustomEventHandler.HUDInfoConfig._elev_x,
|
||||||
|
CustomEventHandler.HUDInfoConfig._elev_y,
|
||||||
|
CustomEventHandler.HUDInfoConfig._elev_font
|
||||||
|
);
|
||||||
|
|
||||||
if (!Directory.Exists(CustomEventHandler.BadgeConfig.Pach))
|
if (!Directory.Exists(CustomEventHandler.BadgeConfig.Pach))
|
||||||
{
|
{
|
||||||
@@ -54,6 +70,9 @@ namespace EasyTools
|
|||||||
CustomHandlersManager.UnregisterEventsHandler(Events);
|
CustomHandlersManager.UnregisterEventsHandler(Events);
|
||||||
|
|
||||||
Instance = null;
|
Instance = null;
|
||||||
|
|
||||||
|
foreach (var hud in CustomEventHandler._huds.Values) hud.Dispose();
|
||||||
|
CustomEventHandler._huds.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user