Skip to content

Commit 85ed301

Browse files
author
REME
committed
2026-04-02 sync
1 parent d83a3e4 commit 85ed301

4 files changed

Lines changed: 166 additions & 4 deletions

File tree

_config.kira.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ docsTree:
8989
path: /docs/05-variable-and-description/,
9090
},
9191
{ title: 06 先古对话, path: /docs/08-ancient-dialogue/ },
92+
{
93+
title: 07 快速调试&热重载,
94+
path: /docs/07-quick-debug-and-hot-reload/,
95+
},
9296
],
9397
},
9498
{

source/_posts/01-env-setup.md

Lines changed: 56 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,14 @@ https://github.com/freude916/sts2-quickRestart/blob/main/README.md
3333

3434
## 选择文本编辑器
3535

36-
选择一个文本编辑器。可以使用[Visual Studio Code](https://code.visualstudio.com/)或者[Rider](https://www.jetbrains.com/zh-cn/rider/download/?section=windows)推荐新手使用Rider)。另外也可以使用 Visual Studio等其他 IDE。以下只介绍 VS Code 的配置方法。
36+
选择一个文本编辑器。可以使用[Visual Studio Code](https://code.visualstudio.com/)或者[Rider](https://www.jetbrains.com/zh-cn/rider/download/?section=windows)<b>强烈推荐</b>新手使用Rider)。另外也可以使用Visual Studio等其他 IDE。以下只介绍 VS Code 的配置方法。
3737

38-
## 安装VS Code插件
38+
## 安装VS Code插件(可选)
3939

4040
安装[C# Dev Kit](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csdevkit)。你还可以安装[Godot Tools](https://marketplace.visualstudio.com/items?itemName=geequlim.godot-tools)等插件。
4141

42+
记得打开设置把自动保存开了。
43+
4244
![alt text](../../images/image2.png)
4345

4446
## 参考官方文档
@@ -84,6 +86,7 @@ https://github.com/freude916/sts2-quickRestart/blob/main/README.md
8486
```xml
8587
<Project Sdk="Godot.NET.Sdk/4.5.1">
8688
<PropertyGroup>
89+
<!-- 如果你安装了10.0并遇到问题,改下这里 -->
8790
<TargetFramework>net9.0</TargetFramework>
8891
<ImplicitUsings>true</ImplicitUsings>
8992
<LangVersion>12.0</LangVersion>
@@ -181,4 +184,54 @@ public class Entry
181184

182185
## 不启动Godot打包(可选)
183186

184-
Godot支持命令行导出pck(首先你需要添加一个导出配置),例如使用终端命令:`"{你的godot.exe的路径}" --headless --export-pack "{你的导出配置的名字,例如Windows Desktop}" "{杀戮尖塔根目录}/mods/{你的modid}/{你的modid}.pck"`,参考 https://docs.godotengine.org/zh-cn/4.x/tutorials/editor/command_line_tutorial.html#exporting 。你可以把这个命令保存成一个cmd或者csproj里的target,自行搜索相关配置说明。
187+
Godot支持命令行导出pck(首先你需要添加一个导出配置),例如使用终端命令:`"{你的godot.exe的路径}" --headless --export-pack "{你的导出配置的名字,例如Windows Desktop}" "{杀戮尖塔根目录}/mods/{你的modid}/{你的modid}.pck"`,参考 https://docs.godotengine.org/zh-cn/4.x/tutorials/editor/command_line_tutorial.html#exporting 。你可以把这个命令保存成一个cmd或者csproj里的target。
188+
189+
例如在你的`.csproj`文件里添加`GodoExe``ExportPck`的内容:
190+
191+
```xml
192+
<Project Sdk="Godot.NET.Sdk/4.5.1">
193+
<PropertyGroup>
194+
<TargetFramework>net9.0</TargetFramework>
195+
<ImplicitUsings>true</ImplicitUsings>
196+
<LangVersion>12.0</LangVersion>
197+
<Nullable>enable</Nullable>
198+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
199+
200+
<Sts2Dir>D:/Files/Softwares/Steam/steamapps/common/Slay the Spire 2</Sts2Dir>
201+
<!-- 新增 -->
202+
<GodotExe>D:/Files/Projects/godot/Godot_v4.5.1-stable_mono_win64/Godot_v4.5.1-stable_mono_win64/Godot_v4.5.1-stable_mono_win64.exe</GodotExe>
203+
<Sts2DataDir>$(Sts2Dir)/data_sts2_windows_x86_64</Sts2DataDir>
204+
</PropertyGroup>
205+
206+
<ItemGroup>
207+
<Reference Include="sts2">
208+
<HintPath>$(Sts2DataDir)/sts2.dll</HintPath>
209+
<Private>false</Private>
210+
</Reference>
211+
212+
<Reference Include="0Harmony">
213+
<HintPath>$(Sts2DataDir)/0Harmony.dll</HintPath>
214+
<Private>false</Private>
215+
</Reference>
216+
</ItemGroup>
217+
218+
<Target Name="Copy Mod" AfterTargets="PostBuildEvent">
219+
<Message Text="Copying mod to Slay the Spire 2 mods folder..." Importance="high" />
220+
<MakeDir Directories="$(Sts2Dir)/mods/" />
221+
<Copy SourceFiles="$(TargetPath)" DestinationFolder="$(Sts2Dir)/mods/$(MSBuildProjectName)/" />
222+
<Copy SourceFiles="$(MSBuildProjectName).json" DestinationFolder="$(Sts2Dir)/mods/$(MSBuildProjectName)/" />
223+
</Target>
224+
225+
<!-- 新增 -->
226+
<Target Name="ExportPck">
227+
<Message Text="Copying PCK to Slay the Spire 2 mods folder..." Importance="high" />
228+
<Exec Command="&quot;$(GodotExe)&quot; --headless --export-pack &quot;Windows Desktop&quot; &quot;$(Sts2Dir)/mods/$(MSBuildProjectName)/$(MSBuildProjectName).pck&quot;"
229+
EnvironmentVariables="IsInnerGodotExport=true;MSBUILDDISABLENODEREUSE=1"
230+
ContinueOnError="WarnAndContinue" />
231+
</Target>
232+
</Project>
233+
```
234+
235+
然后控制台输入`dotnet build -t:ExportPck`即可连PCK一起导出。输入`dotnet build`仅编译dll。
236+
237+
方法不限。你也可以使用`tasks.json`

source/_posts/03-baselib.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ categories:
1111
https://github.com/Alchyr/BaseLib-StS2
1212

1313
> 由于目前`BaseLib`尚处于开发阶段,如果只打patch不添加新内容可以不使用。
14-
> 以下内容使用baselib0.2.1,游戏测试分支。
14+
> 以下内容使用baselib0.2.3,游戏测试分支。
1515
1616
先依赖baselib才能查看这里里面的文章。
1717

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
---
2+
title: 07 快速调试&热重载
3+
date: 2026-04-02 00:00:00
4+
permalink: docs/07-quick-debug-and-hot-reload/
5+
categories:
6+
- Basics
7+
---
8+
9+
## VSCode
10+
11+
`csproj`文件里添加这段:(放在`Project`里面即可)
12+
13+
```xml
14+
<!-- 其余内容省略 -->
15+
<Sts2DataDir>$(Sts2Dir)/data_sts2_windows_x86_64</Sts2DataDir>
16+
</PropertyGroup>
17+
18+
<!-- 新增 -->
19+
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
20+
<Optimize>false</Optimize>
21+
<DebugType>portable</DebugType>
22+
</PropertyGroup>
23+
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
24+
<Optimize>true</Optimize>
25+
<DebugType>none</DebugType>
26+
<PathMap>$(AppOutputBase)=.\</PathMap>
27+
</PropertyGroup>
28+
29+
<ItemGroup>
30+
<Reference Include="sts2">
31+
<HintPath>$(Sts2DataDir)/sts2.dll</HintPath>
32+
<Private>false</Private>
33+
</Reference>
34+
<!-- 其余内容省略 -->
35+
```
36+
37+
在项目根目录创建一个`.vscode`文件夹。
38+
39+
* 在其中放一个`launch.json`文件:
40+
41+
```json
42+
{
43+
"version": "0.2.0",
44+
"configurations": [
45+
{
46+
"name": "Run Debug",
47+
"type": "coreclr",
48+
"request": "launch",
49+
"preLaunchTask": "build",
50+
"program": "${config:sts2.installDir}/${config:sts2.gameExeName}",
51+
"cwd": "${config:sts2.installDir}",
52+
"console": "internalConsole",
53+
"stopAtEntry": false
54+
}
55+
]
56+
}
57+
```
58+
59+
* 然后放一个`tasks.json`文件:
60+
61+
```json
62+
{
63+
"version": "2.0.0",
64+
"tasks": [
65+
{
66+
"label": "build",
67+
"type": "process",
68+
"command": "dotnet",
69+
"args": [
70+
"build",
71+
"${workspaceFolder}/${config:sts2.modId}.csproj",
72+
"-c",
73+
"Debug",
74+
"--nologo"
75+
],
76+
"group": "build",
77+
"problemMatcher": "$msCompile"
78+
}
79+
]
80+
}
81+
```
82+
83+
* 然后放一个`settings.json`文件:(路径、名字改成你自己的)
84+
85+
```json
86+
{
87+
"sts2.installDir": "D:/Steam/steamapps/common/Slay the Spire 2",
88+
"sts2.gameExeName": "SlayTheSpire2.exe",
89+
"sts2.modId": "test"
90+
}
91+
```
92+
93+
* 接着打开vscode的设置(`ctrl+,`),查找`Csharp › Experimental › Debug: Hot Reload``[实验性] 在调试时启用 C# 热重载。`)并启用。
94+
95+
* 然后按F5启动就可以。
96+
97+
* 当你修改代码后,点击测试表盘中的火焰图标(🔥)应用热重载。<b>热重载功能有限,不能有增删函数等过大改动。</b>
98+
99+
* 资源PCK不能通过这个方式热重载。
100+
101+
* 如果你进不了游戏提示不通过steam,记得在根目录创建一个`steam_appid.txt`,里面写`2868840`
102+
103+
## Rider
104+
105+
TODO:我没有Rider

0 commit comments

Comments
 (0)