feat(scum): add map trajectory projection
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
package domain
|
||||
|
||||
import "time"
|
||||
|
||||
const SCUMMapTrajectoryMapID = "scum-island"
|
||||
|
||||
// GameMapTrajectoryDeclaration is plugin-owned metadata used to safely project world coordinates.
|
||||
type GameMapTrajectoryDeclaration struct {
|
||||
MapID, MapVersion string
|
||||
WorldMinX, WorldMinY, WorldMaxX, WorldMaxY float64
|
||||
ImageWidth, ImageHeight, Precision, SampleDistance float64
|
||||
SampleIntervalSeconds, RetentionSeconds int
|
||||
}
|
||||
|
||||
type GameMapTrackEntityKind string
|
||||
|
||||
const (
|
||||
GameMapTrackEntityPlayer GameMapTrackEntityKind = "player"
|
||||
GameMapTrackEntityVehicle GameMapTrackEntityKind = "vehicle"
|
||||
)
|
||||
|
||||
type GameMapTrackPoint struct {
|
||||
ID, EventID, ServerInstanceID, MapID, MapVersion, EntityID, GamePlayerRecordID, Source string
|
||||
EntityKind GameMapTrackEntityKind
|
||||
MapX, MapY float64
|
||||
OccurredAt, CollectedAt, ExpiresAt time.Time
|
||||
}
|
||||
type GameMapTrackPointFilter struct {
|
||||
ServerInstanceID, MapID, MapVersion, EntityID string
|
||||
EntityKind GameMapTrackEntityKind
|
||||
OccurredAfter, OccurredBefore time.Time
|
||||
Limit int
|
||||
}
|
||||
|
||||
type GamePlayerVehicleSegment struct {
|
||||
ID, EventID, ServerInstanceID, GamePlayerRecordID, GamePlayerID, VehicleID, MapID, MapVersion string
|
||||
StartedAt, EndedAt, ExpiresAt time.Time
|
||||
}
|
||||
type GamePlayerVehicleSegmentFilter struct {
|
||||
ServerInstanceID, GamePlayerRecordID, VehicleID, MapID, MapVersion string
|
||||
OccurredAfter, OccurredBefore time.Time
|
||||
Limit int
|
||||
}
|
||||
|
||||
type GameMapTrajectoryQuery struct {
|
||||
ServerInstanceID string
|
||||
From, To time.Time
|
||||
PlayerRecordIDs, VehicleIDs []string
|
||||
}
|
||||
type GameMapTrajectoryEntity struct {
|
||||
Kind GameMapTrackEntityKind
|
||||
EntityID, GamePlayerRecordID, Label string
|
||||
Points []GameMapTrackPoint
|
||||
CollectedAt time.Time
|
||||
Sources []string
|
||||
}
|
||||
type GameMapTrajectorySegment struct {
|
||||
GamePlayerRecordID, VehicleID string
|
||||
StartedAt, EndedAt time.Time
|
||||
}
|
||||
type GameMapTrajectoryView struct {
|
||||
Status, Reason string
|
||||
Map GameMapTrajectoryDeclaration
|
||||
From, To time.Time
|
||||
Players, Vehicles []GameMapTrajectoryEntity
|
||||
RideSegments []GameMapTrajectorySegment
|
||||
}
|
||||
|
||||
func CopyGameMapTrajectoryDeclaration(v GameMapTrajectoryDeclaration) GameMapTrajectoryDeclaration {
|
||||
return v
|
||||
}
|
||||
func CopyGameMapTrackPoint(v GameMapTrackPoint) GameMapTrackPoint { return v }
|
||||
func CopyGameMapTrackPoints(v []GameMapTrackPoint) []GameMapTrackPoint {
|
||||
out := make([]GameMapTrackPoint, len(v))
|
||||
copy(out, v)
|
||||
return out
|
||||
}
|
||||
func CopyGamePlayerVehicleSegment(v GamePlayerVehicleSegment) GamePlayerVehicleSegment { return v }
|
||||
func CopyGamePlayerVehicleSegments(v []GamePlayerVehicleSegment) []GamePlayerVehicleSegment {
|
||||
out := make([]GamePlayerVehicleSegment, len(v))
|
||||
copy(out, v)
|
||||
return out
|
||||
}
|
||||
func CopyGameMapTrajectoryQuery(v GameMapTrajectoryQuery) GameMapTrajectoryQuery {
|
||||
v.PlayerRecordIDs = CopyStringSlice(v.PlayerRecordIDs)
|
||||
v.VehicleIDs = CopyStringSlice(v.VehicleIDs)
|
||||
return v
|
||||
}
|
||||
func CopyGameMapTrajectoryView(v GameMapTrajectoryView) GameMapTrajectoryView {
|
||||
v.Map = CopyGameMapTrajectoryDeclaration(v.Map)
|
||||
v.Players = append([]GameMapTrajectoryEntity(nil), v.Players...)
|
||||
v.Vehicles = append([]GameMapTrajectoryEntity(nil), v.Vehicles...)
|
||||
for i := range v.Players {
|
||||
v.Players[i].Points = CopyGameMapTrackPoints(v.Players[i].Points)
|
||||
v.Players[i].Sources = CopyStringSlice(v.Players[i].Sources)
|
||||
}
|
||||
for i := range v.Vehicles {
|
||||
v.Vehicles[i].Points = CopyGameMapTrackPoints(v.Vehicles[i].Points)
|
||||
v.Vehicles[i].Sources = CopyStringSlice(v.Vehicles[i].Sources)
|
||||
}
|
||||
v.RideSegments = append([]GameMapTrajectorySegment(nil), v.RideSegments...)
|
||||
return v
|
||||
}
|
||||
@@ -620,6 +620,7 @@ type GamePluginManifest struct {
|
||||
RemoteAccess GamePluginRemoteAccess
|
||||
RuntimeProfiles GamePluginRuntimeProfiles
|
||||
GameClientBridge GameClientBridgeManifest
|
||||
MapTrajectories *GameMapTrajectoryDeclaration
|
||||
}
|
||||
|
||||
type GamePluginManifestRegistration struct {
|
||||
@@ -651,6 +652,7 @@ type GamePlugin struct {
|
||||
RemoteAccess GamePluginRemoteAccess
|
||||
RuntimeProfiles GamePluginRuntimeProfiles
|
||||
GameClientBridge GameClientBridgeManifest
|
||||
MapTrajectories *GameMapTrajectoryDeclaration
|
||||
ValidationViolations []string
|
||||
Status GamePluginStatus
|
||||
}
|
||||
@@ -678,6 +680,7 @@ type PluginMarketplacePlugin struct {
|
||||
RemoteAccess GamePluginRemoteAccess
|
||||
RuntimeProfiles GamePluginRuntimeProfiles
|
||||
GameClientBridge GameClientBridgeManifest
|
||||
MapTrajectories *GameMapTrajectoryDeclaration
|
||||
ValidationViolations []string
|
||||
Status GamePluginStatus
|
||||
Source string
|
||||
@@ -1639,6 +1642,10 @@ func CopyGamePlugin(plugin GamePlugin) GamePlugin {
|
||||
plugin.RemoteAccess = CopyGamePluginRemoteAccess(plugin.RemoteAccess)
|
||||
plugin.RuntimeProfiles = CopyGamePluginRuntimeProfiles(plugin.RuntimeProfiles)
|
||||
plugin.GameClientBridge = CopyGameClientBridgeManifest(plugin.GameClientBridge)
|
||||
if plugin.MapTrajectories != nil {
|
||||
value := CopyGameMapTrajectoryDeclaration(*plugin.MapTrajectories)
|
||||
plugin.MapTrajectories = &value
|
||||
}
|
||||
plugin.ValidationViolations = CopyStringSlice(plugin.ValidationViolations)
|
||||
return plugin
|
||||
}
|
||||
@@ -1656,6 +1663,10 @@ func CopyPluginMarketplacePlugin(plugin PluginMarketplacePlugin) PluginMarketpla
|
||||
plugin.RemoteAccess = CopyGamePluginRemoteAccess(plugin.RemoteAccess)
|
||||
plugin.RuntimeProfiles = CopyGamePluginRuntimeProfiles(plugin.RuntimeProfiles)
|
||||
plugin.GameClientBridge = CopyGameClientBridgeManifest(plugin.GameClientBridge)
|
||||
if plugin.MapTrajectories != nil {
|
||||
value := CopyGameMapTrajectoryDeclaration(*plugin.MapTrajectories)
|
||||
plugin.MapTrajectories = &value
|
||||
}
|
||||
plugin.ValidationViolations = CopyStringSlice(plugin.ValidationViolations)
|
||||
return plugin
|
||||
}
|
||||
@@ -1690,6 +1701,10 @@ func CopyGamePluginManifest(manifest GamePluginManifest) GamePluginManifest {
|
||||
manifest.RemoteAccess = CopyGamePluginRemoteAccess(manifest.RemoteAccess)
|
||||
manifest.RuntimeProfiles = CopyGamePluginRuntimeProfiles(manifest.RuntimeProfiles)
|
||||
manifest.GameClientBridge = CopyGameClientBridgeManifest(manifest.GameClientBridge)
|
||||
if manifest.MapTrajectories != nil {
|
||||
value := CopyGameMapTrajectoryDeclaration(*manifest.MapTrajectories)
|
||||
manifest.MapTrajectories = &value
|
||||
}
|
||||
return manifest
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user