se-dev-server-code

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

SE Dev Server Code Skill

SE Dev Server Code Skill

Allows reading the decompiled C# code of the Space Engineers Dedicated Server. The "game logic" of the server is largely the same as the game (client) is running. The entry point (main executable), some aspects of logging and configuration differ. Also, some of the libraries are not used by the server, but they may still present to provide the necessary data structures and some backend functionality.
⚠️ CRITICAL: Commands run in a UNIX shell. Use bash syntax. On Windows this is BusyBox; on Linux use the native shell.
Examples:
  • test -f file.txt && echo exists
  • ls -la | head -10
  • if exist file.txt (echo exists)
    - This will NOT work
Actions:
  • prepare: Run the one-time preparation (
    Prepare.bat
    on Windows,
    prepare.sh
    on Linux)
  • bash: Run UNIX shell commands via busybox
  • search: Run code searches using
    search_server_code.py
  • test: Test this skill by running
    test_search_server_code.bat
允许读取《太空工程师》专用服务器的反编译C#代码。服务器的「游戏逻辑」与客户端运行的游戏基本一致,但入口点(主可执行文件)、日志记录和配置的某些方面存在差异。此外,部分库并未被服务器使用,但它们仍可能存在以提供必要的数据结构和某些后端功能。
⚠️ 重要提示:命令在UNIX shell中运行,请使用bash语法。Windows系统下使用BusyBox;Linux系统下使用原生shell。
示例:
  • test -f file.txt && echo exists
  • ls -la | head -10
  • if exist file.txt (echo exists)
    - 此命令无法运行
操作:
  • prepare: 执行一次性准备操作(Windows系统用
    Prepare.bat
    ,Linux系统用
    prepare.sh
  • bash: 通过busybox运行UNIX shell命令
  • search: 使用
    search_server_code.py
    执行代码搜索
  • test: 运行
    test_search_server_code.bat
    测试此工具

Routing Decision

路由规则

Check these patterns in order - first match wins:
PriorityPatternExampleRoute
1Empty or bare invocation
se-dev-server-code
Show this help
2Prepare keywords
se-dev-server-code prepare
,
se-dev-server-code setup
,
se-dev-server-code init
prepare
3Bash/shell keywords
se-dev-server-code bash
,
se-dev-server-code grep
,
se-dev-server-code cat
bash
4Search keywords
se-dev-server-code search
,
se-dev-server-code find class
,
se-dev-server-code lookup
search
5Test keywords
se-dev-server-code test
,
se-dev-server-code verify
,
se-dev-server-code check
test
按顺序检查以下匹配模式,第一个匹配项生效:
优先级匹配模式示例路由
1空调用或直接调用
se-dev-server-code
显示本帮助文档
2准备类关键词
se-dev-server-code prepare
,
se-dev-server-code setup
,
se-dev-server-code init
prepare
3Bash/Shell类关键词
se-dev-server-code bash
,
se-dev-server-code grep
,
se-dev-server-code cat
bash
4搜索类关键词
se-dev-server-code search
,
se-dev-server-code find class
,
se-dev-server-code lookup
search
5测试类关键词
se-dev-server-code test
,
se-dev-server-code verify
,
se-dev-server-code check
test

Requirements

环境要求

The host system must have the following on
PATH
:
  • Python 3.11 or newer
  • git command line client (used to version each decompiled server build)
  • dotnet SDK (for installing
    ilspycmd
    )
主机系统的
PATH
中必须包含以下组件:
  • Python 3.11或更高版本
  • git命令行客户端(用于为每个反编译的服务器版本做版本控制)
  • dotnet SDK(用于安装
    ilspycmd

Getting Started

快速开始

⚠️ CRITICAL: Before running ANY commands, read CommandExecution.md to avoid common mistakes that cause command failures.
If the
Prepare.DONE
file is missing in this folder, you MUST run the one-time preparation steps first. See the prepare action.
If server auto-detection fails, set
SE_SERVER_ROOT
before running the preparation script. It may point to either the dedicated server root or directly to the
DedicatedServer64
directory.
⚠️ 重要提示:在执行任何命令之前,请阅读CommandExecution.md以避免导致命令失败的常见错误。
如果此文件夹中缺少
Prepare.DONE
文件,必须先执行一次性准备步骤。请查看prepare操作
如果服务器自动检测失败,请在运行准备脚本前设置
SE_SERVER_ROOT
环境变量。它可以指向专用服务器的根目录,也可以直接指向
DedicatedServer64
目录。

Folder Layout

文件夹结构

After preparation the skill folder contains a
Data
junction/symlink. The actual data lives outside the skill folder so that it is preserved across
Clean.bat
/
Prepare.bat
/
prepare.sh
cycles.
skills/se-dev-server-code/
├── Data/                 (junction/symlink → per-user persistent server-code data)
│   ├── .git/             local Git repository tracking decompiled sources
│   ├── .gitignore        ignores CodeIndex/, Content/, __pycache__, *.py[cod], *.bak, *.log
│   ├── game_version.txt  recorded SE_VERSION / CLIENT_BUILD_NUMBER / SERVER_BUILD_NUMBER
│   ├── Decompiled/       decompiled C# sources, organised per assembly (committed)
│   ├── Content/          textual server content (NOT committed - regenerated)
│   └── CodeIndex/        CSV indexes (NOT committed - regenerated)
├── Bin64/                (junction/symlink → server's DedicatedServer64, removed after preparation)
└── ...                   skill scripts and documentation
The
Data
folder is a junction/symlink to the per-user persistent server-code data directory (
%USERPROFILE%\.se-dev\server-code
on Windows,
~/.se-dev/server-code
on Linux). Treat
Data/Decompiled
,
Data/Content
and
Data/CodeIndex
exactly as before.
准备完成后,工具文件夹中会包含一个
Data
链接/符号链接。实际数据存储在工具文件夹之外,以便在
Clean.bat
/
Prepare.bat
/
prepare.sh
循环中保留数据。
skills/se-dev-server-code/
├── Data/                 (链接/符号链接 → 每个用户的持久化服务器代码数据)
│   ├── .git/             本地Git仓库,用于跟踪反编译的源代码
│   ├── .gitignore        忽略CodeIndex/、Content/、__pycache__、*.py[cod]、*.bak、*.log
│   ├── game_version.txt  记录SE_VERSION / CLIENT_BUILD_NUMBER / SERVER_BUILD_NUMBER
│   ├── Decompiled/       反编译的C#源代码,按程序集组织(已提交到Git)
│   ├── Content/          服务器文本内容(未提交到Git - 可重新生成)
│   └── CodeIndex/        CSV索引文件(未提交到Git - 可重新生成)
├── Bin64/                (链接/符号链接 → 服务器的DedicatedServer64目录,准备完成后会被移除)
└── ...                   工具脚本和文档
Data
文件夹是指向每个用户持久化服务器代码数据目录的链接/符号链接(Windows系统为
%USERPROFILE%\.se-dev\server-code
,Linux系统为
~/.se-dev/server-code
)。
Data/Decompiled
Data/Content
Data/CodeIndex
的使用方式与之前完全相同。

Local Versioning of Decompiled Sources

反编译源代码的本地版本控制

The
Data
folder is a local Git repository. Every successful preparation creates a commit of the decompiled C# sources whose message is the server's version label, e.g.
1.208.015 b4
.
This means:
  • All previously decompiled server versions are preserved in the local Git history. You can
    git checkout
    any past commit inside
    Data/
    to inspect or diff against an older build.
  • Server updates are detected automatically by comparing the binaries' embedded version constants with
    Data/game_version.txt
    . If they differ (or the file is missing),
    Decompiled/
    ,
    Content/
    and
    CodeIndex/
    are wiped and a fresh decompilation runs.
  • This makes it easy to update plugins, mods and scripts for compatibility with new server releases: diff the relevant source between two commits inside
    Data/
    to see exactly what changed.
The repository uses an internal author/email (
se-dev-skills@localhost
) so commits work even on machines without a configured global Git identity.
Data
文件夹是一个本地Git仓库。每次成功完成准备操作后,都会创建一个反编译C#源代码的提交,提交信息为服务器的版本标签,例如
1.208.015 b4
这意味着:
  • 所有之前反编译的服务器版本都保存在本地Git历史中。你可以在
    Data/
    目录中执行
    git checkout
    命令切换到任何过往提交,以查看或对比旧版本的代码。
  • 服务器更新会被自动检测:通过比较二进制文件中嵌入的版本常量与
    Data/game_version.txt
    中的内容。如果两者不同(或文件缺失),则会清空
    Decompiled/
    Content/
    CodeIndex/
    并重新执行反编译。
  • 这使得更新插件、模组和脚本以适配新服务器版本变得容易:对比
    Data/
    目录中两个提交之间的相关源代码,即可准确查看变更内容。
该仓库使用内部作者/邮箱(
se-dev-skills@localhost
),因此即使机器未配置全局Git身份,提交操作仍可正常进行。

Essential Documentation

核心文档

  • CommandExecution.md - ⚠️ READ THIS FIRST - Windows command execution details; on Linux keep bash syntax and use
    prepare.sh
  • CommandExecution.md - ⚠️ 请先阅读此文档 - Windows系统下的命令执行细节;Linux系统下请使用bash语法并运行
    prepare.sh

Code Search Documentation

代码搜索文档

  • QuickStart.md - More examples and quick reference
  • CodeSearch.md - Complete guide to searching classes, methods, fields, etc.
  • HierarchySearch.md - Finding class/interface inheritance and implementations
  • Advanced.md - Power user techniques for complex searches
  • Troubleshooting.md - What to do when searches return NO-MATCHES or too many results
  • Implementation.md - Technical details for skill contributors (optional)
  • QuickStart.md - 更多示例和快速参考指南
  • CodeSearch.md - 搜索类、方法、字段等的完整指南
  • HierarchySearch.md - 查找类/接口的继承关系和实现
  • Advanced.md - 高级用户的复杂搜索技巧
  • Troubleshooting.md - 当搜索无结果或结果过多时的解决方法
  • Implementation.md - 工具贡献者的技术细节(可选阅读)

Quick Search Examples

快速搜索示例

bash
undefined
bash
undefined

Find class declarations

查找类声明

uv run search_server_code.py class declaration MyCubeBlock
uv run search_server_code.py class declaration MyCubeBlock

Find method signatures

查找方法签名

uv run search_server_code.py method signature UpdateBeforeSimulation
uv run search_server_code.py method signature UpdateBeforeSimulation

Find class hierarchy

查找类继承层级

uv run search_server_code.py class children MyTerminalBlock
uv run search_server_code.py class children MyTerminalBlock

Count results before viewing (useful for large result sets)

在查看结果前先统计数量(适用于大型结果集)

uv run search_server_code.py class usage MyEntity --count
uv run search_server_code.py class usage MyEntity --count

Limit number of results

限制结果数量

uv run search_server_code.py class usage MyEntity --limit 10
uv run search_server_code.py class usage MyEntity --limit 10

Paginate through results

分页查看结果

uv run search_server_code.py class usage MyEntity --limit 10 --offset 0 uv run search_server_code.py class usage MyEntity --limit 10 --offset 20

Always check the server code when:
- You're unsure about the server's internal APIs and how to interface with them.
- The inner workings of the Space Engineers Dedicated Server is unclear.
uv run search_server_code.py class usage MyEntity --limit 10 --offset 0 uv run search_server_code.py class usage MyEntity --limit 10 --offset 20

在以下情况下,请务必查看服务器代码:
- 你不确定服务器的内部API以及如何与它们交互。
- 《太空工程师》专用服务器的内部运行机制不明确。

Custom Scripting

自定义脚本

For building your own utility scripts to work with the indexes and decompiled code:
  • ScriptingGuide.md - How to write Python scripts, use BusyBox, handle Windows paths
如需构建自己的实用脚本以处理索引和反编译代码:
  • ScriptingGuide.md - 如何编写Python脚本、使用BusyBox、处理Windows路径

Server Content Data

服务器内容数据

The textual part of the server's
Content
is copied into the
Data/Content
folder for free text search:
  • Language translations, including the string IDs
  • Block and other entity definitions
  • Default blueprints and scenarios
  • See ContentTypes.md for the full list of content types
服务器
Content
目录中的文本内容会被复制到
Data/Content
文件夹中,以便进行全文搜索:
  • 语言翻译,包括字符串ID
  • 方块和其他实体定义
  • 默认蓝图和场景
  • 完整的内容类型列表请查看ContentTypes.md

Content Index

内容索引

Data/CodeIndex/content_index.csv
maps every textual content file to the decompiled C# source files that reference it. Columns:
rel_path
(path relative to
Data/Content/
) and
usage
(path of a C# source file in
Data/Decompiled/
that references it). Each content file appears once per usage, so you can filter and page by
rel_path
to see all C# code that loads or references a given content file. Files with no known usages have a single row with an empty
usage
column.
Data/CodeIndex/content_index.csv
将每个文本内容文件映射到引用它的反编译C#源代码文件。列包括:
rel_path
(相对于
Data/Content/
的路径)和
usage
Data/Decompiled/
中引用该内容文件的C#源代码文件路径)。每个内容文件每被引用一次就会出现一行,因此你可以通过
rel_path
进行过滤和分页,查看所有加载或引用该内容文件的C#代码。没有已知引用的文件会有一行
usage
列为空的记录。

Running the Dedicated Server

运行专用服务器

The server executable is
SpaceEngineersDedicated.exe
in the
DedicatedServer64
folder.
服务器可执行文件是
DedicatedServer64
文件夹中的
SpaceEngineersDedicated.exe

Headless Mode (No UI)

无头模式(无UI)

SpaceEngineersDedicated.exe -console
This bypasses the Telerik WinForms configuration UI and runs the server directly.
SpaceEngineersDedicated.exe -console
此命令会绕过Telerik WinForms配置UI,直接运行服务器。

Configuration

配置

The server is configured via XML files. The primary configuration file is
SpaceEngineers-Dedicated.cfg
located in the server's AppData directory (typically
%APPDATA%\SpaceEngineersDedicated\
).
Key configuration areas:
  • Server settings (name, world, mods, max players)
  • World settings (game mode, inventory size, welding speed)
  • Network settings (port, public/private)
Configuration should be done by editing the XML files directly or with utility Python scripts. See below for planned utilities.
服务器通过XML文件进行配置。主配置文件是
SpaceEngineers-Dedicated.cfg
,位于服务器的AppData目录中(通常为
%APPDATA%\SpaceEngineersDedicated\
)。
关键配置领域:
  • 服务器设置(名称、世界、模组、最大玩家数)
  • 世界设置(游戏模式、背包大小、焊接速度)
  • 网络设置(端口、公开/私有)
配置应通过直接编辑XML文件或使用Python实用脚本完成。以下是计划中的实用工具:

Planned Utility Scripts (Not Yet Implemented)

计划中的实用脚本(尚未实现)

  • config_editor.py — Read and modify
    SpaceEngineers-Dedicated.cfg
    values from the command line (e.g. set server name, max players, world name)
  • world_manager.py — List, backup, and manage saved worlds in the server data directory
  • mod_manager.py — List and validate mods referenced in the configuration
  • config_editor.py — 从命令行读取和修改
    SpaceEngineers-Dedicated.cfg
    中的值(例如设置服务器名称、最大玩家数、世界名称)
  • world_manager.py — 列出、备份和管理服务器数据目录中的已保存世界
  • mod_manager.py — 列出并验证配置中引用的模组

Server-Only Assemblies

服务器专属程序集

AssemblyDescription
SpaceEngineersDedicated
Server entry point (replaces
SpaceEngineers.exe
)
VRage.Dedicated
Dedicated server framework, lifecycle, and configuration
VRage.RemoteClient.Core
Remote client support (RCON-like functionality)
程序集描述
SpaceEngineersDedicated
服务器入口点(替代
SpaceEngineers.exe
VRage.Dedicated
专用服务器框架、生命周期和配置
VRage.RemoteClient.Core
远程客户端支持(类似RCON的功能)

General Rules

通用规则

  • In the
    Data/Decompiled
    folder search only inside the C# source files (.cs) in general. If you work on transpiler or preloader patches, then also search in the IL code (.il) files.
  • In the
    Data/Content
    folder search the files appropriate for the task. See ContentTypes.md for the list of types.
  • Do not search for decompiled server code outside the
    Data/Decompiled
    folder. The decompiled server source tree must be there if the preparation succeeded.
  • Do not search for server content data outside the
    Data/Content
    folder. The copied server content must be there if the preparation succeeded.
  • 通常仅在
    Data/Decompiled
    文件夹中搜索C#源代码文件(.cs)。如果你从事转译器或预加载器补丁开发,也可以搜索IL代码文件(.il)。
  • Data/Content
    文件夹中搜索与任务相关的文件。完整的内容类型列表请查看ContentTypes.md
  • 不要在
    Data/Decompiled
    文件夹之外搜索反编译的服务器代码。如果准备操作成功,反编译的服务器源代码树必须位于该文件夹中。
  • 不要在
    Data/Content
    文件夹之外搜索服务器内容数据。如果准备操作成功,复制的服务器内容必须位于该文件夹中。

Action References

操作参考

Follow the detailed instructions in:
  • prepare action - One-time preparation
  • bash action - Running UNIX shell commands via busybox
  • search action - Running code searches
  • test action - Testing this skill
请遵循以下文档中的详细说明:
  • prepare操作 - 一次性准备
  • bash操作 - 通过busybox运行UNIX shell命令
  • search操作 - 执行代码搜索
  • test操作 - 测试此工具

Remarks

备注