Module: Lich::Gemstone::Creature

Extended by:
Common::CreatureFacade
Defined in:
documented/gemstone/creature.rb

Overview

Public Creature API for GemStone runtime creature tracking.

A thin facade: the surface shared with Lich::DragonRealms::Creature comes from Common::CreatureFacade, delegating to CreatureInstance, which mixes in the shared id-keyed registry, room roster and targets/in_room query methods from Common::CreatureBase. GemStone adds recycled-id handling on register and template counts in stats.

Class Method Summary collapse

Methods included from Common::CreatureFacade

[], all, cleanup_old, clear, clear_room, configure, debug_on, in_room, register, stats, targets

Class Method Details

.register(name, id, noun = nil) ⇒ CreatureInstance?

Register a new creature

A known id arriving under a different name is a recycled id: start a fresh instance so the previous creature's reported or inferred flags, statuses and damage don't carry over to it. Skipped when auto-registration is off, since no replacement would be created.

Parameters:

  • name (String, nil) —

    creature name from the room-objs link.

  • id (Integer, String) —

    server creature id.

  • noun (String, nil) (defaults to: nil) —

    creature noun.

Returns:

  • (CreatureInstance, nil) —

    the registered instance, or nil when auto-registration is disabled or the registry is full.



779
780
781
782
783
784
785
# File 'documented/gemstone/creature.rb', line 779

def self.register(name, id, noun = nil)
  existing = CreatureInstance[id]
  if existing && name && existing.name && existing.name != name && CreatureInstance.auto_register?
    CreatureInstance.forget(id)
  end
  super
end

.stats ⇒ Object

Get registry stats (the shared stats plus the bestiary template count).



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

def self.stats
  { instances: CreatureInstance.size, templates: CreatureTemplate.all.size }.merge(super)
end