Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9e7fb4d443 | |||
| 6ab8c38109 | |||
| 9a5d149241 | |||
|
|
f193d8a805 | ||
|
|
00960eb3f7 | ||
|
|
bc2d44f5cd | ||
|
|
c065b14f9d | ||
|
|
46f05b5489 | ||
|
|
3a9e903044 | ||
|
|
ca331d4ac8 | ||
|
|
692fc25d42 | ||
|
|
bec55e4ecc |
@@ -43,5 +43,7 @@ public static class DefaultWidgets
|
|||||||
|
|
||||||
if (PlayerManager.ShowMuteButton.Value)
|
if (PlayerManager.ShowMuteButton.Value)
|
||||||
RegisterManager.RegisterPlayerRow(InternalWidgets.MuteButton.Create());
|
RegisterManager.RegisterPlayerRow(InternalWidgets.MuteButton.Create());
|
||||||
|
if (PlayerManager.ShowAddFriendButton.Value)
|
||||||
|
RegisterManager.RegisterPlayerRow(InternalWidgets.AddFriendButton.Create());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
26
Gui/InternalWidgets/AddFriendButton.cs
Normal file
26
Gui/InternalWidgets/AddFriendButton.cs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
using Steamworks;
|
||||||
|
using UnityEngine;
|
||||||
|
using stick.plugins.playermanager.Recorder;
|
||||||
|
|
||||||
|
namespace stick.plugins.playermanager.Gui.InternalWidgets;
|
||||||
|
|
||||||
|
public static class AddFriendButton
|
||||||
|
{
|
||||||
|
public static IPlayerRowWidget Create()
|
||||||
|
{
|
||||||
|
return new PlayerRowButtonWidget
|
||||||
|
{
|
||||||
|
Name = "Add Friend",
|
||||||
|
GetText = player => "加好友",
|
||||||
|
Condition = player =>
|
||||||
|
!PlayerManager.IsLocalPlayer(player)
|
||||||
|
&& !player.IsFriend,
|
||||||
|
OnClick = player =>
|
||||||
|
{
|
||||||
|
GUIUtility.systemCopyBuffer = player.ToString();
|
||||||
|
SteamFriends.ActivateGameOverlayToUser("friendadd", player.SteamId);
|
||||||
|
},
|
||||||
|
Width = 100f,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,11 +9,9 @@ public static class MuteButton
|
|||||||
return new PlayerRowButtonWidget
|
return new PlayerRowButtonWidget
|
||||||
{
|
{
|
||||||
Name = "mute",
|
Name = "mute",
|
||||||
Condition = player =>
|
Condition = player => !PlayerManager.IsLocalPlayer(player),
|
||||||
!PlayerManager.IsHost(player)
|
|
||||||
&& !PlayerManager.IsLocalPlayer(player),
|
|
||||||
GetText = player =>
|
GetText = player =>
|
||||||
PlayerManager.IsMuted(player) ? "取消禁音" : "禁音",
|
PlayerManager.IsMuted(player) ? "取消静音" : "静音",
|
||||||
OnClick = player =>
|
OnClick = player =>
|
||||||
{
|
{
|
||||||
if (PlayerManager.IsMuted(player))
|
if (PlayerManager.IsMuted(player))
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ public static class PlayerManagerGUI
|
|||||||
if (PlayerManager.MatchmakingHandler.IsInsideLobby)
|
if (PlayerManager.MatchmakingHandler.IsInsideLobby)
|
||||||
{
|
{
|
||||||
DrawCurrentLobbyInfo();
|
DrawCurrentLobbyInfo();
|
||||||
|
DrawLobbySearchInfo();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -99,6 +100,8 @@ public static class PlayerManagerGUI
|
|||||||
{
|
{
|
||||||
if (widget.ShouldDraw(member))
|
if (widget.ShouldDraw(member))
|
||||||
widget.Draw(Cursor.NextColumn(widget.Width, 40f), member);
|
widget.Draw(Cursor.NextColumn(widget.Width, 40f), member);
|
||||||
|
else
|
||||||
|
Cursor.NextColumn(widget.Width, 40f); // 占位推进列位置
|
||||||
}
|
}
|
||||||
Cursor.EndRow();
|
Cursor.EndRow();
|
||||||
}
|
}
|
||||||
@@ -193,6 +196,8 @@ public static class PlayerManagerGUI
|
|||||||
GUIStyles.Button
|
GUIStyles.Button
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
|
// 在大厅中则不加入
|
||||||
|
if (!PlayerManager.MatchmakingHandler.IsInsideLobby)
|
||||||
PlayerManager.JoinSpecificServer(lobbyId);
|
PlayerManager.JoinSpecificServer(lobbyId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
22
Patches/DistanceFilterPatch.cs
Normal file
22
Patches/DistanceFilterPatch.cs
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
using System.Reflection.Emit;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using HarmonyLib;
|
||||||
|
using stick.plugins.playermanager;
|
||||||
|
|
||||||
|
[HarmonyPatch(typeof(MatchmakingHandler), "OnRandomServerJoinFailed")]
|
||||||
|
class DistanceFilterPatch
|
||||||
|
{
|
||||||
|
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
|
||||||
|
{
|
||||||
|
return new CodeMatcher(instructions)
|
||||||
|
.MatchForward(false,
|
||||||
|
new CodeMatch(OpCodes.Ldc_I4_1),
|
||||||
|
new CodeMatch(OpCodes.Stloc_0)
|
||||||
|
)
|
||||||
|
.SetInstruction(
|
||||||
|
new CodeInstruction(OpCodes.Ldsfld,
|
||||||
|
AccessTools.Field(typeof(PlayerManager), nameof(PlayerManager.lobbyDistanceFilter))))
|
||||||
|
.InstructionEnumeration();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
15
Patches/MutePatch.cs
Normal file
15
Patches/MutePatch.cs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
using HarmonyLib;
|
||||||
|
using stick.plugins.playermanager;
|
||||||
|
|
||||||
|
[HarmonyPatch(typeof(NetworkPlayer), "SyncClientChat")]
|
||||||
|
class MutePatch
|
||||||
|
{
|
||||||
|
public static bool Prefix(NetworkPlayer __instance)
|
||||||
|
{
|
||||||
|
if (PlayerManager.MutedPlayers.Contains(__instance.NetworkSpawnID))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
47
Plugin.cs
47
Plugin.cs
@@ -64,6 +64,11 @@ public class PlayerManager : BaseUnityPlugin
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
internal static ConfigEntry<bool> ShowMuteButton;
|
internal static ConfigEntry<bool> ShowMuteButton;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否显示加好友按钮
|
||||||
|
/// </summary>
|
||||||
|
internal static ConfigEntry<bool> ShowAddFriendButton;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Steam回调
|
#region Steam回调
|
||||||
@@ -111,6 +116,11 @@ public class PlayerManager : BaseUnityPlugin
|
|||||||
|
|
||||||
#region 快捷访问属性
|
#region 快捷访问属性
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 多人管理器实例
|
||||||
|
/// </summary>
|
||||||
|
public static MultiplayerManager MultiplayerManager => FindObjectOfType<MultiplayerManager>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 大厅管理器实例
|
/// 大厅管理器实例
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -164,7 +174,7 @@ public class PlayerManager : BaseUnityPlugin
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 禁音玩家列表
|
/// 禁音玩家列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static HashSet<PlayerInfo> MutedPlayers = [];
|
public static HashSet<ushort> MutedPlayers = [];
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -263,6 +273,13 @@ public class PlayerManager : BaseUnityPlugin
|
|||||||
true,
|
true,
|
||||||
"是否显示切换公开性按钮"
|
"是否显示切换公开性按钮"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
ShowAddFriendButton = Config.Bind(
|
||||||
|
"GUI",
|
||||||
|
"ShowAddFriendButton",
|
||||||
|
true,
|
||||||
|
"是否显示加好友按钮"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -276,6 +293,8 @@ public class PlayerManager : BaseUnityPlugin
|
|||||||
}
|
}
|
||||||
Harmony.CreateAndPatchAll(typeof(ApplyBlacklist));
|
Harmony.CreateAndPatchAll(typeof(ApplyBlacklist));
|
||||||
Harmony.CreateAndPatchAll(typeof(ListenForChange));
|
Harmony.CreateAndPatchAll(typeof(ListenForChange));
|
||||||
|
Harmony.CreateAndPatchAll(typeof(MutePatch));
|
||||||
|
Harmony.CreateAndPatchAll(typeof(DistanceFilterPatch));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -310,6 +329,24 @@ public class PlayerManager : BaseUnityPlugin
|
|||||||
|
|
||||||
#region 公共方法
|
#region 公共方法
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 通过SteamID获取NetworkSpawnID
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="targetSteamID"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static ushort GetNetworkSpawnIDBySteamID(CSteamID targetSteamID)
|
||||||
|
{
|
||||||
|
ConnectedClientData[] clients = MultiplayerManager.ConnectedClients;
|
||||||
|
for (ushort i = 0; i < clients.Length; i++)
|
||||||
|
{
|
||||||
|
if (clients[i] != null && clients[i].ClientID == targetSteamID)
|
||||||
|
{
|
||||||
|
return i; // i 就是 NetworkSpawnID
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 65535; // ushort.MaxValue,表示未找到(与默认值一致)
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 判断指定玩家是否被静音
|
/// 判断指定玩家是否被静音
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -317,7 +354,7 @@ public class PlayerManager : BaseUnityPlugin
|
|||||||
/// <returns>如果被静音返回true</returns>
|
/// <returns>如果被静音返回true</returns>
|
||||||
public static bool IsMuted(PlayerInfo player)
|
public static bool IsMuted(PlayerInfo player)
|
||||||
{
|
{
|
||||||
return player != null && MutedPlayers.Contains(player);
|
return player != null && MutedPlayers.Contains(player.NetworkSpawnID);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -328,7 +365,7 @@ public class PlayerManager : BaseUnityPlugin
|
|||||||
{
|
{
|
||||||
if (player != null)
|
if (player != null)
|
||||||
{
|
{
|
||||||
MutedPlayers.Add(player);
|
MutedPlayers.Add(player.NetworkSpawnID);
|
||||||
Debug.Log($"玩家 {player} 已被静音");
|
Debug.Log($"玩家 {player} 已被静音");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -339,9 +376,9 @@ public class PlayerManager : BaseUnityPlugin
|
|||||||
/// <param name="player">要取消静音的玩家</param>
|
/// <param name="player">要取消静音的玩家</param>
|
||||||
public static void UnmutePlayer(PlayerInfo player)
|
public static void UnmutePlayer(PlayerInfo player)
|
||||||
{
|
{
|
||||||
if (player != null && MutedPlayers.Contains(player))
|
if (player != null && MutedPlayers.Contains(player.NetworkSpawnID))
|
||||||
{
|
{
|
||||||
MutedPlayers.Remove(player);
|
MutedPlayers.Remove(player.NetworkSpawnID);
|
||||||
Debug.Log($"玩家 {player} 已被取消静音");
|
Debug.Log($"玩家 {player} 已被取消静音");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,6 +43,12 @@ public class PlayerInfo : IEquatable<PlayerInfo>
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public PlayerRecordStatus RecordStatus { get; set; }
|
public PlayerRecordStatus RecordStatus { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 柴自己的NetworkSpawnID
|
||||||
|
/// </summary>
|
||||||
|
public ushort NetworkSpawnID => PlayerManager.GetNetworkSpawnIDBySteamID(SteamId);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 当前玩家名称(实时获取)
|
/// 当前玩家名称(实时获取)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
24
readme.md
24
readme.md
@@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
- 房间查找
|
- 房间查找
|
||||||
- 玩家记录
|
- 玩家记录
|
||||||
|
|
||||||
- 被记录的玩家显示为黄名
|
- 被记录的玩家显示为黄名
|
||||||
- 是steam好友的玩家显示为绿名(优先级更高)
|
- 是steam好友的玩家显示为绿名(优先级更高)
|
||||||
- 被拉黑的玩家显示为红名(优先级最高)
|
- 被拉黑的玩家显示为红名(优先级最高)
|
||||||
@@ -16,16 +15,31 @@
|
|||||||
- 可配置的界面开启按键,默认为F2
|
- 可配置的界面开启按键,默认为F2
|
||||||
- 可以随时切换房间的公开性
|
- 可以随时切换房间的公开性
|
||||||
- 静音单个玩家
|
- 静音单个玩家
|
||||||
|
- 一键加好友
|
||||||
|
|
||||||
## 更新日志
|
## 更新日志
|
||||||
|
|
||||||
|
### v4.0.6
|
||||||
|
1. 大厅搜索范围按钮现在可同步修改快速匹配的搜索范围
|
||||||
|
2. 修复了禁音功能 *难道他真的是猪??*
|
||||||
|
|
||||||
|
### v4.0.5
|
||||||
|
|
||||||
|
1. 修复了加好友按钮始终不显示的问题 *难道他真的是猪??*
|
||||||
|
|
||||||
|
### v4.0.4
|
||||||
|
|
||||||
|
1. 房间列表现在在房间内也显示,但是点击无效
|
||||||
|
2. 添加了加好友按钮
|
||||||
|
3. 修复了禁音功能 *难道他真的是猪??*
|
||||||
|
|
||||||
### v4.0.3
|
### v4.0.3
|
||||||
|
|
||||||
1. 静音单个玩家
|
1. 静音单个玩家
|
||||||
1. 性能优化
|
2. 性能优化
|
||||||
1. 提供了更多可选是否开启功能显示的配置项
|
3. 提供了更多可选是否开启功能显示的配置项
|
||||||
1. 提供按钮组件注册入口
|
4. 提供按钮组件注册入口
|
||||||
1. 更好的房间公开性切换
|
5. 更好的房间公开性切换
|
||||||
|
|
||||||
### v3.1.1
|
### v3.1.1
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<TargetFramework>net35</TargetFramework>
|
<TargetFramework>net35</TargetFramework>
|
||||||
<AssemblyName>stick.plugins.playermanager</AssemblyName>
|
<AssemblyName>stick.plugins.playermanager</AssemblyName>
|
||||||
<Product>PlayerManager</Product>
|
<Product>PlayerManager</Product>
|
||||||
<Version>4.0.3</Version>
|
<Version>4.0.6</Version>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
<LangVersion>latest</LangVersion>
|
<LangVersion>latest</LangVersion>
|
||||||
<RestoreAdditionalProjectSources>
|
<RestoreAdditionalProjectSources>
|
||||||
|
|||||||
Reference in New Issue
Block a user