Пример #1
0
        /// <summary>
        /// Constructor for vehicle creation recipe.
        /// Must be used only in InitEntityRelationships phase.
        /// </summary>
        /// <param name="vehicleViewModel">View Model of IProtoVehicle.</param>
        /// <param name="vehicle"></param>
        public VehicleBuildRecipeViewModel([NotNull] ProtoVehicleViewModel vehicleViewModel, IProtoVehicle vehicle)
            : base(vehicleViewModel.ProtoEntity)
        {
            if (!EntityViewModelsManager.EntityDictionaryCreated)
            {
                throw new Exception("CNEI: Build constructor used before all entity VMs sets.");
            }

            InputItemsList = vehicle.BuildRequiredItems
                             .Select(item => EntityViewModelsManager.GetEntityViewModel(item.ProtoItem))
                             .ToList();

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

            BuildRequiredElectricityAmount = vehicle.BuildRequiredElectricityAmount;

            OutputItemsList.Add(vehicleViewModel);

            VehicleVM = vehicleViewModel;

            StationsList = EntityViewModelsManager.GetAllEntityViewModelsByType <IProtoVehicleAssemblyBay>()
                           .AsReadOnly();
            ListedInTechNodes = vehicleViewModel.ListedInTechNodes;
        }
Пример #2
0
        /// <summary>
        /// Constructor for build recipe for IProtoStructure.
        /// Must be used only in InitEntityRelationships phase.
        /// </summary>
        /// <param name="structureViewModel">View Model of IProtoStructure.</param>
        /// <param name="config">Building config.</param>
        public StructureBuildRecipeViewModel([NotNull] ProtoObjectStructureViewModel structureViewModel,
                                             [NotNull] IConstructionStageConfigReadOnly config)
            : base(structureViewModel.ProtoEntity)
        {
            if (!EntityViewModelsManager.EntityDictonaryCreated)
            {
                throw new Exception("CNEI: Build constructor used before all entity VMs sets.");
            }

            InputItemsList = config.StageRequiredItems
                             .Select(item => EntityViewModelsManager.GetEntityViewModel(item.ProtoItem))
                             .ToList();

            InputItemsVMList = config.StageRequiredItems
                               .Select(item => new ViewModelEntityWithCount(EntityViewModelsManager.GetEntityViewModel(item.ProtoItem),
                                                                            item.Count * config.StagesCount))
                               .ToList().AsReadOnly();

            OutputItemsList.Add(structureViewModel);

            StructureVM = structureViewModel;

            StationsList      = EntityViewModelsManager.GetAllEntityViewModelsByType <IProtoItemToolToolbox>().AsReadOnly();
            ListedInTechNodes = structureViewModel.ListedInTechNodes;
            IsAutoUnlocked    = structureViewModel.IsAutoUnlocked;
        }
Пример #3
0
        /// <summary>
        /// Constructor for various consumable providing specific status effect.
        /// Must be used only in InitEntityRelationships phase.
        /// </summary>
        /// <param name="statusEffectViewModel">View Model of status effect.</param>
        /// <param name="conumableViewModel">View Model of consumable.</param>
        /// <param name="intensity">Status effect intensity inflicted by this consumable.</param>
        public ConsumableEffectViewModel([NotNull] ProtoEntityViewModel statusEffectViewModel,
                                         [NotNull] ProtoEntityViewModel conumableViewModel,
                                         double intensity)
            : base(statusEffectViewModel.ProtoEntity)
        {
            if (!EntityViewModelsManager.EntityDictionaryCreated)
            {
                throw new Exception("CNEI: Consumable effect constructor used before all entity VMs sets.");
            }

            StatusEffectEntity = statusEffectViewModel;

            OutputItemsList.Add(statusEffectViewModel);

            AddConsumable(conumableViewModel, intensity);
        }
Пример #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;
        }
Пример #5
0
        public void AddBaitUsage([NotNull] ProtoEntityViewModel fishViewModel, double weight)
        {
            if (fishViewModel.ProtoEntity is ProtoItemFish fish)
            {
                FishDetailsList.Add(new FishDetails()
                {
                    FishViewModel = fishViewModel,
                    Name          = fishViewModel.Title,
                    RequiredFishingKnowledgeLevel = fish.RequiredFishingKnowledgeLevel,
                    IsSaltwaterFish = fish.IsSaltwaterFish ? "Yes" : "No",
                    Weight          = weight
                });
                FishDetailsList.SortByDesc(e => e.Weight);
            }

            OutputItemsList.Add(fishViewModel);
        }
        /// <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;
        }