class GameEcs::Condition
Attributes
attr_conditions[R]
k[R]
Public Class Methods
new(k)
click to toggle source
# File lib/game_ecs/entity_store.rb, line 360 def initialize(k) @attr_conditions = {} @k = k end
Public Instance Methods
==(other)
click to toggle source
# File lib/game_ecs/entity_store.rb, line 365 def ==(other) @k == other.k && @attr_conditions.size == other.attr_conditions.size && @attr_conditions.all?{|ac,v| other.attr_conditions[ac] == v} end
Also aliased as: eql?
attrs_match?(id, comps)
click to toggle source
# File lib/game_ecs/entity_store.rb, line 379 def attrs_match?(id, comps) comp = comps[@k] @attr_conditions.all? do |name, cond| val = comp.send(name) if cond.respond_to? :call cond.call val else val == cond end end end
components()
click to toggle source
# File lib/game_ecs/entity_store.rb, line 375 def components @k end
hash()
click to toggle source
# File lib/game_ecs/entity_store.rb, line 371 def hash @_hash ||= @k.hash ^ @attr_conditions.hash end
merge_conditions(attrs)
click to toggle source
# File lib/game_ecs/entity_store.rb, line 391 def merge_conditions(attrs) @attr_conditions ||= {} @attr_conditions.merge! attrs end