2 using System.Collections.Generic;
3 using Microsoft.Xna.Framework.Graphics;
5 namespace Loot.Api.ModContent
14 protected Texture2D
GetFrom(IDictionary<string, Texture2D> dictionary,
string key)
16 return dictionary.TryGetValue(key, out var texture) ? texture : null;
21 return GetFrom(_textures, key);
24 protected void AddTo(IDictionary<string, Texture2D> dictionary,
string key, Texture2D texture)
26 if (dictionary.ContainsKey(key))
28 throw new Exception($
"Key '{key}' already present in ModContent");
31 ProcessTexture2D(ref texture);
32 dictionary.Add(key, texture);
37 AddTo(_textures, key, texture);
42 _textures =
new Dictionary<string, Texture2D>();
65 protected virtual void Load()
73 public abstract string GetRegistryKey();
IDictionary< string, Texture2D > _textures
Texture2D GetFrom(IDictionary< string, Texture2D > dictionary, string key)
Texture2D GetTexture(string key)
virtual void ProcessTexture2D(ref Texture2D texture)
void AddTexture(string key, Texture2D texture)
An abstract class that contains a mapping of strings to texture instances
virtual void Initialize()
void AddTo(IDictionary< string, Texture2D > dictionary, string key, Texture2D texture)