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
10 changes: 10 additions & 0 deletions fission/src/mirabuf/MirabufSceneObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { BodyAssociate, LayerReserve } from "@/systems/physics/PhysicsSystem"
import Mechanism from "@/systems/physics/Mechanism"
import {
Alliance,
Station,
EjectorPreferences,
FieldPreferences,
IntakePreferences,
Expand Down Expand Up @@ -74,6 +75,7 @@ class MirabufSceneObject extends SceneObject implements ContextSupplier {
private _mechanism: Mechanism
private _brain: Brain | undefined
private _alliance: Alliance | undefined
private _station: Station | undefined

private _debugBodies: Map<string, RnDebugMeshes> | null
private _physicsLayerReserve: LayerReserve | undefined
Expand Down Expand Up @@ -165,6 +167,10 @@ class MirabufSceneObject extends SceneObject implements ContextSupplier {
return this._alliance
}

public get station() {
return this._station
}

public set brain(brain: Brain | undefined) {
this._brain = brain
const simLayer = World.simulationSystem.getSimulationLayer(this._mechanism)!
Expand All @@ -175,6 +181,10 @@ class MirabufSceneObject extends SceneObject implements ContextSupplier {
this._alliance = alliance
}

public set station(station: Station | undefined) {
this._station = station
}

public get cacheId() {
return this._cacheId
}
Expand Down
2 changes: 2 additions & 0 deletions fission/src/systems/preferences/PreferenceTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ export type MotorPreferences = {

export type Alliance = "red" | "blue"

export type Station = 1 | 2 | 3

export type ScoringZonePreferences = {
name: string
alliance: Alliance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,9 @@ function getRobotModes(assembly: MirabufSceneObject): Map<ConfigMode, ConfigMode
[
ConfigMode.ALLIANCE,
new ConfigModeSelectionOption(
"Alliance",
"Alliance / Station",
ConfigMode.ALLIANCE,
"Set the robot's alliance color for matches. (red or blue)"
"Set the robot's alliance color and station number for matches. (red or blue, 1-3)"
),
],
])
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import MirabufSceneObject from "@/mirabuf/MirabufSceneObject"
import { Alliance } from "@/systems/preferences/PreferenceTypes"
import { Alliance, Station } from "@/systems/preferences/PreferenceTypes"
import Button from "@/components/Button"
import Label from "@/components/Label"
import React, { useState } from "react"

type AllianceSelectionInterfaceProps = {
Expand All @@ -11,18 +12,57 @@ const saveSetAlliance = (alliance: Alliance, assembly: MirabufSceneObject) => {
assembly.alliance = alliance
}

const saveSetStation = (station: Station, assembly: MirabufSceneObject) => {
assembly.station = station
}
Comment thread
itspvty marked this conversation as resolved.

const AllianceSelectionInterface: React.FC<AllianceSelectionInterfaceProps> = ({ selectedAssembly }) => {
const [alliance, setAlliance] = useState<Alliance>(selectedAssembly.alliance ?? "red")
const [station, setStation] = useState<Station>(selectedAssembly.station ?? 1)

return (
<Button
value={`${alliance[0].toUpperCase() + alliance.substring(1)} Alliance`}
onClick={() => {
setAlliance(alliance == "blue" ? "red" : "blue")
saveSetAlliance(alliance == "blue" ? "red" : "blue", selectedAssembly)
}}
colorOverrideClass={`bg-match-${alliance}-alliance`}
/>
<div className="flex flex-col gap-2">
<div>
<Label>Alliance: </Label>
<Button
value={`${alliance[0].toUpperCase() + alliance.substring(1)} Alliance`}
onClick={() => {
setAlliance(alliance == "blue" ? "red" : "blue")
saveSetAlliance(alliance == "blue" ? "red" : "blue", selectedAssembly)
}}
colorOverrideClass={`bg-match-${alliance}-alliance`}
/>
</div>
<div>
<Label>Station: </Label>
<div className="flex gap-2">
<Button
value="1"
onClick={() => {
setStation(1)
saveSetStation(1, selectedAssembly)
}}
colorOverrideClass={station === 1 ? `bg-match-${alliance}-alliance` : ""}
/>
<Button
value="2"
onClick={() => {
setStation(2)
saveSetStation(2, selectedAssembly)
}}
colorOverrideClass={station === 2 ? `bg-match-${alliance}-alliance` : ""}
/>
<Button
value="3"
onClick={() => {
setStation(3)
saveSetStation(3, selectedAssembly)
}}
colorOverrideClass={station === 3 ? `bg-match-${alliance}-alliance` : ""}
/>
</div>
</div>
</div>
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ import World from "@/systems/World"
import { PAUSE_REF_ASSEMBLY_MOVE } from "@/systems/physics/PhysicsSystem"
import { mirabufPanelState } from "@/panels/mirabuf/MirabufState.tsx"
import Button from "@/components/Button"
import { Alliance } from "@/systems/preferences/PreferenceTypes"
import { Alliance, Station } from "@/systems/preferences/PreferenceTypes"
import Label from "@/ui/components/Label"
import SimulationSystem from "@/systems/simulation/SimulationSystem"

const InitialConfigPanel: React.FC<PanelPropsImpl> = ({ panelId }) => {
const { closePanel, openPanel } = usePanelControlContext()
const { openModal } = useModalControlContext()
const [alliance, setAlliance] = useState<Alliance>("red")
const [station, setStation] = useState<Station>(1)

const targetAssembly = useMemo(() => {
return getSpotlightAssembly()
Expand All @@ -50,6 +51,7 @@ const InitialConfigPanel: React.FC<PanelPropsImpl> = ({ panelId }) => {
const closeFinish = useCallback(() => {
if (targetAssembly?.miraType == MiraType.ROBOT) {
targetAssembly.alliance = alliance
targetAssembly.station = station
SimulationSystem.addPerRobotScore(targetAssembly, 0) // Initialize score for the robot

setSelectedConfigurationType(ConfigurationType.ROBOT)
Expand All @@ -67,7 +69,7 @@ const InitialConfigPanel: React.FC<PanelPropsImpl> = ({ panelId }) => {
}

closePanel(panelId)
}, [closePanel, panelId, alliance, targetAssembly])
}, [closePanel, panelId, alliance, station, targetAssembly])

const closeDelete = useCallback(() => {
if (targetAssembly) {
Expand Down Expand Up @@ -108,6 +110,28 @@ const InitialConfigPanel: React.FC<PanelPropsImpl> = ({ panelId }) => {
}}
colorOverrideClass={`bg-match-${alliance}-alliance`}
/>
<div className="mt-4">
<Label>Station: </Label>
{/** Set the station number */}
<div className="flex gap-2">
<Button
value="1"
onClick={() => setStation(1)}
colorOverrideClass={station === 1 ? `bg-match-${alliance}-alliance` : ""}
/>
<Button
value="2"
onClick={() => setStation(2)}
colorOverrideClass={station === 2 ? `bg-match-${alliance}-alliance` : ""}
/>
<Button
value="3"
onClick={() => setStation(3)}
colorOverrideClass={station === 3 ? `bg-match-${alliance}-alliance` : ""}
/>
</div>
</div>
<div className="mb-4"></div>
</div>
) : (
<></>
Expand Down
Loading