예제 #1
0
        public static EPropHotAreaSelectorWithParameters Create(EPropHotAreaSelector hotAreaSelector, Dictionary <HeightPyramidLevel, Vector2> levelCentersWorldSpace, Vector2 worldSpaceTravellerPosition)
        {
            var newSelector = new EPropHotAreaSelectorWithParameters(hotAreaSelector);

            newSelector.RecalculateMergeRectangles(worldSpaceTravellerPosition, levelCentersWorldSpace);
            return(newSelector);
        }
예제 #2
0
        public void Update()
        {
            var position3D            = Traveller.transform.position;
            var travellerFlatPosition = new Vector2(position3D.x, position3D.z);

            _eTerrainHeightPyramidFacade.Update(travellerFlatPosition);
            DrawObjects();

            var selectorWithParameters = EPropHotAreaSelectorWithParameters.Create(_ePropHotAreaSelector, _eTerrainHeightPyramidFacade.PyramidCenterWorldSpacePerLevel, travellerFlatPosition);

            _elevationManager.UpdateAsync(travellerFlatPosition, _eTerrainHeightPyramidFacade.PyramidCenterWorldSpacePerLevel, selectorWithParameters).Wait();

            if (Time.frameCount % 100 == 0)
            {
                if (RecalculateSectorsDivision)
                {
                    var propLocaleChanges = _elevationManager.RecalculateSectorsDivisionAsync(travellerFlatPosition).Result;
                    _dummyObjectsDisplayer.ProcessLocaleChanges(propLocaleChanges);
                    _dummyObjectsInstancingDisplayer.ProcessLocaleChanges(propLocaleChanges);
                }
                _sectorAreasDisplayer.Update(_elevationManager.DebugQuerySectorStates(selectorWithParameters));
            }

            var rt4 = selectorWithParameters.MergeRings;

            _mergeRingsDisplayer.Update(rt4);

            _mergeRingsDisplayer.SetActive(DisplayMergeRings);
            _sectorAreasDisplayer.SetActive(DisplaySelectorAreas);
            _dummyObjectsDisplayer.SetActive(DisplayDummyObjects);


            if (Time.frameCount > 10000 || _dummyObjectsInstancingDisplayer.CurrentObjectsCount > ObjectsToCreateCount)
            {
                return;
            }

            if (GenerateObjects)
            {
                var sideLength = 400f;
                var axisCount  = ObjectsToCreateOnOneLine;
                var newPropIds = Enumerable.Range(0, axisCount).SelectMany(x =>

                                                                           Enumerable.Range(0, axisCount).Select(y =>
                {
                    var flatPosition = new Vector2(((float)x / axisCount - 0.5f) * sideLength, ((float)y / axisCount - 0.5f) * sideLength);
                    return(new DebugFlatPositionWithEPropPointerAndId()
                    {
                        PointerWithId = _elevationManager.DebugRegisterPropWithElevationId(flatPosition),
                        FlatPosition = flatPosition
                    });
                }
                                                                                                                 )).ToArray();
                AddProps(newPropIds);
            }
        }
예제 #3
0
 public DebugSectorInformation DebugQuerySectorStates(EPropHotAreaSelectorWithParameters selectorWithParameters, int depth)
 {
     return(new DebugSectorInformation()
     {
         Area = _rectangle,
         Depth = depth,
         SectorState = EPropSectorState.Cold,
         Children = _subNodes.Select(c => c.Value.DebugQuerySectorStates(selectorWithParameters, depth)).ToList()
     });
 }
예제 #4
0
 public DebugSectorInformation DebugQuerySectorStates(EPropHotAreaSelectorWithParameters selectorWithParameters, int depth)
 {
     return(new DebugSectorInformation()
     {
         Area = _rectangle,
         Children = new List <DebugSectorInformation>(),
         Depth = depth,
         SectorState = ComputeSectorState(selectorWithParameters)
     });
 }
예제 #5
0
 public DebugSectorInformation DebugQuerySectorStates(EPropHotAreaSelectorWithParameters selectorWithParameters, int depth)
 {
     return(new DebugSectorInformation()
     {
         Depth = depth,
         Area = _rectangle,
         Children = new List <DebugSectorInformation>()
         {
             _node.DebugQuerySectorStates(selectorWithParameters, depth + 1)
         },
         SectorState = EPropSectorState.Cold
     });
 }
예제 #6
0
 public List <DebugSectorInformation> DebugQuerySectorStates(EPropHotAreaSelectorWithParameters selectorWithParameters)
 {
     return(_quadTreeRoots.Select(c => new DebugSectorInformation()
     {
         Area = c.Key,
         Children = new List <DebugSectorInformation>()
         {
             c.Value.DebugQuerySectorStates(selectorWithParameters, 0)
         },
         Depth = 0,
         SectorState = EPropSectorState.Cold
     }).ToList());
 }
예제 #7
0
        public List <SectorWithStateAndRectangle> RetriveSectorsWithState(EPropHotAreaSelectorWithParameters selectorWithParameters)
        {
            var state = ComputeSectorState(selectorWithParameters);

            return(new List <SectorWithStateAndRectangle>()
            {
                new SectorWithStateAndRectangle()
                {
                    Sector = _leafSector,
                    State = state,
                    Rectangle = _rectangle
                }
            });
        }
예제 #8
0
        private EPropSectorState ComputeSectorState(EPropHotAreaSelectorWithParameters selectorWithParameters)
        {
            var isSectorHot = !_leafSector.IsEmpty && selectorWithParameters.IsRectangleInAnyMergeArea(_rectangle.RealSpaceRectangle);
            EPropSectorState state;

            if (isSectorHot)
            {
                state = EPropSectorState.Hot;
            }
            else
            {
                state = EPropSectorState.Cold;
            }

            return(state);
        }
예제 #9
0
 public List <SectorWithStateAndRectangle> RetriveSectorsWithState(EPropHotAreaSelectorWithParameters selectorWithParameters)
 {
     return(_node.RetriveSectorsWithState(selectorWithParameters));
 }
예제 #10
0
 public List <SectorWithStateAndRectangle> RetriveSectorsWithState(EPropHotAreaSelectorWithParameters selectorWithParameters)
 {
     return(_subNodes.Values.SelectMany(c => c.RetriveSectorsWithState(selectorWithParameters)).ToList());
 }
예제 #11
0
        public async Task UpdateAsync(Vector2 travellerFlatPosition, Dictionary <HeightPyramidLevel, Vector2> levelCentersWorldSpace, EPropHotAreaSelectorWithParameters selectorWithParameters)
        {
            var changes      = _quadTreeRoots.Values.SelectMany(c => c.RetriveAndClearUpdateOrders()).ToList();
            var updateOrders = changes.Select(c => new EPropSectorSoleUpdateOrder()
            {
                Change  = c,
                Pointer = _pointersOccupancyContainer.RetrivePointer(new EPropElevationId()
                {
                    InScopeIndex = c.ScopeUpdateOrder.Index, LocaleBufferScopeIndex = c.ScopeIndex
                })
            }).ToList();
            await _localeBufferManager.UpdateBuffersAsync(updateOrders, travellerFlatPosition);

            var sectorsWithState = _quadTreeRoots.Values.SelectMany(c => c.RetriveSectorsWithState(selectorWithParameters)).ToList();
            var hotScopes        = sectorsWithState.Where(c => c.State == EPropSectorState.Hot).SelectMany(c => c.Sector.ScopeIds).ToList();
            await _localeBufferManager.RecalculateLocalesAsync(travellerFlatPosition, hotScopes);
        }