private void initNearLinesOnWorldInfoPanel() { BuildingWorldInfoPanel[] panelList = GameObject.Find("UIView").GetComponentsInChildren <BuildingWorldInfoPanel>(); SVMUtils.doLog("WIP LIST: [{0}]", string.Join(", ", panelList.Select(x => x.name).ToArray())); foreach (BuildingWorldInfoPanel wip in panelList) { SVMUtils.doLog("LOADING WIP HOOK FOR: {0}", wip.name); UIPanel parent = wip.gameObject.GetComponent <UIPanel>(); if (parent == null) { return; } parent.eventVisibilityChanged += (component, value) => { updateBuildingEditShortcutButton(parent); }; parent.eventPositionChanged += (component, value) => { updateBuildingEditShortcutButton(parent); }; } }
private void CreateMainPanel() { m_mainPanel = gameObject.AddComponent <UIPanel>(); m_mainPanel.Hide(); m_mainPanel.width = 250; m_mainPanel.height = 350; m_mainPanel.zOrder = 50; m_mainPanel.color = new Color32(255, 255, 255, 255); m_mainPanel.backgroundSprite = "MenuPanel2"; m_mainPanel.name = "AssetSelectorWindow_" + typeof(T).Name; m_mainPanel.autoLayoutPadding = new RectOffset(5, 5, 10, 10); m_mainPanel.autoLayout = false; m_mainPanel.useCenter = true; m_mainPanel.wrapLayout = false; m_mainPanel.canFocus = true; GetComponentInParent <UIComponent>().eventVisibilityChanged += (component, value) => { m_mainPanel.isVisible = value; }; SVMUtils.createUIElement(out m_title, m_mainPanel.transform); m_title.textAlignment = UIHorizontalAlignment.Center; m_title.autoSize = false; m_title.autoHeight = true; m_title.width = m_mainPanel.width - 30f; m_title.relativePosition = new Vector3(5, 5); m_title.textScale = 0.9f; }
private List <string> GetEffectiveAssetList(uint buildingId, out uint targetCodedId) { uint codedId = buildingId | BUILDING_FLAG; List <string> assetList; if (buildingId > 0 && GetIgnoreDistrict(codedId)) { assetList = GetAssetList(codedId); targetCodedId = codedId; SVMUtils.doLog("[{0}] GetAModel - assetList (Building) = {1}", typeof(SSD).Name, string.Join(",", assetList.ToArray())); } else { targetCodedId = DISTRICT_FLAG | SVMUtils.GetBuildingDistrict(buildingId); assetList = GetAssetList(targetCodedId); if (assetList == null || assetList.Count == 0) { assetList = GetAssetList(DISTRICT_FLAG); } SVMUtils.doLog("[{0}] GetAModel - assetList (District) = {1}", typeof(SSD).Name, string.Join(",", assetList.ToArray())); } if ((assetList?.Count ?? 0) == 0) { if (basicAssetsList == null) { LoadBasicAssets(); } assetList = basicAssetsList; } SVMUtils.doLog("[{0}] GetAModel - assetList (effective) = {1}", typeof(SSD).Name, string.Join(",", assetList.ToArray())); return(assetList); }
public void Awake() { if (instance != null) { Destroy(this); return; } instance = this; GameObject gameObject = GameObject.FindGameObjectWithTag("MainCamera"); if (gameObject != null) { m_CameraController = gameObject.GetComponent <CameraController>(); } createInfoView(); CreateIgnoreDistrictOption(); SVMUtils.createUIElement(out UIPanel confContainer, panelTransform, "SubConfigContainer", new Vector4(m_buildingInfoPanel.width, 0, 0, m_buildingInfoPanel.height)); confContainer.autoLayout = true; confContainer.autoLayoutDirection = LayoutDirection.Horizontal; confContainer.wrapLayout = false; confContainer.height = m_buildingInfoPanel.height; confContainer.clipChildren = false; foreach (var kv in ServiceSystemDefinition.sysDefinitions) { Type targetType = KlyteUtils.GetImplementationForGenericType(typeof(SVMBuildingSSDConfigWindow <>), kv.Value); SVMUtils.createElement(targetType, confContainer.transform); } }
public static IEnumerator RemoveAllUnwantedVehicles(ThreadBase t) { ushort num = 0; while ((uint)num < Singleton <VehicleManager> .instance.m_vehicles.m_size) { var vehicle = Singleton <VehicleManager> .instance.m_vehicles.m_buffer[(int)num]; var vehicleInfo = vehicle.Info; if (vehicleInfo != null && !SVMUtils.IsTrailer(vehicleInfo) && vehicle.m_transportLine == 0 && vehicle.m_sourceBuilding > 0) { var buildingInfo = Singleton <BuildingManager> .instance.m_buildings.m_buffer[vehicle.m_sourceBuilding].Info; var buildingSsd = ServiceSystemDefinition.from(buildingInfo, vehicleInfo.m_vehicleType); if (buildingSsd != null) { if (!buildingSsd.GetTransportExtension().IsModelCompatible(vehicle.m_sourceBuilding, vehicleInfo)) { Singleton <VehicleManager> .instance.ReleaseVehicle(num); } } } if (num % 256 == 255) { yield return(num); } num++; } yield break; }
public Color32 GetEffectiveColorBuilding(uint buildingId) { if (GetIgnoreDistrict(buildingId)) { Color32 c = GetColor(buildingId | BUILDING_FLAG); if (c.a != 255) { c = Color.clear; } return(c); } else { Color32 c = GetColor(SVMUtils.GetBuildingDistrict(buildingId) | DISTRICT_FLAG); if (c.a != 255) { c = GetColor(DISTRICT_FLAG); } if (c.a != 255) { c = Color.clear; } return(c); } }
public void OnLevelLoaded(LoadMode mode) { SVMUtils.doLog("LEVEL LOAD"); if (mode != LoadMode.LoadGame && mode != LoadMode.NewGame && mode != LoadMode.NewGameFromScenario) { m_loaded = false; SVMUtils.doLog("NOT GAME ({0})", mode); return; } if (!IsKlyteCommonsEnabled()) { throw new Exception("SVM requires Klyte Commons active!"); } if (SVMController.taSVM == null) { SVMController.taSVM = CreateTextureAtlas("UI.Images.sprites.png", "ServiceVehicleManagerSprites", GameObject.FindObjectOfType <UIView>().FindUIComponent <UIPanel>("InfoPanel").atlas.material, 64, 64, new string[] { "ServiceVehiclesManagerIcon", "ServiceVehiclesManagerIconSmall", "ToolbarIconGroup6Hovered", "ToolbarIconGroup6Focused", "HelicopterIndicator", "RemoveUnwantedIcon", "CargoIndicator", "OutsideIndicator", "BioIndicator" }); } loadSVMLocale(false); SVMController.instance.Awake(); m_loaded = true; }
private void Awake() { SVMServiceBuildingDetailPanel.eventOnDistrictSelectionChanged += onDistrictChanged; mainPanel = GetComponentInChildren <UIScrollablePanel>(); mainPanel.autoLayout = false; m_uiHelper = new UIHelperExtension(mainPanel); SVMUtils.createUIElement(out UILabel lbl, mainPanel.transform, "DistrictColorLabel", new Vector4(5, 5, 250, 40)); allowColorChange = SVMConfigWarehouse.allowColorChanging(extension.ConfigIndexKey); if (allowColorChange) { SVMUtils.LimitWidth(lbl, 250); lbl.autoSize = true; lbl.localeID = "SVM_DISTRICT_COLOR_LABEL"; m_districtColor = KlyteUtils.CreateColorField(mainPanel); m_districtColor.eventSelectedColorChanged += onChangeDistrictColor; SVMUtils.createUIElement(out UIButton resetColor, mainPanel.transform, "DistrictColorReset", new Vector4(290, 0, 0, 0)); SVMUtils.initButton(resetColor, false, "ButtonMenu"); SVMUtils.LimitWidth(resetColor, 200); resetColor.textPadding = new RectOffset(5, 5, 5, 2); resetColor.autoSize = true; resetColor.localeID = "SVM_RESET_COLOR"; resetColor.eventClick += onResetColor; } SVMUtils.createElement(out m_assetSelectorWindow, mainPanel.transform); m_assetSelectorWindow.setTabContent(this); }
public void RefreshLines() { if (Singleton <BuildingManager> .exists) { int count = 0; var buildingList = SVMBuildingUtils.getAllBuildingsFromCity(Singleton <T> .instance.GetSSD()); SVMUtils.doLog("{0} buildingList = [{1}] (s={2})", GetType(), string.Join(",", buildingList.Select(x => x.ToString()).ToArray()), buildingList.Count); foreach (ushort buildingID in buildingList) { Building b = Singleton <BuildingManager> .instance.m_buildings.m_buffer[buildingID]; var ext = SVMBuildingAIOverrideUtils.getBuildingOverrideExtension(b.Info); var maxCountField = ext.GetVehicleMaxCountField(SVMSysDef <T> .instance.GetSSD().vehicleType); var maxVehicle = SVMUtils.GetPrivateField <int>(b.Info.GetAI(), maxCountField); if (maxCountField == null || maxVehicle > 0) { AddToList(buildingID, ref count); } } RemoveExtraLines(count); SVMUtils.doLog("{0} final count = {1}", GetType(), count); m_LinesUpdated = true; } }
private void CreateTitleRowBuilding(ref UIPanel titleLine, UIComponent parent) { SVMUtils.createUIElement(out titleLine, parent.transform, "SVMtitleline", new Vector4(5, 80, parent.width - 10, 40)); SVMUtils.createUIElement(out UILabel districtNameLabel, titleLine.transform, "districtNameLabel"); districtNameLabel.autoSize = false; districtNameLabel.area = new Vector4(0, 10, 175, 18); districtNameLabel.textAlignment = UIHorizontalAlignment.Center; districtNameLabel.text = Locale.Get("TUTORIAL_ADVISER_TITLE", "District"); SVMUtils.createUIElement(out UILabel buildingNameLabel, titleLine.transform, "buildingNameLabel"); buildingNameLabel.autoSize = false; buildingNameLabel.area = new Vector4(200, 10, 198, 18); buildingNameLabel.textAlignment = UIHorizontalAlignment.Center; buildingNameLabel.text = Locale.Get("SVM_BUILDING_NAME_LABEL"); SVMUtils.createUIElement(out UILabel vehicleCapacityLabel, titleLine.transform, "vehicleCapacityLabel"); vehicleCapacityLabel.autoSize = false; vehicleCapacityLabel.area = new Vector4(400, 10, 200, 18); vehicleCapacityLabel.textAlignment = UIHorizontalAlignment.Center; vehicleCapacityLabel.text = Locale.Get("SVM_VEHICLE_CAPACITY_LABEL"); SVMUtils.createUIElement(out m_directionLabel, titleLine.transform, "directionLabel"); m_directionLabel.autoSize = false; m_directionLabel.area = new Vector4(600, 10, 200, 18); m_directionLabel.textAlignment = UIHorizontalAlignment.Center; m_directionLabel.text = Locale.Get("SVM_DIRECTION_LABEL"); }
private void CreateMainPanel() { SVMUtils.createUIElement(out m_mainPanel, m_parent.transform); m_mainPanel.Hide(); m_mainPanel.relativePosition = new Vector3(m_parent.width - 375f, 0.0f); m_mainPanel.width = 350; m_mainPanel.height = m_parent.height; m_mainPanel.zOrder = 50; m_mainPanel.color = new Color32(255, 255, 255, 255); m_mainPanel.name = "AssetSelectorWindow"; m_mainPanel.autoLayoutPadding = new RectOffset(5, 5, 10, 10); m_mainPanel.autoLayout = false; m_mainPanel.useCenter = true; m_mainPanel.wrapLayout = false; m_mainPanel.canFocus = true; m_parent.eventVisibilityChanged += (component, value) => { m_mainPanel.isVisible = value; }; SVMUtils.createUIElement(out m_title, m_mainPanel.transform); m_title.textAlignment = UIHorizontalAlignment.Center; m_title.autoSize = false; m_title.autoHeight = true; m_title.width = m_mainPanel.width - 30f; m_title.relativePosition = new Vector3(5, 5); m_title.textScale = 0.9f; m_title.localeID = "SVM_DISTRICT_ASSET_SELECT_WINDOW_TITLE_PREFIX"; }
public VehicleInfo GetAModel(uint buildingId) { SVMUtils.doLog("[{0}] GetAModel", typeof(SSD).Name); List <string> assetList = GetEffectiveAssetList(buildingId); return(SVMUtils.GetRandomModel(assetList)); }
protected virtual bool ProcessOffer(ushort buildingID, Building data, TransferManager.TransferReason material, TransferManager.TransferOffer offer, TransferManager.TransferReason trTarget, Tuple <VehicleInfo.VehicleType, bool, bool> tup, U instance) { if (material == trTarget) { ServiceSystemDefinition def = ServiceSystemDefinition.from(instance.m_info, tup.First); if (def == null) { SVMUtils.doLog("SSD Não definido para: {0} {1} {2} {3}", instance.m_info.m_class.m_service, instance.m_info.m_class.m_subService, instance.m_info.m_class.m_level, tup.First); return(false); } SVMUtils.doLog("[{1}] SSD = {0}", def, material); VehicleInfo randomVehicleInfo = ServiceSystemDefinition.availableDefinitions[def].GetAModel(buildingID); SVMUtils.doLog("[{1}] Veh = {0}", randomVehicleInfo?.ToString() ?? "<NULL>", material); if (randomVehicleInfo != null) { Array16 <Vehicle> vehicles = Singleton <VehicleManager> .instance.m_vehicles; instance.CalculateSpawnPosition(buildingID, ref data, ref Singleton <SimulationManager> .instance.m_randomizer, randomVehicleInfo, out Vector3 position, out Vector3 vector2); if (Singleton <VehicleManager> .instance.CreateVehicle(out ushort num, ref Singleton <SimulationManager> .instance.m_randomizer, randomVehicleInfo, position, material, tup.Second, tup.Third)) { randomVehicleInfo.m_vehicleAI.SetSource(num, ref vehicles.m_buffer[(int)num], buildingID); randomVehicleInfo.m_vehicleAI.StartTransfer(num, ref vehicles.m_buffer[(int)num], material, offer); return(true); } } } return(false); }
private void CreateCheckboxes() { foreach (var i in m_checkboxes?.Keys) { UnityEngine.Object.Destroy(m_checkboxes[i].gameObject); } m_defaultAssets = extension.GetAllBasicAssets(); m_checkboxes = new Dictionary <string, UICheckBox>(); SVMUtils.doLog("m_defaultAssets Size = {0} ({1})", m_defaultAssets?.Count, string.Join(",", m_defaultAssets.Keys?.ToArray() ?? new string[0])); foreach (var i in m_defaultAssets.Keys) { var checkbox = (UICheckBox)m_uiHelper.AddCheckbox(m_defaultAssets[i], false, (x) => { int districtIdx = SVMTabPanel.instance.getCurrentSelectedDistrictId(); if (m_isLoading || districtIdx < 0) { return; } if (x) { extension.AddAssetDistrict((uint)districtIdx, i); } else { extension.RemoveAssetDistrict((uint)districtIdx, i); } }); CreateModelCheckBox(i, checkbox); checkbox.label.tooltip = checkbox.label.text; checkbox.label.textScale = 0.9f; checkbox.label.transform.localScale = new Vector3(Math.Min((m_mainPanel.width - 70) / checkbox.label.width, 1), 1); m_checkboxes[i] = checkbox; } }
public bool isFromSystem(BuildingInfo info) { if (ServiceVehiclesManagerMod.debugMode) { SVMUtils.doLog("[{4}->{5}] info.m_class.m_service == service = {0}; subService == info.m_class.m_subService = {1}; info.m_class.m_level == level = {2}; aiOverride?.AllowVehicleType(vehicleType) = {3} ", info?.m_class?.m_service == service, subService == info?.m_class?.m_subService, info?.m_class?.m_level == level, SVMBuildingAIOverrideUtils.getBuildingOverrideExtension(info)?.AllowVehicleType(vehicleType, info?.GetAI()), info?.GetAI()?.GetType(), this); } return(info?.m_class?.m_service == service && subService == info?.m_class?.m_subService && (info?.m_class?.m_level == level || outsideConnection) && info?.GetAI() is OutsideConnectionAI == outsideConnection && (SVMBuildingAIOverrideUtils.getBuildingOverrideExtension(info)?.AllowVehicleType(vehicleType, info?.GetAI()) ?? false)); }
private void CreateScrollPanel() { m_uiHelper = SVMUtils.CreateScrollPanel(m_mainPanel, out m_scrollablePanel, out m_scrollbar, m_mainPanel.width - 20f, m_mainPanel.height - 90f, new Vector3(5, 45)); m_scrollablePanel.eventMouseLeave += (x, y) => { m_previewPanel.isVisible = false; }; }
public override void Awake() { instance = this; var from = typeof(OutsideConnectionAI).GetMethod("StartConnectionTransferImpl", allFlags); var to = typeof(OutsideConnectionAIOverrides).GetMethod("StartTransferOverride", allFlags); SVMUtils.doLog("Loading Hooks: {0} ({1}=>{2})", typeof(OutsideConnectionAI), from, to); AddRedirect(from, to); }
private void CreateScrollPanel() { SVMUtils.createUIElement(out m_scrollablePanel, m_mainPanel.transform); m_scrollablePanel.width = m_mainPanel.width - 20f; m_scrollablePanel.height = m_mainPanel.height - 50f; m_scrollablePanel.autoLayoutDirection = LayoutDirection.Vertical; m_scrollablePanel.autoLayoutStart = LayoutStart.TopLeft; m_scrollablePanel.autoLayoutPadding = new RectOffset(0, 0, 0, 0); m_scrollablePanel.scrollPadding = new RectOffset(10, 10, 10, 10); m_scrollablePanel.autoLayout = true; m_scrollablePanel.clipChildren = true; m_scrollablePanel.relativePosition = new Vector3(5, 45); m_scrollablePanel.backgroundSprite = "ScrollbarTrack"; SVMUtils.createUIElement(out UIPanel trackballPanel, m_mainPanel.transform); trackballPanel.width = 10f; trackballPanel.height = m_scrollablePanel.height; trackballPanel.autoLayoutDirection = LayoutDirection.Horizontal; trackballPanel.autoLayoutStart = LayoutStart.TopLeft; trackballPanel.autoLayoutPadding = new RectOffset(0, 0, 0, 0); trackballPanel.autoLayout = true; trackballPanel.relativePosition = new Vector3(m_mainPanel.width - 15, 45); SVMUtils.createUIElement(out m_scrollbar, trackballPanel.transform); m_scrollbar.width = 10f; m_scrollbar.height = m_scrollbar.parent.height; m_scrollbar.orientation = UIOrientation.Vertical; m_scrollbar.pivot = UIPivotPoint.BottomLeft; m_scrollbar.AlignTo(trackballPanel, UIAlignAnchor.TopRight); m_scrollbar.minValue = 0f; m_scrollbar.value = 0f; m_scrollbar.incrementAmount = 25f; SVMUtils.createUIElement(out UISlicedSprite scrollBg, m_scrollbar.transform); scrollBg.relativePosition = Vector2.zero; scrollBg.autoSize = true; scrollBg.size = scrollBg.parent.size; scrollBg.fillDirection = UIFillDirection.Vertical; scrollBg.spriteName = "ScrollbarTrack"; m_scrollbar.trackObject = scrollBg; SVMUtils.createUIElement(out UISlicedSprite scrollFg, scrollBg.transform); scrollFg.relativePosition = Vector2.zero; scrollFg.fillDirection = UIFillDirection.Vertical; scrollFg.autoSize = true; scrollFg.width = scrollFg.parent.width - 4f; scrollFg.spriteName = "ScrollbarThumb"; m_scrollbar.thumbObject = scrollFg; m_scrollablePanel.verticalScrollbar = m_scrollbar; m_scrollablePanel.eventMouseWheel += delegate(UIComponent component, UIMouseEventParameter param) { m_scrollablePanel.scrollPosition += new Vector2(0f, Mathf.Sign(param.wheelDelta) * -1f * m_scrollbar.incrementAmount); }; m_uiHelper = new UIHelperExtension(m_scrollablePanel); }
private static UIButton CreateTabTemplate() { SVMUtils.createUIElement(out UIButton tabTemplate, null, "SVMTabTemplate"); SVMUtils.initButton(tabTemplate, false, "GenericTab"); tabTemplate.autoSize = false; tabTemplate.width = 40; tabTemplate.height = 40; tabTemplate.foregroundSpriteMode = UIForegroundSpriteMode.Scale; return(tabTemplate); }
private void onChangeDistrictColor(UIComponent component, Color value) { SVMUtils.doLog("onChangeDistrictColor"); if (!getCurrentSelectedId(out int currentDistrict)) { return; } extension.SetColorDistrict((uint)currentDistrict, value); eventOnColorDistrictChanged?.Invoke(value); }
private Color32 GetColor(uint codedId) { if (SVMConfigWarehouse.allowColorChanging(ConfigIndexKey)) { checkId(codedId); string value = SafeGet(codedId, BuildingConfig.COLOR); return(SVMUtils.DeserializeColor(value, ItSepLvl3)); } return(new Color32(0, 0, 0, 1)); }
//ACOES private void saveBuildingName(UITextField u) { string value = u.text; Singleton <BuildingManager> .instance.StartCoroutine(SVMUtils.setBuildingName(m_buildingIdSelecionado.Building, value, () => { buildingNameField.text = Singleton <BuildingManager> .instance.GetBuildingName(m_buildingIdSelecionado.Building, default(InstanceID)); EventOnBuildingSelChanged?.Invoke(m_buildingIdSelecionado.Building); })); }
public static IBasicBuildingAIOverrides getBuildingOverrideExtension(BuildingInfo info) { PrefabAI targetAi = info.GetAI(); Type targetTypeAi = targetAi.GetType(); if (subtypes == null) { subtypes = new Dictionary <Type, Type>(); var subclasses = SVMUtils.GetSubtypesRecursive(typeof(BasicBuildingAIOverrides <,>), typeof(SVMBuildingAIOverrideUtils)); SVMUtils.doLog("GetOverride pré - subclasses:\r\n\t{0}", string.Join("\r\n\t", subclasses?.Select(x => x.ToString())?.ToArray() ?? new string[0])); foreach (Type t in subclasses) { try { subtypes[t.BaseType.GetGenericArguments()[1]] = t; } catch (Exception e) { SVMUtils.doErrorLog("ERROR ADDING SUBTYPE {0}!\r\n{1}", t, subclasses); } } SVMUtils.doLog("GetOverride - Classes:\r\n\t{0}", string.Join("\r\n\t", subtypes?.Select(x => x.Key.ToString() + "=>" + x.Value.ToString())?.ToArray() ?? new string[0])); } Type targetClass = null; IBasicBuildingAIOverrides value = null; if (!subtypes.ContainsKey(targetTypeAi)) { foreach (var clazz in subtypes.Keys) { if (clazz.IsAssignableFrom(targetTypeAi)) { value = (IBasicBuildingAIOverrides)SVMUtils.GetPrivateStaticField("instance", subtypes[clazz]); //SVMUtils.doLog("GetOverride - clazz = {0}; value = {1}", clazz, value); if (value.AcceptsAI(targetAi)) { targetClass = subtypes[clazz]; break; } } } SVMUtils.doLog("GetOverride - targetClass = {0} ({1})", targetClass, targetTypeAi); if (targetClass == null) { return(null); } } else { targetClass = subtypes[targetTypeAi]; value = (IBasicBuildingAIOverrides)SVMUtils.GetPrivateStaticField("instance", targetClass); } //SVMUtils.doLog("GetOverride - value = {0}", value); return((IBasicBuildingAIOverrides)value); }
public void OnSettingsUI(UIHelperBase helperDefault) { UIHelperExtension helper = new UIHelperExtension((UIHelper)helperDefault); void ev() { foreach (Transform child in helper.self.transform) { GameObject.Destroy(child?.gameObject); } helper.self.eventVisibilityChanged += delegate(UIComponent component, bool b) { if (b) { showVersionInfoPopup(); } }; UIHelperExtension group9 = helper.AddGroupExtended(Locale.Get("SVM_BETAS_EXTRA_INFO")); group9.AddDropdownLocalized("SVM_MOD_LANG", SVMLocaleUtils.getLanguageIndex(), currentLanguageId.value, delegate(int idx) { currentLanguageId.value = idx; loadSVMLocale(true); }); group9.AddCheckbox(Locale.Get("SVM_DEBUG_MODE"), m_debugMode.value, delegate(bool val) { m_debugMode.value = val; }); group9.AddLabel("Version: " + fullVersion); group9.AddLabel(Locale.Get("SVM_ORIGINAL_TLM_VERSION") + " " + string.Join(".", ResourceLoader.loadResourceString("TLMVersion.txt").Split(".".ToCharArray()).Take(3).ToArray())); group9.AddButton(Locale.Get("SVM_RELEASE_NOTES"), delegate() { showVersionInfoPopup(true); }); //string testString = ""; //for (int i = 0; i < 360; i++) //{ // var angle = Vector2.zero.GetAngleToPoint(new Vector2(Mathf.Sin(i * Mathf.Deg2Rad), Mathf.Cos(i * Mathf.Deg2Rad))); // testString += $"{i:n0}° => {angle:n1} ({Mathf.Sin(i * Mathf.Deg2Rad):n3}, {Mathf.Cos(i * Mathf.Deg2Rad):n3})\n"; //} //group9.AddLabel("TST:\n" + testString); SVMUtils.doLog("End Loading Options"); } if (IsKlyteCommonsEnabled()) { loadSVMLocale(false); ev(); } else { eventOnLoadLocaleEnd = null; eventOnLoadLocaleEnd += ev; } }
private void PopulateCheckboxes() { foreach (var i in m_checkboxes.Keys) { UnityEngine.Object.Destroy(m_checkboxes[i].gameObject); } var ssd = Singleton <T> .instance.GetSSD(); m_defaultAssets = ssd.GetTransportExtension().GetAllBasicAssets(); m_checkboxes = new Dictionary <string, UICheckBox>(); SVMUtils.doLog("m_defaultAssets Size = {0} ({1})", m_defaultAssets?.Count, string.Join(",", m_defaultAssets.Keys?.ToArray() ?? new string[0])); foreach (var i in m_defaultAssets.Keys) { var checkbox = (UICheckBox)m_uiHelper.AddCheckbox(m_defaultAssets[i], false, (x) => { var ext = Singleton <T> .instance.GetSSD().GetTransportExtension(); ushort buildingId = m_buildingInfo.buildingIdSel.Building; if (m_isLoading) { return; } if (x) { if (ext.GetIgnoreDistrict(buildingId)) { ext.AddAssetBuilding(buildingId, i); } else { ext.AddAssetDistrict(SVMUtils.GetBuildingDistrict(buildingId), i); } } else { if (ext.GetIgnoreDistrict(buildingId)) { ext.RemoveAssetBuilding(buildingId, i); } else { ext.RemoveAssetDistrict(SVMUtils.GetBuildingDistrict(buildingId), i); } } }); CreateModelCheckBox(i, checkbox); checkbox.label.tooltip = checkbox.label.text; checkbox.label.textScale = 0.9f; checkbox.label.transform.localScale = new Vector3(Math.Min((m_mainPanel.width - 50) / checkbox.label.width, 1), 1); m_checkboxes[i] = checkbox; } }
private static bool CreateIncomingVehicle(bool __result, TransportStationAI __instance, ushort buildingID, ref Building buildingData, ushort startStop, int gateIndex) { if (__instance.m_transportLineInfo != null && (ushort)FindConnectionVehicle.Invoke(__instance, new object[] { buildingID, buildingData, startStop, 3000f }) == 0) { SVMUtils.doLog("START CreateIncomingVehicle: {0} , {1}", typeof(TransportStationAI), __instance.name); ServiceSystemDefinition def = ServiceSystemDefinition.from(buildingData.Info).FirstOrDefault(); if (def == null) { SVMUtils.doLog("SSD Não definido para: {0} {1} {2}", buildingData.Info.m_class.m_service, buildingData.Info.m_class.m_subService, buildingData.Info.m_class.m_level); return(false); } SVMUtils.doLog("[{1}] SSD = {0}", def, "CreateIncomingVehicle"); VehicleInfo randomVehicleInfo = ServiceSystemDefinition.availableDefinitions[def].GetAModel(buildingID); SVMUtils.doLog("[{1}] Veh = {0}", randomVehicleInfo?.ToString() ?? "<NULL>", "CreateIncomingVehicle"); if (randomVehicleInfo != null) { ushort num = (ushort)FindConnectionBuilding.Invoke(__instance, new object[] { startStop }); if (num != 0) { Array16 <Vehicle> vehicles = Singleton <VehicleManager> .instance.m_vehicles; BuildingInfo info = Singleton <BuildingManager> .instance.m_buildings.m_buffer[(int)num].Info; Randomizer randomizer = default(Randomizer); randomizer.seed = (ulong)((long)gateIndex); Vector3 vector; Vector3 vector2; info.m_buildingAI.CalculateSpawnPosition(num, ref Singleton <BuildingManager> .instance.m_buildings.m_buffer[(int)num], ref randomizer, randomVehicleInfo, out vector, out vector2); TransportInfo transportInfo = __instance.m_transportInfo; if (__instance.m_secondaryTransportInfo != null && __instance.m_secondaryTransportInfo.m_class.m_subService == __instance.m_transportLineInfo.m_class.m_subService) { transportInfo = __instance.m_secondaryTransportInfo; } if (randomVehicleInfo.m_vehicleAI.CanSpawnAt(vector) && Singleton <VehicleManager> .instance.CreateVehicle(out ushort num2, ref Singleton <SimulationManager> .instance.m_randomizer, randomVehicleInfo, vector, transportInfo.m_vehicleReason, true, false)) { vehicles.m_buffer[(int)num2].m_gateIndex = (byte)gateIndex; Vehicle[] expr_172_cp_0 = vehicles.m_buffer; ushort expr_172_cp_1 = num2; expr_172_cp_0[(int)expr_172_cp_1].m_flags = (expr_172_cp_0[(int)expr_172_cp_1].m_flags | (Vehicle.Flags.Importing | Vehicle.Flags.Exporting)); randomVehicleInfo.m_vehicleAI.SetSource(num2, ref vehicles.m_buffer[(int)num2], num); randomVehicleInfo.m_vehicleAI.SetSource(num2, ref vehicles.m_buffer[(int)num2], buildingID); randomVehicleInfo.m_vehicleAI.SetTarget(num2, ref vehicles.m_buffer[(int)num2], startStop); SVMUtils.doLog("END CreateIncomingVehicle: {0} , {1}", typeof(TransportStationAI), __instance.name); __result = true; return(false); } } } } SVMUtils.doLog("END2 CreateIncomingVehicle: {0} , {1}", typeof(TransportStationAI), __instance.name); __result = false; return(false); }
public override void Awake() { instance = this; var from = typeof(TransportStationAI).GetMethod("CreateIncomingVehicle", allFlags); var to = typeof(TransportStationAIOverrides).GetMethod("CreateIncomingVehicle", allFlags); var from2 = typeof(TransportStationAI).GetMethod("CreateOutgoingVehicle", allFlags); var to2 = typeof(TransportStationAIOverrides).GetMethod("CreateOutgoingVehicle", allFlags); SVMUtils.doLog("Loading Hooks: {0} ({1}=>{2})", typeof(TransportStationAI), from, to); SVMUtils.doLog("Loading Hooks: {0} ({1}=>{2})", typeof(TransportStationAI), from2, to2); AddRedirect(from, to); AddRedirect(from2, to2); }
public override void AwakeBody() { instance = this; ServiceSystemDefinition def = Singleton <V> .instance.GetSSD(); var from = typeof(BuildingManager).GetMethod("CreateBuilding", allFlags); var to = typeof(SVMTabControllerBuildingHooks <T, V>).GetMethod("AfterCreateBuilding", allFlags); var from2 = typeof(BuildingManager).GetMethod("ReleaseBuilding", allFlags); var to2 = typeof(SVMTabControllerBuildingHooks <T, V>).GetMethod("AfterRemoveBuilding", allFlags); SVMUtils.doLog("Loading After Hooks: {0} ({1}=>{2})", typeof(BuildingManager), from, to); SVMUtils.doLog("Loading After Hooks: {0} ({1}=>{2})", typeof(BuildingManager), from2, to2); AddRedirect(from, null, to); AddRedirect(from2, null, to2); }
public void setTabContent <T>(SVMTabControllerDistrictList <T> tabContent) where T : SVMSysDef <T> { if (m_system == null) { m_system = Singleton <T> .instance.GetSSD(); m_parent = tabContent.mainPanel; CreateWindow(); tabContent.eventOnDistrictSelectionChanged += onDistrictChanged; tabContent.eventOnColorDistrictChanged += (color) => { SVMUtils.doLog("eventOnColorDistrictChanged"); m_lastColor = color; }; } }
private void SetPreviewWindow() { SVMUtils.createUIElement(out m_previewPanel, m_mainPanel.transform); m_previewPanel.backgroundSprite = "GenericPanel"; m_previewPanel.width = m_parent.width - 400f; m_previewPanel.height = 170; m_previewPanel.relativePosition = new Vector3(-m_previewPanel.width, m_mainPanel.height - 175); SVMUtils.createUIElement(out m_preview, m_previewPanel.transform); this.m_preview.size = m_previewPanel.size; this.m_preview.relativePosition = Vector3.zero; SVMUtils.createElement(out m_previewRenderer, m_mainPanel.transform); this.m_previewRenderer.size = this.m_preview.size * 2f; this.m_preview.texture = this.m_previewRenderer.texture; m_previewRenderer.zoom = 3; m_previewRenderer.cameraRotation = 40; }