DropTarget
namespace Griff.Scenes;
public sealed class DropTarget : ComponentA place to drop Draggable things: a slot in an inventory, a card’s place on the table, a hole a puzzle piece fits, a bin. Something dropped on it that it Accepts lands in its middle, until it holds Capacity things. It lights up with HoverTint while something it would take is held over it.
Its shape is its collider’s, or its sprite’s if it has no collider. What rests with its middle inside that shape is on it, however it got there: dropped, placed there in the editor, or moved by a script.
This is a component: its saved properties are on its component page.
Properties
Section titled “Properties”Accepts
Section titled “Accepts”public string? Accepts { get; set; }The kinds of thing it takes (each a draggable’s Kind), separated by commas, e.g. “Red Gem, Blue Gem”. Empty takes anything.
AllFullMessage
Section titled “AllFullMessage”public string? AllFullMessage { get; set; }A message sent once every drop target with this same All Full Message is full (holds its Capacity, or something for a Capacity of 0), with this entity as its data: every piece in place, the puzzle solved. It’s sent again if they fill up again after one is emptied.
Capacity
Section titled “Capacity”public int Capacity { get; set; }How many things it holds at once; more are turned away. 0 holds any number: a bin, a discard pile.
Contents
Section titled “Contents”public IReadOnlyList<Entity> Contents { get; }What’s on it, in the order they arrived.
DropMessage
Section titled “DropMessage”public string? DropMessage { get; set; }A message sent with Game.Send when something lands on it, with this entity as its data.
HoverTint
Section titled “HoverTint”public Color HoverTint { get; set; }The color its sprite turns while something it would take is held over it. Transparent leaves it alone.
IsFull
Section titled “IsFull”public bool IsFull { get; }True when it holds its Capacity (or, with a Capacity of 0, anything at all).
public bool Snap { get; set; }True if things dropped on it move to its middle. Off, they stay where they’re let go on it: a play area.
public bool Swap { get; set; }True if dropping something on it while it’s full swaps them: what was on it goes where the dropped thing came from, as in an inventory. Only with a Capacity of 1.
TakeMessage
Section titled “TakeMessage”public string? TakeMessage { get; set; }A message sent with Game.Send when something is taken off it, with this entity as its data.
Methods
Section titled “Methods”AcceptsKind
Section titled “AcceptsKind”public bool AcceptsKind(string? kind)True if it takes things of kind kind (a draggable’s Kind).
Events
Section titled “Events”Received
Section titled “Received”public event Action<Entity>? ReceivedRaised when something lands on it.
public event Action<Entity>? TakenRaised when something is taken off it.