コード例 #1
0
ファイル: LoadProvNames.cs プロジェクト: KornFlaks/NTTC
        private IEnumerator CalculateNames()
        {
            _provinceAngles = new NativeArray <float>(_dataBox.Provinces.Length, Allocator.TempJob);

            _anglesJobHandle = new AnglesJob
            {
                CenterPoints  = _centerPoints,
                FurthestPoint = _furthestPoint,
                Angles        = _provinceAngles
            }.Schedule(_centerPoints.Length, 10, _initialJobHandle);

            while (!_anglesJobHandle.IsCompleted)
            {
                yield return(null);
            }

            _anglesJobHandle.Complete();

            // Removing used Natives
            _pixelsFound.Dispose();
            _furthestPoint.Dispose();

            InstantiateNames(transform, _centerPoints, _provinceAngles,
                             _stringBox.ProvinceNames, _longestDistance, false, out _namesLoaded);
        }
コード例 #2
0
ファイル: LoadProvNames.cs プロジェクト: KornFlaks/NTTC
        private IEnumerator GenerateNational()
        {
            var nationalCapitals = new NativeArray <int>(
                _politicalBox.CountryHistories.Select(country => country.capital).ToArray(), Allocator.TempJob);
            var provinceOwnership = new NativeArray <int>(
                _dataBox.Provinces.Select(province => province.Owner).ToArray(), Allocator.TempJob);
            var provinceLifeRating = new NativeArray <int>(
                _dataBox.Provinces.Select(province => province.LifeRating).ToArray(), Allocator.TempJob);

            var contiguousProvinces =
                new NativeMultiHashMap <int, float2>(_dataBox.Provinces.Length, Allocator.TempJob);
            var checkedProvinces = new NativeArray <bool>(_dataBox.Provinces.Length, Allocator.TempJob);
            var furthestNational = new NativeArray <float2>(_politicalBox.CountryHistories.Length, Allocator.TempJob);

            _centerNational  = new NativeArray <float2>(_politicalBox.CountryHistories.Length, Allocator.TempJob);
            _longestNational = new NativeArray <float>(_politicalBox.CountryHistories.Length, Allocator.TempJob);
            _nationalAngles  = new NativeArray <float>(_politicalBox.CountryHistories.Length, Allocator.TempJob);

            _contiguousJobHandle = new ContiguousJob
            {
                BorderEnds          = _dataBox.BorderEnds,
                BorderIndices       = _dataBox.BorderIndices,
                CheckedProvinces    = checkedProvinces,
                ContiguousProvinces = contiguousProvinces.ToConcurrent(),
                ProvinceCentroids   = _centerPoints,
                ProvinceLifeRating  = provinceLifeRating,
                ProvinceOwnership   = provinceOwnership,
                ProvincePixels      = _numPoints,
                NationalCapitals    = nationalCapitals,
                CenterNationals     = _centerNational
            }.Schedule(_politicalBox.CountryHistories.Length, 1, _initialJobHandle);

            _contiguousJobHandle = new LongestJob
            {
                CenterPoints    = _centerNational,
                FurthestPoint   = furthestNational,
                LongestDistance = _longestNational,
                PointsFound     = contiguousProvinces
            }.Schedule(_politicalBox.CountryHistories.Length, 1, _contiguousJobHandle);

            _contiguousJobHandle = new AnglesJob
            {
                CenterPoints  = _centerNational,
                FurthestPoint = furthestNational,
                Angles        = _nationalAngles
            }.Schedule(_politicalBox.CountryHistories.Length, 1, _contiguousJobHandle);

            while (!_contiguousJobHandle.IsCompleted)
            {
                yield return(null);
            }

            _contiguousJobHandle.Complete();

            _numPoints.Dispose();
            provinceLifeRating.Dispose();
            provinceOwnership.Dispose();
            nationalCapitals.Dispose();
            contiguousProvinces.Dispose();
            checkedProvinces.Dispose();
            furthestNational.Dispose();

            InstantiateNames(nationalHeader.transform, _centerNational, _nationalAngles,
                             _stringBox.CountryNames, _longestNational, true, out _nationalLoaded);
        }