本文整理汇总了C#中FastList.FastClear方法的典型用法代码示例。如果您正苦于以下问题:C# FastList.FastClear方法的具体用法?C# FastList.FastClear怎么用?C# FastList.FastClear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FastList
的用法示例。
在下文中一共展示了FastList.FastClear方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindPath
public static bool FindPath(Vector2d Start, Vector2d End, FastList<Vector2d> outputVectorPath)
{
if (!GetPathNodes(Start.x,Start.y,End.x,End.y,out node1, out node2))
return false;
if (FindPath (node1, node2, OutputPath)) {
outputVectorPath.FastClear ();
length = OutputPath.Count - 1;
for (i = 0; i < length; i++) {
outputVectorPath.Add (OutputPath [i].WorldPos);
}
outputVectorPath.Add (End);
return true;
}
return false;
}
示例2: FindPath
/// <summary>
/// Finds a path and outputs it to <c>OutputPath</c>. Note: OutputPath is unpredictably changed.
/// </summary>
/// <returns>
/// Returns <c>true</c> if path was found and necessary, <c>false</c> if path to End is impossible or not found.
/// </returns>
/// <param name="startNode">Start node.</param>
/// <param name="endNode">End node.</param>
/// <param name="OutputPath">Return path.</param>
public static bool FindPath(GridNode startNode, GridNode endNode, FastList<GridNode> OutputPath)
{
#region Broadphase and Preperation
if (endNode.Unwalkable) {
return false;
}
if (startNode.Unwalkable) {
return false;
}
if (true) {
#region Obstruction Test
//Tests if there is a direct path. If there is, no need to run AStar.
x0 = startNode.gridX;
y0 = startNode.gridY;
x1 = endNode.gridX;
y1 = endNode.gridY;
if (y1 > y0)
compare1 = y1 - y0;
else
compare1 = y0 - y1;
if (x1 > x0)
compare2 = x1 - x0;
else
compare2 = x0 - x1;
steep = compare1 > compare2;
if (steep) {
t = x0; // swap x0 and y0
x0 = y0;
y0 = t;
t = x1; // swap x1 and y1
x1 = y1;
y1 = t;
}
if (x0 > x1) {
t = x0; // swap x0 and x1
x0 = x1;
x1 = t;
t = y0; // swap y0 and y1
y0 = y1;
y1 = t;
}
dx = x1 - x0;
dy = (y1 - y0);
if (dy < 0)
dy = -dy;
error = dx / 2;
ystep = (y0 < y1) ? 1 : -1;
y = y0;
for (x = x0; x <= x1; x++) {
retX = (steep ? y : x);
retY = (steep ? x : y);
if (GridManager.Grid [retX * GridManager.NodeCount + retY].Unwalkable) {
break;
} else if (x == x1) {
OutputPath.FastClear ();
OutputPath.Add (startNode);
OutputPath.Add (endNode);
return true;
}
error = error - dy;
if (error < 0) {
y += ystep;
error += dx;
}
}
#endregion
}
GridHeap.FastClear ();
GridClosedSet.FastClear ();
#endregion
#region AStar Algorithm
GridHeap.Add (startNode);
GridNode.HeuristicTargetX = endNode.gridX;
GridNode.HeuristicTargetY = endNode.gridY;
while (GridHeap.Count > 0) {
currentNode = GridHeap.RemoveFirst ();
GridClosedSet.Add (currentNode);
if (currentNode.gridIndex == endNode.gridIndex) {
OutputPath.FastClear ();
//Retraces the path then outputs it into OutputPath
//.........这里部分代码省略.........
示例3: ScanAll
public static void ScanAll(int gridX, int gridY, int deltaCount, FastList<LSAgent> outputAgents,
Func<LSAgent,bool> conditional)
{
outputAgents.FastClear ();
for (int i = 0; i < deltaCount; i++) {
tempNode = GridManager.GetScanNode (
gridX + DeltaCache.CacheX [i],
gridY + DeltaCache.CacheY [i]);
if (tempNode .IsNotNull () && tempNode.LocatedAgents .IsNotNull ()) {
tempBucket = tempNode.LocatedAgents;
arrayAllocation = tempBucket.arrayAllocation;
for (int j = 0; j < tempBucket.PeakCount; j++) {
if (arrayAllocation.Get (j)) {
tempAgent = tempBucket [j];
if (conditional (tempAgent)) {
outputAgents.Add (tempAgent);
}
}
}
}
}
}