protected void AddToRelevantBlocksIfNeeded(Block newOrModifiedBlock) { if (IsRelevant(newOrModifiedBlock, true)) { var indicesOfNewOrModifiedBlock = GetBlockIndices(newOrModifiedBlock); m_relevantBlocks.Add(indicesOfNewOrModifiedBlock); m_relevantBlocks.Sort(); RelevantBlockAdded(newOrModifiedBlock); if (m_currentBlockIndex == -1 && CurrentBlock.Equals(newOrModifiedBlock)) { m_currentBlockIndex = m_relevantBlocks.IndexOf(indicesOfNewOrModifiedBlock); } } HandleCurrentBlockChanged(); }
private void processTick() { CurrentBlock = _train.CurrentBlock; if (CurrentBlock.hasStation()) { loadPassengers(); } if (AuthorityLimit <= 1) { SpeedInput = 0; } if (_distanceToStation > 0 && _distanceToStation < 3 && !_currentBlock.hasStation()) { SpeedInput = 0; } if (Train.CurrentVelocity < SpeedInput && Train.CurrentVelocity < SpeedLimit || Train.CurrentVelocity > SpeedInput && Train.CurrentVelocity > SpeedLimit) { if (SpeedInput > SpeedLimit) { sendPower(SpeedLimit); } if (SpeedInput <= SpeedLimit) { sendPower(SpeedInput); } } if (CurrentBlock != null && !CurrentBlock.Equals(Train.CurrentBlock)) { AuthorityLimit--; CurrentBlock = Train.CurrentBlock; checkLightsOn(); } }