Class: Linedef

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-doom.rb

Constant Summary collapse

FORMAT =
"sssssss"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(v1 = 0, v2 = 0, s = 0) ⇒ Linedef

Returns a new instance of Linedef.



592
593
594
595
596
597
598
599
# File 'lib/ruby-doom.rb', line 592

def initialize(v1=0,v2=0,s=0)
  @start_vertex=v1
  @end_vertex=v2
  @attributes=1
  @special_effects_type=0
  @right_sidedef=s
  @left_sidedef=-1
end

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



591
592
593
# File 'lib/ruby-doom.rb', line 591

def attributes
  @attributes
end

#end_vertexObject

Returns the value of attribute end_vertex.



591
592
593
# File 'lib/ruby-doom.rb', line 591

def end_vertex
  @end_vertex
end

#idObject

Returns the value of attribute id.



591
592
593
# File 'lib/ruby-doom.rb', line 591

def id
  @id
end

#left_sidedefObject

Returns the value of attribute left_sidedef.



591
592
593
# File 'lib/ruby-doom.rb', line 591

def left_sidedef
  @left_sidedef
end

#right_sidedefObject

Returns the value of attribute right_sidedef.



591
592
593
# File 'lib/ruby-doom.rb', line 591

def right_sidedef
  @right_sidedef
end

#special_effects_typeObject

Returns the value of attribute special_effects_type.



591
592
593
# File 'lib/ruby-doom.rb', line 591

def special_effects_type
  @special_effects_type
end

#start_vertexObject

Returns the value of attribute start_vertex.



591
592
593
# File 'lib/ruby-doom.rb', line 591

def start_vertex
  @start_vertex
end

Instance Method Details

#read(bytes) ⇒ Object



600
601
602
# File 'lib/ruby-doom.rb', line 600

def read(bytes)
  @start_vertex, @end_vertex, @attributes, @special_effects_type, @tag, @right_sidedef, @left_sidedef = Codec.decode(FORMAT, bytes)
end

#to_sObject



606
607
608
# File 'lib/ruby-doom.rb', line 606

def to_s
  "Linedef from " + @start_vertex.to_s + " to " + @end_vertex.to_s + "; attribute flag is " + @attributes.to_s + "; special fx is " + @special_effects_type.to_s + "; tag is " + @tag.to_s + "; right sidedef is " + @right_sidedef.to_s + "; left sidedef is " + @left_sidedef.to_s
end

#writeObject



603
604
605
# File 'lib/ruby-doom.rb', line 603

def write
  Codec.encode(FORMAT, [@start_vertex.id, @end_vertex.id, @attributes, @special_effects_type, @tag, @right_sidedef.id, -1])
end