ElixirQuake.Assets (elixir_quake v0.1.0)

Copy Markdown View Source

The game's files, read once and shared by every process: the game directory, the palette and light table, the QuakeC program, and each map, model and sound the first time it is asked for.

{:ok, _} = ElixirQuake.Assets.load("/games/quake")
ElixirQuake.Assets.map("e1m1")
ElixirQuake.Assets.model("progs/player.mdl")

Everything is kept in :persistent_term; reading it copies nothing.

Summary

Functions

What load/1 read.

Open the game directory at path (its id1, or the directory holding one) and read its palette and light table.

Whether load/1 has run.

The map name (without maps/ or .bsp), as %{bsp:, entities:}, or nil when there is none.

The model file name, as %{kind:, data:, mins:, maxs:}: kind :alias (a Cauldron3D.Formats.Mdl), :sprite (a Cauldron3D.Formats.Spr), :brush (a map file's world, as %{bsp:, entities:}) or :missing.

A loose picture file such as gfx/complete.lmp, or nil.

The gfx.wad pictures, by lower-case name; conchars is the 128 by 128 font.

The QuakeC program, progs.dat. Raises ArgumentError when there is none.

The bytes of file name, or nil.

The sound name under sound/ as a TuningFork.Voice, or nil.

Quake's texture kinds by name: sky… is sky, split into a front layer (the left half, colour 0 see-through) and a back layer; *… is liquid; trigger… and clip… are hidden; everything else is solid.

Functions

get()

@spec get() :: map()

What load/1 read.

load(path)

@spec load(Path.t()) :: {:ok, map()} | {:error, term()}

Open the game directory at path (its id1, or the directory holding one) and read its palette and light table.

loaded?()

@spec loaded?() :: boolean()

Whether load/1 has run.

map(name)

@spec map(String.t()) :: map() | nil

The map name (without maps/ or .bsp), as %{bsp:, entities:}, or nil when there is none.

model(name)

@spec model(String.t()) :: map()

The model file name, as %{kind:, data:, mins:, maxs:}: kind :alias (a Cauldron3D.Formats.Mdl), :sprite (a Cauldron3D.Formats.Spr), :brush (a map file's world, as %{bsp:, entities:}) or :missing.

picture(name)

@spec picture(String.t()) :: Cauldron3D.Texture.t() | nil

A loose picture file such as gfx/complete.lmp, or nil.

pictures()

@spec pictures() :: %{required(String.t()) => Cauldron3D.Texture.t()}

The gfx.wad pictures, by lower-case name; conchars is the 128 by 128 font.

progs()

@spec progs() :: QuakeC.Progs.t()

The QuakeC program, progs.dat. Raises ArgumentError when there is none.

read(name)

@spec read(String.t()) :: binary() | nil

The bytes of file name, or nil.

sound(name)

@spec sound(String.t()) :: TuningFork.Voice.t() | nil

The sound name under sound/ as a TuningFork.Voice, or nil.

texture(name, mips)

@spec texture(String.t(), [Cauldron3D.Texture.t()]) :: map()

Quake's texture kinds by name: sky… is sky, split into a front layer (the left half, colour 0 see-through) and a back layer; *… is liquid; trigger… and clip… are hidden; everything else is solid.