subnautica-ii-coop-mod
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSubnautica II Co-op Mod (Deep Synergy)
Subnautica 2 合作模组(Deep Synergy)
Overview
概述
The Deep Synergy Multiplayer Mod transforms Subnautica 2 into a synchronized cooperative experience using the BepInEx modding framework. It implements deterministic session synchronization, adaptive difficulty scaling, shared inventory systems, and peer-to-peer networking without requiring central servers.
Key Capabilities:
- Deterministic state synchronization across multiple clients
- Adaptive dynamic scaling based on player count
- BepInEx IL2CPP plugin architecture for Unity runtime hooks
- Decentralized peer-to-peer networking with NAT punch-through
- Optional OpenAI/Claude API integration for narrative generation
- Cross-platform support (Windows, Linux, macOS)
Deep Synergy多人合作模组借助BepInEx模组框架,将Subnautica 2转变为同步协作的游戏体验。它实现了确定性会话同步、自适应难度缩放、共享库存系统,以及无需中央服务器的去中心化点对点网络。
核心功能:
- 多客户端间的确定性状态同步
- 基于玩家数量的自适应动态缩放
- 用于Unity运行时钩子的BepInEx IL2CPP插件架构
- 支持NAT穿透的去中心化点对点网络
- 可选的OpenAI/Claude API集成,用于叙事生成
- 跨平台支持(Windows、Linux、macOS)
Installation
安装
Prerequisites
前置条件
- Subnautica 2 installed via Steam or GOG
- BepInEx 6.0.x or later for Unity IL2CPP games
- 通过Steam或GOG安装Subnautica 2
- 适用于Unity IL2CPP游戏的BepInEx 6.0.x或更高版本
Installation Steps
安装步骤
bash
undefinedbash
undefined1. Install BepInEx 6.0.x for Subnautica 2
1. 为Subnautica 2安装BepInEx 6.0.x版本
Download from https://github.com/BepInEx/BepInEx/releases
Extract to Subnautica 2 game directory
解压到Subnautica 2游戏目录
2. Download Deep Synergy Mod
2. 下载Deep Synergy模组
Extract the mod package
解压模组压缩包
3. Copy plugin files
3. 复制插件文件
cp -r BepInEx/plugins/* <Subnautica2Directory>/BepInEx/plugins/
cp -r BepInEx/plugins/* <Subnautica2Directory>/BepInEx/plugins/
4. Create configuration directory
4. 创建配置目录
mkdir -p <Subnautica2Directory>/BepInEx/config/
mkdir -p <Subnautica2Directory>/BepInEx/config/
5. Launch game to generate default configs
5. 启动游戏生成默认配置
BepInEx will create config files on first run
BepInEx会在首次运行时创建配置文件
undefinedundefinedDirectory Structure
目录结构
Subnautica2/
├── BepInEx/
│ ├── core/
│ ├── plugins/
│ │ ├── DeepSynergy.dll
│ │ ├── SessionManager.dll
│ │ └── StateSynchronizer.dll
│ └── config/
│ ├── synergy_profile.json
│ └── session_config.xml
└── Subnautica2.exeSubnautica2/
├── BepInEx/
│ ├── core/
│ ├── plugins/
│ │ ├── DeepSynergy.dll
│ │ ├── SessionManager.dll
│ │ └── StateSynchronizer.dll
│ └── config/
│ ├── synergy_profile.json
│ └── session_config.xml
└── Subnautica2.exeConfiguration
配置
Profile Configuration
配置文件设置
Create :
BepInEx/config/synergy_profile.jsonjson
{
"session_name": "DeepDive Squad",
"max_players": 4,
"difficulty_scale": "adaptive",
"resource_multiplier": 1.0,
"oxygen_consumption": 1.0,
"creature_spawn_divider": 1,
"enable_pvp": false,
"friendly_fire": false,
"shared_blueprints": true,
"ping_locations_shared": true,
"time_of_day_sync": "all",
"voice_chat_integration": "discord_rpc",
"network": {
"use_nat_punchthrough": true,
"port": 7777,
"max_latency_ms": 200,
"sync_interval_ms": 50
},
"api_integration": {
"openai": {
"enabled": false,
"api_key_env": "OPENAI_API_KEY",
"role": "narrator",
"model": "gpt-4"
},
"claude": {
"enabled": false,
"api_key_env": "ANTHROPIC_API_KEY",
"role": "lore_engine",
"model": "claude-3-opus-20240229"
}
},
"locale": "en-US"
}创建:
BepInEx/config/synergy_profile.jsonjson
{
"session_name": "DeepDive Squad",
"max_players": 4,
"difficulty_scale": "adaptive",
"resource_multiplier": 1.0,
"oxygen_consumption": 1.0,
"creature_spawn_divider": 1,
"enable_pvp": false,
"friendly_fire": false,
"shared_blueprints": true,
"ping_locations_shared": true,
"time_of_day_sync": "all",
"voice_chat_integration": "discord_rpc",
"network": {
"use_nat_punchthrough": true,
"port": 7777,
"max_latency_ms": 200,
"sync_interval_ms": 50
},
"api_integration": {
"openai": {
"enabled": false,
"api_key_env": "OPENAI_API_KEY",
"role": "narrator",
"model": "gpt-4"
},
"claude": {
"enabled": false,
"api_key_env": "ANTHROPIC_API_KEY",
"role": "lore_engine",
"model": "claude-3-opus-20240229"
}
},
"locale": "en-US"
}Configuration Options
配置选项
| Field | Type | Description |
|---|---|---|
| string | Display name for your session |
| int | Maximum concurrent players (2-8) |
| string | |
| float | Resource spawn rate multiplier (0.5-2.0) |
| float | Oxygen drain rate (0.5-2.0, lower = slower drain) |
| int | Divides creature spawn counts |
| bool | Share unlocked blueprints across players |
| bool | Synchronize map pings |
| string | |
| 字段 | 类型 | 描述 |
|---|---|---|
| 字符串 | 会话的显示名称 |
| 整数 | 最大并发玩家数(2-8) |
| 字符串 | |
| 浮点数 | 资源生成倍率(0.5-2.0) |
| 浮点数 | 氧气消耗速率(0.5-2.0,数值越低消耗越慢) |
| 整数 | 生物生成数量的除数(数值越大生成数量越少) |
| 布尔值 | 玩家间共享已解锁蓝图 |
| 布尔值 | 同步地图标记位置 |
| 字符串 | |
API Integration Setup
API集成设置
bash
undefinedbash
undefinedSet API keys via environment variables
通过环境变量设置API密钥
export OPENAI_API_KEY="your-openai-key-here"
export ANTHROPIC_API_KEY="your-anthropic-key-here"
export OPENAI_API_KEY="你的OpenAI密钥"
export ANTHROPIC_API_KEY="你的Anthropic密钥"
Enable in synergy_profile.json
在synergy_profile.json中启用集成
The mod will automatically use these keys when api_integration.enabled = true
当api_integration.enabled = true时,模组会自动使用这些密钥
undefinedundefinedConsole Commands
控制台命令
Access the BepInEx console by pressing F1 in-game (default keybind).
在游戏中按F1打开BepInEx控制台(默认快捷键)。
Session Management
会话管理
bash
undefinedbash
undefinedStart a host session
启动主机会话
/start_server
/start_server
Join existing session
加入已有会话
/join_session <session-code>
/join_session <会话代码>
Example: /join_session 9B2A-4C7D-E8F1
示例:/join_session 9B2A-4C7D-E8F1
Leave current session
离开当前会话
/leave_session
/leave_session
Display session status
显示会话状态
/synergy_status
undefined/synergy_status
undefinedGameplay Controls
游戏玩法控制
bash
undefinedbash
undefinedAdjust difficulty scaling (temporary override)
调整难度缩放(临时覆盖配置)
/synergy_scale <multiplier>
/synergy_scale <倍率>
Example: /synergy_scale 1.5
示例:/synergy_scale 1.5
Override world seed
覆盖世界种子
/seed_override <seed>
/seed_override <种子值>
Example: /seed_override 8251
示例:/seed_override 8251
Force inventory sync
强制同步库存
/force_sync inventory
/force_sync inventory
Teleport to player
传送到指定玩家位置
/teleport_to <player_name>
undefined/teleport_to <玩家名称>
undefinedAPI-Powered Features
API驱动功能
bash
undefinedbash
undefinedTrigger AI narration (requires OpenAI enabled)
触发AI叙事(需启用OpenAI)
/api_narrate "<context>"
/api_narrate "<场景描述>"
Example: /api_narrate "exploring the underwater caves"
示例:/api_narrate "探索水下洞穴"
Generate creature lore (requires Claude enabled)
生成生物背景设定(需启用Claude)
/api_lore <creature_id>
/api_lore <生物ID>
Example: /api_lore reaper_leviathan
示例:/api_lore reaper_leviathan
Generate base name suggestions
生成基地名称建议
/api_name_base
undefined/api_name_base
undefinedCode Examples
代码示例
Custom Plugin Integration
自定义插件集成
If you're developing additional BepInEx plugins that interact with Deep Synergy:
csharp
using BepInEx;
using BepInEx.IL2CPP;
using DeepSynergy.API;
using UnityEngine;
namespace MyCustomPlugin
{
[BepInPlugin("com.myname.custommod", "Custom Mod", "1.0.0")]
[BepInDependency("com.deepsynergy.core", BepInDependency.DependencyFlags.HardDependency)]
public class CustomPlugin : BasePlugin
{
public override void Load()
{
// Get Deep Synergy session manager
var sessionManager = DeepSynergyAPI.GetSessionManager();
// Subscribe to session events
sessionManager.OnPlayerJoined += OnPlayerJoined;
sessionManager.OnPlayerLeft += OnPlayerLeft;
sessionManager.OnStateSync += OnStateSync;
Log.LogInfo("Custom plugin loaded with Deep Synergy integration");
}
private void OnPlayerJoined(PlayerInfo player)
{
Log.LogInfo($"Player joined: {player.Name} (ID: {player.PeerId})");
// Send custom data to all clients
DeepSynergyAPI.BroadcastCustomData("MyCustomPlugin", new {
message = $"{player.Name} joined!",
timestamp = System.DateTime.UtcNow
});
}
private void OnPlayerLeft(PlayerInfo player)
{
Log.LogInfo($"Player left: {player.Name}");
}
private void OnStateSync(SyncEvent syncEvent)
{
// Handle synchronized state updates
if (syncEvent.Type == SyncEventType.InventoryUpdate)
{
Log.LogInfo($"Inventory synced for player {syncEvent.PlayerId}");
}
}
}
}如果你正在开发与Deep Synergy交互的其他BepInEx插件:
csharp
using BepInEx;
using BepInEx.IL2CPP;
using DeepSynergy.API;
using UnityEngine;
namespace MyCustomPlugin
{
[BepInPlugin("com.myname.custommod", "Custom Mod", "1.0.0")]
[BepInDependency("com.deepsynergy.core", BepInDependency.DependencyFlags.HardDependency)]
public class CustomPlugin : BasePlugin
{
public override void Load()
{
// 获取Deep Synergy会话管理器
var sessionManager = DeepSynergyAPI.GetSessionManager();
// 订阅会话事件
sessionManager.OnPlayerJoined += OnPlayerJoined;
sessionManager.OnPlayerLeft += OnPlayerLeft;
sessionManager.OnStateSync += OnStateSync;
Log.LogInfo("自定义插件已加载并完成Deep Synergy集成");
}
private void OnPlayerJoined(PlayerInfo player)
{
Log.LogInfo($"玩家加入:{player.Name}(ID:{player.PeerId})");
// 向所有客户端发送自定义数据
DeepSynergyAPI.BroadcastCustomData("MyCustomPlugin", new {
message = $"{player.Name}加入了游戏!",
timestamp = System.DateTime.UtcNow
});
}
private void OnPlayerLeft(PlayerInfo player)
{
Log.LogInfo($"玩家离开:{player.Name}");
}
private void OnStateSync(SyncEvent syncEvent)
{
// 处理同步状态更新
if (syncEvent.Type == SyncEventType.InventoryUpdate)
{
Log.LogInfo($"玩家{syncEvent.PlayerId}的库存已同步");
}
}
}
}Programmatic Configuration
程序化配置
csharp
using DeepSynergy.Config;
using Newtonsoft.Json;
using System.IO;
public class ConfigManager
{
public static SynergyProfile LoadProfile(string path)
{
var json = File.ReadAllText(path);
return JsonConvert.DeserializeObject<SynergyProfile>(json);
}
public static void CreateDefaultProfile(string path)
{
var profile = new SynergyProfile
{
SessionName = "New Session",
MaxPlayers = 4,
DifficultyScale = "adaptive",
ResourceMultiplier = 1.0f,
OxygenConsumption = 1.0f,
CreatureSpawnDivider = 1,
EnablePvp = false,
SharedBlueprints = true,
Network = new NetworkConfig
{
UseNatPunchthrough = true,
Port = 7777,
MaxLatencyMs = 200,
SyncIntervalMs = 50
}
};
var json = JsonConvert.SerializeObject(profile, Formatting.Indented);
File.WriteAllText(path, json);
}
public static void UpdateScaling(float multiplier)
{
var api = DeepSynergyAPI.GetSessionManager();
api.SetDifficultyMultiplier(multiplier);
}
}csharp
using DeepSynergy.Config;
using Newtonsoft.Json;
using System.IO;
public class ConfigManager
{
public static SynergyProfile LoadProfile(string path)
{
var json = File.ReadAllText(path);
return JsonConvert.DeserializeObject<SynergyProfile>(json);
}
public static void CreateDefaultProfile(string path)
{
var profile = new SynergyProfile
{
SessionName = "新会话",
MaxPlayers = 4,
DifficultyScale = "adaptive",
ResourceMultiplier = 1.0f,
OxygenConsumption = 1.0f,
CreatureSpawnDivider = 1,
EnablePvp = false,
SharedBlueprints = true,
Network = new NetworkConfig
{
UseNatPunchthrough = true,
Port = 7777,
MaxLatencyMs = 200,
SyncIntervalMs = 50
}
};
var json = JsonConvert.SerializeObject(profile, Formatting.Indented);
File.WriteAllText(path, json);
}
public static void UpdateScaling(float multiplier)
{
var api = DeepSynergyAPI.GetSessionManager();
api.SetDifficultyMultiplier(multiplier);
}
}Custom API Integration
自定义API集成
csharp
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
public class NarrativeEngine
{
private readonly string _openAiKey;
private readonly HttpClient _client;
public NarrativeEngine()
{
_openAiKey = Environment.GetEnvironmentVariable("OPENAI_API_KEY");
_client = new HttpClient();
_client.DefaultRequestHeaders.Add("Authorization", $"Bearer {_openAiKey}");
}
public async Task<string> GenerateNarration(string context)
{
var request = new
{
model = "gpt-4",
messages = new[]
{
new { role = "system", content = "You are a narrative engine for Subnautica 2, providing immersive journal entries." },
new { role = "user", content = $"Generate a brief journal entry about: {context}" }
},
max_tokens = 150,
temperature = 0.8
};
var json = JsonConvert.SerializeObject(request);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await _client.PostAsync(
"https://api.openai.com/v1/chat/completions",
content
);
var responseJson = await response.Content.ReadAsStringAsync();
var result = JsonConvert.DeserializeObject<dynamic>(responseJson);
return result.choices[0].message.content.ToString();
}
}csharp
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
public class NarrativeEngine
{
private readonly string _openAiKey;
private readonly HttpClient _client;
public NarrativeEngine()
{
_openAiKey = Environment.GetEnvironmentVariable("OPENAI_API_KEY");
_client = new HttpClient();
_client.DefaultRequestHeaders.Add("Authorization", $"Bearer {_openAiKey}");
}
public async Task<string> GenerateNarration(string context)
{
var request = new
{
model = "gpt-4",
messages = new[]
{
new { role = "system", content = "你是Subnautica 2的叙事引擎,负责生成沉浸式日志内容。" },
new { role = "user", content = $"生成关于以下场景的简短日志:{context}" }
},
max_tokens = 150,
temperature = 0.8
};
var json = JsonConvert.SerializeObject(request);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await _client.PostAsync(
"https://api.openai.com/v1/chat/completions",
content
);
var responseJson = await response.Content.ReadAsStringAsync();
var result = JsonConvert.DeserializeObject<dynamic>(responseJson);
return result.choices[0].message.content.ToString();
}
}Common Patterns
常见操作流程
Hosting a Session
创建会话主机
bash
undefinedbash
undefined1. Configure your profile
1. 配置你的配置文件
Edit BepInEx/config/synergy_profile.json
编辑BepInEx/config/synergy_profile.json
2. Launch game
2. 启动游戏
3. Open BepInEx console (F1)
3. 打开BepInEx控制台(F1)
4. Start server
4. 启动服务器
/start_server
/start_server
5. Share the generated session code with friends
5. 将生成的会话代码分享给好友
Example output: "Server created: session code = 9B2A-4C7D-E8F1"
示例输出:"服务器已创建:会话代码 = 9B2A-4C7D-E8F1"
undefinedundefinedJoining a Session
加入会话
bash
undefinedbash
undefined1. Launch game
1. 启动游戏
2. Open BepInEx console (F1)
2. 打开BepInEx控制台(F1)
3. Join using session code
3. 使用会话代码加入
/join_session 9B2A-4C7D-E8F1
/join_session 9B2A-4C7D-E8F1
4. Wait for sync to complete
4. 等待同步完成
/synergy_status
/synergy_status
Look for "State sync: 100% complete"
查看输出中的"State sync: 100% complete"
undefinedundefinedMonitoring Session Health
监控会话状态
bash
undefinedbash
undefinedCheck connected players and latency
查看已连接玩家和延迟
/synergy_status
/synergy_status
Example output:
示例输出:
Connected peers: 3
已连接节点:3
State sync: 100% complete
状态同步:100%完成
Average latency: 45ms
平均延迟:45ms
Inventory hash: 0xFA342B1E
库存哈希值:0xFA342B1E
undefinedundefinedAdaptive Difficulty Adjustment
自适应难度调整
bash
undefinedbash
undefinedView current scaling
查看当前难度缩放
/synergy_status
/synergy_status
Temporarily increase difficulty
临时提高难度
/synergy_scale 1.5
/synergy_scale 1.5
Reset to profile defaults
重置为配置文件默认值
/synergy_scale 1.0
undefined/synergy_scale 1.0
undefinedTroubleshooting
故障排查
Connection Issues
连接问题
Problem: Cannot connect to host / "Connection timeout"
bash
undefined问题:无法连接到主机 / "连接超时"
bash
undefined1. Check firewall rules
1. 检查防火墙规则
Windows: Allow port 7777 (UDP) in Windows Firewall
Windows:在Windows防火墙中允许UDP端口7777
Linux: sudo ufw allow 7777/udp
Linux:sudo ufw allow 7777/udp
2. Verify NAT settings in profile
2. 验证配置文件中的NAT设置
Edit synergy_profile.json:
编辑synergy_profile.json:
"network": {
"use_nat_punchthrough": true,
"port": 7777
}
"network": {
"use_nat_punchthrough": true,
"port": 7777
}
3. Check BepInEx logs
3. 查看BepInEx日志
Location: BepInEx/LogOutput.log
日志位置:BepInEx/LogOutput.log
grep "SessionManager" BepInEx/LogOutput.log
**Problem:** "State sync failed" errors
```bashgrep "SessionManager" BepInEx/LogOutput.log
**问题:出现"状态同步失败"错误**
```bashForce inventory resync
强制重新同步库存
/force_sync inventory
/force_sync inventory
Check for mod conflicts
检查模组冲突
Disable other BepInEx plugins temporarily and test
暂时禁用其他BepInEx插件后测试
undefinedundefinedPerformance Issues
性能问题
Problem: High latency or stuttering
bash
undefined问题:高延迟或卡顿
bash
undefined1. Reduce sync frequency in profile
1. 在配置文件中降低同步频率
"network": {
"sync_interval_ms": 100 # Increase from 50ms to 100ms
}
"network": {
"sync_interval_ms": 100 # 从50ms增加到100ms
}
2. Lower creature spawn rates
2. 降低生物生成率
"creature_spawn_divider": 2 # Half as many creatures
"creature_spawn_divider": 2 # 生物生成数量减半
3. Check network stats
3. 查看网络统计
/synergy_status
/synergy_status
Look for "Average latency" > 200ms
关注"Average latency"是否超过200ms
**Problem:** Game crashes on session join
```bash
**问题:加入会话时游戏崩溃**
```bash1. Check BepInEx version compatibility
1. 检查BepInEx版本兼容性
Ensure BepInEx 6.0.x or later is installed
确保安装的是BepInEx 6.0.x或更高版本
2. Verify mod file integrity
2. 验证模组文件完整性
Re-download and reinstall DeepSynergy.dll
重新下载并安装DeepSynergy.dll
3. Clear cache
3. 清除缓存
rm -rf BepInEx/cache/*
rm -rf BepInEx/cache/*
Restart game
重启游戏
4. Check logs for IL2CPP errors
4. 查看日志中的IL2CPP错误
grep "IL2CPP" BepInEx/LogOutput.log
undefinedgrep "IL2CPP" BepInEx/LogOutput.log
undefinedAPI Integration Issues
API集成问题
Problem: OpenAI/Claude narration not working
bash
undefined问题:OpenAI/Claude叙事功能无法使用
bash
undefined1. Verify environment variables
1. 验证环境变量
echo $OPENAI_API_KEY
echo $ANTHROPIC_API_KEY
echo $OPENAI_API_KEY
echo $ANTHROPIC_API_KEY
2. Check API integration settings in profile
2. 检查配置文件中的API集成设置
"api_integration": {
"openai": {
"enabled": true,
"api_key_env": "OPENAI_API_KEY"
}
}
"api_integration": {
"openai": {
"enabled": true,
"api_key_env": "OPENAI_API_KEY"
}
}
3. Test API connectivity
3. 测试API连通性
/api_narrate "test"
/api_narrate "test"
Check BepInEx logs for API response errors
查看BepInEx日志中的API响应错误
undefinedundefinedInventory Desync
库存不同步
Problem: Items disappearing or duplicating
bash
undefined问题:物品消失或重复
bash
undefined1. Force inventory sync
1. 强制同步库存
/force_sync inventory
/force_sync inventory
2. Check inventory hash consistency
2. 检查库存哈希值一致性
/synergy_status
/synergy_status
All players should have matching "Inventory hash"
所有玩家的"Inventory hash"应保持一致
3. If persistent, restart session
3. 如果问题持续,重启会话
/leave_session
/leave_session
Host restarts with /start_server
主机使用/start_server重启
All players rejoin
所有玩家重新加入
undefinedundefinedLocalization Issues
本地化问题
Problem: UI text showing wrong language
json
// Edit synergy_profile.json
{
"locale": "en-US" // Change to your preferred locale
}
// Supported: en-US, zh-CN, ja-JP, de-DE, fr-FR, pt-BR, ru-RU, es-LA, ko-KR问题:UI文本显示错误语言
json
// 编辑synergy_profile.json
{
"locale": "zh-CN" // 改为你偏好的语言区域
}
// 支持的区域:en-US, zh-CN, ja-JP, de-DE, fr-FR, pt-BR, ru-RU, es-LA, ko-KRLog Analysis
日志分析
bash
undefinedbash
undefinedView recent errors
查看最近的错误
tail -n 100 BepInEx/LogOutput.log | grep ERROR
tail -n 100 BepInEx/LogOutput.log | grep ERROR
Filter for Deep Synergy specific logs
筛选Deep Synergy相关日志
grep "DeepSynergy" BepInEx/LogOutput.log
grep "DeepSynergy" BepInEx/LogOutput.log
Monitor logs in real-time
实时监控日志
tail -f BepInEx/LogOutput.log
undefinedtail -f BepInEx/LogOutput.log
undefinedBest Practices
最佳实践
- Always backup save files before using multiplayer mods
- Use matching mod versions across all players
- Configure firewall rules before hosting sessions
- Monitor latency with during gameplay
/synergy_status - Disable conflicting mods if experiencing issues
- Use environment variables for API keys, never hardcode
- Test configuration changes in solo mode before hosting
- 使用多人模组前始终备份存档文件
- 所有玩家使用相同版本的模组
- 托管会话前配置好防火墙规则
- 游戏过程中使用监控延迟
/synergy_status - 遇到问题时禁用冲突模组
- 使用环境变量存储API密钥,切勿硬编码
- 托管会话前先在单人模式测试配置变更
Advanced Usage
高级用法
Custom Sync Rules
自定义同步规则
csharp
// Register custom synchronization logic
DeepSynergyAPI.RegisterSyncHandler("CustomItemType", (data, playerId) => {
// Handle custom item sync
var item = JsonConvert.DeserializeObject<CustomItem>(data);
GameState.ApplyCustomItem(item, playerId);
});csharp
// 注册自定义同步逻辑
DeepSynergyAPI.RegisterSyncHandler("CustomItemType", (data, playerId) => {
// 处理自定义物品同步
var item = JsonConvert.DeserializeObject<CustomItem>(data);
GameState.ApplyCustomItem(item, playerId);
});Session Migration
会话迁移
bash
undefinedbash
undefinedIf host disconnects, session migrates automatically
如果主机断开连接,会话会自动迁移
Force migration to specific player
强制迁移到指定玩家
/migrate_host <player_name>
undefined/migrate_host <玩家名称>
undefinedDebugging Mode
调试模式
json
// Enable verbose logging in synergy_profile.json
{
"debug": {
"enabled": true,
"log_sync_events": true,
"log_network_packets": true
}
}json
// 在synergy_profile.json中启用详细日志
{
"debug": {
"enabled": true,
"log_sync_events": true,
"log_network_packets": true
}
}