Skip to content

LocalPlayers

namespace Griff.Runtime;
public sealed class LocalPlayers

The people playing at this one machine: two at one keyboard (one on WASD, one on the arrows), on two controllers, or one on the keyboard and one on a controller, each moving their own character. Something a PlayedBy names a player for answers to that player’s keys or controller (InputOf); everything else, menus included, answers to everyone.

With Auto, how many play (the most a scene’s Played Bys name) shares out what’s there: one player has everything; with no controller, two split the keyboard (Player 1 the left keys, Player 2 the right); with a controller for every player but the first, Player 1 has the keyboard and the others a controller each; with one for everyone, each has their own (and Player 1 the keyboard too). A player’s choice (Choose, or Swap) is kept with the player’s settings.

public int Playing { get; }

How many play in the running scene: the most a PlayedBy in it names (at least 1). Worked out as each frame starts.

public void Choose(int player, PlayerDevice device)

Has player player (1 to 4) play with device from now on, kept with the player’s settings.

public PlayerDevice Chosen(int player)

What player player (1 to 4) has chosen to play with; Auto until they choose.

public string Describe(int player, int playing)

What player player plays with, in words: “Left keys (WASD)”, “Right keys (arrows)”, “Keyboard”, “Gamepad 2”, “Keyboard and Gamepad 1”, or “Nothing” (not enough keys and controllers to go round).

public ValueTuple<KeySet, int> DeviceOf(int player, int playing)

What player player plays with, with playing people playing: which keys, and the platform’s number of their controller (-1 for none).

public IInput Input(int player)

The controls of player player with as many playing as the scene has (Playing).

public IInput Input(int player, int playing)

The controls of player player (1 to 4) with playing people playing: their keys and controller only. With one playing, Player 1’s are this machine’s whole Input.

public void ResetChoices()

Forgets every player’s choice: everyone back to Auto.

public void Swap(int a, int b, int playing)

Swaps what players a and b play with, as they are now with playing people playing: the one at the keyboard on the left side and the one on the controller change places.

public const int Max

The most people that can play at one machine.

public const string SaveKey

Where the players’ chosen devices are kept in SaveData.