Beispiel #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));
            }
        }
Beispiel #2
0
        /// <summary>
        /// Deserialization constructor.
        /// </summary>
        /// <param name="group">Blueprint Market Group that the blueprint will contain.</param>
        /// <param name="src">One or more serializable blueprints.</param>
        internal BlueprintCollection(BlueprintMarketGroup group, ICollection<SerializableBlueprint> src)
            : base(src?.Count ?? 0)
        {
            if (src == null)
                return;

            foreach (SerializableBlueprint blueprint in src)
            {
                Items.Add(new Blueprint(group, blueprint));
            }
        }
Beispiel #3
0
        /// <summary>
        /// Recursively collect the blueprints within all groups and stores them in the dictionaries.
        /// </summary>
        /// <param name="marketGroup"></param>
        private static void InitializeDictionaries(BlueprintMarketGroup marketGroup)
        {
            foreach (Blueprint blueprint in marketGroup.Blueprints)
            {
                s_blueprintsByID[blueprint.ID] = blueprint;
            }

            foreach (BlueprintMarketGroup childGroup in marketGroup.SubGroups)
            {
                InitializeDictionaries(childGroup);
            }
        }
        /// <summary>
        /// Recursively collect the blueprints within all groups and stores them in the dictionaries.
        /// </summary>
        /// <param name="group"></param>
        private static void InitializeDictionaries(BlueprintMarketGroup group)
        {
            foreach (var blueprint in group.Blueprints)
            {
                s_blueprintsByID[blueprint.ID] = blueprint;
            }

            foreach (var childGroup in group.SubGroups)
            {
                InitializeDictionaries(childGroup);
            }
        }
        /// <summary>
        /// Deserialization constructor
        /// </summary>
        /// <param name="group">Blueprint Market Group that the blueprint will contain</param>
        /// <param name="src">One or more serializable blueprints</param>
        internal BlueprintCollection(BlueprintMarketGroup group, SerializableBlueprint[] src)
            : base(src == null ? 0 : src.Length)
        {
            if (src == null)
            {
                return;
            }

            foreach (var blueprint in src)
            {
                m_items.Add(new Blueprint(group, blueprint));
            }
        }
Beispiel #6
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));
            }
        }
Beispiel #7
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));
            }
        }
Beispiel #8
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));
            }
        }
 /// <summary>
 /// Deserialization constructor.
 /// </summary>
 /// <param name="src"></param>
 public BlueprintMarketGroup(BlueprintMarketGroup parent, SerializableBlueprintGroup src)
     : base(parent, src)
 {
     m_subCategories = new BlueprintMarketGroupCollection(this, src.SubGroups);
     m_blueprints = new BlueprintCollection(this, src.Blueprints);
 }
 /// <summary>
 /// Deserialization constructor.
 /// </summary>
 /// <param name="src"></param>
 public BlueprintMarketGroup(BlueprintMarketGroup parent, SerializableBlueprintGroup src)
     : base(parent, src)
 {
     m_subCategories = new BlueprintMarketGroupCollection(this, src.SubGroups);
     m_blueprints    = new BlueprintCollection(this, src.Blueprints);
 }
        /// <summary>
        /// Recursively creates tree nodes for the children market groups of the given group.
        /// The added blueprints will be the ones which require the current skill (<see cref="m_skill"/>) at the specified level.
        /// </summary>
        /// <param name="blueprintMarketGroup">The blueprint market group.</param>
        /// <param name="blueprints">The blueprints.</param>
        /// <param name="level">The level.</param>
        /// <returns></returns>
        private IEnumerable<TreeNode> CreateMarketGroupsNode(BlueprintMarketGroup blueprintMarketGroup, IEnumerable<Item> blueprints, int level)
        {
            // Add categories
            foreach (BlueprintMarketGroup category in blueprintMarketGroup.SubGroups)
            {
                IEnumerable<TreeNode> children = CreateMarketGroupsNode(category, blueprints, level);
                if (children.IsEmpty())
                    continue;

                TreeNode node = new TreeNode(category.Name);
                node.Nodes.AddRange(children.ToArray());
                yield return node;
            }

            // Add blueprints
            foreach (Item blueprint in blueprints.Where(x => x.MarketGroup == blueprintMarketGroup))
            {
                List<string> listOfActivities = blueprint.Prerequisites
                                        .Where(x => x.Skill == m_skill.StaticData && x.Level == level)
                                        .Select(x => x.Activity.GetDescription()).ToList();

                TreeNode node = CreateNode(blueprint, blueprint.Prerequisites
                                        .Where(x => listOfActivities.Contains(x.Activity.GetDescription())).ToCharacter(m_character));
                node.Text = String.Format("{0} ({1})", node.Text, string.Join(", ", listOfActivities));
                yield return node;
            }
        }
        /// <summary>
        /// Create the tree nodes for the given category and add them to the given nodes collection
        /// </summary>
        /// <param name="group"></param>
        /// <param name="nodeCollection"></param>
        /// <returns></returns>
        private int BuildSubtree(BlueprintMarketGroup group, TreeNodeCollection nodeCollection)
        {
            // Total blueprints count in this category and its subcategories
            int result = 0;

            // Add all subcategories
            foreach (BlueprintMarketGroup childGroup in group.SubGroups)
            {
                TreeNode node = new TreeNode
                {
                    Text = childGroup.Name,
                    Tag = childGroup
                };

                // Add this subcategory's blueprints count
                result += BuildSubtree(childGroup, node.Nodes);

                // Only add if this subcategory has children
                if (node.GetNodeCount(true) > 0)
                    nodeCollection.Add(node);
            }

            // Add all blueprints
            foreach (TreeNode node in group.Blueprints.Where(
                x => UsabilityPredicate(x) && m_metaGroupPredicate(x)).Select(
                    childItem => new TreeNode { Text = childItem.Name, Tag = childItem }))
            {
                nodeCollection.Add(node);
                result++;
            }
            return result;
        }