import React, { useState, useEffect } from "react"; import { Menu } from "./components/menu"; import { OlSearchBar } from "../components/olsearchbar"; import { OlAccordion } from "../components/olaccordion"; import { getApp } from "../../olympusapp"; import { OlUnitListEntry } from "../components/olunitlistentry"; import { UnitSpawnMenu } from "./unitspawnmenu"; import { SpawnRequestTable, UnitBlueprint } from "../../interfaces"; import { olButtonsVisibilityAircraft, olButtonsVisibilityGroundunit, olButtonsVisibilityGroundunitSam, olButtonsVisibilityHelicopter, olButtonsVisibilityNavyunit, } from "../components/olicons"; import { faExplosion, faSmog } from "@fortawesome/free-solid-svg-icons"; import { OlEffectListEntry } from "../components/oleffectlistentry"; import { EffectSpawnMenu } from "./effectspawnmenu"; import { BLUE_COMMANDER, COMMAND_MODE_OPTIONS_DEFAULTS, GAME_MASTER, NO_SUBSTATE, OlympusState } from "../../constants/constants"; import { AppStateChangedEvent, CommandModeOptionsChangedEvent, StarredSpawnsChangedEvent, UnitDatabaseLoadedEvent } from "../../events"; enum CategoryAccordion { NONE, AIRCRAFT, HELICOPTER, SAM, AAA, GROUND_UNIT, NAVY_UNIT, EFFECT, } export function SpawnMenu(props: { open: boolean; onClose: () => void; children?: JSX.Element | JSX.Element[] }) { const [openAccordion, setOpenAccordion] = useState(CategoryAccordion.NONE); const [blueprint, setBlueprint] = useState(null as null | UnitBlueprint); const [effect, setEffect] = useState(null as null | string); const [filterString, setFilterString] = useState(""); const [selectedRole, setSelectedRole] = useState(null as null | string); const [selectedType, setSelectedType] = useState(null as null | string); const [blueprints, setBlueprints] = useState([] as UnitBlueprint[]); const [roles, setRoles] = useState({ aircraft: [] as string[], helicopter: [] as string[] }); const [types, setTypes] = useState({ groundunit: [] as string[], navyunit: [] as string[] }); const [commandModeOptions, setCommandModeOptions] = useState(COMMAND_MODE_OPTIONS_DEFAULTS); const [showCost, setShowCost] = useState(false); const [starredSpawns, setStarredSpawns] = useState({} as { [key: string]: SpawnRequestTable }); useEffect(() => { if (selectedRole) setBlueprints(getApp()?.getUnitsManager().getDatabase().getByRole(selectedRole)); else if (selectedType) setBlueprints(getApp()?.getUnitsManager().getDatabase().getByType(selectedType)); else setBlueprints(getApp()?.getUnitsManager().getDatabase().getBlueprints()); }, [selectedRole, selectedType, openAccordion]); useEffect(() => { UnitDatabaseLoadedEvent.on(() => { setRoles({ aircraft: getApp() ?.getUnitsManager() .getDatabase() .getRoles((unit) => unit.category === "aircraft"), helicopter: getApp() ?.getUnitsManager() .getDatabase() .getRoles((unit) => unit.category === "helicopter"), }); setTypes({ groundunit: getApp() ?.getUnitsManager() .getDatabase() .getTypes((unit) => unit.category === "groundunit"), navyunit: getApp() ?.getUnitsManager() .getDatabase() .getTypes((unit) => unit.category === "navyunit"), }); }); AppStateChangedEvent.on((state, subState) => { if (subState === NO_SUBSTATE) { setBlueprint(null); setEffect(null); } }); CommandModeOptionsChangedEvent.on((commandModeOptions) => { setCommandModeOptions(commandModeOptions); setShowCost(!(commandModeOptions.commandMode == GAME_MASTER || !commandModeOptions.restrictSpawns)); setOpenAccordion(CategoryAccordion.NONE); }); StarredSpawnsChangedEvent.on((starredSpawns) => setStarredSpawns({ ...starredSpawns })); }, []); /* Filter the blueprints according to the label */ const filteredBlueprints: UnitBlueprint[] = []; if (blueprints) { blueprints.forEach((blueprint) => { if (blueprint.enabled && (filterString === "" || blueprint.label.toLowerCase().includes(filterString.toLowerCase()))) filteredBlueprints.push(blueprint); }); } useEffect(() => { if (!props.open) { if (blueprint !== null) setBlueprint(null); if (effect !== null) setEffect(null); if (filterString !== "") setFilterString(""); if (openAccordion !== CategoryAccordion.NONE) setOpenAccordion(CategoryAccordion.NONE); } }); return ( { getApp().setState(OlympusState.SPAWN); setBlueprint(null); setEffect(null); }} wiki={() => { return (

Spawn menu

The spawn menu allows you to spawn new units in the current mission.

Moreover, it allows you to spawn effects like smokes and explosions.

You can use the search bar to quickly find a specific unit. Otherwise, open the category you are interested in, and use the filters to refine your selection.

Click on a unit to enter the spawn properties menu. The menu is divided into multiple sections:
  • Unit name and short description
  • Quick access name
  • Spawn properties
  • Loadout description

To get more info on each control, hover your cursor on it.

Quick access

If you plan on reusing the same spawn multiple times during the mission, you can "star" the spawn properties. This will allow you to reuse them quickly multiple times. The starred spawn will save all settings, so you can create starred spawn with multiple variations, e.g. loadouts, or skill levels.

); }} > <> {blueprint === null && effect === null && (
setFilterString(value)} text={filterString} /> { setOpenAccordion(openAccordion === CategoryAccordion.AIRCRAFT ? CategoryAccordion.NONE : CategoryAccordion.AIRCRAFT); setSelectedRole(null); setSelectedType(null); }} >
{roles.aircraft.sort().map((role) => { return (
{ selectedRole === role ? setSelectedRole(null) : setSelectedRole(role); }} > {role}
); })}
{filteredBlueprints .filter((blueprint) => blueprint.category === "aircraft") .map((blueprint) => { return ( setBlueprint(blueprint)} showCost={showCost} cost={getApp().getUnitsManager().getDatabase().getSpawnPointsByName(blueprint.name)} /> ); })}
{ setOpenAccordion(openAccordion === CategoryAccordion.HELICOPTER ? CategoryAccordion.NONE : CategoryAccordion.HELICOPTER); setSelectedRole(null); setSelectedType(null); }} >
{roles.helicopter.sort().map((role) => { return (
{ selectedRole === role ? setSelectedRole(null) : setSelectedRole(role); }} > {role}
); })}
{filteredBlueprints .filter((blueprint) => blueprint.category === "helicopter") .map((blueprint) => { return ( setBlueprint(blueprint)} showCost={showCost} cost={getApp().getUnitsManager().getDatabase().getSpawnPointsByName(blueprint.name)} /> ); })}
{ setOpenAccordion(openAccordion === CategoryAccordion.SAM ? CategoryAccordion.NONE : CategoryAccordion.SAM); setSelectedRole(null); setSelectedType(null); }} >
{filteredBlueprints .filter((blueprint) => blueprint.category === "groundunit" && blueprint.type === "SAM Site") .map((blueprint) => { return ( setBlueprint(blueprint)} showCost={showCost} cost={getApp().getUnitsManager().getDatabase().getSpawnPointsByName(blueprint.name)} /> ); })}
{ setOpenAccordion(openAccordion === CategoryAccordion.AAA ? CategoryAccordion.NONE : CategoryAccordion.AAA); setSelectedRole(null); setSelectedType(null); }} >
{filteredBlueprints .filter((blueprint) => blueprint.canAAA) .map((blueprint) => { return ( setBlueprint(blueprint)} showCost={showCost} cost={getApp().getUnitsManager().getDatabase().getSpawnPointsByName(blueprint.name)} /> ); })}
{ setOpenAccordion(openAccordion === CategoryAccordion.GROUND_UNIT ? CategoryAccordion.NONE : CategoryAccordion.GROUND_UNIT); setSelectedRole(null); setSelectedType(null); }} >
{types.groundunit .sort() .filter((type) => type !== "SAM Site") .map((type) => { return (
{ selectedType === type ? setSelectedType(null) : setSelectedType(type); }} > {type}
); })}
{filteredBlueprints .filter((blueprint) => blueprint.category === "groundunit" && blueprint.type !== "SAM Site") .map((blueprint) => { return ( setBlueprint(blueprint)} showCost={showCost} cost={getApp().getUnitsManager().getDatabase().getSpawnPointsByName(blueprint.name)} /> ); })}
{ setOpenAccordion(openAccordion === CategoryAccordion.NAVY_UNIT ? CategoryAccordion.NONE : CategoryAccordion.NAVY_UNIT); setSelectedRole(null); setSelectedType(null); }} >
{types.navyunit.sort().map((type) => { return (
{ selectedType === type ? setSelectedType(null) : setSelectedType(type); }} > {type}
); })}
{filteredBlueprints .filter((blueprint) => blueprint.category === "navyunit") .map((blueprint) => { return ( setBlueprint(blueprint)} showCost={showCost} cost={getApp().getUnitsManager().getDatabase().getSpawnPointsByName(blueprint.name)} /> ); })}
{ setOpenAccordion(openAccordion === CategoryAccordion.EFFECT ? CategoryAccordion.NONE : CategoryAccordion.EFFECT); setSelectedRole(null); setSelectedType(null); }} >
{ setEffect("explosion"); }} /> { setEffect("smoke"); }} />
)}
); }