Skip to content

TurnTaker

namespace Griff.Scenes;
public sealed class TurnTaker : Component, ITeamMember

Takes turns in the TurnOrder that covers it: it acts only on its Team’s turn. Off its turn the player’s controls don’t reach it (nor scripts on it reading input) and its Patrol, Chase, Grid Chase, Grid Patrol, Attack and Shooter hold still; it still falls, gets pushed and gets hurt. Give it Actions to limit what it does in a turn: each attack swing, each shot and each step of its Grid Movement uses one, and once every turn taker on a team has used theirs (and their swings have landed), the turn passes. With actions, a Grid Chase or Grid Patrol steps once an action and passes when it has nowhere to go or nothing to swing at, and a Grid Patrol waits whole turns.

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

public int Actions { get; set; }

How many actions it gets each turn: attack swings, shots, grid steps, or Act from a script. Once it has used them it waits for its next turn. 0 has no limit, so its team’s turn ends some other way.

public int ActionsLeft { get; }

How many actions it has left this turn; -1 with no limit.

public int ActionsUsed { get; set; }

How many of its actions it has used this turn. The game sets it back to 0 as each of its team’s turns starts.

public bool IsTurn { get; }

True while it can act: it’s its team’s turn and it has actions left. The game keeps it up to date.

public string? Side { get; set; }

What Team was called before every genre’s teams were one idea. Kept for scripts.

public string? Team { get; set; }

The team it acts for, one of its turn order’s Teams, e.g. “Player”: the team it’s on in every genre (see Teams). Empty takes the team of a Team on it or the entity it’s inside. In a network game with teams, a player’s character is on its player’s team instead.

public bool Act(int count = 1)

Uses count of its actions, for something a script does (a spell, a move). False, using none, if it isn’t its turn or it doesn’t have that many left.

public static TurnTaker? Of(Entity entity)

The turn taker entity acts for: its own, or the nearest above it (a sword’s hitbox).

public event Action<TurnTaker>? TurnEnded

Raised as its team’s turn ends.

public event Action<TurnTaker>? TurnStarted

Raised as its team’s turn starts.