MrGravity.Import_Code.Importer.CreateSortedIndicies C# (CSharp) Méthode

CreateSortedIndicies() private méthode

Creates the sorted indicies.
private CreateSortedIndicies ( List walls, List indicies, bool cols ) : void
walls List The walls.
indicies List The indicies.
cols bool
Résultat void
        private void CreateSortedIndicies(List<StaticObject> walls, List<StaticObject>[] indicies, bool cols)
        {
            for (var i = 0; i < indicies.Length; i++) indicies[i] = new List<StaticObject>();
            foreach (var obj in walls)
            {
                var i = 0;
                var gridLoc = GridSpace.GetGridCoord(obj.MPosition);
                var index = (int)gridLoc.Y;
                var compNum = gridLoc.X;

                if (cols) { index = (int)gridLoc.X; compNum = gridLoc.Y; }
                for (; i < indicies[index].Count; i++)
                {
                    var otherGridLoc = GridSpace.GetGridCoord(indicies[index][i].MPosition);

                    var otherComp = otherGridLoc.X;
                    if (cols) otherComp = otherGridLoc.Y;

                    if (compNum < otherComp)
                        break;
                }

                if (i < indicies[index].Count)
                    indicies[index].Insert(i, obj);
                else
                    indicies[index].Add(obj);
            }
        }