Module: Lich::Gemstone::Creature

Defined in:
documented/gemstone/creature.rb

Overview

Public Creature API for GemStone runtime creature tracking.

A thin facade: every call delegates to CreatureInstance, which mixes in the shared id-keyed registry, room roster and targets/in_room query methods from Common::CreatureBase.

Class Method Summary collapse

Class Method Details

.[](id) ⇒ Object

Lookup creature instance by ID



525
526
527
# File 'documented/gemstone/creature.rb', line 525

def self.[](id)
  CreatureInstance[id]
end

.allObject

Get all creature instances



602
603
604
# File 'documented/gemstone/creature.rb', line 602

def self.all
  CreatureInstance.all
end

.cleanup_old(max_age_seconds = 600) ⇒ Integer

Removes creatures older than the given age (in seconds).

Positional to match CreatureInstance#cleanup_old (supplied by Common::CreatureBase) and the positional call in Combat::Tracker#cleanup_creatures. A keyword-only signature here raised ArgumentError on every scheduled tracker cleanup, which the tracker's rescue then swallowed - so registry cleanup silently never ran.

Parameters:

  • max_age_seconds (Integer) (defaults to: 600)

    age cutoff in seconds.

Returns:

  • (Integer)

    number of instances removed.



587
588
589
# File 'documented/gemstone/creature.rb', line 587

def self.cleanup_old(max_age_seconds = 600)
  CreatureInstance.cleanup_old(max_age_seconds)
end

.clearObject

Clear all instances



573
574
575
# File 'documented/gemstone/creature.rb', line 573

def self.clear
  CreatureInstance.clear
end

.clear_roomvoid

This method returns an undefined value.

Empties the current room roster.



548
549
550
# File 'documented/gemstone/creature.rb', line 548

def self.clear_room
  CreatureInstance.clear_room
end

.configure(**options) ⇒ Object

Configure the system



558
559
560
# File 'documented/gemstone/creature.rb', line 558

def self.configure(**options)
  CreatureInstance.configure(**options)
end

.damage_report(**options) ⇒ Object

Generate damage report for HP analysis



592
593
594
# File 'documented/gemstone/creature.rb', line 592

def self.damage_report(**options)
  CreatureInstance.damage_report(**options)
end

.debug_on(level = :changes) ⇒ Boolean, Symbol

Toggles live echo of status, flag, and registration changes.

Parameters:

  • level (Boolean, Symbol) (defaults to: :changes)

    false disables debug output; true or :changes reports changes only; :all reports every flag; :active reports only active flags.

Returns:

  • (Boolean, Symbol)

    the configured debug value.



520
521
522
# File 'documented/gemstone/creature.rb', line 520

def self.debug_on(level = :changes)
  $creature_debug = level
end

.in_room(*filters) ⇒ Array<CreatureInstance>

Returns all tracked creatures currently in the room.

Parameters:

  • filters (Array<String, Symbol>)

    optional ANDed status/classification filters.

Returns:



541
542
543
# File 'documented/gemstone/creature.rb', line 541

def self.in_room(*filters)
  CreatureInstance.in_room(*filters)
end

Print formatted damage report



597
598
599
# File 'documented/gemstone/creature.rb', line 597

def self.print_damage_report(**options)
  CreatureInstance.print_damage_report(**options)
end

.register(name, id, noun = nil) ⇒ Object

Register a new creature



553
554
555
# File 'documented/gemstone/creature.rb', line 553

def self.register(name, id, noun = nil)
  CreatureInstance.register(name, id, noun)
end

.statsObject

Get registry stats



563
564
565
566
567
568
569
570
# File 'documented/gemstone/creature.rb', line 563

def self.stats
  {
    instances: CreatureInstance.size,
    templates: CreatureTemplate.all.size,
    max_size: CreatureInstance.max_size,
    auto_register: CreatureInstance.auto_register?
  }
end

.targets(*filters) ⇒ Array<CreatureInstance>

Returns attackable hostile creatures currently in the room.

Parameters:

  • filters (Array<String, Symbol>)

    optional ANDed status/classification filters.

Returns:



533
534
535
# File 'documented/gemstone/creature.rb', line 533

def self.targets(*filters)
  CreatureInstance.targets(*filters)
end