Skip to content
This repository has been archived by the owner on Sep 18, 2022. It is now read-only.

Commit

Permalink
Added texture set
Browse files Browse the repository at this point in the history
  • Loading branch information
craftersmine committed Mar 4, 2019
1 parent c0ff13a commit ae966c0
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
71 changes: 71 additions & 0 deletions craftersmine.EtherEngine.Content/TextureSet.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace craftersmine.EtherEngine.Content
{
/// <summary>
/// Represents texture set. This class cannot be inherited
/// </summary>
public sealed class TextureSet
{
private Dictionary<string, Texture> _textures = new Dictionary<string, Texture>();

/// <summary>
/// Creates new <see cref="TextureSet"/> instance
/// </summary>
public TextureSet()
{

}

/// <summary>
/// Tries to add texture in set and returns true if success, otherwise false
/// </summary>
/// <param name="id">Texture id</param>
/// <param name="texture">Texture</param>
/// <returns></returns>
public bool AddTexture(string id, Texture texture)
{
if (!_textures.ContainsKey(id))
{
_textures.Add(id, texture);
return true;
}
else return false;
}

/// <summary>
/// Tries to remove texture from set and returns true if success, otherwise false
/// </summary>
/// <param name="id">Id of removing texture</param>
/// <returns></returns>
public bool RemoveTexture(string id)
{
if (_textures.ContainsKey(id))
{
_textures.Remove(id);
return true;
}
else return false;
}

/// <summary>
/// Tries to existing texture in set with another one and returns true if success, otherwise false
/// </summary>
/// <param name="id">Replacing texture id</param>
/// <param name="newTexture">New texture</param>
/// <returns></returns>
public bool ChangeTexture(string id, Texture newTexture)
{
if (_textures.ContainsKey(id))
{
_textures[id] = newTexture;
return true;
}
else return false;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Texture.cs" />
<Compile Include="TextureAtlas.cs" />
<Compile Include="TextureSet.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

0 comments on commit ae966c0

Please sign in to comment.