Skip to content

Bumper

namespace Griff.Modules.PhysicsGames;
public sealed class Bumper : Component, IDrawEffect, IPlaytestReport

A pinball bumper, with no code: whatever touches it is knocked away hard, at Strength, as it flashes, pops, plays its Sound and scores its Points. A round one (a pop bumper) knocks things straight away from its middle; give it a Direction and it’s a slingshot kicker, knocking whatever touches its kicking side that way.

Its Message carries its points to a Counter keeping the score, and its Hits and Lit outputs are for a wire, a Counter or a Bar: a bumper that hurts a boss each time it’s hit. It knocks nothing while a Tilt covering it has tilted, or with its On unticked (a switch or a wire can turn it on and off); then it’s just a wall.

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

public Vector2 Direction { get; set; }

Which way it knocks things, in its own space (turned with it): (0, 0), the default, knocks them straight away from its middle, as a pop bumper does. Set it, e.g. (0.85, 0.5), for a slingshot kicker: it knocks only what touches its side facing that way, that way.

public Color FlashColor { get; set; }

The color its sprites flash as it’s hit; clear flashes none.

public float FlashTime { get; set; }

How long it stays lit (its Lit output on, its sprites flashed) after a hit, in seconds.

public int Hits { get; set; }

How many times it has knocked something away.

public string? Layers { get; set; }

The collision layers it knocks, e.g. “Ball”. Empty knocks any body (but flippers).

public bool Lit { get; }

True for a moment after each hit: for a light, a wire or a script.

public float LitFor { get; set; }

Seconds it stays lit for. Set by the game.

public string? Message { get; set; }

A message sent with Game.Send as it knocks something away, with its Points as its data.

public bool On { get; set; }

It knocks things away. Untick it (or turn it off with a switch or a wire into its Power) and it’s just a wall: no knock, no points.

public int Points { get; set; }

What a knock scores: the data its Message carries, for a Counter keeping the score. 0 sends the entity.

public float Pop { get; set; }

How much bigger it pops as it’s hit, springing back: 1.15 is a little pop, 1 none.

public float Recover { get; set; }

Seconds after a knock before it knocks again: a pop bumper’s moment to recover.

public float Resting { get; set; }

Seconds until it can knock again. Set by the game.

public string? Sound { get; set; }

A sound played as it knocks something, e.g. “Sounds/bumper.wav”.

public float Strength { get; set; }

How fast it sends what touches it off, in world units a second.

public Vector2 WorldDirection { get; }

The way it knocks things in the world, for a kicker (its Direction turned with it); zero for a pop bumper.

public void Flash()

Lights it up and plays its sound, as if hit, knocking nothing: a light show on the beat.

public override bool Uses(string property)
public event Action<Bumper, Entity>? Knocked

Raised as it knocks something away, with what it knocked.