Compare commits
2 Commits
a9c14c3adf
...
6a128a836d
| Author | SHA1 | Date | |
|---|---|---|---|
| 6a128a836d | |||
| 5fa2cc1c92 |
47
AGENTS.md
Normal file
47
AGENTS.md
Normal file
@@ -0,0 +1,47 @@
|
||||
# Repository Guidelines
|
||||
|
||||
## Project Structure & Module Organization
|
||||
|
||||
- `Main.cs`: primary Harmony patches, gameplay hooks, and high-level multiplayer flow.
|
||||
- `Packets/`: network message types and handlers (client/server). Subfolders group by domain (e.g., `Lobby`, `Game`, `State`, `Handlers`).
|
||||
- `LoadSaveOverrides/`: multiplayer-aware save/load containers and BinaryFormatter binder.
|
||||
- `StateManagement/`: observer-based state syncing (e.g., building state updates).
|
||||
- `ServerBrowser/`, `ServerLobby/`, `UI/`: menu screens, lobby UI, and related scripts/prefabs glue.
|
||||
- `Riptide/`, `RiptideSteamTransport/`: networking and Steam transport integration.
|
||||
- `Enums/`, `Constants.cs`, `ErrorCodeMessages.cs`, `ReflectionHelper/`: shared types/utilities.
|
||||
|
||||
## Build, Test, and Development Commands
|
||||
|
||||
This mod is typically compiled/loaded by the game’s mod loader (there is no `.csproj` here).
|
||||
|
||||
- Validate changes quickly: `rg -n "TODO|FIXME|throw|NotImplementedException" -S .`
|
||||
- Inspect recent log output: `Get-Content .\\output.txt -Tail 200`
|
||||
- Check history/context: `git log -n 20 --oneline`
|
||||
|
||||
To run locally, copy/enable the mod in *Kingdoms and Castles* and **fully restart the game** after changes. Keep host/client mod versions identical.
|
||||
|
||||
## Coding Style & Naming Conventions
|
||||
|
||||
- Language: C# (Unity/Mono). Prefer conservative language features to avoid in-game compiler issues.
|
||||
- Indentation: 4 spaces; braces on new lines (match existing files).
|
||||
- Names: `PascalCase` for types/methods, `camelCase` for locals/fields. Packet properties are public and serialized—treat renames as breaking changes.
|
||||
- Logging: use `Main.helper.Log(...)` with short, searchable messages.
|
||||
|
||||
## Testing Guidelines
|
||||
|
||||
No automated test suite. Verify in-game with a minimal repro:
|
||||
|
||||
- Host ↔ join, place buildings, save/load, leave/rejoin, and confirm sync.
|
||||
- When reporting bugs, include `output.txt` excerpts around the first exception and “Save Transfer” markers.
|
||||
|
||||
## Commit & Pull Request Guidelines
|
||||
|
||||
Git history uses short, informal summaries. For contributions:
|
||||
|
||||
- Commits: one-line, descriptive, avoid profanity; include a scope when helpful (e.g., `save: fix load fallback`).
|
||||
- PRs: describe the issue, repro steps, expected vs actual, and attach relevant `output.txt` snippets. Note game version, mod version, and whether it’s Workshop or local mod folder.
|
||||
|
||||
## Agent-Specific Notes
|
||||
|
||||
- Avoid edits that depend on newer C# syntax not supported by the runtime compiler.
|
||||
- Prefer small, isolated fixes; multiplayer regressions are easy to introduce—add logs around save/load and connect/disconnect paths.
|
||||
@@ -45,7 +45,8 @@ namespace KCM.LoadSaveOverrides
|
||||
}
|
||||
|
||||
Main.helper.Log($"Attempting to pack data for: {player.name} ({player.steamId})");
|
||||
Main.helper.Log($"Player object: {player.inst} {player.inst.gameObject?.name}");
|
||||
string playerGoName = (player.inst.gameObject != null) ? player.inst.gameObject.name : string.Empty;
|
||||
Main.helper.Log($"Player object: {player.inst} {playerGoName}");
|
||||
|
||||
this.players[player.steamId] = new Player.PlayerSaveData().Pack(player.inst);
|
||||
kingdomNames[player.steamId] = player.kingdomName ?? " ";
|
||||
@@ -54,7 +55,9 @@ namespace KCM.LoadSaveOverrides
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Main.helper.Log($"Error packing player data for save (steamId={player?.steamId ?? string.Empty}, name={player?.name ?? string.Empty})");
|
||||
string steamId = (player != null && player.steamId != null) ? player.steamId : string.Empty;
|
||||
string name = (player != null && player.name != null) ? player.name : string.Empty;
|
||||
Main.helper.Log($"Error packing player data for save (steamId={steamId}, name={name})");
|
||||
Main.helper.Log(ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user