Documentation
¶
Overview ¶
Package v1 contains the v1 export format for OCAP2 mission data. This format is compatible with the ocap2-web frontend.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Stream ¶
func Stream(w io.Writer, data *MissionData) error
Stream writes the v1 export JSON directly to w without holding the full Export struct in memory. Peak additional memory is bounded by the largest single entity's gap-filled positions plus the aggregate events/markers slices, which are typically orders of magnitude smaller than the sum of all entity positions.
Output is JSON-equivalent to json.NewEncoder(w).Encode(Build(data)). The entities array is indexed by ID so map iteration order does not affect final output.
Types ¶
type Entity ¶
type Entity struct {
ID uint16 `json:"id"`
Name string `json:"name"`
Group string `json:"group,omitempty"`
Side string `json:"side"`
IsPlayer int `json:"isPlayer"`
Type string `json:"type"`
Role string `json:"role,omitempty"`
Class string `json:"class,omitempty"`
StartFrameNum int `json:"startFrameNum"`
Positions [][]any `json:"positions"`
FramesFired [][]any `json:"framesFired"`
}
Entity represents a soldier or vehicle
type Export ¶
type Export struct {
AddonVersion string `json:"addonVersion"`
ExtensionVersion string `json:"extensionVersion"`
ExtensionBuild string `json:"extensionBuild"`
MissionName string `json:"missionName"`
MissionAuthor string `json:"missionAuthor"`
WorldName string `json:"worldName"`
EndFrame int `json:"endFrame"`
CaptureDelay float32 `json:"captureDelay"`
Tags string `json:"tags"`
Times []Time `json:"times"`
Entities []Entity `json:"entities"`
Events [][]any `json:"events"`
Markers [][]any `json:"Markers"` // Capital M for ocap2-web compatibility
}
Export is the root JSON structure for v1 format Note: Markers uses capital M for compatibility with ocap2-web
type MarkerRecord ¶
type MarkerRecord struct {
Marker core.Marker
States []core.MarkerState
}
MarkerRecord groups a marker with all its state changes
type MissionData ¶
type MissionData struct {
Mission *core.Mission
World *core.World
Soldiers map[uint16]*SoldierRecord
Vehicles map[uint16]*VehicleRecord
Markers map[string]*MarkerRecord
PlacedObjects map[uint16]*PlacedObjectRecord
GeneralEvents []core.GeneralEvent
SectorEvents []core.SectorEvent
EndMissionEvents []core.EndMissionEvent
HitEvents []core.HitEvent
KillEvents []core.KillEvent
TimeStates []core.TimeState
ProjectileEvents []core.ProjectileEvent
}
MissionData contains all the data needed to build an export
type PlacedObjectRecord ¶
type PlacedObjectRecord struct {
PlacedObject core.PlacedObject
Events []core.PlacedObjectEvent
}
PlacedObjectRecord groups a placed object with all its lifecycle events
type SoldierRecord ¶
type SoldierRecord struct {
Soldier core.Soldier
States []core.SoldierState
FiredEvents []core.FiredEvent
}
SoldierRecord groups a soldier with all its time-series data
type Time ¶
type Time struct {
Date string `json:"date"`
FrameNum int `json:"frameNum"`
SystemTimeUTC string `json:"systemTimeUTC"`
Time float32 `json:"time"`
TimeMultiplier float32 `json:"timeMultiplier"`
}
Time represents time synchronization data for a frame
type VehicleRecord ¶
type VehicleRecord struct {
Vehicle core.Vehicle
States []core.VehicleState
}
VehicleRecord groups a vehicle with all its time-series data