Class: Things
- Inherits:
-
DecodedLump
- Object
- Lump
- DecodedLump
- Things
- Defined in:
- lib/ruby-doom.rb
Constant Summary collapse
- BYTES_EACH =
10
- NAME =
"THINGS"
Instance Attribute Summary
Attributes inherited from DecodedLump
Attributes inherited from Lump
Instance Method Summary collapse
- #add_barrel(p) ⇒ Object
- #add_commando(p) ⇒ Object
- #add_imp(p) ⇒ Object
- #add_player(p) ⇒ Object
- #add_sergeant(p) ⇒ Object
- #add_shotgun(p) ⇒ Object
-
#initialize ⇒ Things
constructor
A new instance of Things.
- #player ⇒ Object
- #read(bytes) ⇒ Object
- #size ⇒ Object
Methods inherited from DecodedLump
Constructor Details
Instance Method Details
#add_barrel(p) ⇒ Object
533 534 535 |
# File 'lib/ruby-doom.rb', line 533 def (p) items << Thing.new(p, Dictionary.get.thing_for_name("Barrel").id) end |
#add_commando(p) ⇒ Object
530 531 532 |
# File 'lib/ruby-doom.rb', line 530 def add_commando(p) items << Thing.new(p, Dictionary.get.thing_for_name("Commando").id) end |
#add_imp(p) ⇒ Object
539 540 541 |
# File 'lib/ruby-doom.rb', line 539 def add_imp(p) items << Thing.new(p, Dictionary.get.thing_for_name("Imp").id) end |
#add_player(p) ⇒ Object
542 543 544 |
# File 'lib/ruby-doom.rb', line 542 def add_player(p) items << Thing.new(p, Dictionary.get.thing_for_name("Player 1").id) end |
#add_sergeant(p) ⇒ Object
527 528 529 |
# File 'lib/ruby-doom.rb', line 527 def add_sergeant(p) items << Thing.new(p, Dictionary.get.thing_for_name("Sergeant").id) end |
#add_shotgun(p) ⇒ Object
536 537 538 |
# File 'lib/ruby-doom.rb', line 536 def add_shotgun(p) items << Thing.new(p, Dictionary.get.thing_for_name("Shotgun").id) end |
#player ⇒ Object
545 546 547 |
# File 'lib/ruby-doom.rb', line 545 def player @items.find {|t| t.type_id == Dictionary.get.thing_for_name("Player 1").id} end |
#read(bytes) ⇒ Object
517 518 519 520 521 522 523 |
# File 'lib/ruby-doom.rb', line 517 def read(bytes) (bytes.size / BYTES_EACH).times {|index| thing = Thing.new thing.read(bytes.slice(index*BYTES_EACH, BYTES_EACH)) @items << thing } end |
#size ⇒ Object
524 525 526 |
# File 'lib/ruby-doom.rb', line 524 def size @items.size * BYTES_EACH end |