public bool ExportData(CMatrix <T> rMatrix) { if (rMatrix == this) { return(IsCreated()); } if (!IsCreated()) { return(false); } if (rMatrix.CX != m_cx || rMatrix.CY != m_cy) { if (!rMatrix.Create(m_cx, m_cy)) { return(false); } } for (var i = 0; i < m_cx; ++i) { for (var j = 0; j < m_cy; ++j) { rMatrix.m_ppData[i][j] = m_ppData[i][j]; } } return(true); }
protected int MakePath(int x, int y, List <uint> areas, bool MoveThrough) { uint dwCount = 0; var aPath = new Point[255]; var g_collisionMap = game.MapHandler.GetCollisionData(areas.ToArray()); if (!g_collisionMap.m_map.IsCreated()) { return(0); } UnitAny unit; if (!game.GetPlayerUnit(out unit) || unit.pPath == 0) { return(0); } var path = game.Debugger.Read <Path>(unit.pPath); var ptStart = new Point(path.xPos, path.yPos); var ptEnd = new Point(x, y); if (!g_collisionMap.IsValidAbsLocation(ptStart.X, ptStart.Y)) { return(0); } if (!g_collisionMap.IsValidAbsLocation(ptEnd.X, ptEnd.Y)) { return(0); } g_collisionMap.AbsToRelative(ref ptStart); g_collisionMap.AbsToRelative(ref ptEnd); var matrix = new CMatrix <ushort>(); if (!g_collisionMap.CopyMapData(matrix)) { return(0); } var tf = new TeleportPath(matrix.GetData(), matrix.CX, matrix.CY); dwCount = tf.FindTeleportPath(ptStart, ptEnd, aPath, 255); if (dwCount == 0) { return(0); } for (var i = 0; i < dwCount; ++i) { g_collisionMap.RelativeToAbs(ref aPath[i]); } if (MoveThrough) { if (aPath[dwCount - 1].X > aPath[dwCount - 2].X) { aPath[dwCount].X = aPath[dwCount - 1].X + 2; } else { aPath[dwCount].X = aPath[dwCount - 1].X - 2; } if (aPath[dwCount - 1].Y > aPath[dwCount - 2].Y) { aPath[dwCount].Y = aPath[dwCount - 1].Y + 2; } else { aPath[dwCount].Y = aPath[dwCount - 1].Y - 2; } ++dwCount; if (TeleportPath.CalculateDistance(aPath[dwCount - 1].X, aPath[dwCount - 1].Y, aPath[dwCount - 3].X, aPath[dwCount - 3].Y) <= (uint)Range.TpRange) { aPath[dwCount - 2] = aPath[dwCount - 1]; aPath[dwCount - 1].X = 0; aPath[dwCount - 1].Y = 0; --dwCount; } } TPath.Clear(); for (var i = 0; i < dwCount; ++i) { TPath.Add(aPath[i]); } return((int)dwCount); }