private void updateBuildingView() { ushort buildingID = this.getSelectedBuildingID(); Level buildingLockLevel = Buildings.getLockLevel(buildingID); this.updateBuildingView(buildingID, buildingLockLevel); }
private void BuildingProgressBarClick(UIComponent progressBar, UIMouseEventParameter eventParam) { ushort buildingID = this.getSelectedBuildingID(); Level buildingLockLevel = Buildings.getLockLevel(buildingID); Level progressBarLevel = this.getProgressBarLevel(progressBar); if (buildingLockLevel == Level.None) { Buildings.add(buildingID, progressBarLevel); this.updateBuildingView(buildingID, progressBarLevel); #if DEBUG Logger.Info("building lock level (" + buildingID + "): " + progressBarLevel); #endif } else { if (buildingLockLevel == progressBarLevel) { Buildings.remove(buildingID); this.updateBuildingView(buildingID, Level.None); #if DEBUG Logger.Info("building lock level (" + buildingID + "): none"); #endif } else { Buildings.update(buildingID, progressBarLevel); this.updateBuildingView(buildingID, progressBarLevel); #if DEBUG Logger.Info("building lock level (" + buildingID + "): " + progressBarLevel); #endif } } }
public void OnSaveData() { #if DEBUG Logger.Info("Try to save mod data"); #endif try { if (this.sd != null) { byte[] building_data = Buildings.toByteArray(); if (building_data != null) { this.sd.SaveData(BUILDINGS_DATA_ID, building_data); } byte[] district_data = Districts.toByteArray(); if (district_data != null) { this.sd.SaveData(DISTRICT_DATA_ID, district_data); } #if DEBUG Logger.Info("Saving was successful"); #endif } else { Logger.Warning("Serializer is null, saving mod data not possible"); } } catch (Exception e) { Logger.Error("Error during save mod data :" + e.Message); } }
public void OnLoadData() { #if DEBUG Logger.Info("Try to load mod data"); #endif try { if (this.sd != null) { byte[] building_data = this.sd.LoadData(BUILDINGS_DATA_ID); Buildings.fromByteArray(building_data); byte[] district_data = this.sd.LoadData(DISTRICT_DATA_ID); Districts.fromByteArray(district_data); #if DEBUG Logger.Info("Loading was successful"); Buildings.dump(); Districts.dump(); #endif } else { Logger.Warning("Serializer is null, loading mod data not possible"); } } catch (Exception e) { Logger.Error("Error during load mod data :" + e.Message); } }
private Level determineLockLevel(ushort buildingID) { Level buildingLockLevel = Buildings.getLockLevel(buildingID); if (buildingLockLevel != Level.None) { return(buildingLockLevel); } else { Byte districtID = Buildings.getDistrictID(buildingID); int buildingType = Buildings.getBuildingType(buildingID); Level districtLockLevel = Districts.getLockLevels(districtID)[buildingType]; if (districtLockLevel != Level.None) { return(districtLockLevel); } else { return(Level.None); } } }
private void bulldozeBuilding(ushort buildingID) { try { BuildingManager buildingManager = Singleton <BuildingManager> .instance; Building building = buildingManager.m_buildings.m_buffer[buildingID]; BuildingInfo buildingInfo = building.Info; buildingManager.ReleaseBuilding(buildingID); Buildings.remove(buildingID); /* * EffectInfo effect = buildingManager.m_properties.m_bulldozeEffect; * if (effect != null) { * InstanceID instance = new InstanceID(); * Vector3 pos = building.m_position; * float angle = building.m_angle; * int length = building.Length; * * EffectInfo.SpawnArea spawnArea = new EffectInfo.SpawnArea( * Matrix4x4.TRS(Building.CalculateMeshPosition(buildingInfo, pos, angle, length), * Building.CalculateMeshRotation(angle), Vector3.one), buildingInfo.m_lodMeshData); * * AudioGroup nullAudioGroup = new AudioGroup(0, * new SavedFloat("NOTEXISTINGELEMENT", Settings.gameSettingsFile, 0, false)); * Singleton<EffectManager>.instance.DispatchEffect(effect, instance, spawnArea, * Vector3.zero, 0.0f, 1f, nullAudioGroup); * } */ } catch (Exception e) { Logger.Error("Error during bulldozing building :" + e.Message); } }
private void updateBuildingView(ushort buildingID, Level buildingLockLevel) { if (buildingLockLevel != Level.None) { this.updateProgressPanel(this.panelBuildingProgress, buildingLockLevel, false); } else { Byte districtID = Buildings.getDistrictID(buildingID); int buildingType = Buildings.getBuildingType(buildingID); Level districtLockLevel = Districts.getLockLevels(districtID)[buildingType]; if (districtLockLevel != Level.None) { this.updateProgressPanel(this.panelBuildingProgress, districtLockLevel, true); } else { this.updateProgressPanel(this.panelBuildingProgress, Level.None, false); } } }