コード例 #1
0
        /// <summary>
        ///     This destroys all the used resourced, so that we can start fresh if the user wants to load a new game.
        ///     Before destroying everything, we store an auto-save file containing the current configuration.
        /// </summary>
        public void OnDestroy()
        {
            try
            {
                Log.Info($"[{nameof(ParallelRoadTool)}.{nameof(OnDestroy)}] Destroying...");

                // Remove existing auto-save
                if (File.Exists(Configuration.AutoSaveFilePath))
                {
                    File.Delete(Configuration.AutoSaveFilePath);
                }

                Log.Info($"[{nameof(ParallelRoadTool)}.{nameof(OnDestroy)}] Saving networks...");

                // Save current networks
                PresetsUtils.Export(Configuration.AutoSaveFileName);

                ToggleDetours(false);
                UnsubscribeFromUIEvents();

                // Reset data structures
                AvailableRoadTypes.Clear();
                SelectedRoadTypes.Clear();
                AvailableRoadNames = null;
                IsSnappingEnabled  = false;
                IsLeftHandTraffic  = false;
                _isToolActive      = _isToolEnabled = false;

                _mainWindow.OnToolChanged -= ToolBaseDetour_OnToolChanged;

                // Unsubscribe to milestones updated
                Singleton <UnlockManager> .instance.m_milestonesUpdated -= OnMilestoneUpdate;

                // Destroy UI
                Destroy(_mainWindow);
                _mainWindow = null;

                Log.Info($"[{nameof(ParallelRoadTool)}.{nameof(OnDestroy)}] Destroyed");
            }
            catch (Exception e)
            {
                // HACK - [ISSUE 31]
                Log._DebugOnlyError($"[{nameof(ParallelRoadTool)}.{nameof(OnDestroy)}] Destroy failed");
                Log.Exception(e);
            }
        }
コード例 #2
0
 private void AddNetworkType(NetInfo net)
 {
     AvailableRoadNames[AvailableRoadTypes.Count] = net.GenerateBeautifiedNetName();
     AvailableRoadTypes.Add(net);
 }