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)
|
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)
|
||||||
|
|||||||
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>
|
/// </summary>
|
||||||
internal static ConfigEntry<bool> ShowKickButton;
|
internal static ConfigEntry<bool> ShowKickButton;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否显示转让按钮
|
||||||
|
/// </summary>
|
||||||
|
internal static ConfigEntry<bool> ShowTransButton;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否显示记录/拉黑按钮
|
/// 是否显示记录/拉黑按钮
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -244,6 +249,13 @@ public class PlayerManager : BaseUnityPlugin
|
|||||||
"是否显示踢人按钮"
|
"是否显示踢人按钮"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
ShowTransButton = Config.Bind(
|
||||||
|
"GUI",
|
||||||
|
"ShowTransButton",
|
||||||
|
true,
|
||||||
|
"是否显示转让按钮"
|
||||||
|
);
|
||||||
|
|
||||||
ShowRecordButton = Config.Bind(
|
ShowRecordButton = Config.Bind(
|
||||||
"GUI",
|
"GUI",
|
||||||
"ShowRecordButton",
|
"ShowRecordButton",
|
||||||
@@ -334,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>
|
||||||
|
|||||||
Reference in New Issue
Block a user