Target
namespace Griff.Modules.PhysicsGames;
public sealed class Target : Component, IDrawEffect, IPlaytestReportA pinball target, with no code: the ball hitting it scores its Points and lights it up, and a drop target (Drops) falls out of the way. Once every target in its set (those inside the same entity) is lit, the set scores its CompletePoints and sends CompleteMessage, and they all come back up unlit ResetAfter seconds later.
Put it on a solid collider. Its Message carries its points to a Counter keeping the score; its Lit, Down and Hits outputs are for a wire or a Counter, and the set’s Complete Message for a Trigger (an extra ball, a ball save, a door opening). Hits softer than its MinHit (the ball barely touching it) don’t count, and none count while a Tilt covering it has tilted. Unlit, its sprites are drawn darker; down, faint.
This is a component: its saved properties are on its component page.
Properties
Section titled “Properties”CompleteMessage
Section titled “CompleteMessage”public string? CompleteMessage { get; set; }A message sent as every target in its set is lit, with the set’s points as its data, e.g. “Score”.
CompletePoints
Section titled “CompletePoints”public int CompletePoints { get; set; }What lighting every target in its set (those inside the same entity) scores, as the data of its Complete Message.
public bool Down { get; set; }True while a drop target lies down out of the way.
public bool Drops { get; set; }A drop target: hit, it falls out of the way (nothing bumps into it) until its set comes back up.
public int Hits { get; set; }How many times it’s been hit.
Layers
Section titled “Layers”public string? Layers { get; set; }The collision layers that hit it, e.g. “Ball”. Empty is any body (but flippers).
public bool Lit { get; set; }True once it’s been hit, until its set comes back up (or its Reset action).
Message
Section titled “Message”public string? Message { get; set; }A message sent with Game.Send as it’s hit, with its Points as its data.
MinHit
Section titled “MinHit”public float MinHit { get; set; }How hard the ball has to hit it to count (a ball of Mass 1 at 2 units a second hits 2).
Points
Section titled “Points”public int Points { get; set; }What a hit scores: the data its Message carries. 0 sends the entity.
ResetAfter
Section titled “ResetAfter”public float ResetAfter { get; set; }Seconds after its set is complete before they all come back up unlit; 0 leaves them lit (until Reset).
ResetIn
Section titled “ResetIn”public float ResetIn { get; set; }Seconds until its set comes back up; 0 when it isn’t due to. Set by the game.
public string? Sound { get; set; }A sound played as it’s hit, e.g. “Sounds/target.wav”.
Methods
Section titled “Methods”public void Light()Lights it as if hit, scoring nothing (a set completed this way still scores).
public void Reset()Brings it back up, unlit.
public override bool Uses(string property)Events
Section titled “Events”public event Action<Target, Entity>? HitRaised as it’s hit, with what hit it.