protected override void GameChange(IGame game) { base.GameChange(game); if (game != null) { this.PlayerControllerRepositoryService = game.Services.GetService <IPlayerControllerRepositoryService>(); return; } this.PlayerControllerRepositoryService = null; if (this.City != null) { this.City.CityDistrictCollectionChange -= this.City_CityDistrictCollectionChange; this.City.Empire.GetAgency <DepartmentOfTheInterior>().CitiesCollectionChanged -= this.DistrictWorldCursor_CitiesCollectionChanged; this.City = null; } this.WorldDistrict = null; this.CheckNodes = false; }
protected void OnCursorDeactivate() { if (this.City != null) { this.City.OnCityCampChanged -= this.City_OnCityCampChanged; this.City.OnCityDisposed -= this.City_OnCityDisposed; this.City.CityDistrictCollectionChange -= this.City_CityDistrictCollectionChange; this.City.Empire.GetAgency <DepartmentOfTheInterior>().CitiesCollectionChanged -= this.DistrictWorldCursor_CitiesCollectionChanged; this.City = null; this.ResourceRendererService.SetSelectedRegion(-1); } this.WorldDistrict = null; this.Camp = null; if (this.ResourceRendererService != null) { this.ResourceRendererService.Clear(); } GameObject[] array = this.nodeBoundryObjects.Values.ToArray <GameObject>(); for (int i = array.Length - 1; i >= 0; i--) { MeshFilter component = array[i].GetComponent <MeshFilter>(); if (component != null) { Mesh mesh = component.mesh; component.mesh = null; UnityEngine.Object.DestroyImmediate(mesh, true); } UnityEngine.Object.DestroyImmediate(array[i]); array[i] = null; } this.nodeBoundryObjects.Clear(); this.NodesToDraw.Clear(); if (this.worldEntityHelperContent != null) { this.worldEntityHelperContent.Clear(); this.worldEntityHelperContent = null; } this.departmentOfCreepingNodes = null; this.CheckNodes = false; }
protected void OnCursorActivate(params object[] parameters) { Diagnostics.Assert(base.WorldPositionningService != null); Diagnostics.Assert(this.PlayerControllerRepositoryService != null); Diagnostics.Assert(base.GlobalPositionningService != null); if (this.City != null) { this.City.CityDistrictCollectionChange -= this.City_CityDistrictCollectionChange; this.City.Empire.GetAgency <DepartmentOfTheInterior>().CitiesCollectionChanged -= this.DistrictWorldCursor_CitiesCollectionChanged; this.City = null; this.ResourceRendererService.SetSelectedRegion(-1); } if (parameters != null) { this.City = (parameters.FirstOrDefault((object iterator) => iterator != null && iterator.GetType() == typeof(City)) as City); } if (base.CursorTarget != null) { this.WorldDistrict = base.CursorTarget.GetComponent <WorldDistrict>(); if (this.WorldDistrict != null) { this.City = this.WorldDistrict.District.City; } else if (this.City == null) { Diagnostics.LogError("Invalid cursor target (cant find component of type: 'WorldDistrict')."); return; } } else if (this.City == null) { Diagnostics.LogError("Cursor target is null."); return; } if (this.City == null) { base.Back(); return; } IAudioEventService service = Services.GetService <IAudioEventService>(); Diagnostics.Assert(service != null); service.Play2DEvent("Gui/Interface/CitySelection"); if (this.City.Empire != this.PlayerControllerRepositoryService.ActivePlayerController.Empire) { this.City.CityDistrictCollectionChange += this.City_CityDistrictCollectionChange; this.City.Empire.GetAgency <DepartmentOfTheInterior>().CitiesCollectionChanged += this.DistrictWorldCursor_CitiesCollectionChanged; return; } if (this.ResourceRendererService != null) { this.ResourceRendererService.Clear(); } this.Camp = (parameters.FirstOrDefault((object iterator) => iterator != null && iterator.GetType() == typeof(Camp)) as Camp); if (this.Camp != null || (this.District != null && this.City.Camp != null && this.City.Camp.ContainsDistrict(this.District.GUID))) { if (this.Camp == null) { this.Camp = this.City.Camp; } base.Focus(this.City.Camp, true); for (int i = 0; i < this.City.Camp.Districts.Count; i++) { this.ResourceRendererService.Add(this.City.Camp.Districts[i].WorldPosition); } } else { this.ResourceRendererService.SetSelectedRegion(this.City.Region.Index); if (this.ResourceRendererService != null) { this.City_CityDistrictCollectionChange(this, new CollectionChangeEventArgs(CollectionChangeAction.Refresh, null)); this.City.CityDistrictCollectionChange += this.City_CityDistrictCollectionChange; this.City.Empire.GetAgency <DepartmentOfTheInterior>().CitiesCollectionChanged += this.DistrictWorldCursor_CitiesCollectionChanged; } } this.City.OnCityCampChanged += this.City_OnCityCampChanged; this.City.OnCityDisposed += this.City_OnCityDisposed; global::Empire empire = this.PlayerControllerRepositoryService.ActivePlayerController.Empire as global::Empire; if (this.City.Empire.Index == empire.Index && empire.SimulationObject.Tags.Contains("FactionTraitMimics1")) { this.departmentOfCreepingNodes = empire.GetAgency <DepartmentOfCreepingNodes>(); this.CheckNodes = true; } this.SelectCreepingNodes(10); }