public void Active(TAvatar avatar, ViAvatarDurationVisualInterface <TAvatar> kEffect) { if (m_kPriorityList.IsEmpty()) { m_kPriorityList.PushBack(kEffect._priorityNode); kEffect.OnActive(avatar); _OnUpdated(avatar, null); } else { ViDoubleLinkNode2 <ViAvatarDurationVisualInterface <TAvatar> > iter = m_kPriorityList.GetHead(); ViAvatarDurationVisualInterface <TAvatar> pkOldTop = iter.Data as ViAvatarDurationVisualInterface <TAvatar>; ViDebuger.AssertError(pkOldTop); while (!m_kPriorityList.IsEnd(iter)) { ViAvatarDurationVisualInterface <TAvatar> pkEffect = iter.Data as ViAvatarDurationVisualInterface <TAvatar>; ViDebuger.AssertError(pkEffect); if (kEffect.Weight > pkEffect.Weight) { break; } ViDoubleLink2 <ViAvatarDurationVisualInterface <TAvatar> > .Next(ref iter); } ViDoubleLink2 <ViAvatarDurationVisualInterface <TAvatar> > .PushBefore(iter, kEffect._priorityNode); if (kEffect._priorityNode == m_kPriorityList.GetHead()) { pkOldTop.OnDeactive(avatar); kEffect.OnActive(avatar); _OnUpdated(avatar, pkOldTop); } } }
public void Delete(ViDoubleLinkNode2 <T> node) { if (node != null) { _nodes.PushBack(node); } }
#pragma warning disable 0219 public static void Test() { ViDoubleLink2 <int> list = new ViDoubleLink2 <int>(); { ViDoubleLinkNode2 <int> node1 = new ViDoubleLinkNode2 <int>(); node1.Data = 1; ViDoubleLinkNode2 <int> node2 = new ViDoubleLinkNode2 <int>(); node2.Data = 2; list.PushBack(node1); list.PushBack(node2); {//<正向迭代> ViDoubleLinkNode2 <int> iter = list.GetHead(); while (!list.IsEnd(iter)) { int value = iter.Data; ViDoubleLink2 <int> .Next(ref iter); } } {//<反向迭代> ViDoubleLinkNode2 <int> iter = list.GetTail(); while (!list.IsEnd(iter)) { int value = iter.Data; ViDoubleLink2 <int> .Pre(ref iter); } } } }
//------------------------------------------------------------------------- static void _PushAfter(ViDoubleLinkNode2 <T> before, ViDoubleLinkNode2 <T> node) { ViDoubleLinkNode2 <T> next = before._next; ViDebuger.AssertError(next); _Link(before, node); _Link(node, next); }
// public void Append(ViVector3 pos) { ViDoubleLinkNode2 <ViRouteNode> node = S_Nodes.New(); node.Data._eventId = ViRouteNode.NULL_EVENT; node.Data._pos = pos; _nodes.PushBack(node); }
//------------------------------------------------------------------------- static void _PushBefore(ViDoubleLinkNode2 <T> after, ViDoubleLinkNode2 <T> node) { ViDoubleLinkNode2 <T> pre = after._pre; ViDebuger.AssertError(pre); _Link(pre, node); _Link(node, after); }
public void Append(ViVector3 pos, UInt32 eventId) { ViDoubleLinkNode2 <ViRouteNode> node = S_Nodes.New(); node.Data._eventId = eventId; node.Data._pos = pos; _nodes.PushBack(node); }
//------------------------------------------------------------------------- public void SetValue(T value) { ViDoubleLinkNode2 <T> next = _root._next; while (next != _root) { next.Data = value; next = next._next; } }
//------------------------------------------------------------------------- public void Detach() { if (_pre != null) { _pre._next = _next; _next._pre = _pre; _pre = null; _next = null; } }
//------------------------------------------------------------------------- public static void PushAfter(ViDoubleLinkNode2 <T> before, ViDoubleLink2 <T> list) { if (before.IsAttach() == false) { return; } if (list.IsEmpty()) { return; } _PushAfter(before, list); }
//------------------------------------------------------------------------- public static void PushBefore(ViDoubleLinkNode2 <T> after, ViDoubleLink2 <T> list) { if (after.IsAttach() == false) { return; } if (list.IsEmpty()) { return; } _PushBefore(after, list); }
public void Deactive(TAvatar avatar) { ViDoubleLinkNode2 <ViAvatarDurationVisualInterface <TAvatar> > iter = m_kEffectList.GetHead(); while (!m_kEffectList.IsEnd(iter)) { ViAvatarDurationVisualInterface <TAvatar> pkEffect = iter.Data as ViAvatarDurationVisualInterface <TAvatar>; ViDebuger.AssertError(pkEffect); ViDoubleLink2 <ViAvatarDurationVisualInterface <TAvatar> > .Next(ref iter); _Deactive(avatar, pkEffect); } }
//------------------------------------------------------------------------- public void Clear() { ViDoubleLinkNode2 <T> next = _root._next; while (next != _root) { ViDoubleLinkNode2 <T> nextCopy = next._next; next._pre = null; next._next = null; next = nextCopy; } _Init(); }
public ViDoubleLinkNode2 <T> New() { if (_nodes.IsEmpty()) { return(new ViDoubleLinkNode2 <T>(new T())); } else { ViDoubleLinkNode2 <T> node = _nodes.GetHead(); node.Detach(); return(node); } }
//------------------------------------------------------------------------- static void _PushBefore(ViDoubleLinkNode2 <T> after, ViDoubleLink2 <T> list) { if (list.IsEmpty()) { return; } ViDoubleLinkNode2 <T> first = list._root._next; ViDoubleLinkNode2 <T> back = list._root._pre; ViDoubleLinkNode2 <T> pre = after._pre; _Link(pre, first); _Link(back, after); list._Init(); }
//------------------------------------------------------------------------- public void ClearAndClearContent() { ViDoubleLinkNode2 <T> next = _root._next; while (next != _root) { ViDoubleLinkNode2 <T> nextCopy = next._next; next._pre = null; next._next = null; next.Data = default(T); next = nextCopy; } _Init(); }
//------------------------------------------------------------------------- static void _PushAfter(ViDoubleLinkNode2 <T> before, ViDoubleLink2 <T> list) { if (list.IsEmpty()) { return; } ViDoubleLinkNode2 <T> first = list._root._next; ViDoubleLinkNode2 <T> back = list._root._pre; ViDoubleLinkNode2 <T> next = before._next; _Link(before, first); _Link(back, next); list._Init(); }
public float Length() { float len = 0.0f; ViVector3 prePos = _currentPos; ViDoubleLinkNode2 <ViRouteNode> iter = _nodes.GetHead(); while (!_nodes.IsEnd(iter)) { ViRouteNode value = iter.Data; ViDoubleLink2 <ViRouteNode> .Next(ref iter); // len += Distance(value._pos, prePos); prePos = value._pos; } return(len); }
internal static void Attach(string key, ViDoubleLinkNode2 <T> node) { ValueList <T> list; if (_values.TryGetValue(key, out list)) { if (list._init) { node.Data = list._value; } list._list.PushBack(node); } else { list = new ValueList <T>(); list._list.PushBack(node); _values.Add(key, list); } }
public void Clear(TAvatar avatar) { if (m_kPriorityList.IsEmpty()) { return; } ViDoubleLinkNode2 <ViAvatarDurationVisualInterface <TAvatar> > iter = m_kPriorityList.GetHead(); ViAvatarDurationVisualInterface <TAvatar> top = iter.Data as ViAvatarDurationVisualInterface <TAvatar>; ViDebuger.AssertError(top); top.OnDeactive(avatar); while (!m_kPriorityList.IsEnd(iter)) { ViAvatarDurationVisualInterface <TAvatar> pkEffect = iter.Data as ViAvatarDurationVisualInterface <TAvatar>; ViDebuger.AssertError(pkEffect); ViDoubleLink2 <ViAvatarDurationVisualInterface <TAvatar> > .Next(ref iter); pkEffect._priorityNode.Detach(); } }
//------------------------------------------------------------------------- public void Reset() { ViDoubleLinkNode2 <ViAstarStep> iter = _openList.GetHead(); while (!_openList.IsEnd(iter)) { iter.Data.Clear(); ViDoubleLink2 <ViAstarStep> .Next(ref iter); } _openList.Clear(); // iter = _closeList.GetHead(); while (!_closeList.IsEnd(iter)) { iter.Data.Clear(); ViDoubleLink2 <ViAstarStep> .Next(ref iter); } _closeList.Clear(); // _openHeap.Clear(); }
//------------------------------------------------------------------------- public bool IsEnd(ViDoubleLinkNode2 <T> node) { return(node == _root); }
public void _AddReference(ViDoubleLinkNode2 <ViRefObj> node) { _List.PushBack(node); }
//------------------------------------------------------------------------- public static void PushBefore(ViDoubleLinkNode2 <T> after, ViDoubleLinkNode2 <T> node) { node.Detach(); _PushBefore(after, node); }
//------------------------------------------------------------------------- public void PushBack(ViDoubleLinkNode2 <T> node) { node.Detach(); _PushBefore(_root, node); }
//------------------------------------------------------------------------- public static void PushAfter(ViDoubleLinkNode2 <T> before, ViDoubleLinkNode2 <T> node) { node.Detach(); _PushAfter(before, node); }
//------------------------------------------------------------------------- public static void Pre(ref ViDoubleLinkNode2 <T> node) { ViDebuger.AssertError(node != null && node._pre != null); node = node._pre; }
//------------------------------------------------------------------------- public static void Next(ref ViDoubleLinkNode2 <T> node) { ViDebuger.AssertError(node != null && node._next != null); node = node._next; }
//------------------------------------------------------------------------- public void PushFront(ViDoubleLinkNode2 <T> node) { node.Detach(); _PushAfter(_root, node); }
//------------------------------------------------------------------------- static void _Link(ViDoubleLinkNode2 <T> pre, ViDoubleLinkNode2 <T> next) { pre._next = next; next._pre = pre; }