public ShipOutfittingViewModel(IDataLoaderService loader, IEventAggregator eventaggregator, ShipOutfittingModel data) { this._loader = loader; this.Data = data; this._updateItem = new Pair<int, ItemType>(); this._selectedShip = new ShipModel(); this._eventAggregator = eventaggregator; _eventAggregator.GetEvent<SelectedIDEvent>().Subscribe(LoadNewItem); _eventAggregator.GetEvent<SelectedShipEvent>().Subscribe(ShipSelectionChanged); _eventAggregator.GetEvent<OutfittingRestrictionsEvent>().Subscribe(RestrictionsChanged); // Initialize the filthy rest this.HardpointClickCommand = new DelegateCommand(this.OnHardpointClick); this.BulkheadClickCommand = new DelegateCommand(this.OnBulkheadClick); this.PowerPlantClickCommand = new DelegateCommand(this.OnPowerPlantClick); this.ThrusterClickCommand = new DelegateCommand(this.OnThrusterClick); this.FSDClickCommand = new DelegateCommand(this.OnFSDClick); this.LifeSupportClickCommand = new DelegateCommand(this.OnLifeSupportClick); this.PowerDistribClickCommand = new DelegateCommand(this.OnPowerDistribClick); this.SensorClickCommand = new DelegateCommand(this.OnSensorClick); this.FuelTankClickCommand = new DelegateCommand(this.OnFuelTankClick); this.UtilityClickCommand = new DelegateCommand(this.OnUtilityClick); this.Internal1ClickCommand = new DelegateCommand(this.OnInternal1Click); this.Internal2ClickCommand = new DelegateCommand(this.OnInternal2Click); }
// --------------------------------------------------------------------------------- // --------------------------------- 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); }