Class: Doom::Wad::TextureManager

Inherits:
Object
  • Object
show all
Defined in:
lib/doom/wad/texture.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(wad) ⇒ TextureManager



86
87
88
89
90
91
92
93
# File 'lib/doom/wad/texture.rb', line 86

def initialize(wad)
  @wad = wad
  result = Texture.load_all(wad)
  @textures = result[:textures]
  @pnames = result[:pnames]
  @patches = {}
  @composite_cache = {}
end

Instance Attribute Details

#patchesObject (readonly)

Returns the value of attribute patches.



84
85
86
# File 'lib/doom/wad/texture.rb', line 84

def patches
  @patches
end

#pnamesObject (readonly)

Returns the value of attribute pnames.



84
85
86
# File 'lib/doom/wad/texture.rb', line 84

def pnames
  @pnames
end

#texturesObject (readonly)

Returns the value of attribute textures.



84
85
86
# File 'lib/doom/wad/texture.rb', line 84

def textures
  @textures
end

Instance Method Details

#[](name) ⇒ Object



95
96
97
98
99
# File 'lib/doom/wad/texture.rb', line 95

def [](name)
  return nil if name.nil? || name.empty? || name == '-'

  @composite_cache[name] ||= build_composite(name.upcase)
end

#get_patch(index) ⇒ Object



101
102
103
104
105
106
# File 'lib/doom/wad/texture.rb', line 101

def get_patch(index)
  name = @pnames[index]
  return nil unless name

  @patches[name] ||= Patch.load(@wad, name)
end