public void openDepotInfo(ushort buildingID) { isLoading = true; WorldInfoPanel.HideAllWorldInfoPanels(); m_buildingIdSelecionado = default(InstanceID); m_buildingIdSelecionado.Building = buildingID; DepotAI depotAI = Singleton <BuildingManager> .instance.m_buildings.m_buffer[buildingID].Info.GetAI() as DepotAI; if (depotAI == null) { return; } depotNameField.text = Singleton <BuildingManager> .instance.GetBuildingName(buildingID, default(InstanceID)); lineTransportIconTypeLabel.relativePosition = new Vector3(10f, 12f); lineTransportIconTypeLabel.height = 20; lineTransportIconTypeLabel.backgroundSprite = PublicTransportWorldInfoPanel.GetVehicleTypeIcon(depotAI.m_transportInfo.m_transportType); Show(); m_controller.defaultListingLinesPanel.Hide(); updateCheckboxes(); isLoading = false; }
public void openInfo(ushort buildingID) { WorldInfoPanel.HideAllWorldInfoPanels(); var ssds = ServiceSystemDefinition.from(Singleton <BuildingManager> .instance.m_buildings.m_buffer[buildingID].Info); var ext = ssds.First().GetTransportExtension(); m_buildingIdSelecionado = default(InstanceID); m_ignoreDistrict.isChecked = ext.GetIgnoreDistrict(buildingID); m_buildingIdSelecionado.Building = buildingID; buildingNameField.text = Singleton <BuildingManager> .instance.GetBuildingName(buildingID, default(InstanceID)); var configIdx = ssds.First().toConfigIndex(); String bgIcon = SVMConfigWarehouse.getIconServiceSystem(configIdx); String fgIcon = SVMConfigWarehouse.getFgIconServiceSystem(configIdx); buildingTypeIcon.normalFgSprite = bgIcon; buildingTypeIconFg.spriteName = fgIcon; SVMController.instance.CloseSVMPanel(); Show(); EventOnBuildingSelChanged?.Invoke(buildingID); }
private void EnableTool() { Log("EnableTool: called"); WorldInfoPanel.HideAllWorldInfoPanels(); GameAreaInfoPanel.Hide(); ToolsModifierControl.toolController.CurrentTool = this; }
public override void OnUpdate(float realTimeDelta, float simulationTimeDelta) { if (Event.current.alt && Input.GetKeyDown(KeyCode.T)) { var manager = Singleton <InfoManager> .instance; UIView.playSoundDelegate(UIView.GetAView().defaultClickSound, 1f); if (manager.CurrentMode != InfoManager.InfoMode.TerrainHeight) { BuildingTool currentTool = ToolsModifierControl.GetCurrentTool <BuildingTool>(); if (currentTool != null && currentTool.m_relocate != 0) { currentTool.CancelRelocate(); } Singleton <InfoViewsPanel> .instance.CloseToolbar(); WorldInfoPanel.HideAllWorldInfoPanels(); if (Singleton <InfoManager> .exists) { m_previousMode = manager.CurrentMode; m_previousSubInfoMode = manager.CurrentSubMode; Singleton <InfoManager> .instance.SetCurrentMode(InfoManager.InfoMode.TerrainHeight, InfoManager.SubInfoMode.Default); Singleton <GuideManager> .instance.InfoViewUsed(); } } else { Singleton <InfoViewsPanel> .instance.CloseToolbar(); manager.SetCurrentMode(m_previousMode, m_previousSubInfoMode); Singleton <GuideManager> .instance.InfoViewUsed(); } } }
/// <summary> /// ToolsModifierControl.SetTool /// But instead of searching the tool in ToolsModifierControl.m_Tools, /// this method uses ToolsModifierControl.toolController.gameObject.GetComponent<T> /// </summary> public static T SetTool <T>() where T : ToolBase { var toolController = ToolsModifierControl.toolController; if (toolController == null) { return(null); } var tool = toolController.GetComponent <T>(); if (tool == null) { return(null); } if (!ToolsModifierControl.keepThisWorldInfoPanel) { WorldInfoPanel.HideAllWorldInfoPanels(); } GameAreaInfoPanel.Hide(); ToolsModifierControl.keepThisWorldInfoPanel = false; if (toolController.CurrentTool != tool) { toolController.CurrentTool = tool; } return(tool); }
public void Show(Vector3 worldMousePosition, InstanceID instanceID) { this.m_WorldMousePosition = worldMousePosition; this.m_InstanceID = instanceID; if (InstanceManager.IsValid(this.m_InstanceID)) { WorldInfoPanel.HideAllWorldInfoPanels(); NetManager instance = Singleton <NetManager> .instance; ushort transportLine = instance.m_nodes.m_buffer[(int)this.m_InstanceID.NetNode].m_transportLine; this.m_VehicleType.spriteName = PublicTransportWorldInfoPanel.GetVehicleTypeIcon(Singleton <TransportManager> .instance.m_lines.m_buffer[(int)transportLine].Info.m_transportType); this.m_StopIndex = TransportLineMod.GetStopIndex(transportLine, this.m_InstanceID.NetNode); this.m_StopName.text = Singleton <InstanceManager> .instance.GetName(this.m_InstanceID) ?? string.Format(Localization.Get("STOP_LIST_BOX_ROW_STOP"), (object)(this.m_StopIndex + 1)); this.m_SuggestedNames.ClearItems(); this.m_SuggestedNames.AddItems(this.FindBuildings(instance.m_nodes.m_buffer[(int)this.m_InstanceID.NetNode].m_position), new Func <ushort, string>(this.IDToName)); this.m_Line.text = Singleton <TransportManager> .instance.GetLineName(transportLine); this.Show(); this.LateUpdate(); } else { this.Hide(); } }
public void openDepotInfo(ushort buildingID, bool secondary) { isLoading = true; WorldInfoPanel.HideAllWorldInfoPanels(); m_buildingIdSelecionado = default(InstanceID); m_buildingIdSelecionado.Building = buildingID; DepotAI depotAI = Singleton <BuildingManager> .instance.m_buildings.m_buffer[buildingID].Info.GetAI() as DepotAI; if (depotAI == null) { return; } depotNameField.text = Singleton <BuildingManager> .instance.GetBuildingName(buildingID, default(InstanceID)); bool hasPrimary = depotAI.m_transportInfo != null && depotAI.m_maxVehicleCount > 0; bool hasSecondary = depotAI.m_secondaryTransportInfo != null && depotAI.m_maxVehicleCount2 > 0; if (!hasPrimary && !hasSecondary) { closeDepotInfo(null, null); return; } m_secondary = !hasPrimary || (secondary && hasSecondary); TransportInfo currentTransportInfo = m_secondary ? depotAI.m_secondaryTransportInfo : depotAI.m_transportInfo; TransportInfo otherInfo = !m_secondary && depotAI.m_secondaryTransportInfo != null ? depotAI.m_secondaryTransportInfo : depotAI.m_transportInfo; var tsd = TransportSystemDefinition.from(currentTransportInfo); depotInfoPanel.color = Color.Lerp(TLMCW.getColorForTransportType(tsd.toConfigIndex()), Color.white, 0.5f); lineTransportIconTypeLabel.relativePosition = new Vector3(10f, 12f); lineTransportIconTypeLabel.height = 20; lineTransportIconTypeLabel.normalBgSprite = PublicTransportWorldInfoPanel.GetVehicleTypeIcon(currentTransportInfo.m_transportType); lineTransportIconTypeLabel.disabledBgSprite = PublicTransportWorldInfoPanel.GetVehicleTypeIcon(currentTransportInfo.m_transportType); lineTransportIconTypeLabel.focusedBgSprite = PublicTransportWorldInfoPanel.GetVehicleTypeIcon(currentTransportInfo.m_transportType); lineTransportIconTypeLabel.hoveredBgSprite = PublicTransportWorldInfoPanel.GetVehicleTypeIcon(otherInfo.m_transportType); if (depotAI.m_secondaryTransportInfo != null) { lineTransportIconTypeLabel.tooltip = string.Format(Locale.Get("TLM_SEE_OTHER_DEPOT"), TLMConfigWarehouse.getNameForTransportType(TransportSystemDefinition.from(otherInfo).toConfigIndex())); } else { lineTransportIconTypeLabel.tooltip = ""; } Show(); m_controller.defaultListingLinesPanel.Hide(); updateCheckboxes(); isLoading = false; }
private void RemoveButtonHandler(UIComponent component, UIMouseEventParameter param) { InstanceID id = WorldInfoPanel.GetCurrentInstanceID(); if (id.IsEmpty) { return; } if (id.Vehicle != 0) { Helper.Instance.NotifyPlayer($"Registering vehicle {id.Vehicle} for removal."); _helper.ManualRemovalRequests.Add(id.Vehicle); } else if (id.ParkedVehicle != 0) { InstanceID _selected; InstanceID _dummy = default(InstanceID); if (WorldInfoPanel.AnyWorldInfoPanelOpen()) { _selected = WorldInfoPanel.GetCurrentInstanceID(); if (_selected.IsEmpty || _selected.ParkedVehicle == 0) { _selected = default(InstanceID); } } else { _selected = default(InstanceID); } if (!_selected.IsEmpty && _selected.ParkedVehicle == id.ParkedVehicle) { WorldInfoPanel.HideAllWorldInfoPanels(); if (!InstanceManager.IsValid(_dummy) || _dummy.ParkedVehicle == id.ParkedVehicle) { _dummy = default(InstanceID); _dummy.Type = InstanceType.ParkedVehicle; } Singleton <InstanceManager> .instance.SelectInstance(_dummy); Singleton <InstanceManager> .instance.FollowInstance(_dummy); } Singleton <VehicleManager> .instance.m_parkedVehicles.m_buffer[(int)id.ParkedVehicle].m_flags |= 2; Singleton <VehicleManager> .instance.ReleaseParkedVehicle((ushort)id.ParkedVehicle); } }
public void deleteSelectedVehicle() { if (!remove_init) { InstanceID _selected; if (WorldInfoPanel.AnyWorldInfoPanelOpen()) { _selected = WorldInfoPanel.GetCurrentInstanceID(); if (_selected.IsEmpty || _selected.ParkedVehicle == 0) { _selected = default(InstanceID); } } else { _selected = default(InstanceID); } remove_init = true; } if (!_selected.IsEmpty) { uint citizen = _selected.Citizen; if (!SkylinesOverwatch.Data.Instance.IsResident(citizen)) { return; } CitizenInfo citizenInfo = Singleton <CitizenManager> .instance.m_citizens.m_buffer[(int)((UIntPtr)citizen)].GetCitizenInfo(citizen); InstanceID instanceID2; if (citizenInfo.m_citizenAI.GetLocalizedStatus(citizen, ref Singleton <CitizenManager> .instance.m_citizens.m_buffer[(int)((UIntPtr)citizen)], out instanceID2) == _citizen_confused) { WorldInfoPanel.HideAllWorldInfoPanels(); if (!InstanceManager.IsValid(_dummy) || _dummy.ParkedVehicle == _selected.ParkedVehicle) { _dummy = default(InstanceID); _dummy.Type = InstanceType.ParkedVehicle; } Singleton <InstanceManager> .instance.SelectInstance(_dummy); Singleton <InstanceManager> .instance.FollowInstance(_dummy); deleteParkedVehicle(_selected.ParkedVehicle); } } }
protected override void OnButtonClicked(int index) { if (index >= 0 && index < this.m_buttonToResource.Length) { index = this.m_buttonToResource[index]; } if (index >= 0 && index < kResources.Length) { var currentTool = ToolsModifierControl.GetCurrentTool <ToolBase>(); if (currentTool != null && (currentTool is NetTool || currentTool is BuildingTool || currentTool is DistrictTool || currentTool is TreeTool || currentTool is ResourceTool)) { ToolBaseDetour.ForceMode(kResources[index].enumValue, InfoManager.SubInfoMode.Default); } else { ToolBaseDetour.ResetForceMode(); this.CloseToolbar(); WorldInfoPanel.HideAllWorldInfoPanels(); if (!Singleton <InfoManager> .exists) { return; } Singleton <InfoManager> .instance.SetCurrentMode(kResources[index].enumValue, InfoManager.SubInfoMode.Default); Singleton <GuideManager> .instance.InfoViewUsed(); } } else { ToolBaseDetour.ResetForceMode(); this.CloseToolbar(); if (!Singleton <InfoManager> .exists) { return; } Singleton <InfoManager> .instance.SetCurrentMode(InfoManager.InfoMode.None, InfoManager.SubInfoMode.Default); Singleton <GuideManager> .instance.InfoViewUsed(); } }
private static void SetToolInternal(ToolController toolController, Type toolType) { FieldInfo toolField = typeof(ToolsModifierControl).GetField("m_Tools", BindingFlags.Static | BindingFlags.NonPublic); var tools = (Dictionary <Type, ToolBase>)toolField.GetValue(null); ToolBase toolBase; if (toolController != null && tools.TryGetValue(toolType, out toolBase)) { if (!ToolsModifierControl.keepThisWorldInfoPanel) { WorldInfoPanel.HideAllWorldInfoPanels(); } GameAreaInfoPanel.Hide(); ToolsModifierControl.keepThisWorldInfoPanel = false; if (toolController.CurrentTool != toolBase) { toolController.CurrentTool = toolBase; } } }
public void LaunchRowObject(UIComponent component) { UIPanel panel = component as UIPanel; if (panel != null) { SaveGameRowStruct sgrs = panel.objectUserData as SaveGameRowStruct; if (sgrs != null) { if (SavePanel.isSaving || !Singleton <LoadingManager> .exists || Singleton <LoadingManager> .instance.m_currentlyLoading) { return; } //this.CloseEverything(); WorldInfoPanel.HideAllWorldInfoPanels(); SaveGameMetaData listingMetaData = sgrs.saveMeta; // this.GetListingMetaData(this.m_SaveList.selectedIndex); Package.Asset listingData = sgrs.saveMeta.assetRef; // this.GetListingData(this.m_SaveList.selectedIndex); SimulationMetaData ngs = new SimulationMetaData() { m_CityName = listingMetaData.cityName, m_updateMode = SimulationManager.UpdateMode.LoadGame //, //m_environment = this.m_forceEnvironment }; if (Singleton <PluginManager> .instance.enabledModCount > 0 || listingData.package.GetPublishedFileID() != PublishedFileId.invalid) { ngs.m_disableAchievements = SimulationMetaData.MetaBool.True; } Singleton <LoadingManager> .instance.LoadLevel(listingData, "Game", "InGame", ngs); //UIView.library.Hide(this.GetType().Name, 1); ParentBetterLoadPanelWrapper.Hide(); } } }
public void Show(ushort stopId) { InstanceID instanceId = InstanceID.Empty; instanceId.NetNode = stopId; if (!InstanceManager.IsValid(instanceId)) { Debug.LogWarning("Invalid instance ID for StopDestinationInfoPanel"); this.Hide(); return; } this.AttemptToShowIPT2Panel(instanceId); this.stopId = stopId; var node = Singleton <NetManager> .instance.m_nodes.m_buffer[this.stopId]; this.transportLineId = node.m_transportLine; Debug.Log("Valid instance ID for StopDestinationInfoPanel"); WorldInfoPanel.HideAllWorldInfoPanels(); this.m_LineNameLabel.text = Singleton <TransportManager> .instance.GetLineName(this.transportLineId) + " destinations"; this.m_StopNameLabel.text = "Stop #" + this.GetStopIndex(); int passengerCount = Singleton <TransportManager> .instance.m_lines.m_buffer[this.transportLineId].CalculatePassengerCount(this.stopId); this.m_PassengerCountLabel.text = "Waiting passengers: " + passengerCount; this.m_BuildingPopularities = this.GetPositionPopularities(); ToolsModifierControl.cameraController.SetTarget(instanceId, node.m_position, false); this.Show(); }
public void openLineInfo(ushort lineID) { if (lineID <= 0) { return; } WorldInfoPanel.HideAllWorldInfoPanels(); linePrefixDropDown.eventSelectedIndexChanged -= saveLineNumber; lineNumberLabel.eventLostFocus -= saveLineNumber; m_lineIdSelecionado = default(InstanceID); m_lineIdSelecionado.TransportLine = lineID; TransportLine t = m_controller.tm.m_lines.m_buffer[(int)lineID]; ushort lineNumber = t.m_lineNumber; TLMCW.ConfigIndex transportType = TLMCW.getDefinitionForLine(lineID).toConfigIndex(); ModoNomenclatura mnPrefixo = (ModoNomenclatura)TLMCW.getCurrentConfigInt(TLMConfigWarehouse.ConfigIndex.PREFIX | transportType); if (mnPrefixo != ModoNomenclatura.Nenhum) { lineNumberLabel.text = (lineNumber % 1000).ToString(); lineNumberLabel.relativePosition = new Vector3(110f, 3f); lineNumberLabel.width = 55; linePrefixDropDown.enabled = false; var temp = TLMUtils.getStringOptionsForPrefix(mnPrefixo); for (uint i = 0; i < temp.Length; i++) { string prefixName = TLMUtils.getTransportSystemPrefixName(transportType, i); if (prefixName != null && prefixName != string.Empty) { temp[(int)i] += " (" + prefixName + ")"; } } linePrefixDropDown.items = temp; linePrefixDropDown.selectedIndex = lineNumber / 1000; linePrefixDropDown.enabled = true; lineNumberLabel.maxLength = 3; } else { lineNumberLabel.text = (lineNumber).ToString(); lineNumberLabel.relativePosition = new Vector3(80f, 3f); lineNumberLabel.width = 75; lineNumberLabel.maxLength = 4; linePrefixDropDown.enabled = false; } lineNumberLabel.color = m_controller.tm.GetLineColor(lineID); lineNameField.text = m_controller.tm.GetLineName(lineID); lineTransportIconTypeLabel.relativePosition = new Vector3(10f, 12f); lineTransportIconTypeLabel.height = 20; lineTransportIconTypeLabel.atlas = linePrefixDropDown.atlas; lineTransportIconTypeLabel.backgroundSprite = PublicTransportWorldInfoPanel.GetVehicleTypeIcon(t.Info.m_transportType); lineColorPicker.selectedColor = m_controller.tm.GetLineColor(lineID); bool day, night, zeroed; TLMLineUtils.getLineActive(ref t, out day, out night, out zeroed); if (day && night) { lineTime.selectedIndex = 0; } else if (day) { lineTime.selectedIndex = 1; } else if (night) { lineTime.selectedIndex = 2; } else { lineTime.selectedIndex = 3; } m_linearMap.redrawLine(); Show(); m_controller.defaultListingLinesPanel.Hide(); m_autoNameLabel.text = m_linearMap.autoName; vehicleQuantitySet.text = TLMVehiclesLineManager.instance[this.lineIdSelecionado.TransportLine].ToString(); vehicleQuantitySet.area = new Vector4(150, 150, 50, 20); vehicleQuantitySet.color = Color.gray; linePrefixDropDown.eventSelectedIndexChanged += saveLineNumber; lineNumberLabel.eventLostFocus += saveLineNumber; }
private void RemoveVehicle(ushort vehicle, Boolean manual = false) { if (!remove_init) { if (WorldInfoPanel.AnyWorldInfoPanelOpen()) { _selected = WorldInfoPanel.GetCurrentInstanceID(); if (_selected.IsEmpty || _selected.Vehicle == 0) { _selected = default(InstanceID); } } else { _selected = default(InstanceID); } remove_init = true; } if (!_selected.IsEmpty && _selected.Vehicle == vehicle) { WorldInfoPanel.HideAllWorldInfoPanels(); if (!InstanceManager.IsValid(_dummy) || _dummy.Vehicle == vehicle) { _dummy = default(InstanceID); _dummy.Type = InstanceType.Vehicle; foreach (ushort i in SkylinesOverwatch.Data.Instance.Vehicles) { if (i == vehicle) { continue; } _dummy.Vehicle = i; break; } } Singleton <InstanceManager> .instance.SelectInstance(_dummy); Singleton <InstanceManager> .instance.FollowInstance(_dummy); } VehicleManager instance = Singleton <VehicleManager> .instance; HashSet <ushort> removals = new HashSet <ushort>(); ushort current = vehicle; while (current != 0) { removals.Add(current); current = instance.m_vehicles.m_buffer[(int)current].m_trailingVehicle; } current = instance.m_vehicles.m_buffer[(int)vehicle].m_firstCargo; while (current != 0) { removals.Add(current); current = instance.m_vehicles.m_buffer[(int)current].m_nextCargo; } foreach (ushort i in removals) { var targetVehicle = i; var thread = new System.Threading.Thread(() => { try { instance.ReleaseVehicle(i); } catch (Exception e) { string error = String.Format("Failed to release {0}\r\n", i); error += String.Format("Error: {0}\r\n", e.Message); error += "\r\n"; error += "==== STACK TRACE ====\r\n"; error += e.StackTrace; _helper.Log(error); if (manual) { _helper.NotifyPlayer($"Failed to remove vehicle: {i}{Environment.NewLine}{error}"); } } }); thread.Start(); thread.Join(); } SkylinesOverwatch.Helper.Instance.RequestVehicleRemoval(vehicle); if (manual) { _helper.NotifyPlayer($"Successfully removed vehicle: {vehicle}"); } }
protected override void OnToolGUI(Event e) { try { var hoverInstance = this.m_hoverInstance; var building = hoverInstance.Building; WorldInfoPanel.HideAllWorldInfoPanels(); if (Settings.keyCopy.IsPressed(e)) { if (building == 0 || BuildingManager.instance.m_buildings.m_buffer[building].Info.GetAI() is DummyBuildingAI || !(TransferManagerInfo.IsDistrictServicesBuilding(building) || TransferManagerInfo.IsCustomVehiclesBuilding(building))) { Utils.DisplayMessage( str1: "Enhanced District Services", str2: $"Cannot copy policy from this building!", str3: "IconMessage"); return; } CopyPaste.BuildingTemplate = building; } if (Settings.keyPaste.IsPressed(e)) { if (CopyPaste.BuildingTemplate == 0) { Utils.DisplayMessage( str1: "Enhanced District Services", str2: $"Please hover over a valid building and press Ctrl-C to copy its policy first!", str3: "IconMessage"); return; } if (building == 0 || BuildingManager.instance.m_buildings.m_buffer[building].Info.GetAI() is DummyBuildingAI || !(TransferManagerInfo.IsDistrictServicesBuilding(building) || TransferManagerInfo.IsCustomVehiclesBuilding(building))) { Utils.DisplayMessage( str1: "Enhanced District Services", str2: $"Cannot copy policy to this unsupported building!", str3: "IconMessage"); return; } var inputType1 = TransferManagerInfo.GetBuildingInputType(CopyPaste.BuildingTemplate); var inputType2 = TransferManagerInfo.GetBuildingInputType(building); if (inputType1 != inputType2) { Utils.DisplayMessage( str1: "Enhanced District Services", str2: $"Can only copy-paste policy between buildings of the same policy type!", str3: "IconMessage"); return; } var success = CopyPaste.CopyPolicyTo(building); if (!success) { Utils.DisplayMessage( str1: "Enhanced District Services", str2: $"Could not copy certain supply chain restrictions. Please check results of copy operation!", str3: "IconMessage"); return; } var position = BuildingManager.instance.m_buildings.m_buffer[building].m_position; var txt = GetBuildingInfoText(building); ShowToolInfo(true, txt, position); } if (!m_toolController.IsInsideUI && e.type == UnityEngine.EventType.MouseDown && e.button == 0) { if (!(TransferManagerInfo.IsDistrictServicesBuilding(building) || TransferManagerInfo.IsCustomVehiclesBuilding(building))) { return; } if (this.m_selectErrors == ToolBase.ToolErrors.None || this.m_selectErrors == ToolBase.ToolErrors.RaycastFailed) { Vector3 mousePosition = this.m_mousePosition; UIInput.MouseUsed(); if (!Singleton <InstanceManager> .instance.SelectInstance(hoverInstance)) { return; } SimulationManager.instance.AddAction(() => { var panel = EnhancedDistrictServicesUIPanel.Instance; if (panel != null) { panel.SetBuilding(hoverInstance.Building); panel.UpdatePositionToBuilding(hoverInstance.Building); panel.UpdatePanelToBuilding(hoverInstance.Building); panel.opacity = 1f; } Singleton <GuideManager> .instance.m_worldInfoNotUsed.Disable(); }); } } } catch (Exception ex) { Logger.LogWarning($"EnhancedDistrictServicesTool::OnToolGUI: ..."); Logger.LogException(ex); } }
private void RemoveVehicle(ushort vehicle) { if (!_selected.IsEmpty && _selected.Vehicle == vehicle) { WorldInfoPanel.HideAllWorldInfoPanels(); if (!InstanceManager.IsValid(_dummy) || _dummy.Vehicle == vehicle) { _dummy = default(InstanceID); _dummy.Type = InstanceType.Vehicle; foreach (ushort i in SkylinesOverwatch.Data.Instance.Vehicles) { if (i == vehicle) { continue; } _dummy.Vehicle = i; break; } } Singleton <InstanceManager> .instance.SelectInstance(_dummy); Singleton <InstanceManager> .instance.FollowInstance(_dummy); } VehicleManager instance = Singleton <VehicleManager> .instance; HashSet <ushort> removals = new HashSet <ushort>(); ushort current = vehicle; while (current != 0) { removals.Add(current); current = instance.m_vehicles.m_buffer[(int)current].m_trailingVehicle; } current = instance.m_vehicles.m_buffer[(int)vehicle].m_firstCargo; while (current != 0) { removals.Add(current); current = instance.m_vehicles.m_buffer[(int)current].m_nextCargo; } foreach (ushort i in removals) { try { instance.ReleaseVehicle(i); } catch (Exception e) { string error = String.Format("Failed to release {0}\r\n", i); error += String.Format("Error: {0}\r\n", e.Message); error += "\r\n"; error += "==== STACK TRACE ====\r\n"; error += e.StackTrace; _helper.Log(error); } } SkylinesOverwatch.Helper.Instance.RequestVehicleRemoval(vehicle); }