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

Returns a new instance of TextureManager.



78
79
80
81
82
83
84
85
86
# File 'lib/doom/wad/texture.rb', line 78

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

Instance Attribute Details

#patchesObject (readonly)

Returns the value of attribute patches.



76
77
78
# File 'lib/doom/wad/texture.rb', line 76

def patches
  @patches
end

#pnamesObject (readonly)

Returns the value of attribute pnames.



76
77
78
# File 'lib/doom/wad/texture.rb', line 76

def pnames
  @pnames
end

#texture_namesObject (readonly)

Returns the value of attribute texture_names.



76
77
78
# File 'lib/doom/wad/texture.rb', line 76

def texture_names
  @texture_names
end

#texturesObject (readonly)

Returns the value of attribute textures.



76
77
78
# File 'lib/doom/wad/texture.rb', line 76

def textures
  @textures
end

Instance Method Details

#[](name) ⇒ Object



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

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

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

#get_patch(index) ⇒ Object



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

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

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