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



756
757
758
# File 'documented/gemstone/creature.rb', line 756

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

.all ⇒ Object

Get all creature instances



833
834
835
# File 'documented/gemstone/creature.rb', line 833

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.



818
819
820
# File 'documented/gemstone/creature.rb', line 818

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

.clear ⇒ Object

Clear all instances



804
805
806
# File 'documented/gemstone/creature.rb', line 804

def self.clear
  CreatureInstance.clear
end

.clear_room ⇒ void

This method returns an undefined value.

Empties the current room roster.



779
780
781
# File 'documented/gemstone/creature.rb', line 779

def self.clear_room
  CreatureInstance.clear_room
end

.configure(**options) ⇒ Object

Configure the system



789
790
791
# File 'documented/gemstone/creature.rb', line 789

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

.damage_report(**options) ⇒ Object

Generate damage report for HP analysis



823
824
825
# File 'documented/gemstone/creature.rb', line 823

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.



751
752
753
# File 'documented/gemstone/creature.rb', line 751

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:



772
773
774
# File 'documented/gemstone/creature.rb', line 772

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

Print formatted damage report



828
829
830
# File 'documented/gemstone/creature.rb', line 828

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

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

Register a new creature



784
785
786
# File 'documented/gemstone/creature.rb', line 784

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

.stats ⇒ Object

Get registry stats



794
795
796
797
798
799
800
801
# File 'documented/gemstone/creature.rb', line 794

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:



764
765
766
# File 'documented/gemstone/creature.rb', line 764

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