Class: PathCompiler

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

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ PathCompiler

Returns a new instance of PathCompiler.



792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
# File 'lib/ruby-doom.rb', line 792

def initialize(path)
  @path = path
  @sectors = Sectors.new
  @sectors.add(Sector.new)
  @vertexes = Vertexes.new
  @vertexes.add(Vertex.new(@path.start))
  @path.visit(self)
  @sidedefs = Sidedefs.new
  @path.segment_count.times do |v|
    s = @sidedefs.add Sidedef.new
    s.sector_id = @sectors.items[0].id  
  end
  @linedefs = Linedefs.new
  last = nil
  @vertexes.items.each do |v|
    if last.nil?
      last = v
      next
    end
    @linedefs.add Linedef.new(last, v, @sidedefs.items[last.id])
    last = v
  end
  @linedefs.add(Linedef.new(@vertexes.items.last, @vertexes.items.first, @sidedefs.items.last))
end

Instance Method Details

#line_to(p) ⇒ Object



816
817
818
# File 'lib/ruby-doom.rb', line 816

def line_to(p)
  @vertexes.add(Vertex.new(p)) if (@vertexes.items.find {|x| x.location == p }).nil?
end

#lumpsObject



819
820
821
# File 'lib/ruby-doom.rb', line 819

def lumps
  [@vertexes, @sectors, @linedefs, @sidedefs]
end