Beispiel #1
0
        public void Refresh(bool partialRefresh = false)
        {
            List <Entity> labDesigns = _factionEntity.GetDataBlob <FactionInfoDB>().ComponentDesigns.Values.Where(item => item.HasDataBlob <ResearchPointsAtbDB>()).ToList();

            _allLabs = new Dictionary <Guid, int>();

            //ResearchableTechs = new ObservableCollection<TechSD>(_factionTech.ResearchableTechs.Keys);
            ResearchableTechs = new DictionaryVM <TechSD, string>(DisplayMode.Value);
            foreach (var tech in _factionTech.ResearchableTechs.Keys)
            {
                ResearchableTechs.Add(tech, tech.Name);
            }

            /*
             * foreach (var kvp in _colonyEntity.GetDataBlob<ComponentInstancesDB>().ComponentsByDesign)
             * {
             *  if (labDesigns.Contains(kvp.Key))
             *      _allLabs.Add(kvp.Key.Guid, kvp.Value.Count);
             * }*/
            AllLabs = AllLabs;

            _freeLabs = 0;
            foreach (var kvp in AllLabs)
            {
                _freeLabs += kvp.Value;
            }
            foreach (var scientist in Scientists)
            {
                _freeLabs -= scientist.ScientistAssignedLabs;
            }
            FreeLabs = _freeLabs;
        }
Beispiel #2
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));
        }
Beispiel #3
0
        public ColonyResearchVM(StaticDataStore staticData, Entity colonyEntity)
        {
            //_factionEntity;// = colonyEntity.GetDataBlob<OwnedDB>().OwnedByFaction;
            colonyEntity.Manager.FindEntityByGuid(colonyEntity.FactionOwner, out _factionEntity);
            _colonyEntity = colonyEntity;
            _factionTech  = _factionEntity.GetDataBlob <FactionTechDB>();
            Scientists    = new List <ScientistControlVM>();
            if (_factionTech.ResearchableTechs.Count > 0)
            {
                //ResearchableTechs = new ObservableCollection<TechSD>(_factionTech.ResearchableTechs.Keys);
                ResearchableTechs = new DictionaryVM <TechSD, string>(DisplayMode.Value);
                foreach (var tech in _factionTech.ResearchableTechs.Keys)
                {
                    ResearchableTechs.Add(tech, tech.Name);
                }
                SelectedTechIndex = 0;
            }

            foreach (var scientist in _colonyEntity.GetDataBlob <ColonyInfoDB>().Scientists)
            {
                Scientists.Add(new ScientistControlVM(staticData, _factionTech, scientist));
            }
            SelectedScientist = Scientists[0];
            Refresh();
        }
        /// <summary>
        /// Constructor for filled
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="abilitySD"></param>
        /// <param name="parentList"></param>
        /// <param name="staticData"></param>
        public ComponentAbilityTemplateVM(ComponentTemplateParentVM parent, ComponentTemplateAbilitySD abilitySD, ObservableCollection <ComponentAbilityTemplateVM> parentList, StaticDataStore staticData) : this(parent, parentList, staticData)
        {
            Name        = abilitySD.Name;
            Description = abilitySD.Description;
            SelectedGuiHint.SelectedIndex = (int)abilitySD.GuiHint;
            if (abilitySD.AbilityDataBlobType != null)
            {
                AbilityDataBlobType = abilitySD.AbilityDataBlobType;
            }
            AbilityFormula = abilitySD.AbilityFormula;
            MinFormula     = abilitySD.MinFormula;
            MaxFormula     = abilitySD.MaxFormula;
            StepFormula    = abilitySD.StepFormula;
            //GuidDictionary = abilitySD.GuidDictionary;
            DictionaryVM <Guid, string> techSelected = new DictionaryVM <Guid, string>();

            if (abilitySD.GuiHint == GuiHint.GuiTechSelectionList)
            {
                foreach (var item in abilitySD.GuidDictionary)
                {
                    techSelected.Add(Guid.Parse(item.Key.ToString()), _staticData.Techs[Guid.Parse(item.Key.ToString())].Name);
                }
                GuidDict = new TechListVM(techSelected, _staticData);
            }
        }
Beispiel #5
0
        public ShipOrderVM(GameVM game)
        {
            _gameVM = game;

            FactionInfoDB finfo = _gameVM.CurrentFaction.GetDataBlob <FactionInfoDB>();

            foreach (StarSystem starSystem in _gameVM.StarSystemSelectionViewModel.StarSystems.Keys)
            {
                if (finfo.KnownSystems.Contains(starSystem.Guid))
                {
                    _starSystems.Add(starSystem, starSystem.NameDB.GetName(_gameVM.CurrentFaction));
                }
            }

            _starSystems.SelectedIndex = 0;

            TargetShown     = false;
            TargetAreaWidth = 2;

            RefreshShips(0, 0);

            //PropertyChanged += ShipOrderVM_PropertyChanged;
            SelectedSystem.ManagerSubpulses.SystemDateChangedEvent += UpdateInterface_SystemDateChangedEvent;

            _starSystems.SelectionChangedEvent        += RefreshShips;
            _shipList.SelectionChangedEvent           += RefreshOrders;
            _shipList.SelectionChangedEvent           += RefreshFireControlList;
            _moveOrdersPossible.SelectionChangedEvent += RefreshTarget;
            _moveTargetList.SelectionChangedEvent     += RefreshTargetDistance;
            _fireControlList.SelectionChangedEvent    += RefreshBeamWeaponsList;
            _fireControlList.SelectionChangedEvent    += RefreshFCTarget;

            OnPropertyChanged(nameof(StarSystems));
            OnPropertyChanged(nameof(SelectedSystem));
        }
Beispiel #6
0
 public MineralFormulaVM(ComponentTemplateParentVM parent, StaticDataStore staticDataStore) : base(parent)
 {
     _dataStore = staticDataStore;
     Minerals   = new DictionaryVM <Guid, string>(DisplayMode.Value);
     foreach (var item in staticDataStore.Minerals.Values)
     {
         Minerals.Add(item.ID, item.Name);
     }
 }
Beispiel #7
0
 public TechListVM(StaticDataStore staticData)
 {
     SelectedItems = new DictionaryVM <Guid, string>();
     PossibleItems = new DictionaryVM <Guid, string>();
     foreach (var item in staticData.Techs.Values)
     {
         PossibleItems.Add(item.ID, item.Name);
     }
 }
Beispiel #8
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));
        }
Beispiel #9
0
 public RefineryAbilityVM(StaticDataStore staticData, Entity colonyEntity) : base(staticData, colonyEntity)
 {
     ItemDictionary = new DictionaryVM <Guid, string>(DisplayMode.Value);
     foreach (var kvp in _staticData_.ProcessedMaterials)
     {
         ItemDictionary.Add(kvp.Key, kvp.Value.Name);
     }
     //NewJobSelectedItem = ItemDictionary[ItemDictionary.ElementAt(0).Key];
     NewJobSelectedIndex = 0;
     NewJobBatchCount    = 1;
     NewJobRepeat        = false;
 }
Beispiel #10
0
        public void RefreshTarget(int a, int b)
        {
            if (_starSystems.SelectedIndex == -1) //if b is not a valid selection
            {
                return;
            }

            _moveTargetList.Clear();
            _attackTargetList.Clear();

            int moveTargetIndex   = _moveTargetList.SelectedIndex;
            int attackTargetIndex = _attackTargetList.SelectedIndex;

            foreach (Entity target in SelectedSystem.GetAllEntitiesWithDataBlob <PositionDB>(_gameVM.CurrentAuthToken))
            {
                if (target != SelectedShip)
                {
                    _moveTargetList.Add(target, target.GetDataBlob <NameDB>().GetName(_gameVM.CurrentFaction));
                    if (target.HasDataBlob <SensorProfileDB>())
                    {
                        _attackTargetList.Add(target, target.GetDataBlob <NameDB>().GetName(_gameVM.CurrentFaction));
                    }
                }
            }

            _moveTargetList.SelectedIndex   = moveTargetIndex;
            _attackTargetList.SelectedIndex = attackTargetIndex;

            if (SelectedPossibleMoveOrder == null)
            {
                TargetShown = false;
            }
            else if (SelectedPossibleMoveOrder.OrderType == orderType.MOVETO)
            {
                TargetShown = true;
            }
            else
            {
                TargetShown = false;
            }

            if (TargetShown)
            {
                TargetAreaWidth = 200;
            }
            else
            {
                TargetAreaWidth = 2;
            }

            OnPropertyChanged(nameof(TargetShown));
            OnPropertyChanged(nameof(TargetAreaWidth));
        }
Beispiel #11
0
 public ConstructionAbilityVM(StaticDataStore staticData, Entity colonyEntity) : base(staticData, colonyEntity)
 {
     ItemDictionary = new DictionaryVM <Guid, string>(DisplayMode.Value);
     foreach (var kvp in _factionInfo.ComponentDesigns)
     {
         ItemDictionary.Add(kvp.Key, kvp.Value.Name);
     }
     //NewJobSelectedItem = ItemDictionary.SelectedKey;
     NewJobSelectedIndex = 0;
     NewJobBatchCount    = 1;
     NewJobRepeat        = false;
 }
Beispiel #12
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));
        }
Beispiel #13
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));
        }
Beispiel #14
0
        public FormulaEditorVM(ComponentTemplateParentVM parent, StaticDataStore staticData)
        {
            _parent = parent;

            TechList = new DictionaryVM <Guid, string>();
            foreach (var item in staticData.Techs.Values)
            {
                TechList.Add(item.ID, item.Name);
            }
            TechList.SelectionChangedEvent += TechList_SelectionChangedEvent;

            ParameterButtons = new List <ButtonInfo>();
            ParameterButtons.Add(new ButtonInfo("[Size]", "Links to the Size formula field", this));
            ParameterButtons.Add(new ButtonInfo("[Crew]", "Links to the Crew requred formula field", this));
            ParameterButtons.Add(new ButtonInfo("[HTK]", "Links to the Hit To Kill formula field", this));
            ParameterButtons.Add(new ButtonInfo("[ResearchCost]", "Links to the Research cost formula field", this));
            ParameterButtons.Add(new ButtonInfo("[MineralCost]", "Links to the Mineral cost formula field", this));
            ParameterButtons.Add(new ButtonInfo("[CreditCost]", "Links to the Credit Cost formula field", this));
            ParameterButtons.Add(new ButtonInfo("[GuidDict]", "A special parameter for a key value pair collection, used in ability formula fields", this));

            FunctionButtons = new List <ButtonInfo>();
        }