コード例 #1
0
        public override void OnSave(ConfigNode gameNode)
        {
            base.OnSave(gameNode);

            try
            {
                ConfigNode registeredLocations = new ConfigNode("REGISTEREDLOCATIONS");
                foreach (RegisteredDockingPort registeredDockingPort in this.RegisteredDockingPorts)
                {
                    ConfigNode dockingPortConfig = ConfigNode.CreateConfigFromObject(registeredDockingPort);
                    dockingPortConfig.name = "DOCKINGPORT";
                    registeredLocations.AddNode(dockingPortConfig);
                }

                gameNode.AddNode(registeredLocations);

                ConfigNode orderedMissions = new ConfigNode("ORDEREDMISSIONS");
                foreach (OrderedMission orderedMission in this.OrderedMissions)
                {
                    ConfigNode orderedMissionConfig = orderedMission.SaveNode();
                    orderedMissions.AddNode(orderedMissionConfig);
                }

                gameNode.AddNode(orderedMissions);
            }
            catch
            {
                LoggerRmm.Error("Rmm: saving to savefile failed");
            }
        }
コード例 #2
0
        public override void OnLoad(ConfigNode gameNode)
        {
            base.OnLoad(gameNode);

            this.RegisteredDockingPorts.Clear();
            this.OrderedMissions.Clear();

            try
            {
                ConfigNode registeredLocations = gameNode.GetNode("REGISTEREDLOCATIONS");
                if (registeredLocations != null)
                {
                    foreach (ConfigNode dockingPortConfig in registeredLocations.GetNodes("DOCKINGPORT"))
                    {
                        RegisteredDockingPort dockingPort = ConfigNode.CreateObjectFromConfig <RegisteredDockingPort>(dockingPortConfig);
                        this.RegisteredDockingPorts.Add(dockingPort);
                    }
                }

                ConfigNode orderedMissions = gameNode.GetNode("ORDEREDMISSIONS");
                if (orderedMissions != null)
                {
                    foreach (ConfigNode orderedMissionConfig in orderedMissions.GetNodes("ORDEREDMISSION"))
                    {
                        OrderedMission orderedMission = OrderedMission.LoadNode(orderedMissionConfig);
                        this.OrderedMissions.Add(orderedMission);
                    }
                }
            }
            catch
            {
                LoggerRmm.Error("RMM: loading from savefile failed");
            }
        }