public void OnRemoveBeam() { ComponentInstance beam = SelectedAttachedBeam; if (SelectedFireControl == null || _fireControlList.SelectedIndex == -1) { return; } if (SelectedAttachedBeam == null || _attachedBeamList.SelectedIndex == -1) { return; } List <ComponentInstance> weaponList = SelectedFireControl.GetAbilityState <FireControlAbilityState>().AssignedWeapons; weaponList.Remove(SelectedAttachedBeam); // @todo: unset the fire control for the beam beam.GetAbilityState <WeaponState>().FireControl = null; RefreshBeamWeaponsList(0, 0); }
public void RefreshFCTarget(int a, int b) { if (SelectedFireControl == null || _fireControlList.SelectedIndex == -1) { return; } _targetedEntity = SelectedFireControl.GetAbilityState <FireControlAbilityState>().Target; OnPropertyChanged(TargetedEntity); }
public void RefreshBeamWeaponsList(int a, int b) { _attachedBeamList.Clear(); _freeBeamList.Clear(); if (SelectedShip == null || _shipList.SelectedIndex == -1) { return; } if (_fireControlList.Count > 0 && _fireControlList.SelectedIndex != -1) { int beamCount = 0; foreach (ComponentInstance beam in SelectedFireControl.GetAbilityState <FireControlAbilityState>().AssignedWeapons) { beamCount++; _attachedBeamList.Add(beam, beam.GetName()); } } else { _attachedBeamList.Clear(); } var instancesDB = SelectedShip.GetDataBlob <ComponentInstancesDB>(); var designs = instancesDB.GetDesignsByType(typeof(BeamWeaponAtbDB)); _freeBeamList.Clear(); foreach (var design in designs) { foreach (var instance in instancesDB.GetComponentsBySpecificDesign(design.Guid)) { int beamCount = 0; if (instance.GetAbilityState <WeaponState>().FireControl == null) { _freeBeamList.Add(new KeyValuePair <ComponentInstance, string>(instance, instance.GetName())); } } } /* * List<KeyValuePair<Entity, List<Entity>>> beamList = EntityStoreHelpers.GetComponentsOfType<BeamWeaponAtbDB>(instancesDB.SpecificInstances); * beamList.AddRange(EntityStoreHelpers.GetComponentsOfType<SimpleBeamWeaponAtbDB>(instancesDB.SpecificInstances)); * //new List<KeyValuePair<Entity, List<Entity>>>(SelectedShip.GetDataBlob<ComponentInstancesDB>().SpecificInstances.Where(item => item.Key.HasDataBlob<BeamWeaponAtbDB>() || item.Key.HasDataBlob<SimpleBeamWeaponAtbDB>()).ToList()); * * bool isBeamControlled = false; */ // Get a list of all beam weapons not currently controlled by a fire control // @todo: make sure you check all fire controls - currently only lists // beams not set to the current fire control /* * foreach (KeyValuePair<Entity, List<Entity>> kvp in beamList) * { * int beamCount = 0; * foreach (Entity instance in kvp.Value) * { * if (instance.GetDataBlob<WeaponStateDB>().FireControl == null) * _freeBeamList.Add(new KeyValuePair<Entity, string>(instance, kvp.Key.GetDataBlob<NameDB>().DefaultName + " " + ++beamCount)); * * } * }*/ OnPropertyChanged(nameof(AttachedBeamList)); OnPropertyChanged(nameof(FreeBeamList)); }