Пример #1
0
        /// <summary>
        /// Deserialization constructor.
        /// </summary>
        /// <param name="group">Market Group the Blueprint will be a member of.</param>
        /// <param name="src">Source serializable blueprint.</param>
        internal Blueprint(BlueprintMarketGroup group, SerializableBlueprint src)
            : base(group, src)
        {

            m_maxProductionLimit = src.MaxProductionLimit;
            m_produceItemID = src.ProduceItemID;
            m_productionTime= src.ProductionTime;
            m_productivityModifier = src.ProductivityModifier;
            m_researchCopyTime = src.ResearchCopyTime;
            m_researchMaterialTime = src.ResearchMaterialTime;
            m_researchProductivityTime = src.ResearchProductivityTime;
            m_researchTechTime = src.ResearchTechTime;
            m_techLevel = src.TechLevel;
            m_wasteFactor = src.WasteFactor;

            // Invented blueprint
            m_inventBlueprint = new FastList<int>(src.InventionTypeID != null ? src.InventionTypeID.Length : 0);
            if (src.InventionTypeID != null)
            {
                foreach (var blueprintID in src.InventionTypeID)
                {
                    m_inventBlueprint.Add(blueprintID);
                }
            }

            // Materials prerequisites
            m_materialRequirements = new FastList<StaticRequiredMaterial>(src.ReqMaterial != null ? src.ReqMaterial.Length : 0);
            if (src.ReqMaterial == null)
                return;
            
            foreach (var prereq in src.ReqMaterial)
            {
                m_materialRequirements.Add(new StaticRequiredMaterial(prereq));
            }
        }
Пример #2
0
        /// <summary>
        /// Deserialization constructor.
        /// </summary>
        /// <param name="group">Market Group the Blueprint will be a member of.</param>
        /// <param name="src">Source serializable blueprint.</param>
        internal Blueprint(MarketGroup group, SerializableBlueprint src)
            : base(group, src)
        {
            RunsPerCopy = src.MaxProductionLimit;
            ProducesItem = StaticItems.GetItemByID(src.ProduceItemID);
            ProductionTime = src.ProductionTime;
            ResearchCopyTime = src.ResearchCopyTime;
            ResearchMaterialTime = src.ResearchMaterialTime;
            ResearchProductivityTime = src.ResearchProductivityTime;
            ResearchInventionTime = src.InventionTime;
            ReverseEngineeringTime = src.ReverseEngineeringTime;

            // Invented blueprints
            m_inventBlueprints = new Dictionary<int, double>(src.InventionTypeIDs?.Count ?? 0);
            if (src.InventionTypeIDs != null && src.InventionTypeIDs.Any())
            {
                m_inventBlueprints.AddRange(src.InventionTypeIDs);
            }

            // Materials prerequisites
            m_materialRequirements =
                new FastList<StaticRequiredMaterial>(src.ReqMaterial?.Count ?? 0);
            if (src.ReqMaterial == null)
                return;

            foreach (SerializableRequiredMaterial prereq in src.ReqMaterial)
            {
                m_materialRequirements.Add(new StaticRequiredMaterial(prereq));
            }
        }
Пример #3
0
        /// <summary>
        /// Base constructor for blueprints.
        /// </summary>
        /// <param name="id"></param>
        /// <param name="name"></param>
        internal Item(BlueprintMarketGroup group, SerializableBlueprint src)
            : this(src.ID, src.Name)
        {
            m_icon = src.Icon;
            m_metaGroup = src.MetaGroup;
            m_marketGroup = group;
            m_family = ItemFamily.Bpo;

            m_prerequisites = new FastList<StaticSkillLevel>(src.PrereqSkill != null ? src.PrereqSkill.Length : 0);
            if (src.PrereqSkill == null)
                return;

            foreach (var prereq in src.PrereqSkill)
            {
                m_prerequisites.Add(new StaticSkillLevel(prereq.ID, prereq.Level, prereq.Activity));
            }
        }
Пример #4
0
        /// <summary>
        /// Base constructor for blueprints.
        /// </summary>
        /// <param name="group">The group.</param>
        /// <param name="src">The source.</param>
        internal Item(MarketGroup group, SerializableBlueprint src)
            : this(src.ID, src.Name)
        {
            Icon = src.Icon;
            MetaGroup = src.MetaGroup;
            MarketGroup = group;
            Family = ItemFamily.Blueprint;

            // Skills prerequisites
            m_prerequisites = new FastList<StaticSkillLevel>(src.PrereqSkill?.Count ?? 0);
            if (src.PrereqSkill == null)
                return;

            foreach (SerializablePrereqSkill prereq in src.PrereqSkill)
            {
                m_prerequisites.Add(new StaticSkillLevel(prereq.ID, prereq.Level, prereq.Activity));
            }
        }
Пример #5
0
        /// <summary>
        /// Export item requirements. 
        /// </summary>
        /// <param name="srcBlueprint"></param>
        /// <param name="blueprint"></param>
        private static void ExportRequirements(InvType srcBlueprint, SerializableBlueprint blueprint)
        {
            var prerequisiteSkills = new List<SerializablePrereqSkill>();
            var requiredMaterials = new List<SerializableRequiredMaterial>();

            // Add the required raw materials
            AddRequiredRawMaterials(blueprint.ProduceItemID, requiredMaterials);

            // Add the required extra materials
            AddRequiredExtraMaterials(srcBlueprint.ID, prerequisiteSkills, requiredMaterials);

            // Add prerequisite skills to item
            blueprint.PrereqSkill = prerequisiteSkills.OrderBy(x => x.Activity).ToArray();

            // Add required materials to item
            blueprint.ReqMaterial = requiredMaterials.OrderBy(x => x.Activity).ToArray();
        }
Пример #6
0
        /// <summary>
        /// Add properties to a blueprint.
        /// </summary>
        /// <param name="srcBlueprint"></param>
        /// <param name="blueprintsGroup"></param>
        /// <returns></returns>
        private static void CreateBlueprint(InvType srcBlueprint, List<SerializableBlueprint> blueprintsGroup)
        {
            UpdatePercentDone(s_blueprintGenTotal);

            srcBlueprint.Generated = true;

            // Creates the blueprint with base informations
            var blueprint = new SerializableBlueprint
                           {
                               ID = srcBlueprint.ID,
                               Name = srcBlueprint.Name,
                           };

            // Icon
            blueprint.Icon = (srcBlueprint.IconID.HasValue ? s_icons[srcBlueprint.IconID.Value].Icon : String.Empty);

            // Export attributes
            foreach (InvBlueprintTypes attribute in s_blueprintTypes.Where(x => x.ID == srcBlueprint.ID))
            {
                blueprint.ProduceItemID = attribute.ProductTypeID;
                blueprint.ProductionTime = attribute.ProductionTime;
                blueprint.TechLevel = attribute.TechLevel;
                blueprint.ResearchProductivityTime = attribute.ResearchProductivityTime;
                blueprint.ResearchMaterialTime = attribute.ResearchMaterialTime;
                blueprint.ResearchCopyTime = attribute.ResearchCopyTime;
                blueprint.ResearchTechTime = attribute.ResearchTechTime;
                blueprint.ProductivityModifier = attribute.ProductivityModifier;
                blueprint.WasteFactor = attribute.WasteFactor;
                blueprint.MaxProductionLimit = attribute.MaxProductionLimit;
            }

            // Metagroup
            foreach (InvMetaType relation in s_metaTypes
                .Where(x => x.ItemID == s_blueprintTypes[srcBlueprint.ID].ProductTypeID))
            {
                switch (relation.MetaGroupID)
                {
                    default:
                    case 1:
                        blueprint.MetaGroup = ItemMetaGroup.T1;
                        break;
                    case 2:
                        blueprint.MetaGroup = ItemMetaGroup.T2;
                        break;
                    case 3:
                        blueprint.MetaGroup = ItemMetaGroup.Storyline;
                        break;
                    case 4:
                        blueprint.MetaGroup = ItemMetaGroup.Faction;
                        break;
                    case 5:
                        blueprint.MetaGroup = ItemMetaGroup.Officer;
                        break;
                    case 6:
                        blueprint.MetaGroup = ItemMetaGroup.Deadspace;
                        break;
                    case 14:
                        blueprint.MetaGroup = ItemMetaGroup.T3;
                        break;
                }
            }

            // Metagroup for the custom market groups
            switch (srcBlueprint.MarketGroupID)
            {
                case DBConstants.BlueprintNonMarketStorylineGroupID:
                    blueprint.MetaGroup = ItemMetaGroup.Storyline;
                    break;
                case DBConstants.BlueprintNonMarketFactionGroupID:
                    blueprint.MetaGroup = ItemMetaGroup.Faction;
                    break;
                case DBConstants.BlueprintNonMarketTechIIIGroupID:
                    blueprint.MetaGroup = ItemMetaGroup.T3;
                    break;
                case DBConstants.BlueprintNonMarketTechIIGroupID:
                    blueprint.MetaGroup = ItemMetaGroup.T2;
                    break;
            }

            if (blueprint.MetaGroup == ItemMetaGroup.Empty)
                blueprint.MetaGroup = ItemMetaGroup.T1;

            // Export item requirements
            ExportRequirements(srcBlueprint, blueprint);

            // Look for the tech 2 variations that this blueprint invents
            var inventionBlueprint = new List<int>();
            foreach (int relationItemID in s_metaTypes
                .Where(x => x.ParentItemID == blueprint.ProduceItemID && x.MetaGroupID == 2)
                .Select(x => x.ItemID))
            {
                // Look for a blueprint that produces the related item
                foreach (int variationItemID in s_blueprintTypes
                    .Where(x => x.ProductTypeID == relationItemID).Select(x => x.ID))
                {
                    // Add the variation blueprint
                    inventionBlueprint.Add(s_types[variationItemID].ID);
                }
            }

            // Add invention blueprints to item
            blueprint.InventionTypeID = inventionBlueprint.ToArray();

            // Add this item
            blueprintsGroup.Add(blueprint);
        }
Пример #7
0
        /// <summary>
        /// Sets the blueprint meta group.
        /// </summary>
        /// <param name="srcBlueprint">The SRC blueprint.</param>
        /// <param name="blueprint">The blueprint.</param>
        private static void SetBlueprintMetaGroup(InvTypes srcBlueprint, SerializableBlueprint blueprint)
        {
            foreach (InvMetaTypes relation in Database.InvMetaTypesTable.Where(
                x => x.ItemID == Database.InvBlueprintTypesTable[srcBlueprint.ID].ProductTypeID))
            {
                switch (relation.MetaGroupID)
                {
                    default:
                        blueprint.MetaGroup = ItemMetaGroup.T1;
                        break;
                    case DBConstants.TechIIMetaGroupID:
                        blueprint.MetaGroup = ItemMetaGroup.T2;
                        break;
                    case DBConstants.StorylineMetaGroupID:
                        blueprint.MetaGroup = ItemMetaGroup.Storyline;
                        break;
                    case DBConstants.FactionMetaGroupID:
                        blueprint.MetaGroup = ItemMetaGroup.Faction;
                        break;
                    case DBConstants.OfficerMetaGroupID:
                        blueprint.MetaGroup = ItemMetaGroup.Officer;
                        break;
                    case DBConstants.DeadspaceMetaGroupID:
                        blueprint.MetaGroup = ItemMetaGroup.Deadspace;
                        break;
                    case DBConstants.TechIIIMetaGroupID:
                        blueprint.MetaGroup = ItemMetaGroup.T3;
                        break;
                }
            }

            // Metagroup for the custom market groups
            switch (srcBlueprint.MarketGroupID)
            {
                case DBConstants.BlueprintStorylineNonMarketGroupID:
                    blueprint.MetaGroup = ItemMetaGroup.Storyline;
                    break;
                case DBConstants.BlueprintFactionNonMarketGroupID:
                    blueprint.MetaGroup = ItemMetaGroup.Faction;
                    break;
                case DBConstants.BlueprintOfficerNonMarketGroupID:
                    blueprint.MetaGroup = ItemMetaGroup.Officer;
                    break;
                case DBConstants.BlueprintTechIIINonMarketGroupID:
                    blueprint.MetaGroup = ItemMetaGroup.T3;
                    break;
                case DBConstants.BlueprintTechIINonMarketGroupID:
                    blueprint.MetaGroup = ItemMetaGroup.T2;
                    break;
            }

            if (blueprint.MetaGroup == ItemMetaGroup.None)
                blueprint.MetaGroup = ItemMetaGroup.T1;
        }
Пример #8
0
        /// <summary>
        /// Get's the item requirements. 
        /// </summary>
        /// <param name="srcBlueprint"></param>
        /// <param name="blueprint"></param>
        private static void GetRequirements(IHasID srcBlueprint, SerializableBlueprint blueprint)
        {
            List<SerializablePrereqSkill> prerequisiteSkills = new List<SerializablePrereqSkill>();
            List<SerializableRequiredMaterial> requiredMaterials = new List<SerializableRequiredMaterial>();

            // Find the requirements and add them to the list, ignore any blueprint type
            foreach (RamTypeRequirements requirement in Database.RamTypeRequirementsTable
                .Where(requirement => requirement.ID == srcBlueprint.ID &&
                                      Database.InvBlueprintTypesTable.All(x => x.ID != requirement.RequiredTypeID)))
            {
                // Is it a skill ? Add it to the prerequisities skills list
                if (requirement.Level.HasValue)
                {
                    prerequisiteSkills.Add(new SerializablePrereqSkill
                    {
                        ID = requirement.RequiredTypeID,
                        Level = requirement.Level.Value,
                        Activity = requirement.ActivityID
                    });
                    continue;
                }

                // It is an item (material)
                if (requirement.Quantity.HasValue)
                {
                    requiredMaterials.Add(new SerializableRequiredMaterial
                    {
                        ID = requirement.RequiredTypeID,
                        Quantity = requirement.Quantity.Value,
                        Activity = requirement.ActivityID,
                    });
                }
            }

            // Add prerequisite skills to item
            blueprint.PrereqSkill.AddRange(prerequisiteSkills.OrderBy(x => x.Activity));

            // Add required materials to item
            blueprint.ReqMaterial.AddRange(requiredMaterials.OrderBy(x => x.Activity));
        }
Пример #9
0
 /// <summary>
 /// Gets the inventing items.
 /// </summary>
 /// <param name="srcBlueprint">The source blueprint.</param>
 /// <param name="blueprint">The blueprint.</param>
 private static void GetInventingItems(InvTypes srcBlueprint, SerializableBlueprint blueprint)
 {
     foreach (RamTypeRequirements requirement in Database.RamTypeRequirementsTable
         .Where(requirement => requirement.ID == srcBlueprint.ID &&
                               Database.InvBlueprintTypesTable.Any(x => x.ID == requirement.RequiredTypeID) &&
                               (requirement.ActivityID == (int)BlueprintActivity.Invention ||
                                requirement.ActivityID == (int)BlueprintActivity.ReverseEngineering)))
     {
         blueprint.InventionTypeIDs.Add(requirement.RequiredTypeID, requirement.Probability.GetValueOrDefault());
     }
 }
Пример #10
0
        /// <summary>
        /// Add properties to a blueprint.
        /// </summary>
        /// <param name="srcBlueprint"></param>
        /// <param name="blueprintsGroup"></param>
        /// <returns></returns>
        private static void CreateBlueprint(InvTypes srcBlueprint, ICollection<SerializableBlueprint> blueprintsGroup)
        {
            Util.UpdatePercentDone(Database.BlueprintsTotalCount);

            // Guard in case an item of blueprint type is not contained in the blueprints table (glorious CCP)
            if (Database.InvBlueprintTypesTable.All(x => x.ID != srcBlueprint.ID))
                return;

            InvBlueprintTypes blueprintType = Database.InvBlueprintTypesTable[srcBlueprint.ID];

            // Creates the blueprint with base informations
            SerializableBlueprint blueprint = new SerializableBlueprint
            {
                ID = srcBlueprint.ID,
                Name = srcBlueprint.Name,
                Icon = srcBlueprint.IconID.HasValue
                    ? Database.EveIconsTable[srcBlueprint.IconID.Value].Icon
                    : String.Empty,
                ProduceItemID = blueprintType.ProductTypeID,
                ProductionTime = blueprintType.ProductionTime,
                ResearchProductivityTime = blueprintType.ResearchProductivityTime,
                ResearchMaterialTime = blueprintType.ResearchMaterialTime,
                ResearchCopyTime = blueprintType.ResearchCopyTime,
                InventionTime = blueprintType.InventionTime,
                ReverseEngineeringTime = blueprintType.ReverseEngineeringTime,
                MaxProductionLimit = blueprintType.MaxProductionLimit,
            };

            // Metagroup
            SetBlueprintMetaGroup(srcBlueprint, blueprint);

            // Export item requirements
            GetRequirements(srcBlueprint, blueprint);

            // Look for the tech 2 or tech 3 variations that this blueprint invents
            GetInventingItems(srcBlueprint, blueprint);

            // Add this item
            blueprintsGroup.Add(blueprint);
        }