Skip to content

Commander

namespace Griff.Modules.Strategy;
public sealed class Commander : Component, IWorldPlaced

The player’s strategy controls, on the camera: click or drag a box to select units, right-click to send them (to walk, attack, gather or build), hotkeys and the command card for everything else. It shows the team’s resources and supply, what’s selected, a minimap, and pans the camera with the arrow keys, the screen’s edges and the minimap, zooming with the mouse wheel.

Keys: A then click attacks-moves, S stops, H holds position, M then click moves, Esc cancels. Ctrl and a number keeps the selection as a group, the number picks it again. Shift adds to the selection, or queues up buildings to place. Double-click a unit to pick all of its kind on screen. It selects by the rules of Griff’s SelectionState (as SelectionControls does), with the same input actions: Select, Command, AddToSelection, AssignGroup and Group1 to Group9, which the player can rebind.

This is a component: its saved properties are on its component page.

public bool Controllable { get; set; }

Untick it to have the controls ignore the mouse and keys (selecting, orders, panning) while the game plays on: another part of the scene has the player’s input. Its Focus action ticks it and unticks it on everything else the player plays, and another’s Focus takes it back.

public string? DefeatPanel { get; set; }

A panel opened when the player’s team is beaten, e.g. “Defeat”.

public bool EdgeScroll { get; set; }

Whether resting the mouse at the screen’s edge pans the camera.

public bool Hud { get; set; }

Whether to show the resources bar, selection, command card and minimap.

public Box MapArea { get; }

The map in the world, from MapCenter and MapSize: the strategy game it commands is played here. Units and buildings outside it aren’t its (another commander’s, or no strategy game’s), and its fog of war covers only it.

public Vector2 MapCenter { get; set; }

The middle of the map, in world units. The camera, minimap and pathfinding stay within the map.

public Vector2 MapSize { get; set; }

How big the map is, in world units.

public float MaxZoom { get; set; }

The furthest the mouse wheel zooms out: the camera’s largest Size.

public float MinZoom { get; set; }

The closest the mouse wheel zooms in: the camera’s smallest Size.

public string? OrderSound { get; set; }

A sound played when the player gives an order, e.g. “Sounds/select.wav”.

public string? ReadySound { get; set; }

A sound played when something’s finished: a unit trained, a building up.

public float ScrollSpeed { get; set; }

How fast the camera pans, in world units per second.

public string? Team { get; set; }

The team the player commands: a Faction’s Team.

public string? VictoryPanel { get; set; }

A panel opened when every other team is beaten, e.g. “Victory”.