Example #1
0
        public static StationModuleBase InvokeCreate(string typ)
        {
            StationModuleBase si = StructXml.CreateInstanceFromType(typ) as StationModuleBase;

            if (si == null)
            {
                return(new StationModuleBase());
            }
            else
            {
                return(si);
            }
        }
Example #2
0
        /// <summary>
        /// Dismounts mounted module
        /// </summary>
        /// <param name="index">Index of module to dismount</param>
        /// <returns>True if successful.</returns>
        public virtual bool DismountModule(StationModuleBase module)
        {
            if (modules != null)
            {
                module.OnDismount();

                return(modules.Remove(module));
            }
            else
            {
                return(false);
            }
        }
Example #3
0
        public virtual void FromXml(XmlNode node)
        {
            this.title = node.Attributes["Title"].Value;
            if (node.Attributes["Location"] != null)
            {
                this.location = node.Attributes["Location"].Value;
            }
            if (node.Attributes["Owner"] != null)
            {
                this.owner = node.Attributes["Owner"].Value;
            }

            this.modules.Clear();
            foreach (XmlNode xMod in node["Modules"].ChildNodes)
            {
                StationModuleBase mod = StationModuleBase.InvokeCreate(xMod.Name);

                mod.FromXml(xMod);
                this.MountModule(mod);
            }
        }
Example #4
0
        /// <summary>
        /// Mounts a new module to the station
        /// </summary>
        /// <param name="module">Station module to mount</param>
        /// <returns>Negative if error. If successful, returns the module index.</returns>
        public virtual int MountModule(StationModuleBase module)
        {
            if (modules != null)
            {
                for (int i = 0; i < modules.Count; i++)
                {
                    if (modules[i] != null && modules[i].GetType() == module.GetType())
                    {
                        return(-2);
                    }
                }

                modules.Add(module);
                module.parent = this;
                module.OnMount();

                return(0);
            }
            else
            {
                return(-3);
            }
        }