Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions fission/src/Window.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ declare interface Window {
convertAuthToken(code: string): void
gtag?: (command: "config" | "set" | "get" | "event" | "consent", ...args: unknown[]) => void
dataLayer?: unknown[][]
World?: unknown
}
39 changes: 38 additions & 1 deletion fission/src/mirabuf/FieldMiraEditor.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import type MirabufSceneObject from "@/mirabuf/MirabufSceneObject.ts"
import { ContactType } from "@/mirabuf/ZoneTypes.ts"
import { mirabuf } from "@/proto/mirabuf"
import { MatchModeType } from "@/systems/match_mode/MatchModeTypes.ts"
import {
defaultFieldPreferences,
type FieldPreferences,
type ProtectedZonePreferences,
type ScoringZonePreferences,
} from "@/systems/preferences/PreferenceTypes"

export interface DevtoolMiraData {
"devtool:scoring_zones": ScoringZonePreferences[]
"devtool:camera_locations": unknown
"devtool:protected_zones": ProtectedZonePreferences[]
"devtool:spawn_locations": FieldPreferences["spawnLocations"]
"devtool:a": unknown
"devtool:b": unknown
Expand Down Expand Up @@ -50,6 +53,40 @@ export const devtoolHandlers = {
)
},
},
"devtool:protected_zones": {
get(field) {
return field.fieldPreferences?.protectedZones ?? defaultFieldPreferences().protectedZones
},
set(field, val) {
val ??= defaultFieldPreferences().protectedZones
if (!field.fieldPreferences || !this.validate(val)) {
console.warn("validation failed", val, field.fieldPreferences)
return
}
field.fieldPreferences.protectedZones = val
field.updateProtectedZones()
},
validate(val): val is ProtectedZonePreferences[] {
if (!Array.isArray(val)) return false
return val.every(
z =>
typeof z === "object" &&
z !== null &&
typeof z.name === "string" &&
(z.alliance === "red" || z.alliance === "blue") &&
(typeof z.parentNode === "string" || z.parentNode === undefined) &&
typeof z.penaltyPoints === "number" &&
typeof z.contactType === "string" &&
Object.values(ContactType).includes(z.contactType as ContactType) &&
Array.isArray(z.activeDuring) &&
z.activeDuring.every(
(v: unknown) =>
typeof v === "string" && Object.values(MatchModeType).includes(v as MatchModeType)
) &&
Array.isArray(z.deltaTransformation)
)
},
},
"devtool:spawn_locations": {
get(field) {
return field.fieldPreferences?.spawnLocations ?? defaultFieldPreferences().spawnLocations
Expand Down
2 changes: 1 addition & 1 deletion fission/src/mirabuf/MirabufSceneObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ class MirabufSceneObject extends SceneObject implements ContextSupplier {
}

// Centered in xz plane, bottom surface of object
private getPositionTransform(vec: THREE.Vector3) {
public getPositionTransform(vec: THREE.Vector3 = new THREE.Vector3()) {
const box = this.computeBoundingBox()
const transform = box.getCenter(vec)
transform.setY(box.min.y)
Expand Down
4 changes: 4 additions & 0 deletions fission/src/systems/World.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ class World {
} catch (_) {
World._analyticsSystem = undefined
}

if (import.meta.env.DEV) {
window.World = World
}
}

public static destroyWorld() {
Expand Down
Loading