예제 #1
0
        private bool IsBeamInFireControlList(Entity beam)
        {
            if (SelectedFireControl == null || _fireControlList.SelectedIndex == -1)
            {
                return(false);
            }

            var instancesDB = SelectedShip.GetDataBlob <ComponentInstancesDB>();
            List <KeyValuePair <Entity, List <Entity> > > fcList = EntityStoreHelpers.GetComponentsOfType <BeamFireControlAtbDB>(instancesDB.SpecificInstances);

            //new List<KeyValuePair<Entity, List<Entity>>>(SelectedShip.GetDataBlob<ComponentInstancesDB>().SpecificInstances.Where(item => item.Key.HasDataBlob<BeamFireControlAtbDB>()).ToList());

            foreach (KeyValuePair <Entity, List <Entity> > kvp in fcList)
            {
                foreach (Entity instance in kvp.Value)
                {
                    if (SelectedFireControl.GetDataBlob <FireControlInstanceAbilityDB>().AssignedWeapons.Contains(beam))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
예제 #2
0
        public void OnRemoveOrder()
        {
            if (SelectedShip == null)
            {
                return;
            }

            BaseOrder         nextOrder;
            Queue <BaseOrder> orderList = SelectedShip.GetDataBlob <ShipInfoDB>().Orders;


            int totalOrders = orderList.Count;

            for (int i = 0; i < totalOrders; i++)
            {
                nextOrder = orderList.Dequeue();
                if (nextOrder != SelectedMoveOrder)
                {
                    orderList.Enqueue(nextOrder);
                }
            }


            RefreshOrders(0, 0);
        }
예제 #3
0
        public void RefreshOrderList(int a, int b)
        {
            if (SelectedShip == null)
            {
                return;
            }
            List <BaseOrder> orders = new List <BaseOrder>(SelectedShip.GetDataBlob <ShipInfoDB>().Orders);

            _moveOrderList.Clear();

            foreach (BaseOrder order in orders)
            {
                string orderDescription = "";

                switch (order.OrderType)
                {
                case orderType.MOVETO:
                    MoveOrder moveOrder = (MoveOrder)order;
                    orderDescription += "Move to ";
                    orderDescription += moveOrder.Target.GetDataBlob <NameDB>().GetName(_gameVM.CurrentFaction);
                    break;

                default:
                    break;
                }
                _moveOrderList.Add(order, orderDescription);
            }

            OnPropertyChanged(nameof(MoveOrderList));
            OnPropertyChanged(nameof(MoveOrdersPossible));
        }
예제 #4
0
        public void RefreshOrders(int a, int b)
        {
            if (SelectedShip == null)
            {
                return;
            }

            _moveOrdersPossible.Clear();

            if (SelectedShip.HasDataBlob <PropulsionDB>())
            {
                _moveOrdersPossible.Add(new MoveOrder(), "Move to");
            }

            _moveOrdersPossible.SelectedIndex = 0;

            RefreshOrderList(0, 0);



            OnPropertyChanged(nameof(SelectedMoveOrder));
            OnPropertyChanged(nameof(SelectedPossibleMoveOrder));

            OnPropertyChanged(nameof(ShipSpeed));
            OnPropertyChanged(nameof(XSpeed));
            OnPropertyChanged(nameof(YSpeed));
            OnPropertyChanged(nameof(XPos));
            OnPropertyChanged(nameof(YPos));
            OnPropertyChanged(nameof(MaxSpeed));

            return;
        }
예제 #5
0
        public void RefreshFireControlList(int a, int b)
        {
            _fireControlList.Clear();

            if (SelectedShip == null)
            {
                return;
            }

            if (!SelectedShip.HasDataBlob <BeamWeaponsDB>())
            {
                _fireControlList.Clear();
                return;
            }



            var instanceDB = SelectedShip.GetDataBlob <ComponentInstancesDB>();

            if (instanceDB.TryGetComponentsByAttribute <BeamFireControlAtbDB>(out var fcList))
            {
                int fcCount = 0;
                foreach (var item in fcList)
                {
                    fcCount++;
                    _fireControlList.Add(item, item.GetName());
                }
            }

            //List<KeyValuePair<Entity, List<Entity>>> fcList = EntityStoreHelpers.GetComponentsOfType<BeamFireControlAtbDB>(instanceDB.SpecificInstances);
            //new List<KeyValuePair<Entity, List<Entity>>>(instanceDB.SpecificInstances.ToDictionary().Where(item => item.Key.HasDataBlob<BeamFireControlAtbDB>()).ToList());

            /*
             * foreach (KeyValuePair<Entity, List<Entity>> kvp in fcList)
             * {
             *  int fcCount = 0;
             *  if (kvp.Key.HasDataBlob<BeamFireControlAtbDB>())
             *  foreach(Entity instance in kvp.Value)
             *  {
             *      fcCount++;
             *      _fireControlList.Add(instance, kvp.Key.GetDataBlob<NameDB>().DefaultName + fcCount);
             *  }
             *
             *
             * }
             */
            _fireControlList.SelectedIndex = 0;



            RefreshBeamWeaponsList(0, 0);

//            OnPropertyChanged(nameof(FireControlList));
        }
예제 #6
0
        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 (Entity beam in SelectedFireControl.GetDataBlob <FireControlInstanceAbilityDB>().AssignedWeapons)
                {
                    beamCount++;
                    _attachedBeamList.Add(beam, beam.GetDataBlob <ComponentInstanceInfoDB>().DesignEntity.GetDataBlob <NameDB>().DefaultName + " " + beamCount);
                }
            }
            else
            {
                _attachedBeamList.Clear();
            }
            var instancesDB = SelectedShip.GetDataBlob <ComponentInstancesDB>();
            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;

            _freeBeamList.Clear();

            // 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));
        }
예제 #7
0
        public void UpdateUploadOrder()
        {
            var stacksToSearch = Stacks.ToList();

            UploadSequence.Clear();

            if (SelectedShip == null)
            {
                return;
            }

            foreach (var sequence in SelectedShip.GetSequences().OrderBy(s => s.GetId()))
            {
                var material = sequence.GetMaterial();
                var tonnage  = sequence.GetTonnage();

                if (stacksToSearch.Count == 0)
                {
                    return;
                }

                var stack = stacksToSearch.FirstOrDefault(s => s.GetMaterial().Equals(material) && s.GetTonnage() >= tonnage);

                if (stack == null)
                {
                    return;
                }

                var yard = Yards.FirstOrDefault(y => y.GetStacks().Contains(stack));
                if (yard == null)
                {
                    return;
                }

                stacksToSearch.Remove(stack);

                var machine = Machines.FirstOrDefault(m => m.GetYards().Contains(yard));
                if (machine == null)
                {
                    return;
                }

                var order = new Order();
                order.SetMachine(machine);
                order.SetStack(stack);
                order.SetYard(yard);

                UploadSequence.Add(order);
            }
        }
예제 #8
0
        public void RefreshFireControlList(int a, int b)
        {
            _fireControlList.Clear();

            if (SelectedShip == null)
            {
                return;
            }

            if (!SelectedShip.HasDataBlob <BeamWeaponsDB>())
            {
                _fireControlList.Clear();
                return;
            }



            // The component instances all seem to think that their parent entity is Ensuing Calm, regardless of SelectedShip
            var instanceDB = SelectedShip.GetDataBlob <ComponentInstancesDB>();
            List <KeyValuePair <Entity, List <Entity> > > fcList = EntityStoreHelpers.GetComponentsOfType <BeamFireControlAtbDB>(instanceDB.SpecificInstances);

            //new List<KeyValuePair<Entity, List<Entity>>>(instanceDB.SpecificInstances.ToDictionary().Where(item => item.Key.HasDataBlob<BeamFireControlAtbDB>()).ToList());
            foreach (KeyValuePair <Entity, List <Entity> > kvp in fcList)
            {
                int fcCount = 0;
                if (kvp.Key.HasDataBlob <BeamFireControlAtbDB>())
                {
                    foreach (Entity instance in kvp.Value)
                    {
                        fcCount++;
                        _fireControlList.Add(instance, kvp.Key.GetDataBlob <NameDB>().DefaultName + fcCount);
                    }
                }
            }

            _fireControlList.SelectedIndex = 0;



            RefreshBeamWeaponsList(0, 0);

//            OnPropertyChanged(nameof(FireControlList));
        }
예제 #9
0
        private bool IsBeamInFireControlList(Entity beam)
        {
            if (SelectedFireControl == null || _fireControlList.SelectedIndex == -1)
            {
                return(false);
            }

            var instancesDB = SelectedShip.GetDataBlob <ComponentInstancesDB>();

            var designs = instancesDB.GetDesignsByType(typeof(BeamFireControlAtbDB));

            foreach (var design in designs)
            {
                foreach (var fc in instancesDB.GetComponentsBySpecificDesign(design.Guid))
                {
                    if (fc.ParentEntity.GetDataBlob <FireControlInstanceStateDB>().AssignedWeapons.Contains(beam))
                    {
                        return(true);
                    }
                }
            }



            //List<KeyValuePair<Entity, List<Entity>>> fcList = EntityStoreHelpers.GetComponentsOfType<BeamFireControlAtbDB>(instancesDB.SpecificInstances);
            //new List<KeyValuePair<Entity, List<Entity>>>(SelectedShip.GetDataBlob<ComponentInstancesDB>().SpecificInstances.Where(item => item.Key.HasDataBlob<BeamFireControlAtbDB>()).ToList());

            /*
             * foreach (KeyValuePair<Entity, List<Entity>> kvp in fcList)
             * {
             *  foreach (Entity instance in kvp.Value)
             *  {
             *      if (SelectedFireControl.GetDataBlob<FireControlInstanceAbilityDB>().AssignedWeapons.Contains(beam))
             *          return true;
             *  }
             * }
             */
            return(false);
        }