Exemplo n.º 1
0
        /// <summary>
        /// Constructor for entity with droplist.
        /// Must be used only in InitEntityRelationships phase.
        /// </summary>
        /// <param name="entityViewModel">View Model of entity with droplist.</param>
        /// <param name="droplist">Droplist</param>
        public DroplistRecipeViewModel([NotNull] ProtoEntityViewModel entityViewModel,
                                       [NotNull] IEnumerable <IProtoItem> droplist)
            : base(entityViewModel.ProtoEntity)
        {
            if (!EntityViewModelsManager.EntityDictionaryCreated)
            {
                throw new Exception("CNEI: Droplist constructor used before all entity VMs sets.");
            }

            InputItemsList.Add(entityViewModel);

            TargetEntity = entityViewModel;

            HashSet <IProtoItem> uniqueDroplist = new HashSet <IProtoItem>(droplist);

            OutputItemsList = uniqueDroplist.Select(EntityViewModelsManager.GetEntityViewModel).ToList();

            OutputItemsVMList = uniqueDroplist
                                .Select(item => new ViewModelEntityWithCount(EntityViewModelsManager.GetEntityViewModel(item)))
                                .ToList().AsReadOnly();

            if (entityViewModel is ProtoCharacterMobViewModel protoCharacterMobViewModel)
            {
                icon = protoCharacterMobViewModel.Icon;
            }
        }
Exemplo n.º 2
0
 public void AddConsumable([NotNull] ProtoEntityViewModel conumableViewModel, double intensity)
 {
     ConsumableList.Add(new ConsumableInfo()
     {
         ConsumableViewModel = conumableViewModel,
         Name      = conumableViewModel.Title,
         Intensity = intensity,
     });
     ConsumableList = ConsumableList.OrderByDescending(c => c.Intensity).ThenBy(c => c.Name).ToList();
     InputItemsList.Add(conumableViewModel);
 }
Exemplo n.º 3
0
        /// <summary>
        /// Constructor for entity with droplist.
        /// Must be used only in InitEntityRelationships phase.
        /// </summary>
        /// <param name="ammoViewModel">View Model of ammo.</param>
        /// <param name="gunViewModel">View Model of gun that uses that ammo.</param>
        public AmmoUsageViewModel([NotNull] ProtoEntityViewModel ammoViewModel,
                                  [NotNull] ProtoEntityViewModel gunViewModel)
            : base(ammoViewModel.ProtoEntity)
        {
            if (!EntityViewModelsManager.EntityDictonaryCreated)
            {
                throw new Exception("CNEI: Droplist constructor used before all entity VMs sets.");
            }

            AmmoEntity = ammoViewModel;

            InputItemsList.Add(ammoViewModel);

            //GunsVMList.Add(gunViewModel);
            GunsInformationList.Add(new ViewModelEntityWithCount(gunViewModel));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Constructor for entity with droplist.
        /// Must be used only in InitEntityRelationships phase.
        /// </summary>
        /// <param name="seedEntityViewModel">View Model of seed entity.</param>
        /// <param name="plantEntityViewModel">View Model of grown plant entity.</param>
        public PlantRecipeViewModel([NotNull] ProtoEntityViewModel seedEntityViewModel,
                                    [NotNull] ProtoEntityViewModel plantEntityViewModel)
            : base(seedEntityViewModel.ProtoEntity)
        {
            if (!EntityViewModelsManager.EntityDictionaryCreated)
            {
                throw new Exception("CNEI: Droplist constructor used before all entity VMs sets.");
            }

            InputItemsList.Add(seedEntityViewModel);

            SeedEntity = seedEntityViewModel;

            OutputItemsList.Add(plantEntityViewModel);

            PlantEntity = plantEntityViewModel;
        }
Exemplo n.º 5
0
        /// <summary>
        /// Constructor for fishing recipe.
        /// Must be used only in InitEntityRelationships phase.
        /// </summary>
        /// <param name="baitViewModel">View Model of fishing bait entity.</param>
        /// <param name="fishViewModel">View Model of fish entity.</param>
        /// <param name="chance">Chance for catching this fish with this bait.</param>
        public FishingViewModel([NotNull] ProtoEntityViewModel baitViewModel,
                                [NotNull] ProtoEntityViewModel fishViewModel,
                                double weight)
            : base(baitViewModel.ProtoEntity)
        {
            if (!EntityViewModelsManager.EntityDictionaryCreated)
            {
                throw new Exception("CNEI: Droplist constructor used before all entity VMs sets.");
            }

            BaitEntity = baitViewModel;

            InputItemsList.Add(baitViewModel);

            AddBaitUsage(fishViewModel, weight);

            StationsList = EntityViewModelsManager.GetAllEntityViewModelsByType <IProtoItemToolFishing>()
                           .ToList().AsReadOnly();
        }
        /// <summary>
        /// Constructor for upgrade recipe for IProtoStructure.
        /// Must be used only in InitEntityRelationships phase.
        /// </summary>
        /// <param name="structureViewModel">View Model of IProtoStructure.</param>
        /// <param name="upgradeEntry">Entry of upgrade config.</param>
        public StructureUpgradeRecipeViewModel([NotNull] ProtoObjectStructureViewModel structureViewModel,
                                               [NotNull] IConstructionUpgradeEntryReadOnly upgradeEntry)
            : base(upgradeEntry.ProtoStructure)
        {
            if (!EntityViewModelsManager.EntityDictionaryCreated)
            {
                throw new Exception("CNEI: Upgrade constructor used before all entity VMs sets.");
            }

            StructureVM = structureViewModel;

            InputItemsList = upgradeEntry.RequiredItems
                             .Select(item => EntityViewModelsManager.GetEntityViewModel(item.ProtoItem))
                             .ToList();
            InputItemsList.Add(structureViewModel);

            InputItemsVMList = upgradeEntry.RequiredItems
                               .Select(item => new ViewModelEntityWithCount(EntityViewModelsManager.GetEntityViewModel(item.ProtoItem),
                                                                            item.Count))
                               .ToList().AsReadOnly();

            if (!(EntityViewModelsManager.GetEntityViewModel(upgradeEntry.ProtoStructure)
                  is ProtoObjectStructureViewModel newStructureViewModel))
            {
                throw new Exception("CNEI: Can not find ProtoObjectStructureViewModel for " +
                                    upgradeEntry.ProtoStructure);
            }

            OutputItemsList.Add(newStructureViewModel);

            UpgradedStructureVM = newStructureViewModel;

            // Can not simply get it from result entityVM because it can has not Initialized Tech.
            //ListedInTechNodes = newStructureViewModel.ListedInTechNodes;
            ListedInTechNodes = upgradeEntry.ProtoStructure.ListedInTechNodes
                                .Select(EntityViewModelsManager.GetEntityViewModel)
                                .ToList().AsReadOnly();
            IsAutoUnlocked = structureViewModel.IsAutoUnlocked;
        }