public void Simulate() { if (Body.PositionChangedBuffer) { tempNode = GridManager.GetNode(Body._position.x, Body._position.y); if (tempNode.IsNull()) { return; } if (System.Object.ReferenceEquals(tempNode, LocatedNode) == false) { if (LocatedNode != null) { LocatedNode.Remove(this); } tempNode.Add(this); LocatedNode = tempNode; } } if (!ReplayManager.IsPlayingBack) { foreach (var AI in AgentAI) { AI.OnSimulate(); } } }
void CheckNeighbor(GridNode neighbor) { if (neighbor.IsNull() || neighbor.Unwalkable) { _clearanceDegree = 1; _clearanceSource = (byte)i; } //Cap clearance to 8. Something larger than that won't work very well with pathfinding. if (neighbor._clearanceDegree < ClearanceDegree && neighbor._clearanceDegree < 8) { _clearanceDegree = (byte)(neighbor._clearanceDegree + 1); _clearanceSource = (byte)i; } }
public static bool GetScanCoordinates(long xPos, long yPos, out int xGrid, out int yGrid) { //xGrid = (int)((((xPos + FixedMath.Half - 1 - OffsetX) >> FixedMath.SHIFT_AMOUNT) + ScanResolution / 2) / ScanResolution); //yGrid = (int)((((yPos + FixedMath.Half - 1 - OffsetY) >> FixedMath.SHIFT_AMOUNT) + ScanResolution / 2) / ScanResolution); GridNode gridNode = GetNode(xPos, yPos); if (gridNode.IsNull()) { xGrid = 0; yGrid = 0; return(false); } ScanNode scanNode = gridNode.LinkedScanNode; xGrid = scanNode.X; yGrid = scanNode.Y; return(true); }
public void Simulate() { if (Body.PositionChangedBuffer) { tempNode = GridManager.GetNode(Body._position.x, Body._position.y); if (tempNode.IsNull()) { return; } if (System.Object.ReferenceEquals(tempNode, LocatedNode) == false) { if (LocatedNode != null) { LocatedNode.Remove(this); } tempNode.Add(this); LocatedNode = tempNode; } } }