More code added, EntityContainer switched to a LinkedList

This commit is contained in:
Youmu Konpaku
2022-10-18 20:14:36 +08:00
parent c3ff7cbb5c
commit 01de763a28
81 changed files with 2322343 additions and 30 deletions
@@ -1,5 +1,4 @@
using StgSharp_Entity;
using StgSharp_Game;
using StgSharp_Game;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -8,16 +7,16 @@ using System.Threading.Tasks;
namespace StgSharp_Logic
{
public class EntityContainer<T>
public class EntityContainer
{
readonly int _limit;
private Counter<int> _limit;
private float _leftBorder;
private float _rightBorder;
private float _topBorder;
private float _bottomBorder;
private T[] _container;
private LinkedList _container;
public T[] Container
public LinkedList Container
{
get { return _container; }
set { _container = value; }
@@ -43,41 +42,48 @@ namespace StgSharp_Logic
get { return _bottomBorder; }
set { _bottomBorder = value; }
}
public EntityContainer(T sample)
{
_limit = 2048;
this.Container = new T[_limit];
}
public void Add(T target)
public EntityContainer(Counter<int> counter)
{
for (int i = 0; i < _limit; i++)
this._limit = counter;
this.Container = new LinkedList(_limit);
}
public void Add(LinkedTarget target)
{
if (true)
{
if (Container[i].Equals(default(T)))
{
Container[i] = target;
}
}
_container.Add(target);
}
public void Remove(int id)
public void RemoveAt(int id)
{
Container[id] = default(T);
_container.Remove(id);
}
//Move an entity from one container to another one
public void Move(T target, EntityContainer<T> targetContainer)
public void Move(LinkedTarget target, EntityContainer targetContainer)
{
target.Previous = target.Next;
target.Next = target.Previous;
targetContainer.Add(target);
}
//What should a container do on each rendering frame
//This method should be overriden
public void OnRender()
{
//坐标刷新
//边界判定
//碰撞判定
}
public void ReportCapacity()
{
Console.WriteLine(_limit.Value);
}
}
}