コード例 #1
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");
            }
        }
コード例 #2
0
        public RegisteredDockingPort Copy()
        {
            var copy = new RegisteredDockingPort();

            copy.flightId = flightId;
            copy.Name     = Name;
            return(copy);
        }
コード例 #3
0
        public List <RegisteredDockingPort> GetRegisteredDockingPortsList()
        {
            List <RegisteredDockingPort> list = new List <RegisteredDockingPort>();

            foreach (RegisteredDockingPort dockingPort in RegisteredDockingPorts)
            {
                RegisteredDockingPort dockingPortCopy = dockingPort.Copy();
                list.Add(dockingPortCopy);
            }

            return(list);
        }
コード例 #4
0
        public void SetRegisteredDockingPort(uint flightID, string name)
        {
            if (flightID == 0)
            {
                return;
            }

            // search for existing port
            RegisteredDockingPort existingDockingPort = null;

            foreach (RegisteredDockingPort dockingPort in RegisteredDockingPorts)
            {
                if (dockingPort.flightId == flightID)
                {
                    existingDockingPort = dockingPort;
                    break;
                }
            }

            // edit port
            if (existingDockingPort != null)
            {
                if (String.IsNullOrEmpty(name.Trim()))
                {
                    // unregister
                    RegisteredDockingPorts.Remove(existingDockingPort);
                }
                else
                {
                    // change
                    existingDockingPort.Name = name;
                }
                return;
            }

            // new port
            if (!String.IsNullOrEmpty(name.Trim()))
            {
                // register new
                RegisteredDockingPort newDockingPort = new RegisteredDockingPort();
                newDockingPort.flightId = flightID;
                newDockingPort.Name     = name;
                RegisteredDockingPorts.Add(newDockingPort);
            }
        }