dmlary / morrow

Ruby ECS-based MUD server
MIT License
4 stars 1 forks source link

Update System registry #22

Closed dmlary closed 4 years ago

dmlary commented 4 years ago

Implement two system approaches: block-based and class-based.

block-based not implementing this approach; makes it hard to test systems

World.register_system(:regen, all: [ HealthComponent, PositionComponent]) do |entity,health,pos|
   case pos.position
   when :standing
     health += 2
end

Class-based

class System::Regen < System::Base
  World.register_system(:regen, all: [HealthComponent, PositionComponent], handler: self)

  def update(entity, health, position)
    # ...
  end
end