Skip to content

Commit 7e9089c

Browse files
Added station selection [AARD-1988] (#1207)
Co-authored-by: Aries Powvalla <74034072+ariesninjadev@users.noreply.github.com> Co-authored-by: Brandon Pacewic <92102436+BrandonPacewic@users.noreply.github.com>
2 parents d20b7f0 + 0c1baa1 commit 7e9089c

File tree

5 files changed

+89
-13
lines changed

5 files changed

+89
-13
lines changed

fission/src/mirabuf/MirabufSceneObject.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { BodyAssociate, LayerReserve } from "@/systems/physics/PhysicsSystem"
1111
import Mechanism from "@/systems/physics/Mechanism"
1212
import {
1313
Alliance,
14+
Station,
1415
EjectorPreferences,
1516
FieldPreferences,
1617
IntakePreferences,
@@ -74,6 +75,7 @@ class MirabufSceneObject extends SceneObject implements ContextSupplier {
7475
private _mechanism: Mechanism
7576
private _brain: Brain | undefined
7677
private _alliance: Alliance | undefined
78+
private _station: Station | undefined
7779

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

170+
public get station() {
171+
return this._station
172+
}
173+
168174
public set brain(brain: Brain | undefined) {
169175
this._brain = brain
170176
const simLayer = World.simulationSystem.getSimulationLayer(this._mechanism)!
@@ -175,6 +181,10 @@ class MirabufSceneObject extends SceneObject implements ContextSupplier {
175181
this._alliance = alliance
176182
}
177183

184+
public set station(station: Station | undefined) {
185+
this._station = station
186+
}
187+
178188
public get cacheId() {
179189
return this._cacheId
180190
}

fission/src/systems/preferences/PreferenceTypes.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ export type MotorPreferences = {
141141

142142
export type Alliance = "red" | "blue"
143143

144+
export type Station = 1 | 2 | 3
145+
144146
export type ScoringZonePreferences = {
145147
name: string
146148
alliance: Alliance

fission/src/ui/panels/configuring/assembly-config/ConfigurePanel.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,9 @@ function getRobotModes(assembly: MirabufSceneObject): Map<ConfigMode, ConfigMode
167167
[
168168
ConfigMode.ALLIANCE,
169169
new ConfigModeSelectionOption(
170-
"Alliance",
170+
"Alliance / Station",
171171
ConfigMode.ALLIANCE,
172-
"Set the robot's alliance color for matches. (red or blue)"
172+
"Set the robot's alliance color and station number for matches. (red or blue, 1-3)"
173173
),
174174
],
175175
])

fission/src/ui/panels/configuring/assembly-config/interfaces/AllianceSelectionInterface.tsx

Lines changed: 49 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import MirabufSceneObject from "@/mirabuf/MirabufSceneObject"
2-
import { Alliance } from "@/systems/preferences/PreferenceTypes"
2+
import { Alliance, Station } from "@/systems/preferences/PreferenceTypes"
33
import Button from "@/components/Button"
4+
import Label from "@/components/Label"
45
import React, { useState } from "react"
56

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

15+
const saveSetStation = (station: Station, assembly: MirabufSceneObject) => {
16+
assembly.station = station
17+
}
18+
1419
const AllianceSelectionInterface: React.FC<AllianceSelectionInterfaceProps> = ({ selectedAssembly }) => {
1520
const [alliance, setAlliance] = useState<Alliance>(selectedAssembly.alliance ?? "red")
21+
const [station, setStation] = useState<Station>(selectedAssembly.station ?? 1)
1622

1723
return (
18-
<Button
19-
value={`${alliance[0].toUpperCase() + alliance.substring(1)} Alliance`}
20-
onClick={() => {
21-
setAlliance(alliance == "blue" ? "red" : "blue")
22-
saveSetAlliance(alliance == "blue" ? "red" : "blue", selectedAssembly)
23-
}}
24-
colorOverrideClass={`bg-match-${alliance}-alliance`}
25-
/>
24+
<div className="flex flex-col gap-2">
25+
<div>
26+
<Label>Alliance: </Label>
27+
<Button
28+
value={`${alliance[0].toUpperCase() + alliance.substring(1)} Alliance`}
29+
onClick={() => {
30+
setAlliance(alliance == "blue" ? "red" : "blue")
31+
saveSetAlliance(alliance == "blue" ? "red" : "blue", selectedAssembly)
32+
}}
33+
colorOverrideClass={`bg-match-${alliance}-alliance`}
34+
/>
35+
</div>
36+
<div>
37+
<Label>Station: </Label>
38+
<div className="flex gap-2">
39+
<Button
40+
value="1"
41+
onClick={() => {
42+
setStation(1)
43+
saveSetStation(1, selectedAssembly)
44+
}}
45+
colorOverrideClass={station === 1 ? `bg-match-${alliance}-alliance` : ""}
46+
/>
47+
<Button
48+
value="2"
49+
onClick={() => {
50+
setStation(2)
51+
saveSetStation(2, selectedAssembly)
52+
}}
53+
colorOverrideClass={station === 2 ? `bg-match-${alliance}-alliance` : ""}
54+
/>
55+
<Button
56+
value="3"
57+
onClick={() => {
58+
setStation(3)
59+
saveSetStation(3, selectedAssembly)
60+
}}
61+
colorOverrideClass={station === 3 ? `bg-match-${alliance}-alliance` : ""}
62+
/>
63+
</div>
64+
</div>
65+
</div>
2666
)
2767
}
2868

fission/src/ui/panels/configuring/initial-config/InitialConfigPanel.tsx

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@ import World from "@/systems/World"
1616
import { PAUSE_REF_ASSEMBLY_MOVE } from "@/systems/physics/PhysicsSystem"
1717
import { mirabufPanelState } from "@/panels/mirabuf/MirabufState.tsx"
1818
import Button from "@/components/Button"
19-
import { Alliance } from "@/systems/preferences/PreferenceTypes"
19+
import { Alliance, Station } from "@/systems/preferences/PreferenceTypes"
2020
import Label from "@/ui/components/Label"
2121
import SimulationSystem from "@/systems/simulation/SimulationSystem"
2222

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

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

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

6971
closePanel(panelId)
70-
}, [closePanel, panelId, alliance, targetAssembly])
72+
}, [closePanel, panelId, alliance, station, targetAssembly])
7173

7274
const closeDelete = useCallback(() => {
7375
if (targetAssembly) {
@@ -108,6 +110,28 @@ const InitialConfigPanel: React.FC<PanelPropsImpl> = ({ panelId }) => {
108110
}}
109111
colorOverrideClass={`bg-match-${alliance}-alliance`}
110112
/>
113+
<div className="mt-4">
114+
<Label>Station: </Label>
115+
{/** Set the station number */}
116+
<div className="flex gap-2">
117+
<Button
118+
value="1"
119+
onClick={() => setStation(1)}
120+
colorOverrideClass={station === 1 ? `bg-match-${alliance}-alliance` : ""}
121+
/>
122+
<Button
123+
value="2"
124+
onClick={() => setStation(2)}
125+
colorOverrideClass={station === 2 ? `bg-match-${alliance}-alliance` : ""}
126+
/>
127+
<Button
128+
value="3"
129+
onClick={() => setStation(3)}
130+
colorOverrideClass={station === 3 ? `bg-match-${alliance}-alliance` : ""}
131+
/>
132+
</div>
133+
</div>
134+
<div className="mb-4"></div>
111135
</div>
112136
) : (
113137
<></>

0 commit comments

Comments
 (0)