84 lines
1.9 KiB
C#
84 lines
1.9 KiB
C#
using StgSharp_Entity;
|
|
using StgSharp_Game;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace StgSharp_Logic
|
|
{
|
|
public class EntityContainer<T>
|
|
{
|
|
readonly int _limit;
|
|
private float _leftBorder;
|
|
private float _rightBorder;
|
|
private float _topBorder;
|
|
private float _bottomBorder;
|
|
private T[] _container;
|
|
|
|
public T[] Container
|
|
{
|
|
get { return _container; }
|
|
set { _container = value; }
|
|
}
|
|
|
|
public float LeftBorder
|
|
{
|
|
get { return _leftBorder; }
|
|
set { _leftBorder = value; }
|
|
}
|
|
public float RightBorder
|
|
{
|
|
get { return _rightBorder; }
|
|
set { _rightBorder = value; }
|
|
}
|
|
public float TopBorder
|
|
{
|
|
get { return _topBorder; }
|
|
set { _topBorder = value; }
|
|
}
|
|
public float BottomBorder
|
|
{
|
|
get { return _bottomBorder; }
|
|
set { _bottomBorder = value; }
|
|
}
|
|
|
|
public EntityContainer(T sample)
|
|
{
|
|
_limit = 2048;
|
|
this.Container = new T[_limit];
|
|
}
|
|
|
|
|
|
|
|
public void Add(T target)
|
|
{
|
|
for (int i = 0; i < _limit; i++)
|
|
{
|
|
if (Container[i].Equals(default(T)))
|
|
{
|
|
Container[i] = target;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void Remove(int id)
|
|
{
|
|
Container[id] = default(T);
|
|
}
|
|
|
|
//Move an entity from one container to another one
|
|
public void Move(T target, EntityContainer<T> targetContainer)
|
|
{
|
|
targetContainer.Add(target);
|
|
}
|
|
|
|
//What should a container do on each rendering frame
|
|
//This method should be overriden
|
|
public void OnRender()
|
|
{
|
|
}
|
|
}
|
|
}
|