struct

Flock::Cli::Field

Inherits Struct < Value < Object

A name:type field spec for component/resource generators. Maps a short type name to its Crystal type and a sensible default value (nil = no default, so the field is required).

Constants

TYPES = {"f32" => {"Float32", "0.0f32"}, "float" => {"Float32", "0.0f32"}, "float32" => {"Float32", "0.0f32"}, "f64" => {"Float64", "0.0"}, "float64" => {"Float64", "0.0"}, "i32" => {"Int32", "0"}, "int" => {"Int32", "0"}, "int32" => {"Int32", "0"}, "i64" => {"Int64", "0_i64"}, "u32" => {"UInt32", "0_u32"}, "bool" => {"Bool", "false"}, "str" => {"String", "\"\""}, "string" => {"String", "\"\""}, "vec2" => {"Flock::Vec2", "Flock::Vec2.new"}, "vec3" => {"Flock::Vec3", "Flock::Vec3.new"}, "color" => {"Flock::Color", "Flock::Color::WHITE"}, "entity" => {"Flock::Entity", nil}} of String => Tuple(String, String | ::Nil)

short name => {Crystal type, default value expression?}

Constructors

new(name : String, type : String, default : Nil | String)
Source
parse(spec : String) : Field
Source

Class methods

params(fields : Array(Field)) : String

Joined initialize parameter list, ordered required-first. Crystal forbids a parameter with a default value before one without, so no-default fields (e.g. entity) must lead regardless of the order the user listed them. Array#partition keeps each group stable.

Source

Instance methods

declaration

property dx : Float32

Source
default
Source
name
Source
param

@dx : Float32 = 0.0f32 (or @target : Flock::Entity when there's no default).

Source
type
Source