/// <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.Dismount(); return(modules.Remove(module)); } else { return(false); } }
/// <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 override int MountModule(StationModuleBase module) { int ret = base.MountModule(module); if (ret >= 0) { if (module is MiningStoreStationModule) { this.MiningStore = module as MiningStoreStationModule; } else if (module is MiningFacilityStationModule) { this.MiningFacility = module as MiningFacilityStationModule; } } return(ret); }
/// <summary> /// Loads the station from a XmlElement. /// </summary> /// <param name="node">The Xml node.</param> public virtual void LoadXml(XmlElement node) { this.title = node.GetAttributeOrNull("title"); this.location = node.GetAttributeOrNull("location"); this.owner = node.GetAttributeOrNull("owner"); this.modules.Clear(); foreach (XmlElement xMod in node["Modules"].ChildNodes.OfType <XmlElement>()) { StationModuleBase mod = XmlHelper.CreateType(Game, xMod.Name, Game) as StationModuleBase; if (mod == null) { throw new DeuterosException(string.Format(Resources.InvalidStationModule, xMod.Name)); } mod.LoadXml(xMod); this.MountModule(mod); } }
/// <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.Mount(this); return(modules.Count - 1); } else { return(-3); } }