private IEnumerator ResetCellVisibility()
        {
            yield return(new WaitForEndOfFrame());

            while (Grid.Chunks.Any(chunk => chunk.IsRefreshing))
            {
                yield return(new WaitForEndOfFrame());
            }

            VisibilityCanon.ClearCellVisibility();

            foreach (var unit in UnitFactory.AllUnits)
            {
                var unitOwner = UnitPossessionCanon.GetOwnerOfPossession(unit);

                foreach (var visibleCell in UnitLineOfSightLogic.GetCellsVisibleToUnit(unit))
                {
                    VisibilityCanon.IncreaseCellVisibilityToCiv(visibleCell, unitOwner);
                    ExplorationCanon.SetCellAsExploredByCiv(visibleCell, unitOwner);
                }
            }

            foreach (var city in CityFactory.AllCities)
            {
                var cityOwner = CityPossessionCanon.GetOwnerOfPossession(city);

                foreach (var visibleCell in CityLineOfSightLogic.GetCellsVisibleToCity(city))
                {
                    VisibilityCanon.IncreaseCellVisibilityToCiv(visibleCell, cityOwner);
                    ExplorationCanon.SetCellAsExploredByCiv(visibleCell, cityOwner);
                }
            }

            foreach (var cell in Grid.Cells)
            {
                HexCellShaderData.RefreshVisibility(cell);
            }

            ResetVisionCoroutine = null;

            yield break;
        }
Beispiel #2
0
        private IEnumerator ClearRuntime_Coroutine(bool immediateMode)
        {
            var oldVisibility = VisibilityResponder.UpdateVisibility;

            VisibilityResponder.UpdateVisibility = false;

            CapitalCitySynchronizer.SetCapitalUpdating(false);

            foreach (var element in PlayModeSensitiveElements)
            {
                element.IsActive = false;
            }

            ImprovementComposer.ClearRuntime(immediateMode);
            CityComposer.ClearRuntime(immediateMode);
            BuildingComposer.ClearRuntime();
            UnitComposer.ClearRuntime();
            ResourceComposer.ClearRuntime();
            DiplomacyComposer.ClearRuntime();
            CivilizationComposer.ClearRuntime();
            PlayerComposer.ClearRuntime();
            BarbarianComposer.ClearRuntime();

            if (!immediateMode)
            {
                yield return(new WaitForEndOfFrame());
            }

            CapitalCitySynchronizer.SetCapitalUpdating(true);

            HexCellComposer.ClearRuntime();

            VisibilityCanon.ClearCellVisibility();

            VisibilityResponder.UpdateVisibility = oldVisibility;

            ClearCoroutine = null;
        }