Class: GameMachine::GameSystems::EntityTracking
- Inherits:
-
Actor::Base
- Object
- JavaLib::GameActor
- Actor::Base
- GameMachine::GameSystems::EntityTracking
- Includes:
- Commands
- Defined in:
- lib/game_machine/game_systems/entity_tracking.rb
Overview
Note:
Handles player location tracking and neighbor requests. The client must explicitly send a TrackEntit component to the server to be tracked, it doesn’t happen automatically.
Constant Summary collapse
- EXTRA =
java.util.concurrent.ConcurrentHashMap.new
Constants inherited from Actor::Base
Instance Attribute Summary collapse
-
#aoe_grid ⇒ Object
readonly
Returns the value of attribute aoe_grid.
-
#extra_params ⇒ Object
readonly
Returns the value of attribute extra_params.
-
#grid ⇒ Object
readonly
Returns the value of attribute grid.
Instance Method Summary collapse
Methods included from Commands
Methods inherited from Actor::Base
aspect, aspects, find, find_by_address, find_distributed, find_distributed_local, find_remote, hashring, local_path, model_filter, #onReceive, player_controller, #receive_message, #schedule_message, #sender, set_player_controller
Instance Attribute Details
#aoe_grid ⇒ Object (readonly)
Returns the value of attribute aoe_grid.
18 19 20 |
# File 'lib/game_machine/game_systems/entity_tracking.rb', line 18 def aoe_grid @aoe_grid end |
#extra_params ⇒ Object (readonly)
Returns the value of attribute extra_params.
18 19 20 |
# File 'lib/game_machine/game_systems/entity_tracking.rb', line 18 def extra_params @extra_params end |
#grid ⇒ Object (readonly)
Returns the value of attribute grid.
18 19 20 |
# File 'lib/game_machine/game_systems/entity_tracking.rb', line 18 def grid @grid end |
Instance Method Details
#on_receive(message) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/game_machine/game_systems/entity_tracking.rb', line 30 def on_receive() if .is_a?(MessageLib::Entity) if .get_neighbors send_neighbors() end # If a tracking handler is defined, it must return true to have # the player location saved if .track_entity #GameMachine.logger.info "#{message.player.id} tracked" if @tracking_handler && .entity_type == 'player' if @tracking_handler.verify() set_entity_location() end else set_entity_location() end end elsif .is_a?(MessageLib::ClientManagerEvent) if .event == 'disconnected' @grid.remove(.player_id) @aoe_grid.remove(.player_id) EXTRA.delete(.player_id) GameMachine.logger.info "#{message.player_id} removed from grid" end else unhandled() end end |
#post_init ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/game_machine/game_systems/entity_tracking.rb', line 20 def post_init @entity_updates = [] @grid = Grid.find_or_create('default') @aoe_grid = Grid.find_or_create('aoe') @paths = {} @width = grid.get_width @cell_count = grid.get_cell_count commands.misc.client_manager_register(self.class.name) end |