struct Godot::GroupQuery

Overview

============================================================================= Fluent Group Query DSL

Zero-allocation stack struct providing clean, chainable group queries:

# 1. Iterate with typed receiver:
group(:enemies).each(as: Enemy) do |enemy|
  enemy.take_damage(50)
end

# 2. Collect as typed or untyped array:
enemies = group(:enemies).to_a(as: Enemy)

# 3. Fetch first member:
boss = group(:boss).first(as: Boss)

# 4. Broadcast / call_group:
group(:enemies).call("alert", player.global_position)

# 5. Metrics and predicates:
count = group(:loot).size
is_empty = group(:enemies).empty?

Defined in:

libgodot/extensions/query.cr

Constructors

Instance Method Summary

Instance methods inherited from class Object

try?(&)
try?
try?

Constructor Detail

def self.new(name : String | Symbol, node : Node | Nil = nil) #

Instance Method Detail

def any? : Bool #

Returns true if the group contains any nodes


def call(method_name : String | Symbol, *args) : Void #

Broadcasts a method call with optional arguments to every node in the group


def each(as type : T.class, &block : T -> Void) : Void forall T #

Iterates through each node in this group cast to type T


def each(&block : Godot::Node -> Void) : Void #

Iterates through each node in this group as Godot::Node


def empty? : Bool #

Returns true if the group contains no nodes


def first(as type : T.class) : T | Nil forall T #

Returns the first node in this group cast to type T, or nil if none found


def first : Godot::Node | Nil #

Returns the first node in this group as Godot::Node, or nil if none found


def first!(as type : T.class) : T forall T #

Returns the first node in this group cast to type T, raising NodeNotFoundError if none found


def first! : Godot::Node #

Returns the first node in this group as Godot::Node, raising NodeNotFoundError if none found


def first?(as type : T.class) : T | Nil forall T #

Returns the first node in this group cast to type T, or nil if none found


def first? : Godot::Node | Nil #

Returns the first node in this group as Godot::Node, or nil if none found


def name : String #

def node : Node | Nil #

def size : Int32 #

Returns the count of nodes in this group


def to_a(as type : T.class) : Array(T) forall T #

Returns all nodes in this group cast to type T


def to_a : Array(Godot::Node) #

Returns all nodes in this group as Array(Godot::Node)