One player's ship: its body, fuel, shield, lives and score, and what it is doing.
Positions are tiles; the ship turns through 64 headings. A dead ship keeps its place
in the game with alive? false and a respawn_in countdown among its timers/0.
Summary
Types
Where the ship is in a race: the next checkpoint, laps done, and whether it has finished?.
The ship's count: score, kills and deaths over the whole game, the round's
streak of kills without dying and its best_streak, seconds of contact with an
enemy and the round's best_contact, and what result/2 last recorded.
The ship's clocks, in the game's seconds: cooldown until it can fire, respawn_in
while dead, the *_until times its immunity, phasing, emergency shield, emergency
thrust and confusion end, and empty_since, when its tank ran dry, or nil.
Functions
Whether the ship has a life left to respawn with.
Credit a kill.
Mark the ship dead, counting the death and starting the respawn clock.
Fit the ship out with a kit: :fuel in the tank (the tank grows to hold it) and
:items as counts by kind, given as ExPilot.Items.pick_up/2 gives them.
The number of headings a ship turns through.
Whether action is held.
Another dt seconds alive with an enemy in contact: the current stretch, and the round's longest.
The heading a ship faces on a base with dir.
A full tank.
A new ship for id named name, resting on its base facing the way :dir says (:up by default).
Give the ship its lives back for a new round, keeping its score; the round's streak and contact start over.
The ship's position.
A ship's radius in tiles.
Put the ship back on its base with a full tank, alive.
The ship's result since the last one was taken — kills, deaths and score gained, the round's best streak of kills without dying and longest contact in seconds — and the ship with those taken as recorded.
How hard action is held, 0.0 to 1.0: what an analog control said, 1.0 for a key.
What another player sees of this ship.
The ship with one of its timers/0 set.
Types
@type race() :: %{ checkpoint: non_neg_integer(), laps: non_neg_integer(), finished?: boolean() }
Where the ship is in a race: the next checkpoint, laps done, and whether it has finished?.
@type t() :: %ExPilot.Ship{ aim: {number(), number()} | nil, alive?: boolean(), armour: non_neg_integer(), autopilot?: boolean(), ball: term(), base: {integer(), integer()}, body: Cauldron2D.Body.t(), cloaked?: boolean(), deflecting?: boolean(), fuel: float(), held: MapSet.t(atom()), held_before: MapSet.t(atom()), id: term(), items: %{required(atom()) => pos_integer()}, landed?: boolean(), launch_heading: non_neg_integer(), lives: integer() | :unlimited, max_fuel: float(), missile: :torpedo | :smart | :heat, name: String.t(), race: race(), robot?: boolean(), shape: String.t() | nil, shielding?: boolean(), strength: %{required(atom()) => float()}, tally: tally(), team: integer() | nil, thrusting?: boolean(), timers: timers(), watching: term() | nil }
@type tally() :: %{ score: integer(), kills: non_neg_integer(), deaths: non_neg_integer(), streak: non_neg_integer(), best_streak: non_neg_integer(), contact: float(), best_contact: float(), recorded: %{ kills: non_neg_integer(), deaths: non_neg_integer(), score: integer() } }
The ship's count: score, kills and deaths over the whole game, the round's
streak of kills without dying and its best_streak, seconds of contact with an
enemy and the round's best_contact, and what result/2 last recorded.
@type timers() :: %{ cooldown: float(), respawn_in: float(), immune_until: float(), phasing_until: float(), emergency_shield_until: float(), emergency_thrust_until: float(), ecm_until: float(), empty_since: float() | nil }
The ship's clocks, in the game's seconds: cooldown until it can fire, respawn_in
while dead, the *_until times its immunity, phasing, emergency shield, emergency
thrust and confusion end, and empty_since, when its tank ran dry, or nil.
Functions
Whether the ship has a life left to respawn with.
Credit a kill.
Mark the ship dead, counting the death and starting the respawn clock.
@spec equip(t(), %{fuel: float(), items: %{required(atom()) => non_neg_integer()}}) :: t()
Fit the ship out with a kit: :fuel in the tank (the tank grows to hold it) and
:items as counts by kind, given as ExPilot.Items.pick_up/2 gives them.
@spec headings() :: pos_integer()
The number of headings a ship turns through.
Whether action is held.
Another dt seconds alive with an enemy in contact: the current stretch, and the round's longest.
@spec launch_heading(:up | :down | :left | :right) :: non_neg_integer()
The heading a ship faces on a base with dir.
@spec max_fuel() :: float()
A full tank.
A new ship for id named name, resting on its base facing the way :dir says (:up by default).
Give the ship its lives back for a new round, keeping its score; the round's streak and contact start over.
@spec pos(t()) :: Cauldron2D.Body.point()
The ship's position.
@spec radius() :: float()
A ship's radius in tiles.
Put the ship back on its base with a full tank, alive.
The ship's result since the last one was taken — kills, deaths and score gained, the round's best streak of kills without dying and longest contact in seconds — and the ship with those taken as recorded.
How hard action is held, 0.0 to 1.0: what an analog control said, 1.0 for a key.
What another player sees of this ship.
The ship with one of its timers/0 set.