Compare commits
1 Commits
v4.0.7
...
feat/trans
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a0d1386712 |
@@ -41,6 +41,9 @@ public static class DefaultWidgets
|
||||
if (PlayerManager.ShowNameToggleButton.Value)
|
||||
RegisterManager.RegisterPlayerRow(InternalWidgets.NameToggleButton.Create());
|
||||
|
||||
if (PlayerManager.ShowTransButton.Value)
|
||||
RegisterManager.RegisterPlayerRow(InternalWidgets.TransButton.Create());
|
||||
|
||||
if (PlayerManager.ShowMuteButton.Value)
|
||||
RegisterManager.RegisterPlayerRow(InternalWidgets.MuteButton.Create());
|
||||
if (PlayerManager.ShowAddFriendButton.Value)
|
||||
|
||||
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,
|
||||
};
|
||||
}
|
||||
}
|
||||
25
Plugin.cs
25
Plugin.cs
@@ -39,6 +39,11 @@ public class PlayerManager : BaseUnityPlugin
|
||||
/// </summary>
|
||||
internal static ConfigEntry<bool> ShowKickButton;
|
||||
|
||||
/// <summary>
|
||||
/// 是否显示转让按钮
|
||||
/// </summary>
|
||||
internal static ConfigEntry<bool> ShowTransButton;
|
||||
|
||||
/// <summary>
|
||||
/// 是否显示记录/拉黑按钮
|
||||
/// </summary>
|
||||
@@ -244,6 +249,13 @@ public class PlayerManager : BaseUnityPlugin
|
||||
"是否显示踢人按钮"
|
||||
);
|
||||
|
||||
ShowTransButton = Config.Bind(
|
||||
"GUI",
|
||||
"ShowTransButton",
|
||||
true,
|
||||
"是否显示转让按钮"
|
||||
);
|
||||
|
||||
ShowRecordButton = Config.Bind(
|
||||
"GUI",
|
||||
"ShowRecordButton",
|
||||
@@ -334,6 +346,19 @@ public class PlayerManager : BaseUnityPlugin
|
||||
|
||||
#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>
|
||||
/// 通过SteamID获取NetworkSpawnID
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user