54 lines
1.6 KiB
C#
54 lines
1.6 KiB
C#
|
using AirBomber.MovementStrategy;
|
|||
|
using AirBomber.Rendering;
|
|||
|
|
|||
|
namespace AirBomber.Generics
|
|||
|
{
|
|||
|
internal class EntitiesGenericStorage
|
|||
|
{
|
|||
|
readonly Dictionary<string, EntitiesGenericCollection<BomberRendererBase, ObjectEntityRenderer>> _entityStorages;
|
|||
|
|
|||
|
public List<string> Keys => _entityStorages.Keys.ToList();
|
|||
|
|
|||
|
private readonly int _pictureWidth;
|
|||
|
private readonly int _pictureHeight;
|
|||
|
|
|||
|
public EntitiesGenericStorage(int PictureWidth, int PictureHeight)
|
|||
|
{
|
|||
|
_entityStorages = new Dictionary<string, EntitiesGenericCollection<BomberRendererBase, ObjectEntityRenderer>>();
|
|||
|
|
|||
|
_pictureWidth = PictureWidth;
|
|||
|
_pictureHeight = PictureHeight;
|
|||
|
}
|
|||
|
|
|||
|
public void AddSet(string Name)
|
|||
|
{
|
|||
|
var NewCollection =
|
|||
|
new EntitiesGenericCollection<BomberRendererBase, ObjectEntityRenderer>(_pictureWidth, _pictureHeight);
|
|||
|
|
|||
|
if (Keys.Contains(Name))
|
|||
|
{
|
|||
|
MessageBox.Show("Набор с таким именем уже существует", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
_entityStorages.Add(Name, NewCollection);
|
|||
|
}
|
|||
|
|
|||
|
public void RemoveSet(string Name)
|
|||
|
{
|
|||
|
_entityStorages.Remove(Name);
|
|||
|
}
|
|||
|
|
|||
|
public EntitiesGenericCollection<BomberRendererBase, ObjectEntityRenderer>? this[string Index]
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
if (!_entityStorages.ContainsKey(Index))
|
|||
|
return null;
|
|||
|
|
|||
|
return _entityStorages[Index];
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|