public static bool SimulationStepPre(ushort lineID) { try { TransportLine t = Singleton <TransportManager> .instance.m_lines.m_buffer[lineID]; bool activeDayNightManagedByTLM = TLMLineUtils.isPerHourBudget(lineID); if (t.m_lineNumber != 0 && t.m_stops != 0) { Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_budget = (ushort)(TLMLineUtils.getBudgetMultiplierLine(lineID) * 100); } unchecked { TLMLineUtils.getLineActive(ref Singleton <TransportManager> .instance.m_lines.m_buffer[lineID], out bool day, out bool night); bool isNight = Singleton <SimulationManager> .instance.m_isNightTime; bool zeroed = false; if ((activeDayNightManagedByTLM || (isNight && night) || (!isNight && day)) && Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_budget == 0) { Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_flags |= (TransportLine.Flags)TLMTransportLineFlags.ZERO_BUDGET_CURRENT; zeroed = true; } else { Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_flags &= ~(TransportLine.Flags)TLMTransportLineFlags.ZERO_BUDGET_CURRENT; } TLMUtils.doLog("activeDayNightManagedByTLM = {0}; zeroed = {1}", activeDayNightManagedByTLM, zeroed); if (activeDayNightManagedByTLM) { if (zeroed) { TLMLineUtils.setLineActive(ref Singleton <TransportManager> .instance.m_lines.m_buffer[lineID], false, false); } else { TLMLineUtils.setLineActive(ref Singleton <TransportManager> .instance.m_lines.m_buffer[lineID], true, true); } } } } catch (Exception e) { TLMUtils.doErrorLog("Error processing budget for line: {0}\n{1}", lineID, e); } return(true); }