Sha256: 72177a8400b90cf63ca9559923efc439f25b7e123626aebff689159291a7b2ae
Contents?: true
Size: 711 Bytes
Versions: 1
Compression:
Stored size: 711 Bytes
Contents
module Lotu class StalkerSystem < System def initialize(user, opts={}) super default_opts = { :stalk => [Actor], :ticks_per_update => 30 } opts = default_opts.merge!(opts) @ticks = 0 @ticks_per_update = opts[:ticks_per_update] @stalked = {} opts[:stalk].each do |type| @stalked[type] = 0 end end def update @ticks += 1 if @ticks >= @ticks_per_update @stalked.each_key do |type| @stalked[type] = ObjectSpace.each_object(type).count end @ticks = 0 end end def to_s @stalked.map do |type, count| "#{type}: #{count}" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lotu-0.1.15 | lib/lotu/systems/stalker_system.rb |