private void Update() { if ((Singleton <SimulationManager> .instance.m_currentTickIndex & 15) == 15) { if (!WorldInfoPanel.AnyWorldInfoPanelOpen()) { return; } InstanceID id = WorldInfoPanel.GetCurrentInstanceID(); if (id.IsEmpty) { return; } if (id.Vehicle == 0 && id.ParkedVehicle == 0) { foreach (UIButton button in _buttons) { button.Hide(); } } else { foreach (UIButton button in _buttons) { button.Show(); } } } }
private void Update() { if (!WorldInfoPanel.AnyWorldInfoPanelOpen()) { return; } InstanceID id = WorldInfoPanel.GetCurrentInstanceID(); if (id.IsEmpty) { return; } if (id.Vehicle == 0) { foreach (UIButton button in _buttons) { button.Hide(); } } else { foreach (UIButton button in _buttons) { button.Show(); } } }
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); } } }
public override void OnUpdate(float realTimeDelta, float simulationTimeDelta) { if (lastReset < SimulationManager.instance.m_currentGameTime.Date && SimulationManager.instance.m_currentGameTime.Day == 1) { lastReset = SimulationManager.instance.m_currentGameTime.Date; mod.data.UpdateCounters(); Debug.Log("Monthly counter values updated"); } if (!WorldInfoPanel.AnyWorldInfoPanelOpen()) { return; } UpdateBuildingInfoPanel(); UpdateVehicleInfoPanel(); base.OnUpdate(realTimeDelta, simulationTimeDelta); }
public override void Update() { if (!WorldInfoPanel.AnyWorldInfoPanelOpen() || !isVisible) { return; } var buildingId = WorldInfoPanel.GetCurrentInstanceID().Building; if (BuildingManager.instance != null && ((SimulationManager.instance.m_currentFrameIndex & 15u) == 15u || lastSelected != buildingId)) { strs = new string[] { Environment.NewLine, "", "", "", "", "" }; lastSelected = buildingId; Building data = BuildingManager.instance.m_buildings.m_buffer[buildingId]; FindBuildingType(data); text = String.IsNullOrEmpty(strs[1]) ? "" : String.Format(strs[5] == "" ? "{1} : {2}{0}{3} : {4}" : "{1} : {2}{0}{3} : {4}{0}{5}", strs); } base.Update(); }
public override void Update() { if (!WorldInfoPanel.AnyWorldInfoPanelOpen()) { return; } var instanceId = WorldInfoPanel.GetCurrentInstanceID(); if (instanceId.Type == InstanceType.Building && instanceId.Building != 0) { ushort building = instanceId.Building; if (baseBuildingWindow != null && enabled && isVisible && Singleton <BuildingManager> .exists && ((Singleton <SimulationManager> .instance.m_currentFrameIndex & 15u) == 15u || selectedBuilding != building)) { BuildingManager instance = Singleton <BuildingManager> .instance; UpdateBuildingInfo(building, instance.m_buildings.m_buffer[building]); selectedBuilding = building; } } base.Update(); }
public override void OnUpdate(float realTimeDelta, float simulationTimeDelta) { DateTime tempDateTime = SimulationManager.instance.m_currentGameTime; if ((mod.Options.UpdateHourly && lastReset.Hour < tempDateTime.Hour) || (!mod.Options.UpdateHourly && lastReset < tempDateTime && tempDateTime.Day == 1)) { lastReset = tempDateTime; mod.data.UpdateCounters(); #if DEBUG Debug.Log("Monthly counter values updated"); #endif } if (!WorldInfoPanel.AnyWorldInfoPanelOpen()) { return; } UpdateBuildingInfoPanel(); UpdateVehicleInfoPanel(); base.OnUpdate(realTimeDelta, simulationTimeDelta); }
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}"); } }
public override void OnUpdate(float realTimeDelta, float simulationTimeDelta) { if (_terminated) { return; } if (!_helper.GameLoaded) { return; } try { if (!_initialized) { if (!IsOverwatched()) { _helper.NotifyPlayer("Skylines Overwatch not found. Terminating..."); _terminated = true; return; } SkylinesOverwatch.Settings.Instance.Enable.VehicleMonitor = true; _initialized = true; _helper.NotifyPlayer("Initialized"); } else { if (WorldInfoPanel.AnyWorldInfoPanelOpen()) { _selected = WorldInfoPanel.GetCurrentInstanceID(); if (_selected.IsEmpty || _selected.Vehicle == 0) { _selected = default(InstanceID); } } else { _selected = default(InstanceID); } VehicleManager instance = Singleton <VehicleManager> .instance; InstanceID instanceID = new InstanceID(); SkylinesOverwatch.Data data = SkylinesOverwatch.Data.Instance; foreach (ushort i in data.VehiclesUpdated) { Vehicle v = instance.m_vehicles.m_buffer[(int)i]; bool isBlocked = !data.IsCar(i) && v.m_blockCounter >= 64; // we will let the game decide when to remove a blocked car bool isConfused = v.Info.m_vehicleAI.GetLocalizedStatus(i, ref v, out instanceID) == _confused; if (!isBlocked && !isConfused) { continue; } RemoveVehicle(i); } foreach (ushort i in _helper.ManualRemovalRequests) { RemoveVehicle(i); } _helper.ManualRemovalRequests.Clear(); } } catch (Exception e) { string error = String.Format("Failed to {0}\r\n", !_initialized ? "initialize" : "update"); error += String.Format("Error: {0}\r\n", e.Message); error += "\r\n"; error += "==== STACK TRACE ====\r\n"; error += e.StackTrace; _helper.Log(error); if (!_initialized) { _terminated = true; } } base.OnUpdate(realTimeDelta, simulationTimeDelta); }