Module: Omega::Server::CommandHelpers
- Included in:
- Manufactured::Commands::Attack, Manufactured::Commands::Construction, Manufactured::Commands::Mining, Manufactured::Commands::ShieldRefresh
- Defined in:
- lib/omega/server/command.rb
Overview
Convencience methods which commands may include to simplify operations
Instance Method Summary collapse
-
#invoke(*args) ⇒ Object
invoke a command via the node.
-
#retrieve(entity_id) ⇒ Object
retrieve entity from registry.
-
#run_callbacks(entity, *args) ⇒ Object
run callbacks with args on the registry entity.
-
#update_registry(entity) ⇒ Object
update entity in registry.
Instance Method Details
#invoke(*args) ⇒ Object
invoke a command via the node
163 164 165 |
# File 'lib/omega/server/command.rb', line 163 def invoke(*args) node.invoke *args end |
#retrieve(entity_id) ⇒ Object
retrieve entity from registry
150 151 152 |
# File 'lib/omega/server/command.rb', line 150 def retrieve(entity_id) registry.entity { |e| e.respond_to?(:id) && e.id == entity_id } end |
#run_callbacks(entity, *args) ⇒ Object
run callbacks with args on the registry entity
155 156 157 158 159 160 |
# File 'lib/omega/server/command.rb', line 155 def run_callbacks(entity, *args) registry.safe_exec { |entities| e = entities.find { |e| e.respond_to?(:id) && e.id == entity.id } e.run_callbacks *args } end |
#update_registry(entity) ⇒ Object
update entity in registry
145 146 147 |
# File 'lib/omega/server/command.rb', line 145 def update_registry(entity) registry.update(entity) { |e| e.respond_to?(:id) && e.id == entity.id } end |