Compare commits
7 Commits
be50401453
...
v3.1.1-rc1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
652693883b | ||
|
|
8261d243e6 | ||
|
|
4de0778dc8 | ||
|
|
eb27008e4d | ||
|
|
0b3a12f64d | ||
|
|
f44815c600 | ||
|
|
ca1f7c0637 |
46
.gitea/workflows/dotnet.yml
Normal file
46
.gitea/workflows/dotnet.yml
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
name: Publish Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*' # 匹配 v 开头的标签,如 v1.0.0
|
||||||
|
# 或者使用 '*' 匹配所有标签
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: http://MonBianG.lan:3000/actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup .NET
|
||||||
|
uses: http://MonBianG.lan:3000/actions/setup-dotnet@v4
|
||||||
|
with:
|
||||||
|
dotnet-version: 8.0.x
|
||||||
|
|
||||||
|
- name: Restore dependencies
|
||||||
|
run: dotnet restore
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: dotnet build --no-restore --configuration Release
|
||||||
|
|
||||||
|
# 使用 Gitea Release Action 创建 Release
|
||||||
|
- name: Create Release
|
||||||
|
uses: http://MonBianG.lan:3000/actions/gitea-release-action@main
|
||||||
|
with:
|
||||||
|
# 使用推送的标签名作为版本号
|
||||||
|
tag: ${{ github.ref_name }}
|
||||||
|
# 自动从标签名生成 Release 标题
|
||||||
|
name: Release ${{ github.ref_name }}
|
||||||
|
# 使用提交信息或自定义发布说明
|
||||||
|
body: |
|
||||||
|
## Changes in ${{ github.ref_name }}
|
||||||
|
|
||||||
|
Auto-generated release for tag ${{ github.ref_name }}.
|
||||||
|
# 上传构建产物
|
||||||
|
files: |
|
||||||
|
./bin/Release/net35/stick.plugins.*.dll
|
||||||
|
# 是否为预发布版本(如果是 alpha/beta/rc 标签)
|
||||||
|
prerelease: ${{ contains(github.ref_name, 'alpha') || contains(github.ref_name, 'beta') || contains(github.ref_name, 'rc') }}
|
||||||
|
|
||||||
@@ -167,7 +167,7 @@ public static class PlayerManagerGUI
|
|||||||
|
|
||||||
private static string GetRoomPublicText()
|
private static string GetRoomPublicText()
|
||||||
{
|
{
|
||||||
return MatchmakingHandler.LobbyType == ELobbyType.k_ELobbyTypePublic ? "公开" : "好友可见";
|
return PlayerManager.IsPublic ? "公开" : "好友可见";
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -180,17 +180,7 @@ public static class PlayerManagerGUI
|
|||||||
|
|
||||||
private static void OnRoomPublicToggleButtonClick()
|
private static void OnRoomPublicToggleButtonClick()
|
||||||
{
|
{
|
||||||
if (MultiplayerManager.IsServer)
|
PlayerManager.ToggleLobbyPublicity();
|
||||||
{
|
|
||||||
if (MatchmakingHandler.LobbyType == ELobbyType.k_ELobbyTypePublic)
|
|
||||||
{
|
|
||||||
MatchmakingHandler.SetNewLobbyType(ELobbyType.k_ELobbyTypeFriendsOnly);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MatchmakingHandler.SetNewLobbyType(ELobbyType.k_ELobbyTypePublic);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -243,6 +233,7 @@ public static class PlayerManagerGUI
|
|||||||
private static void OnCycleLobbyDistanceFilterClick()
|
private static void OnCycleLobbyDistanceFilterClick()
|
||||||
{
|
{
|
||||||
CycleLobbyDistanceFilter();
|
CycleLobbyDistanceFilter();
|
||||||
|
PlayerManager.RequestLobbyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -276,14 +267,14 @@ public static class PlayerManagerGUI
|
|||||||
{
|
{
|
||||||
// 绘制房间公开性
|
// 绘制房间公开性
|
||||||
GUI.Label(
|
GUI.Label(
|
||||||
new Rect(OffsetX, GetNewYPosition(), 500f, 40f),
|
new Rect(OffsetX, GetNewYPosition(), 200f, 40f),
|
||||||
$"房间类型: {GetRoomPublicText()}",
|
$"房间类型: {GetRoomPublicText()}",
|
||||||
TitleStyle
|
TitleStyle
|
||||||
);
|
);
|
||||||
|
|
||||||
// 绘制房间公开切换按钮
|
// 绘制房间公开切换按钮
|
||||||
if (GUI.Button(
|
if (GUI.Button(
|
||||||
new Rect(OffsetX + 520f, GetCurrentYPosition(), 100f, 40f),
|
new Rect(OffsetX + 220f, GetCurrentYPosition(), 150f, 40f),
|
||||||
"切换公开性",
|
"切换公开性",
|
||||||
CommonButtonStyle
|
CommonButtonStyle
|
||||||
))
|
))
|
||||||
@@ -471,9 +462,8 @@ public static class PlayerManagerGUI
|
|||||||
"当前不在大厅中",
|
"当前不在大厅中",
|
||||||
TitleStyle
|
TitleStyle
|
||||||
);
|
);
|
||||||
|
DrawLobbySearchInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawLobbySearchInfo();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
85
Plugin.cs
85
Plugin.cs
@@ -82,6 +82,24 @@ public class PlayerManager : BaseUnityPlugin
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static MatchmakingHandler MatchmakingHandler => MatchmakingHandler.Instance;
|
public static MatchmakingHandler MatchmakingHandler => MatchmakingHandler.Instance;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 原始的设置lobby类型方法
|
||||||
|
/// </summary>
|
||||||
|
public static MethodInfo RawChangeLobbyTypeMI => AccessTools.Method(
|
||||||
|
typeof(MatchmakingHandler),
|
||||||
|
"ChangeLobbyType"
|
||||||
|
);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// leverhandler实例
|
||||||
|
/// </summary>
|
||||||
|
public static HostLeverHandler HostLeverHandler => UnityEngine.Object.FindObjectOfType<HostLeverHandler>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 房间公开性
|
||||||
|
/// </summary>
|
||||||
|
public static bool IsPublic => HostLeverHandler?.isOn ?? MatchmakingHandler.LobbyType == ELobbyType.k_ELobbyTypePublic;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 当前大厅ID
|
/// 当前大厅ID
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -186,6 +204,25 @@ public class PlayerManager : BaseUnityPlugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 修改lever朝向
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="angle">朝向角度</param>
|
||||||
|
/// <returns>修改成功返回true</returns>
|
||||||
|
private static bool SetHostLeverDirection(float angle)
|
||||||
|
{
|
||||||
|
if (HostLeverHandler is not null)
|
||||||
|
{
|
||||||
|
var rig = HostLeverHandler.lever.GetComponent<Rigidbody>();
|
||||||
|
if (rig is not null)
|
||||||
|
{
|
||||||
|
rig.MoveRotation(Quaternion.Euler(0, angle, 0));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 公共方法
|
#region 公共方法
|
||||||
@@ -210,21 +247,51 @@ public class PlayerManager : BaseUnityPlugin
|
|||||||
return player.Equals(LocalPlayer);
|
return player.Equals(LocalPlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 修改大厅公开性
|
||||||
|
/// </summary>
|
||||||
|
public static void ToggleLobbyPublicity()
|
||||||
|
{
|
||||||
|
if (MultiplayerManager.IsServer)
|
||||||
|
{
|
||||||
|
if (IsPublic)
|
||||||
|
{
|
||||||
|
MatchmakingHandler.SetNewLobbyType(ELobbyType.k_ELobbyTypeFriendsOnly);
|
||||||
|
if (!SetHostLeverDirection(30f))
|
||||||
|
{
|
||||||
|
// 如果lever不存在则直接调用原始方法
|
||||||
|
RawChangeLobbyTypeMI.Invoke(MatchmakingHandler, [ELobbyType.k_ELobbyTypeFriendsOnly]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MatchmakingHandler.SetNewLobbyType(ELobbyType.k_ELobbyTypePublic);
|
||||||
|
if (!SetHostLeverDirection(-30f))
|
||||||
|
{
|
||||||
|
// 如果lever不存在则直接调用原始方法
|
||||||
|
RawChangeLobbyTypeMI.Invoke(MatchmakingHandler, [ELobbyType.k_ELobbyTypePublic]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 请求大厅列表
|
/// 请求大厅列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void RequestLobbyList()
|
public static void RequestLobbyList()
|
||||||
{
|
{
|
||||||
|
Debug.Log("正在请求大厅列表...");
|
||||||
SteamMatchmaking.AddRequestLobbyListDistanceFilter(lobbyDistanceFilter);
|
SteamMatchmaking.AddRequestLobbyListDistanceFilter(lobbyDistanceFilter);
|
||||||
SteamAPICall_t apiCall = SteamMatchmaking.RequestLobbyList();
|
SteamAPICall_t apiCall = SteamMatchmaking.RequestLobbyList();
|
||||||
LobbyMatchListCallResult.Set(apiCall, OnLobbyMatchListReceived);
|
LobbyMatchListCallResult.Set(apiCall, new CallResult<LobbyMatchList_t>.APIDispatchDelegate(OnRequestLobbyList));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 处理大厅列表查询结果
|
/// 处理大厅列表查询结果
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static void OnLobbyMatchListReceived(LobbyMatchList_t result, bool ioFailure)
|
private static void OnRequestLobbyList(LobbyMatchList_t result, bool ioFailure)
|
||||||
{
|
{
|
||||||
|
Debug.Log("大厅列表请求完成: " + result.m_nLobbiesMatching + " 个大厅");
|
||||||
lobbyDataList = [];
|
lobbyDataList = [];
|
||||||
uint lobbyCount = result.m_nLobbiesMatching;
|
uint lobbyCount = result.m_nLobbiesMatching;
|
||||||
|
|
||||||
@@ -235,6 +302,11 @@ public class PlayerManager : BaseUnityPlugin
|
|||||||
{
|
{
|
||||||
lobbyDataList.Add(lobbyId);
|
lobbyDataList.Add(lobbyId);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.Log("过滤掉不兼容版本的大厅: " + lobbyId);
|
||||||
|
Debug.Log("大厅 " + lobbyId + " 版本: " + SteamMatchmaking.GetLobbyData(lobbyId, StickFightConstants.VERSION_KEY));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -297,12 +369,3 @@ public class PlayerManager : BaseUnityPlugin
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Stick Fight游戏常量
|
|
||||||
/// </summary>
|
|
||||||
internal static class StickFightConstants
|
|
||||||
{
|
|
||||||
public const string VERSION_KEY = "version";
|
|
||||||
public const string VERSION_VALUE = "1.0.0";
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -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>3.1.0</Version>
|
<Version>3.1.1</Version>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
<LangVersion>latest</LangVersion>
|
<LangVersion>latest</LangVersion>
|
||||||
<RestoreAdditionalProjectSources>
|
<RestoreAdditionalProjectSources>
|
||||||
|
|||||||
Reference in New Issue
Block a user