ComponentModel
namespace Griff.Scenes;
public sealed class ComponentModelWhat a component type exposes, worked out once per type: what’s saved (Saved), what anything can set off and read (Actions, Outputs), whether it takes input (Focus), the part of the world it covers (Area), what it sends in a network game (Sent), what tables and cards may set (Settable) and what agents read and set (Live, Saved). The serializer, the Inspector, triggers and wires, the network, tables, cards and the agent tools all ask this, so they can’t disagree about a component. Held only while its type is: a script compiled again leaves its old types to unload.
Properties
Section titled “Properties”Actions
Section titled “Actions”public IReadOnlyList<ComponentAction> Actions { get; }What it does that anything can set off (see ActionAttribute), base types’ first.
Category
Section titled “Category”public string? Category { get; }Where the editor’s catalog lists it, from CategoryAttribute; null if it doesn’t say.
public IReadOnlyList<PropertyInfo> Focus { get; }Its properties marked FocusAttribute: what says whether it takes the player’s input.
FormerNames
Section titled “FormerNames”public IReadOnlyList<string> FormerNames { get; }Names it was saved under before (see FormerNames).
HasArea
Section titled “HasArea”public bool HasArea { get; }True if it covers a part of the world (a property marked AreaAttribute).
public IReadOnlyList<PropertyInfo> Live { get; }What it says about itself while the game runs and doesn’t save, which agents read but don’t set: its other public values (Spawned, IsCollected, a beat clock’s Beat, one marked DoNotSerializeAttribute) as simple values. Lists and the like are left out.
public string Name { get; }The name written to scene files: its ComponentNameAttribute, or its full name.
NetLocal
Section titled “NetLocal”public bool NetLocal { get; }True if it’s marked NetLocalAttribute: each machine keeps its own, and nothing of its entity is sent.
Outputs
Section titled “Outputs”public IReadOnlyList<ComponentOutput> Outputs { get; }What it knows that anything can read (see OutputAttribute), base types’ first.
PlayerMovement
Section titled “PlayerMovement”public bool PlayerMovement { get; }True if it’s marked PlayerMovementAttribute: a player’s own machine moves it.
Requires
Section titled “Requires”public IReadOnlyList<ComponentLink> Requires { get; }Components it needs on the same entity, from RequiresAttribute.
Resizable
Section titled “Resizable”public ValueTuple<PropertyInfo, ResizableAttribute>? Resizable { get; }The size the Scene view’s handles resize: its first saved Vector2 marked ResizableAttribute (a button’s clickable area), or null for none.
public IReadOnlyList<PropertyDescriptor> Saved { get; }What’s saved: its public properties that can be read and set, but those marked DoNotSerializeAttribute, in declaration order (base class first). The Inspector shows these, agents set them and tables and cards set some.
public IReadOnlyList<SentProperty> Sent { get; }What a network game sends of it: its saved properties but those marked NotSentAttribute, then the others marked SentAttribute. A component that’s INetState may skip some and add its own.
Settable
Section titled “Settable”public IReadOnlyList<PropertyDescriptor> Settable { get; }What a table’s row (a TableValues) and a card’s effect may set: its saved properties that take a value from a table, a number, whole number, true or false, name, choice or color, or a list of those (a text cell split on commas and line breaks).
public Type Type { get; }Version
Section titled “Version”public int Version { get; }The version of its saved data, from ComponentVersionAttribute; 1 without one.
WorksWith
Section titled “WorksWith”public IReadOnlyList<ComponentLink> WorksWith { get; }Components it says it goes well with, from its own WorksWithAttributes.
Methods
Section titled “Methods”Method
Section titled “Method”public MethodInfo? Method(string name, params Type[] parameters)Its method called name taking parameters, public or not, static or not: what a field editor names by name (a text’s preview, a picture’s cells). Null for none.
public static ComponentModel Of(Type type)The model of type, worked out the first time it’s asked for.
public static ComponentModel Of(Component component)The model of component’s type.
Property
Section titled “Property”public PropertyInfo? Property(string name, StringComparison comparison = StringComparison.Ordinal)The property called name that can be read of it: a saved one (Saved), else one it says while the game runs (Live); null for neither. What an attribute names by name (a Unless, an On) is read through this.
RollsFor
Section titled “RollsFor”public PropertyInfo? RollsFor(string property)The name property marked RollsForAttributeproperty, or null.
SavedProperty
Section titled “SavedProperty”public PropertyDescriptor? SavedProperty(string name)The saved property called name (as in code), or null.
public static bool Takes(Type type)True if a table’s cell can set a property of type (see Settable).