method
Reflect.get
Reflect.get(entity, prop, field) -> int
Reads the value of field field of property prop on entity, as an int. A fixed field comes back as its raw Q16.16 bits (the same integer fixed stores), so a generic reader can move it without interpreting it. Same as World.get, under the reflection namespace.
Parameters
entitythe entity to readpropa property id (from Reflect.prop)fielda field id (from Reflect.field)Example
program Demo {
property Health { hp: int = 0 }
model Unit { Health }
entry {
spawn Unit { Health { hp: 7 } }
let H = Reflect.prop("Health")
print(Reflect.get(0, H, Reflect.field(H, "hp"))) # 7
}
}