API Reference › Reflect › Reflect.has
method

Reflect.has

Reflect.has(entity, prop) -> bool

Returns whether entity carries property prop. A generic walker checks it before reading a component's fields, so it visits only the components an entity actually has.

Parameters

entitythe entity to test
propa property id (from Reflect.prop)

Example

program Demo {
  property Health { hp: int = 0 }
  model Unit { Health }
  entry {
    spawn Unit { Health { hp: 7 } }
    if Reflect.has(0, Reflect.prop("Health")) { print(1) }
  }
}
← All symbols