Poprawka czasu gry
This commit is contained in:
25
CLAUDE.md
25
CLAUDE.md
@@ -18,6 +18,13 @@ The plugin **never directly references TOU Mira types**. All access is via refle
|
||||
### Harmony Patching Strategy
|
||||
Uses `[HarmonyPriority(Priority.Low)]` on the `AmongUsClient.OnGameEnd` patch to ensure TOU Mira's `BuildEndGameData()` runs first and populates `EndGameData.PlayerRecords` before the export begins.
|
||||
|
||||
### Game Duration Tracking
|
||||
The plugin tracks actual gameplay duration (not lobby time) using `GameStartTimePatch`:
|
||||
- Patches `ShipStatus.Begin` to capture when the game round starts
|
||||
- Stores start time as `Time.time` when gameplay begins
|
||||
- Calculates duration as difference between game end time and start time
|
||||
- Resets on each game to ensure accurate per-game timing
|
||||
|
||||
### Async Export Pattern
|
||||
Export runs in a fire-and-forget Task.Run() to avoid blocking the game UI. The entire export process (reflection, data transformation, API call) happens asynchronously.
|
||||
|
||||
@@ -63,20 +70,27 @@ If the `AmongUs` environment variable is set, the DLL auto-copies to `$(AmongUs)
|
||||
1. `TownOfUsStatsPlugin.Load()` - BepInEx entry point
|
||||
2. `TouMiraReflectionBridge.Initialize()` - Find TOU Mira assembly, cache reflection metadata
|
||||
3. `VersionCompatibility.CheckVersion()` - Verify TOU Mira version compatibility
|
||||
4. `Harmony.PatchAll()` - Apply patches (EndGameExportPatch)
|
||||
4. `Harmony.PatchAll()` - Apply patches (EndGameExportPatch, GameStartTimePatch)
|
||||
|
||||
### Game Start Flow
|
||||
1. **ShipStatus.Begin** fires (game round starts, gameplay begins)
|
||||
2. **GameStartTimePatch.OnShipStatusBegin** runs - records `Time.time` as game start time
|
||||
|
||||
### Export Flow (Game End)
|
||||
1. **AmongUsClient.OnGameEnd** fires (game ends)
|
||||
2. **TOU Mira's patch** runs (High priority) - populates EndGameData.PlayerRecords
|
||||
3. **EndGameExportPatch.Postfix** runs (Low priority) - starts export
|
||||
2. **GameStartTimePatch.OnGameEndPrefix** runs - logs game duration
|
||||
3. **TOU Mira's patch** runs (High priority) - populates EndGameData.PlayerRecords
|
||||
4. **EndGameExportPatch.Postfix** runs (Low priority) - starts export
|
||||
- Checks for Hide & Seek mode (skip if true)
|
||||
- Fires Task.Run() with `StatsExporter.ExportGameStatsAsync()`
|
||||
4. **StatsExporter.ExportGameStatsAsync()**
|
||||
5. **StatsExporter.ExportGameStatsAsync()**
|
||||
- Reads `ApiSet.ini` config
|
||||
- Calls reflection bridge methods to collect data
|
||||
- Transforms data via `DataTransformer.TransformToExportFormat()`
|
||||
- Uses `GameStartTimePatch.GetGameDuration()` for accurate game time
|
||||
- Saves local backup if enabled
|
||||
- POSTs to API via `ApiClient.SendToApiAsync()`
|
||||
6. **GameStartTimePatch.OnGameEndPostfix** runs - clears game start time for next game
|
||||
|
||||
### Key Reflection Patterns
|
||||
|
||||
@@ -164,7 +178,7 @@ GameStatsData
|
||||
│ ├── Timestamp (UTC)
|
||||
│ ├── LobbyCode (e.g., "ABCDEF")
|
||||
│ ├── GameMode (Normal/HideNSeek)
|
||||
│ ├── Duration (seconds)
|
||||
│ ├── Duration (seconds, actual gameplay time from intro end to game end)
|
||||
│ └── Map (string)
|
||||
├── Players[] (list)
|
||||
│ ├── PlayerId (byte)
|
||||
@@ -309,3 +323,4 @@ Symbols are extracted **before** text cleaning to preserve information:
|
||||
- No compile-time type safety (all reflection is string-based)
|
||||
- Breaking changes in TOU Mira require plugin updates
|
||||
- Symbol encoding may vary by console/log viewer (e.g., `♥` may display as `ÔÖą` in logs)
|
||||
- to memorize
|
||||
Reference in New Issue
Block a user