daily update on 20230525 by nitload youmu, ses00001 not solved
This commit is contained in:
@@ -1,48 +1,74 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data.SqlTypes;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp
|
||||
{
|
||||
public abstract class INode<T> where T : INode<T>
|
||||
{
|
||||
[NotNull]
|
||||
protected ContainerNode<T> _id;
|
||||
|
||||
[AllowNull]
|
||||
internal ContainerNode<T> ID { get; }
|
||||
|
||||
internal void setID(ContainerNode<T> id)
|
||||
internal ContainerNode<T> Previous
|
||||
{
|
||||
if (_id!=null)
|
||||
{
|
||||
throw new ArgumentException("Cannot set ID twice");
|
||||
}
|
||||
else
|
||||
{
|
||||
_id = id;
|
||||
}
|
||||
get { return _id._previous; }
|
||||
set { _id._previous = value; }
|
||||
}
|
||||
|
||||
internal ContainerNode<T> Next
|
||||
{
|
||||
get { return _id._next; }
|
||||
set { _id._next = value; }
|
||||
}
|
||||
|
||||
public INode()
|
||||
{
|
||||
_id = new ContainerNode<T>(this as T);
|
||||
}
|
||||
|
||||
internal void SetId(ContainerNode<T> tContainer)
|
||||
{
|
||||
_id = tContainer;
|
||||
}
|
||||
|
||||
internal void SelfDestrcut()
|
||||
{
|
||||
_id._previous._next = _id._next;
|
||||
_id._next._previous = _id._previous;
|
||||
this._id = default;
|
||||
_id._next = null;
|
||||
_id._previous = null;
|
||||
GC.Collect();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public class ContainerNode<T> where T : INode<T>
|
||||
public class ContainerNode<T> : INullable where T : INode<T>
|
||||
{
|
||||
internal readonly T _value;
|
||||
|
||||
[AllowNull]
|
||||
internal ContainerNode<T> _previous;
|
||||
[AllowNull]
|
||||
internal ContainerNode<T> _next;
|
||||
internal ContainerNode<T> _side;
|
||||
|
||||
internal ContainerNode()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public ContainerNode(T t)
|
||||
{
|
||||
_value = t;
|
||||
t.setID(this);
|
||||
_previous = new ContainerNode<T>();
|
||||
_next = new ContainerNode<T>();
|
||||
}
|
||||
|
||||
public virtual ContainerNode<T> Previous
|
||||
@@ -57,17 +83,16 @@ namespace StgSharp
|
||||
set { _next = value; }
|
||||
}
|
||||
|
||||
public ContainerNode<T> Side
|
||||
{
|
||||
get { return _side; }
|
||||
set { _side = value; }
|
||||
}
|
||||
|
||||
public T Value
|
||||
{
|
||||
get { return _value; }
|
||||
}
|
||||
|
||||
public bool IsNull
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public void Remove()
|
||||
{
|
||||
_previous.Next = _next;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using StgSharp.Logic;
|
||||
using StgSharp.Graphics;
|
||||
using StgSharp.Logic;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
@@ -9,43 +10,60 @@ namespace StgSharp
|
||||
public class LinkedList<T>:INode<LinkedList<T>>,IEnumerable where T: INode<T>
|
||||
{
|
||||
internal readonly ContainerNode<T> _heading;
|
||||
internal ContainerNode<T> _first;
|
||||
internal ContainerNode<T> _tail;
|
||||
private ContainerNode<T> _cache;
|
||||
private bool isEmpty;
|
||||
|
||||
public LinkedList()
|
||||
{
|
||||
_heading = new ContainerNode<T>(default(T));
|
||||
_heading = new ContainerNode<T>(null);
|
||||
isEmpty = true;
|
||||
|
||||
#if DEBUG
|
||||
Console.WriteLine("Linked list init ok");
|
||||
#endif
|
||||
}
|
||||
|
||||
public T First
|
||||
{
|
||||
get { return _first._value; }
|
||||
set
|
||||
{
|
||||
_first = new ContainerNode<T>(value);
|
||||
_heading._next = _first;
|
||||
}
|
||||
get { return _heading._next._value; }
|
||||
private set { _heading._next = value.ID; }
|
||||
}
|
||||
|
||||
public T Tail
|
||||
{
|
||||
get { return _tail._value; }
|
||||
set { _tail = new ContainerNode<T>(value); }
|
||||
get { return _heading._previous._value; }
|
||||
private set { _heading._previous = value.ID; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add an item to the tail of linked list.
|
||||
/// </summary>
|
||||
/// <param name="t">The item ready to add to the list</param>
|
||||
public void Add(T t)
|
||||
{
|
||||
if (_first != default(ContainerNode<T>))
|
||||
//checkout if the linkedlist is null
|
||||
if (isEmpty)
|
||||
{
|
||||
First = t;
|
||||
_heading._next = t.ID;
|
||||
_heading._previous = t.ID;
|
||||
t.Next = _heading;
|
||||
t.Previous = _heading;
|
||||
isEmpty = false;
|
||||
Console.WriteLine("1st item ok");
|
||||
Console.WriteLine(_heading._next);
|
||||
Console.WriteLine(_heading._previous);
|
||||
}
|
||||
else
|
||||
{
|
||||
_cache = new ContainerNode<T>(t);
|
||||
_tail._next = _cache;
|
||||
_cache._previous = _tail;
|
||||
_tail = _cache;
|
||||
Console.WriteLine("next begin");
|
||||
t.Next = _heading;
|
||||
Console.WriteLine("step 01 ok");
|
||||
t.Previous = _heading.Previous;
|
||||
Console.WriteLine("step 02 ok");
|
||||
_heading._previous._next = t.ID;
|
||||
Console.WriteLine("step 03 ok");
|
||||
_heading._previous = t.ID;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,15 +81,18 @@ namespace StgSharp
|
||||
|
||||
public void RemoveTail()
|
||||
{
|
||||
if (_tail==default(ContainerNode<T>))
|
||||
//check out if the list has only one member
|
||||
if (Tail == First)
|
||||
{
|
||||
First = default;
|
||||
|
||||
|
||||
isEmpty = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_cache = _tail;
|
||||
_tail = _cache._previous;
|
||||
_cache._previous = default(ContainerNode<T>);
|
||||
Tail.Previous.Next = _heading;
|
||||
Tail.Next = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,15 +29,24 @@ namespace StgSharp
|
||||
|
||||
internal Sensor<EntityPartical> Sensor;
|
||||
|
||||
|
||||
#if DEBUG
|
||||
public Pool()
|
||||
{
|
||||
initContainers();
|
||||
Console.WriteLine("Pool init OK!");
|
||||
}
|
||||
#endif
|
||||
|
||||
public Pool(Line left, Line right, Line top, Line bottom)
|
||||
{
|
||||
initContainers();
|
||||
topBoader = top;
|
||||
bottomBoader= bottom;
|
||||
rightBoader = right;
|
||||
leftBoader = left;
|
||||
}
|
||||
|
||||
|
||||
public Pool( Geometries.Rectangle area)
|
||||
{
|
||||
vec3d vec = area.vertex01.Position - area.vertex02.Position;
|
||||
@@ -79,6 +88,17 @@ namespace StgSharp
|
||||
}
|
||||
}
|
||||
}
|
||||
initContainers();
|
||||
}
|
||||
|
||||
private void initContainers()
|
||||
{
|
||||
_id = new ContainerNode<Pool>(this);
|
||||
pointContainer = new LinkedList<Point>();
|
||||
_bulletContainer = new LinkedList<IEntity>();
|
||||
_awardContainer = new LinkedList<IEntity>();
|
||||
_enemyContainer = new LinkedList<IEntity>();
|
||||
|
||||
}
|
||||
|
||||
public void OnRender()
|
||||
|
||||
Reference in New Issue
Block a user