Skip to content

Tilt

namespace Griff.Modules.PhysicsGames;
public sealed class Tilt : Component, IDrawable, IPlaytestReport

Nudging and tilting a pinball table, with no code: its NudgeAction bumps the table, giving every ball on it a small push (and shaking the view), but nudge too often in a short time and it warns, then tilts: the flippers drop and stay down and the bumpers, kickers, targets and lanes go dead until the ball drains.

Each nudge adds one to its Danger, which falls back by one every Settle seconds. A nudge that takes it past one warns (its WarningMessage, “DANGER” over the table); past Warnings plus one, it tilts. It covers what’s inside the entity its Within names (or stands in its area), or the whole scene. A Drain it covers puts it right as the ball drains; its Reset action does too.

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

public bool Controllable { get; set; }

Untick it to have it ignore the keys and gamepad (its actions and scripts still work). Its Focus action ticks it and unticks it on everything else the player plays.

public float Danger { get; set; }

How close it is to tilting: one for each recent nudge, falling back by one every Settle seconds.

public string? NudgeAction { get; set; }

The input action that nudges the table: “Nudge” is N, the up arrow or the gamepad’s B.

public Vector2 NudgeDirection { get; set; }

Which way a nudge pushes the balls, in the world: (0, 1) is up the table. Holding left or right as it’s nudged (the arrows, A and D, the stick) pushes them that way too.

public string? NudgeSound { get; set; }

A sound played with each nudge, e.g. “Sounds/thud.wav”.

public float NudgeStrength { get; set; }

How hard a nudge pushes each ball, in world units a second.

public int Nudges { get; set; }

How many times the table has been nudged.

public float Settle { get; set; }

Seconds for each nudge to wear off: nudges further apart than this never add up to a tilt.

public float Shake { get; set; }

How hard the view shakes with each nudge; 0 doesn’t shake it.

public bool ShowText { get; set; }

Shows “DANGER” over the table for a moment after a warning, and “TILT” while it’s tilted, at its position.

public Color TextColor { get; set; }

The color of its “DANGER” and “TILT”.

public float TextSize { get; set; }

How tall its “DANGER” and “TILT” are, in world units.

public string? TiltMessage { get; set; }

A message sent as it tilts, e.g. “Tilted”.

public string? TiltSound { get; set; }

A sound played as it tilts.

public bool Tilted { get; set; }

True once it has tilted, until the ball drains (or its Reset action).

public float WarningFor { get; set; }

Seconds “DANGER” still shows. Set by the game.

public string? WarningMessage { get; set; }

A message sent as it warns, with how many warnings it has given this ball as its data, e.g. “Danger”.

public string? WarningSound { get; set; }

A sound played as it warns.

public int Warnings { get; set; }

How many nudges close together only warn: the next tilts.

public string? Within { get; set; }

The table it covers, by an entity’s name: the balls, flippers, bumpers, targets and lanes inside it or standing in its area. Empty covers the whole scene.

public void Nudge()

Nudges the table: each ball gets a little push, and it’s one nudge nearer tilting.

public void Reset()

Puts it right: not tilted, and no nudges counting against it.

public void TiltNow()

Tilts it now: the flippers drop and the table goes dead until the ball drains.

public override bool Uses(string property)
public event Action<Tilt>? TiltedOver

Raised as it tilts.

public event Action<Tilt>? Warned

Raised as it warns.