Class: Entity::OwnedEntity
- Defined in:
- lib/game_2d/entity/owned_entity.rb
Constant Summary
Constants included from EntityConstants
EntityConstants::CELL_WIDTH_IN_PIXELS, EntityConstants::MAX_VELOCITY, EntityConstants::PIXEL_WIDTH, EntityConstants::WIDTH
Instance Attribute Summary collapse
-
#owner_id ⇒ Object
Returns the value of attribute owner_id.
Attributes inherited from Entity
#a, #moving, #space, #x, #x_vel, #y, #y_vel
Instance Method Summary collapse
- #all_state ⇒ Object
- #as_json ⇒ Object
- #owner ⇒ Object
- #owner=(new_owner) ⇒ Object
- #update_from_json(json) ⇒ Object
Methods inherited from Entity
#accelerate, #angle_to_vector, #bottom_cell_y, bottom_cell_y_at, #destroy!, #direction_to, #doomed?, #draw, #draw_zorder, #drop_diagonal, #empty_above?, #empty_on_left?, #empty_on_right?, #empty_underneath?, #entities_obstructing, #going_past_entity, #harmed_by, #i_hit, #image_filename, #initialize, #left_cell_x, left_cell_x_at, #move, #move_x, #move_y, #moving?, #next_to, #occupied_cells, #opaque, #pixel_x, #pixel_y, #right_cell_x, right_cell_x_at, #should_fall?, #sleep_now?, #to_s, #top_cell_y, top_cell_y_at, #transparent_to_me?, #update, #vector_to_angle, #wake!, #warp
Methods included from Registerable
#nullsafe_registry_id, #registry_id, #registry_id=, #registry_id?, #registry_id_safe
Methods included from Serializable
#<=>, #==, as_json, #eql?, from_json, #hash, #to_json, #to_s
Constructor Details
This class inherits a constructor from Entity
Instance Attribute Details
#owner_id ⇒ Object
Returns the value of attribute owner_id.
6 7 8 |
# File 'lib/game_2d/entity/owned_entity.rb', line 6 def owner_id @owner_id end |
Instance Method Details
#all_state ⇒ Object
21 |
# File 'lib/game_2d/entity/owned_entity.rb', line 21 def all_state; super.push(owner_id); end |
#as_json ⇒ Object
22 |
# File 'lib/game_2d/entity/owned_entity.rb', line 22 def as_json; super.merge! :owner => owner_id; end |
#owner ⇒ Object
12 13 14 15 |
# File 'lib/game_2d/entity/owned_entity.rb', line 12 def owner fail "Can't look up owner when not in a space" unless @space @space[@owner_id] end |
#owner=(new_owner) ⇒ Object
17 18 19 |
# File 'lib/game_2d/entity/owned_entity.rb', line 17 def owner=(new_owner) self.owner_id = new_owner.nullsafe_registry_id end |
#update_from_json(json) ⇒ Object
23 24 25 26 |
# File 'lib/game_2d/entity/owned_entity.rb', line 23 def update_from_json(json) self.owner_id = json[:owner] super end |