Compare commits
11 Commits
v4.0.5
...
a0d1386712
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a0d1386712 | ||
|
|
ab960fc38b | ||
|
|
a40a605c37 | ||
|
|
b19f906216 | ||
|
|
3ecb7fb78b | ||
|
|
4e8931caba | ||
|
|
3adcdc46ba | ||
|
|
b6edc70594 | ||
| 9e7fb4d443 | |||
| 6ab8c38109 | |||
| 9a5d149241 |
@@ -21,6 +21,11 @@ jobs:
|
|||||||
|
|
||||||
- name: Restore dependencies
|
- name: Restore dependencies
|
||||||
run: dotnet restore
|
run: dotnet restore
|
||||||
|
# 直接加代理得了
|
||||||
|
env:
|
||||||
|
http_proxy: "http://172.17.0.1:7890"
|
||||||
|
https_proxy: "http://172.17.0.1:7890"
|
||||||
|
no_proxy: "localhost,127.0.0.1,*.lan"
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: dotnet build --no-restore --configuration Release
|
run: dotnet build --no-restore --configuration Release
|
||||||
|
|||||||
@@ -41,6 +41,9 @@ public static class DefaultWidgets
|
|||||||
if (PlayerManager.ShowNameToggleButton.Value)
|
if (PlayerManager.ShowNameToggleButton.Value)
|
||||||
RegisterManager.RegisterPlayerRow(InternalWidgets.NameToggleButton.Create());
|
RegisterManager.RegisterPlayerRow(InternalWidgets.NameToggleButton.Create());
|
||||||
|
|
||||||
|
if (PlayerManager.ShowTransButton.Value)
|
||||||
|
RegisterManager.RegisterPlayerRow(InternalWidgets.TransButton.Create());
|
||||||
|
|
||||||
if (PlayerManager.ShowMuteButton.Value)
|
if (PlayerManager.ShowMuteButton.Value)
|
||||||
RegisterManager.RegisterPlayerRow(InternalWidgets.MuteButton.Create());
|
RegisterManager.RegisterPlayerRow(InternalWidgets.MuteButton.Create());
|
||||||
if (PlayerManager.ShowAddFriendButton.Value)
|
if (PlayerManager.ShowAddFriendButton.Value)
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ public static class GUIStyles
|
|||||||
/// <summary>普通按钮样式(fontSize=22, richText=false)</summary>
|
/// <summary>普通按钮样式(fontSize=22, richText=false)</summary>
|
||||||
public static GUIStyle Button;
|
public static GUIStyle Button;
|
||||||
|
|
||||||
|
/// <summary>被按过的按钮样式,用于标识已经进入过的房间(fontSize=22)</summary>
|
||||||
|
public static GUIStyle ButtonPressed;
|
||||||
|
|
||||||
/// <summary>黄色按钮样式(已记录玩家)</summary>
|
/// <summary>黄色按钮样式(已记录玩家)</summary>
|
||||||
public static GUIStyle YellowButton;
|
public static GUIStyle YellowButton;
|
||||||
|
|
||||||
@@ -35,6 +38,8 @@ public static class GUIStyles
|
|||||||
|
|
||||||
Label = new GUIStyle(GUI.skin.label) { fontSize = 22 };
|
Label = new GUIStyle(GUI.skin.label) { fontSize = 22 };
|
||||||
Button = new GUIStyle(GUI.skin.button) { fontSize = 22, richText = false };
|
Button = new GUIStyle(GUI.skin.button) { fontSize = 22, richText = false };
|
||||||
|
ButtonPressed = new GUIStyle(GUI.skin.button) { fontSize = 22, richText = false };
|
||||||
|
ButtonPressed.normal.textColor = Color.grey;
|
||||||
|
|
||||||
YellowButton = new GUIStyle(GUI.skin.button) { fontSize = 22, richText = false };
|
YellowButton = new GUIStyle(GUI.skin.button) { fontSize = 22, richText = false };
|
||||||
YellowButton.normal.textColor = Color.yellow;
|
YellowButton.normal.textColor = Color.yellow;
|
||||||
|
|||||||
21
Gui/InternalWidgets/TransButton.cs
Normal file
21
Gui/InternalWidgets/TransButton.cs
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
using MultiplayerBasicExample;
|
||||||
|
|
||||||
|
namespace stick.plugins.playermanager.Gui.InternalWidgets;
|
||||||
|
|
||||||
|
public static class TransButton
|
||||||
|
{
|
||||||
|
public static IPlayerRowWidget Create()
|
||||||
|
{
|
||||||
|
return new PlayerRowButtonWidget
|
||||||
|
{
|
||||||
|
Name = "Trans Host",
|
||||||
|
Condition = player =>
|
||||||
|
PlayerManager.IsHost(PlayerManager.LocalPlayer)
|
||||||
|
&& !PlayerManager.IsLocalPlayer(player),
|
||||||
|
GetText = _ => "转让",
|
||||||
|
OnClick = player =>
|
||||||
|
PlayerManager.TransferLobbyOwnership(player),
|
||||||
|
Width = 100f,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -190,17 +190,23 @@ public static class PlayerManagerGUI
|
|||||||
for (int i = 0; i < PlayerManager.lobbyDataList.Count; i++)
|
for (int i = 0; i < PlayerManager.lobbyDataList.Count; i++)
|
||||||
{
|
{
|
||||||
CSteamID lobbyId = PlayerManager.lobbyDataList[i];
|
CSteamID lobbyId = PlayerManager.lobbyDataList[i];
|
||||||
|
var style = PlayerManager.enteredLobbyList.Contains(lobbyId) ? GUIStyles.ButtonPressed : GUIStyles.Button;
|
||||||
|
|
||||||
if (GUI.Button(
|
if (GUI.Button(
|
||||||
new Rect(Cursor.OffsetX, Cursor.LineHeight * i, 500f, 40f),
|
new Rect(Cursor.OffsetX, Cursor.LineHeight * i, 500f, 40f),
|
||||||
$"{lobbyId} 人数{SteamMatchmaking.GetNumLobbyMembers(lobbyId)}",
|
$"{lobbyId} 人数{SteamMatchmaking.GetNumLobbyMembers(lobbyId)}",
|
||||||
GUIStyles.Button
|
style
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
// 在大厅中则不加入
|
// 在大厅中则不加入
|
||||||
if (!PlayerManager.MatchmakingHandler.IsInsideLobby)
|
if (!PlayerManager.MatchmakingHandler.IsInsideLobby)
|
||||||
|
{
|
||||||
|
// 记录一下加入过的状态
|
||||||
|
PlayerManager.enteredLobbyList.Add(lobbyId);
|
||||||
PlayerManager.JoinSpecificServer(lobbyId);
|
PlayerManager.JoinSpecificServer(lobbyId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
GUI.EndScrollView();
|
GUI.EndScrollView();
|
||||||
}
|
}
|
||||||
|
|||||||
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
35
Plugin.cs
35
Plugin.cs
@@ -39,6 +39,11 @@ public class PlayerManager : BaseUnityPlugin
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
internal static ConfigEntry<bool> ShowKickButton;
|
internal static ConfigEntry<bool> ShowKickButton;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否显示转让按钮
|
||||||
|
/// </summary>
|
||||||
|
internal static ConfigEntry<bool> ShowTransButton;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否显示记录/拉黑按钮
|
/// 是否显示记录/拉黑按钮
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -102,6 +107,11 @@ public class PlayerManager : BaseUnityPlugin
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static List<CSteamID> lobbyDataList = [];
|
public static List<CSteamID> lobbyDataList = [];
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 进入过的大厅列表
|
||||||
|
/// </summary>
|
||||||
|
public static HashSet<CSteamID> enteredLobbyList = [];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 大厅距离过滤设置
|
/// 大厅距离过滤设置
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -195,7 +205,7 @@ public class PlayerManager : BaseUnityPlugin
|
|||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
HandleInput();
|
HandleInput();
|
||||||
if (SteamManager.Initialized)
|
if (SteamManager.Initialized && LocalPlayer is null)
|
||||||
{
|
{
|
||||||
LocalPlayer = new(SteamUser.GetSteamID());
|
LocalPlayer = new(SteamUser.GetSteamID());
|
||||||
}
|
}
|
||||||
@@ -239,6 +249,13 @@ public class PlayerManager : BaseUnityPlugin
|
|||||||
"是否显示踢人按钮"
|
"是否显示踢人按钮"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
ShowTransButton = Config.Bind(
|
||||||
|
"GUI",
|
||||||
|
"ShowTransButton",
|
||||||
|
true,
|
||||||
|
"是否显示转让按钮"
|
||||||
|
);
|
||||||
|
|
||||||
ShowRecordButton = Config.Bind(
|
ShowRecordButton = Config.Bind(
|
||||||
"GUI",
|
"GUI",
|
||||||
"ShowRecordButton",
|
"ShowRecordButton",
|
||||||
@@ -293,6 +310,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>
|
||||||
@@ -327,6 +346,19 @@ public class PlayerManager : BaseUnityPlugin
|
|||||||
|
|
||||||
#region 公共方法
|
#region 公共方法
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 转让房主
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="targetPlayer">目标玩家</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static void TransferLobbyOwnership(PlayerInfo targetPlayer)
|
||||||
|
{
|
||||||
|
if (targetPlayer != null && targetPlayer != LocalPlayer)
|
||||||
|
{
|
||||||
|
SteamMatchmaking.SetLobbyOwner(CurrentLobbyID, targetPlayer.SteamId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 通过SteamID获取NetworkSpawnID
|
/// 通过SteamID获取NetworkSpawnID
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -432,6 +464,7 @@ public class PlayerManager : BaseUnityPlugin
|
|||||||
{
|
{
|
||||||
Debug.Log("大厅列表请求完成: " + result.m_nLobbiesMatching + " 个大厅");
|
Debug.Log("大厅列表请求完成: " + result.m_nLobbiesMatching + " 个大厅");
|
||||||
lobbyDataList = [];
|
lobbyDataList = [];
|
||||||
|
enteredLobbyList = [];
|
||||||
uint lobbyCount = result.m_nLobbiesMatching;
|
uint lobbyCount = result.m_nLobbiesMatching;
|
||||||
|
|
||||||
for (uint i = 0; i < lobbyCount; i++)
|
for (uint i = 0; i < lobbyCount; i++)
|
||||||
|
|||||||
14
readme.md
14
readme.md
@@ -17,8 +17,22 @@
|
|||||||
- 静音单个玩家
|
- 静音单个玩家
|
||||||
- 一键加好友
|
- 一键加好友
|
||||||
|
|
||||||
|
## 作者
|
||||||
|
|
||||||
|
老狼老狼几点钟、Moncak、z7572
|
||||||
|
|
||||||
## 更新日志
|
## 更新日志
|
||||||
|
|
||||||
|
### v4.0.7
|
||||||
|
|
||||||
|
1. 现在点击大厅列表中的按钮进入大厅会在列表中将该大厅用灰色样式标识,标记已进入过
|
||||||
|
2. 现在不会在每帧都初始化一遍LocalPlayer *难道他真的是猪??*
|
||||||
|
|
||||||
|
### v4.0.6
|
||||||
|
|
||||||
|
1. 大厅搜索范围按钮现在可同步修改快速匹配的搜索范围
|
||||||
|
2. 修复了禁音功能 *难道他真的是猪??*
|
||||||
|
|
||||||
### v4.0.5
|
### v4.0.5
|
||||||
|
|
||||||
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.5</Version>
|
<Version>4.0.7</Version>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
<LangVersion>latest</LangVersion>
|
<LangVersion>latest</LangVersion>
|
||||||
<RestoreAdditionalProjectSources>
|
<RestoreAdditionalProjectSources>
|
||||||
|
|||||||
Reference in New Issue
Block a user