private void ComputeWorldObject(IWorldObject worldObject) { lock (worldObject) { if (!worldObject.Exists) { return; } pos = worldObject.Position; } var posX = OffsetPosition(pos.X); var posY = OffsetPosition(pos.Y); if (posX < 0 || posY < 0 || posX > MaxCoordinate || posY > MaxCoordinate) { return; } //TODO: when ceiling and floor is not the same divided by AreaSize we need to check two areas, that can happen on border var xIndex = (int)Math.Floor(posX / areaSize); var yIndex = (int)Math.Floor(posY / areaSize); lock (colShapeAreas) { var areaColShapes = colShapeAreas[xIndex][yIndex]; for (int j = 0, innerLength = areaColShapes.Length; j < innerLength; j++) { shape = areaColShapes[j]; if (!shape.IsPositionInside(in pos)) { continue; } shape.SetCheck(worldObject); if (shape.AddWorldObject(worldObject)) { OnEntityEnterColShape?.Invoke(worldObject, shape); } } } }