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);
        }
        public override void Initialize()
        {
            _configView           = new TankConfigView();
            _configVm             = new TankConfigVM();
            _configView.ViewModel = _configVm;

            var panel = new FeaturedPanelInfo(
                Guid.Parse("090B35D3-1760-4A37-8589-4F8C66A8D30B"),
                new[] { typeof(ITankConfigurable) },
                this.OnRequiredFeaturesSatisficationChanged)
            {
                Title      = this.L("tank_configurator", "panel_title"),
                CanHide    = true,
                CanClose   = true,
                CanFloat   = true,
                Width      = 200,
                Content    = _configView,
                IconSource = BitmapImageEx.LoadAsFrozen("Resources/Images/Config_16.png"),
            };

            DockingViewManager.Instance.PanelManager.Register(panel);
        }
        private bool HasSufficientLoad(ComponentVM chassis)
        {
            var newWeight = this.TotalWeight - TankConfigVM.GetModuleWeight(this.SelectedChassis) + TankConfigVM.GetModuleWeight(chassis);

            return(((Chassis)chassis.Model).MaximumLoad >= newWeight);
        }