Compare commits

..

6 Commits

Author SHA1 Message Date
11f6144c2b 忘删了
Some checks failed
Publish Release / build (push) Failing after 35s
2026-06-21 02:46:41 +08:00
dd8db77135 grammar police(x 2026-06-21 02:38:12 +08:00
f2631109fd 合并 2026-06-21 02:33:53 +08:00
f5464a3673 匹配原仓库结构 2026-06-21 02:22:54 +08:00
ed9505af0f gitea 2026-06-21 02:15:51 +08:00
13a2886a76 添加项目文件。 2026-06-21 01:51:06 +08:00
27 changed files with 300 additions and 184 deletions

63
.gitattributes vendored Normal file
View File

@@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain

1
.gitignore vendored
View File

@@ -33,6 +33,7 @@ x86/
bld/ bld/
[Bb]in/ [Bb]in/
[Oo]bj/ [Oo]bj/
[Oo]ut/
[Ll]og/ [Ll]og/
[Ll]ogs/ [Ll]ogs/

25
FixLocalForce.sln Normal file
View File

@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.14.36915.13 d17.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FixLocalForce", "FixLocalForce\FixLocalForce.csproj", "{098EA556-4E9C-C66B-5038-1C6A942CB02D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{098EA556-4E9C-C66B-5038-1C6A942CB02D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{098EA556-4E9C-C66B-5038-1C6A942CB02D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{098EA556-4E9C-C66B-5038-1C6A942CB02D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{098EA556-4E9C-C66B-5038-1C6A942CB02D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {65403CFC-3D5E-420E-A241-5915A8C036DB}
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,59 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net35</TargetFramework>
<LangVersion>latest</LangVersion>
<AssemblyName>FixLocalForce</AssemblyName>
<RootNamespace>FixLocalForce</RootNamespace>
<Authors>z7572</Authors>
<Version>0.0.1</Version>
<Product></Product>
<Description>A BepInEx mod for Stick Fight: The Game</Description>
<AssemblyVersion></AssemblyVersion>
<FileVersion></FileVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BepInEx.Analyzers" Version="1.*" PrivateAssets="all" />
<PackageReference Include="BepInEx.Core" Version="5.*" />
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" />
<PackageReference Include="UnityEngine.Modules" Version="5.6.3" IncludeAssets="compile" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'">
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" PrivateAssets="all" />
</ItemGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp">
<HintPath>..\..\..\..\StickFight_Data\Managed\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp-firstpass">
<HintPath>..\..\..\..\StickFight_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath>
</Reference>
<Reference Include="Lidgren.Network">
<HintPath>..\..\..\..\StickFight_Data\Managed\Lidgren.Network.dll</HintPath>
</Reference>
<Reference Include="Mono.Security">
<HintPath>..\..\..\..\StickFight_Data\Managed\Mono.Security.dll</HintPath>
</Reference>
<Reference Include="TextMeshPro-1.0.55.56.0b9">
<HintPath>..\..\..\..\StickFight_Data\Managed\TextMeshPro-1.0.55.56.0b9.dll</HintPath>
</Reference>
<Reference Include="UnityEngine">
<HintPath>..\..\..\..\StickFight_Data\Managed\UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.Analytics">
<HintPath>..\..\..\..\StickFight_Data\Managed\UnityEngine.Analytics.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.Networking">
<HintPath>..\..\..\..\StickFight_Data\Managed\UnityEngine.Networking.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UI">
<HintPath>..\..\..\..\StickFight_Data\Managed\UnityEngine.UI.dll</HintPath>
</Reference>
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="copy /Y $(TargetPath) $(ProjectDir)\..\..\..\..\BepInEx\plugins\$(TargetFileName)" />
</Target>
</Project>

50
FixLocalForce/Logger.cs Normal file
View File

@@ -0,0 +1,50 @@
global using static FixLocalForce.Logger;
using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
namespace FixLocalForce;
public static class Logger
{
public static void LogInfo(params object[] obj)
{
Plugin.Logger.LogInfo(string.Join(" ", obj.Select(o => o?.ToString() ?? "null").ToArray()));
}
public static void LogMessage(params object[] obj)
{
Plugin.Logger.LogMessage(string.Join(" ", obj.Select(o => o?.ToString() ?? "null").ToArray()));
}
public static void LogWarning(params object[] obj)
{
Plugin.Logger.LogWarning(string.Join(" ", obj.Select(o => o?.ToString() ?? "null").ToArray()));
}
public static void LogError(params object[] obj)
{
Plugin.Logger.LogError(string.Join(" ", obj.Select(o => o?.ToString() ?? "null").ToArray()));
}
public static void LogDebug(params object[] obj)
{
Plugin.Logger.LogDebug(GetPrefix() + string.Join(" ", obj.Select(o => o?.ToString() ?? "null").ToArray()));
}
private static string GetPrefix()
{
var callerMethod = new StackFrame(2).GetMethod();
var callerType = callerMethod?.DeclaringType;
if (callerType is not null)
{
// string ns = callerType.Namespace??"";
// int i = ns.LastIndexOf('.');
// string substr = ns.Substring(i >= 0 ? i : 0);
return $"[{callerType.Name}.{callerMethod.Name}] ";
}
return "[Unknown method] ";
}
}

32
FixLocalForce/PLugin.cs Normal file
View File

@@ -0,0 +1,32 @@
using System;
using System.Reflection;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
namespace FixLocalForce;
[BepInPlugin(PLUGIN_GUID, PLUGIN_NAME, PLUGIN_VERSION)]
public class Plugin : BaseUnityPlugin
{
public const string PLUGIN_GUID = "stick.plugins.fixlocalforce";
public const string PLUGIN_NAME = "FixLocalForce";
public const string PLUGIN_VERSION = "0.0.1";
internal new static ManualLogSource Logger;
private void Awake()
{
Logger = base.Logger;
LogMessage("FixLocalForce is loaded!");
try
{
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly());
}
catch (Exception e)
{
LogError(e);
}
}
}

View File

@@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Reflection.Emit;
using HarmonyLib;
using UnityEngine;
namespace FixLocalForce.Patches;
internal static class Patches
{
[HarmonyPatch(typeof(ProjectileCollision))]
private static class ProjectileCollisionPatch
{
[HarmonyPatch("AddForce")]
[HarmonyTranspiler]
public static IEnumerable<CodeInstruction> AddForceTranspiler(IEnumerable<CodeInstruction> instructions)
{
return new CodeMatcher(instructions)
.MatchForward(false,
new CodeMatch(OpCodes.Call, AccessTools.Method(typeof(Vector3), "op_Multiply", [typeof(Vector3), typeof(float)])),
new CodeMatch(OpCodes.Ldc_I4_1),
new CodeMatch(OpCodes.Callvirt, AccessTools.Method(typeof(Rigidbody), "AddForce", [typeof(Vector3), typeof(ForceMode)]))
)
.Repeat(matcher =>
{
// 此时栈顶是计算完毕的 (a * d * damageScale) 或 (a2 * damageScale)
// 光标在 Call op_Multiply 上,我们往下移一步,来到 ldc.i4.1 之前
matcher.Advance(1);
// 插入:加载局部变量 a并调用我们的 Helper 方法
matcher.InsertAndAdvance(
new CodeInstruction(OpCodes.Ldloc_0), // 将最原始的力 `a` (发给网络的那个包的数据) 压入栈
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(ProjectileCollisionPatch), nameof(GetAdjustedForce))) // 拦截替换
);
})
.InstructionEnumeration();
}
public static Vector3 GetAdjustedForce(Vector3 calculatedForce, Vector3 rawPacketForce)
{
// 在线模式不改变原始逻辑。
if (MatchmakingHandler.IsNetworkMatch) return calculatedForce;
// 本地模式,复刻线上的 Bug
// 直接返回未经衰减的 `a`,包括 Torso 那里错误复制粘贴的 `a`。
return rawPacketForce;
}
}
}

View File

@@ -0,0 +1,9 @@
{
"profiles": {
"FixLocalForce": {
"commandName": "Executable",
"executablePath": "C:\\Windows\\System32\\cmd.exe",
"commandLineArgs": "/c \"start steam://rungameid/674940\""
}
}
}

6
NuGet.config Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="BepInEx" value="https://nuget.bepinex.dev/v3/index.json" />
</packageSources>
</configuration>

View File

@@ -1,13 +0,0 @@
using HarmonyLib;
using UnityEngine;
[HarmonyPatch(typeof(MultiplayerManager), "OnKicked")]
class IgnoreKick
{
public static bool Prefix(ref byte[] data)
{
MultiplayerManager.KickResponse kickResponse = (MultiplayerManager.KickResponse)data[0];
Debug.LogWarning("Received Kick Message, the reason is: " + kickResponse.ToString());
return false;
}
}

105
Plugin.cs
View File

@@ -1,105 +0,0 @@
using BepInEx;
using BepInEx.Configuration;
using UnityEngine;
using Steamworks;
using HarmonyLib;
namespace stick.plugins.tmpl;
/// <summary>
/// 玩家管理器插件主类
/// 提供大厅信息显示、玩家记录、黑名单管理等功能
/// </summary>
[BepInPlugin(MyPluginInfo.PLUGIN_GUID, MyPluginInfo.PLUGIN_NAME, MyPluginInfo.PLUGIN_VERSION)]
[BepInProcess("StickFight.exe")]
public class Tmpl : BaseUnityPlugin
{
#region
/// <summary>
/// 是否屏蔽来自其他玩家的踢出请求
/// </summary>
private static ConfigEntry<bool> _blockKicks;
/// <summary>
/// 大厅信息开关快捷键
/// </summary>
private static ConfigEntry<KeyCode> _lobbyInfoToggleKeyCode;
#endregion
#region
private void Awake()
{
InitializeConfiguration();
ApplyPatches();
}
private void Update()
{
HandleInput();
}
private void OnGUI()
{
if (PlayerManagerGUI.ShowLobbyInfo)
{
PlayerManagerGUI.DrawLobbyInfoGUI();
}
}
#endregion
#region
/// <summary>
/// 初始化配置项
/// </summary>
private void InitializeConfiguration()
{
_blockKicks = Config.Bind(
"General",
"BlockKicks",
true,
"是否屏蔽来自其他玩家的踢出请求"
);
_lobbyInfoToggleKeyCode = Config.Bind(
"LobbyInfo",
"ToggleKeyCode",
KeyCode.F2,
"Lobby信息开关快捷键"
);
}
/// <summary>
/// 应用Harmony补丁
/// </summary>
private void ApplyPatches()
{
if (_blockKicks.Value)
{
Harmony.CreateAndPatchAll(typeof(IgnoreKick));
}
}
/// <summary>
/// 处理输入
/// </summary>
private void HandleInput()
{
if (Input.GetKeyDown(_lobbyInfoToggleKeyCode.Value))
{
ToggleLobbyInfoGUI();
}
}
#endregion
#region
#endregion
}

View File

@@ -1,6 +1,8 @@
# stick.plugins.tmpl # stick.plugins.fixlocalforce
简要描述 在本地游戏里复现在线的bug
~~make laser great again~~
## 功能 ## 功能
@@ -15,5 +17,4 @@
### v0.0.1 ### v0.0.1
1. 新增xxx功能 1. 可用
2. 添加工作流

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,62 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net35</TargetFramework>
<AssemblyName>stick.plugins.tmpl</AssemblyName>
<Product>Tmpl</Product>
<Version>0.0.1</Version>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion>
<Authors>sleeeeeep</Authors>
<RestoreAdditionalProjectSources>
https://api.nuget.org/v3/index.json;
https://nuget.bepinex.dev/v3/index.json;
https://nuget.samboy.dev/v3/index.json
</RestoreAdditionalProjectSources>
<RootNamespace>stick.plugins.tmpl</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BepInEx.Analyzers" Version="1.*" PrivateAssets="all" />
<PackageReference Include="BepInEx.Core" Version="5.*" />
<PackageReference Include="BepInEx.PluginInfoProps" Version="2.*" />
<PackageReference Include="Mono.Cecil" Version="0.10.4" />
<PackageReference Include="UnityEngine.Modules" Version="5.6.3.16509117" IncludeAssets="compile" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'">
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2"
PrivateAssets="all" />
</ItemGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp">
<HintPath>lib/Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp-firstpass">
<HintPath>lib/Assembly-CSharp-firstpass.dll</HintPath>
</Reference>
<Reference Include="Lidgren.Network">
<HintPath>lib/Lidgren.Network.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<None Remove="Assembly-CSharp.dll" />
<None Remove="Assembly-CSharp-firstpass.dll" />
<None Remove="Lidgren.Network.dll" />
<None Remove="TextMeshPro-1.0.55.56.0b9.dll" />
<None Remove="UnityEngine.UI.dll" />
<None Remove="Mono.Security.dll" />
<None Remove="mscorlib.dll" />
<None Remove="System.dll" />
<None Remove="System.Core.dll" />
<None Remove="System.Xml.dll" />
<None Remove="UnityEngine.dll" />
<None Remove="UnityEngine.Analytics.dll" />
<None Remove="UnityEngine.dll.mdb" />
<None Remove="UnityEngine.Networking.dll" />
</ItemGroup>
</Project>