Пример #1
0
        // ---------------------------------------------------------------------------------
        // --------------------------- ITEM SELECTION FUNCTIONS ----------------------------
        // ---------------------------------------------------------------------------------

        // Load new Item form DB, depending on the "ItemType" and
        // the Item-DatabaseID, returned from the "SelectionDialogView"
        private void LoadNewItem(SelectedIDEventArgs e) {
            if (this._updateItem.Second == ItemType.HARDPOINT) {
                int maxclass = this.Data.Hardpoints[_updateItem.First].MaxClass;
                HardpointModel tmp = new HardpointModel(this._loader.ItemID, maxclass);
                if(e.Addition != "empty") tmp = this._loader.loadHardpoint(e.ItemID, maxclass);
                List<HardpointModel> hps = this.Data.Hardpoints;
                hps[this._updateItem.First] = tmp;
                this.Data.Hardpoints = new List<HardpointModel>();
                this.Data.Hardpoints = hps;
            } else if (this._updateItem.Second == ItemType.BULKHEADS) {
                var tmp = this._loader.loadBasic<BulkheadModel>(e.ItemID, Data.SelectedBulkhead.MaxClass);
                List<BulkheadModel> bhm = new List<BulkheadModel>() { tmp };
                this.Data.Bulkheads = new List<BulkheadModel>();
                this.Data.Bulkheads = bhm;
            } else if (this._updateItem.Second == ItemType.POWERPLANT) {
                var tmp = this._loader.loadBasic<PowerPlantModel>(e.ItemID, Data.SelectedPowerPlant.MaxClass);
                List<PowerPlantModel> ppm = new List<PowerPlantModel>() { tmp };
                this.Data.PowerPlants = new List<PowerPlantModel>();
                this.Data.PowerPlants = ppm;
            } else if (this._updateItem.Second == ItemType.THURSTER) {
                var tmp = this._loader.loadBasic<ThrusterModel>(e.ItemID, Data.SelectedThruster.MaxClass);
                List<ThrusterModel> tm = new List<ThrusterModel>() { tmp };
                this.Data.Thrusters = new List<ThrusterModel>();
                this.Data.Thrusters = tm;
            } else if (this._updateItem.Second == ItemType.FSD) {
                var tmp = this._loader.loadBasic<FSDModel>(e.ItemID, Data.SelectedFSD.MaxClass);
                List<FSDModel> fsdm = new List<FSDModel>() { tmp };
                this.Data.FSDs = new List<FSDModel>();
                this.Data.FSDs = fsdm;
            } else if (this._updateItem.Second == ItemType.LIFESUPPORT) {
                var tmp = this._loader.loadBasic<LifeSupportModel>(e.ItemID, Data.SelectedLifeSupport.MaxClass);
                List<LifeSupportModel> lsms = new List<LifeSupportModel>() { tmp };
                this.Data.LifeSupports = new List<LifeSupportModel>();
                this.Data.LifeSupports = lsms;
            } else if (this._updateItem.Second == ItemType.POWERDISTRIB) {
                var tmp = this._loader.loadBasic<PowerDistributorModel>(e.ItemID, Data.SelectedPowerDistrib.MaxClass);
                List<PowerDistributorModel> pdms = new List<PowerDistributorModel>() { tmp };
                this.Data.PowerDistributors = new List<PowerDistributorModel>();
                this.Data.PowerDistributors = pdms;
            } else if (this._updateItem.Second == ItemType.SENSORES) {
                var tmp = this._loader.loadBasic<SensorsModel>(e.ItemID, Data.SelectedSensor.MaxClass);
                List<SensorsModel> sms = new List<SensorsModel>() { tmp };
                this.Data.Sensors = new List<SensorsModel>();
                this.Data.Sensors = sms;
            } else if (this._updateItem.Second == ItemType.FUELTANK) {
                var tmp = this._loader.loadBasic<FuelTankModel>(e.ItemID, Data.SelectedFuelTank.MaxClass);
                List<FuelTankModel> ftms = new List<FuelTankModel>() { tmp };
                this.Data.FuelTanks = new List<FuelTankModel>();
                this.Data.FuelTanks = ftms;
            } else if (this._updateItem.Second == ItemType.UTILITY) {
                UtilityModel tmp = new UtilityModel(this._loader.ItemID);
                if (e.Addition != "empty") tmp = this._loader.loadUtility(e.ItemID, e.Addition);
                List<UtilityModel> ums = this.Data.UtilityMounts;
                ums[this._updateItem.First] = tmp;
                this.Data.UtilityMounts = new List<UtilityModel>();
                this.Data.UtilityMounts = ums;
            } else if (this._updateItem.Second == ItemType.INTERNAL) {
                int maxclass = this.Data.InternalComps1[_updateItem.First].MaxClass;
                InternalModel tmp = new InternalModel(this._loader.ItemID, maxclass);
                if (e.Addition != "empty") tmp = this._loader.loadInternal(e.ItemID, e.Addition, maxclass);
                List<InternalModel> ints = this.Data.InternalComps1;
                ints[this._updateItem.First] = tmp;
                this.Data.InternalComps1 = new List<InternalModel>();
                this.Data.InternalComps1 = ints;
            } else if (this._updateItem.Second == ItemType.INTERNALX) {
                int maxclass = this.Data.InternalComps2[_updateItem.First].MaxClass;
                InternalModel tmp = new InternalModel(this._loader.ItemID, maxclass);
                if (e.Addition != "empty") tmp = this._loader.loadInternal(e.ItemID, e.Addition, maxclass);
                List<InternalModel> ints = this.Data.InternalComps2;
                ints[this._updateItem.First] = tmp;
                this.Data.InternalComps2 = new List<InternalModel>();
                this.Data.InternalComps2 = ints;
            }
            // Fire Event, when the Outfitting Item was changed
            OutfittingChangedEventArgs eventargs = new OutfittingChangedEventArgs(this.Data, false);
            this._eventAggregator.GetEvent<OutfittingChangedEvent>().Publish(eventargs);
        }
Пример #2
0
        // ---------------------------------------------------------------------------------
        // --------------------------------- EVENT FUNCTIONS -------------------------------
        // ---------------------------------------------------------------------------------

        // Reset Lists / View when a new Ship is selected
        private void ShipSelectionChanged(SelectedShipEventArgs e) {
            this._selectedShip = e.Ship;
            this.Data.SelectedHardpoint = null;
            // get the new ships default loadout
            this.Data.Hardpoints = _loader.loadShipsHardpoints(e.Ship.Hardpoints);
            this.Data.Bulkheads = _loader.loadShipsBasics<BulkheadModel>(e.Ship.BaseEquip, ItemType.BULKHEADS);
            this.Data.PowerPlants = _loader.loadShipsBasics<PowerPlantModel>(e.Ship.BaseEquip, ItemType.POWERPLANT);
            this.Data.Thrusters = _loader.loadShipsBasics<ThrusterModel>(e.Ship.BaseEquip, ItemType.THURSTER);
            this.Data.FSDs = _loader.loadShipsBasics<FSDModel>(e.Ship.BaseEquip, ItemType.FSD);
            this.Data.LifeSupports = _loader.loadShipsBasics<LifeSupportModel>(e.Ship.BaseEquip, ItemType.LIFESUPPORT);
            this.Data.PowerDistributors = _loader.loadShipsBasics<PowerDistributorModel>(e.Ship.BaseEquip, ItemType.POWERDISTRIB);
            this.Data.Sensors = _loader.loadShipsBasics<SensorsModel>(e.Ship.BaseEquip, ItemType.SENSORES);
            this.Data.FuelTanks = _loader.loadShipsBasics<FuelTankModel>(e.Ship.BaseEquip, ItemType.FUELTANK);
            this.Data.UtilityMounts = _loader.loadShipsUtilities(e.Ship.UtilityMounts);
            this.Data.InternalComps1 = _loader.loadShipsInternals(e.Ship.InternalCompartments).First;
            this.Data.InternalComps2 = _loader.loadShipsInternals(e.Ship.InternalCompartments).Second;
            // Fire Event, when the Outfitting Item was changed
            OutfittingChangedEventArgs eventargs = new OutfittingChangedEventArgs(this.Data, true);
            this._eventAggregator.GetEvent<OutfittingChangedEvent>().Publish(eventargs);
        }
Пример #3
0
 // Recieve the outfitting changes, calculate the according stats and
 // send the new outfitting restrictions ( e.g. The Hullmass ) to the "OutfittingViewModel"
 private void SaveOutfitting(OutfittingChangedEventArgs e) {
     this._shipout = e.Outfitting;
     this._combinedInternals = new List<InternalModel>(e.Outfitting.InternalComps1);
     this._combinedInternals.AddRange(e.Outfitting.InternalComps2);
     CalculateAttributes();
     RestrictionModel tmpres = new RestrictionModel((int)Double.Parse(this.Data.Hullladen));
     var eventargs = new OutfittingRestrictionsEventArgs(tmpres);
     this._eventAggregator.GetEvent<OutfittingRestrictionsEvent>().Publish(eventargs);
 }