# `QuakeServer.Physics`
[🔗](https://github.com/jaman/quake_server/blob/v0.1.0/lib/quake_server/physics.ex#L1)

One physics frame of a level, as FTE's server runs it (`sv_phys.c`): the program's
`StartFrame`, then every entity by its move type (`WPhys_RunEntity`), then `EndFrame`,
and the clock moved on by the frame.

    server = QuakeServer.Physics.frame(server)

The program's `time` is the frame's start for everything run in it, and its end for
`EndFrame`. An entity whose `customphysics` holds a function has that run instead of
its move type. A player whose commands the program runs itself
(`QuakeServer.Physics.Command`) is left out: its commands move it. Any other player
runs its command (`QuakeServer.Player`), then `PlayerPreThink`, its move, and
`PlayerPostThink`. After each entity, the missile it may have spawned (`newmis`) runs
at once, for a twentieth of a second.

# `check_velocity`

```elixir
@spec check_velocity(QuakeServer.Server.t(), non_neg_integer()) ::
  QuakeServer.Server.t()
```

Bound `entity`'s velocity to the length `sv_maxvelocity` (`WPhys_CheckVelocity`).

# `frame`

```elixir
@spec frame(QuakeServer.Server.t()) :: QuakeServer.Server.t()
```

Run `server`'s entities for one frame of `server.frametime` seconds and move its clock on.

# `impact`

```elixir
@spec impact(QuakeServer.Server.t(), non_neg_integer(), map()) ::
  QuakeServer.Server.t()
```

Run the touches of two entities that have met, from `trace`.

# `independent`

```elixir
@spec independent(QuakeServer.Server.t(), non_neg_integer()) :: QuakeServer.Server.t()
```

Mark player `entity` as running its own commands.

# `independent?`

```elixir
@spec independent?(QuakeServer.Server.t(), non_neg_integer()) :: boolean()
```

Whether player `entity` runs its own commands (`QuakeServer.Physics.Command`), so a frame leaves it out.

# `run_entity`

```elixir
@spec run_entity(QuakeServer.Server.t(), non_neg_integer()) :: QuakeServer.Server.t()
```

Run `entity` for the frame by its move type (`WPhys_RunEntity`).

# `run_newmis`

```elixir
@spec run_newmis(QuakeServer.Server.t()) :: QuakeServer.Server.t()
```

Run the missile the program last spawned (`newmis`), for a twentieth of a second, and clear `newmis`.

# `step_size`

```elixir
@spec step_size(QuakeServer.Server.t()) :: float()
```

The height of a step, FTE's `movevars.stepheight`: the cvar `pm_stepheight`, or 18 while it is empty.

# `think`

```elixir
@spec think(QuakeServer.Server.t(), non_neg_integer()) ::
  {QuakeServer.Server.t(), boolean()}
```

Run `entity`'s think if it is due before the frame ends, at the time it was due (the
frame's start when that has passed), again while it sets a later `nextthink` still due
this frame and the cvar `sv_gameplayfix_multiplethinks` is on (`WPhys_RunThink`).
Returns `{server, still_there?}`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
