private void UpdateTotalWeight() { if (_isInitializing) { return; } var vehicleWeight = _configuration.Tank.Hull.Weight + TankConfigVM.GetModuleWeight(this.SelectedTurret) + TankConfigVM.GetModuleWeight(this.SelectedGun) + TankConfigVM.GetModuleWeight(this.SelectedChassis) + TankConfigVM.GetModuleWeight(this.SelectedEngine) + TankConfigVM.GetModuleWeight(this.SelectedRadio); var weight = vehicleWeight; if (this.SelectedEquipment1 != null) { weight += ((Equipment)this.SelectedEquipment1.Model).GetWeight(vehicleWeight); } if (this.SelectedEquipment2 != null) { weight += ((Equipment)this.SelectedEquipment2.Model).GetWeight(vehicleWeight); } if (this.SelectedEquipment3 != null) { weight += ((Equipment)this.SelectedEquipment3.Model).GetWeight(vehicleWeight); } this.TotalWeight = weight; }
private bool IsAvailableForCurrentChassis(ComponentVM module) { if (module.Model is Chassis) { return(this.HasSufficientLoad(module)); } var newWeight = this.TotalWeight - TankConfigVM.GetModuleWeight(this.GetSelectedModule(module.Model.ElementName)) + TankConfigVM.GetModuleWeight(module); return(this.MaxLoad - newWeight >= 0); }
private bool HasSufficientLoad(ComponentVM chassis) { var newWeight = this.TotalWeight - TankConfigVM.GetModuleWeight(this.SelectedChassis) + TankConfigVM.GetModuleWeight(chassis); return(((Chassis)chassis.Model).MaximumLoad >= newWeight); }