示例#1
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();
        }
示例#2
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);
        }
示例#3
0
        /// <summary>
        /// Add properties to an item.
        /// </summary>
        /// <param name="srcItem"></param>
        /// <param name="groupItems"></param>
        /// <returns></returns>
        private static void CreateItem(InvType srcItem, List<SerializableItem> groupItems)
        {
            UpdatePercentDone(s_itemGenTotal);

            srcItem.Generated = true;

            // Creates the item with base informations
            var item = new SerializableItem
                           {
                               ID = srcItem.ID,
                               Name = srcItem.Name,
                               Description = srcItem.Description
                           };

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

            // Initialize item metagroup
            item.MetaGroup = ItemMetaGroup.Empty;

            // Add the properties and prereqs
            int baseWarpSpeed = 3;
            double warpSpeedMultiplier = 1;
            var props = new List<SerializablePropertyValue>();
            var prereqSkills = new int[DBConstants.RequiredSkillPropertyIDs.Length];
            var prereqLevels = new int[DBConstants.RequiredSkillPropertyIDs.Length];
            foreach (DgmTypeAttribute srcProp in s_typeAttributes.Where(x => x.ItemID == srcItem.ID))
            {
                var propIntValue = (srcProp.ValueInt.HasValue ? srcProp.ValueInt.Value : (int) srcProp.ValueFloat.Value);

                // Is it a prereq skill ?
                int prereqIndex = Array.IndexOf(DBConstants.RequiredSkillPropertyIDs, srcProp.AttributeID);
                if (prereqIndex >= 0)
                {
                    prereqSkills[prereqIndex] = propIntValue;
                    continue;
                }

                // Is it a prereq level ?
                prereqIndex = Array.IndexOf(DBConstants.RequiredSkillLevelPropertyIDs, srcProp.AttributeID);
                if (prereqIndex >= 0)
                {
                    prereqLevels[prereqIndex] = propIntValue;
                    continue;
                }

                // Launcher group ?
                int launcherIndex = Array.IndexOf(DBConstants.LauncherGroupIDs, srcProp.AttributeID);
                if (launcherIndex >= 0)
                {
                    props.Add(new SerializablePropertyValue
                                    {
                                        ID = srcProp.AttributeID,
                                        Value = s_groups[propIntValue].Name
                                    });
                    continue;
                }

                // Charge group ?
                int chargeIndex = Array.IndexOf(DBConstants.ChargeGroupIDs, srcProp.AttributeID);
                if (chargeIndex >= 0)
                {
                    props.Add(new SerializablePropertyValue
                                    {
                                        ID = srcProp.AttributeID,
                                        Value = s_groups[propIntValue].Name
                                    });
                    continue;
                }

                // CanFitShip group ?
                int canFitShipIndex = Array.IndexOf(DBConstants.CanFitShipGroupIDs, srcProp.AttributeID);
                if (canFitShipIndex >= 0)
                {
                    props.Add(new SerializablePropertyValue
                                    {
                                        ID = srcProp.AttributeID,
                                        Value = s_groups[propIntValue].Name
                                    });
                    continue;
                }

                // ModuleShip group ?
                int moduleShipIndex = Array.IndexOf(DBConstants.ModuleShipGroupIDs, srcProp.AttributeID);
                if (moduleShipIndex >= 0)
                {
                    props.Add(new SerializablePropertyValue
                                    {
                                        ID = srcProp.AttributeID,
                                        Value = s_groups[propIntValue].Name
                                    });
                    continue;
                }

                // SpecialisationAsteroid group ?
                int specialisationAsteroidIndex = Array.IndexOf(DBConstants.SpecialisationAsteroidGroupIDs,
                                                                srcProp.AttributeID);
                if (specialisationAsteroidIndex >= 0)
                {
                    props.Add(new SerializablePropertyValue
                                    {
                                        ID = srcProp.AttributeID,
                                        Value = s_groups[propIntValue].Name
                                    });
                    continue;
                }

                // Reaction group ?
                int reactionIndex = Array.IndexOf(DBConstants.ReactionGroupIDs, srcProp.AttributeID);
                if (reactionIndex >= 0)
                {
                    props.Add(new SerializablePropertyValue
                                    {
                                        ID = srcProp.AttributeID,
                                        Value = s_groups[propIntValue].Name
                                    });
                    continue;
                }

                // PosCargobayAccept group ?
                int posCargobayAcceptIndex = Array.IndexOf(DBConstants.PosCargobayAcceptGroupIDs, srcProp.AttributeID);
                if (posCargobayAcceptIndex >= 0)
                {
                    props.Add(new SerializablePropertyValue
                                    {
                                        ID = srcProp.AttributeID,
                                        Value = s_groups[propIntValue].Name
                                    });
                    continue;
                }

                // Get the warp speed multiplier
                if (srcProp.AttributeID == DBConstants.WarpSpeedMultiplierPropertyID)
                    warpSpeedMultiplier = srcProp.ValueFloat.Value;

                // We calculate the Ships Warp Speed
                if (srcProp.AttributeID == DBConstants.ShipWarpSpeedPropertyID)
                    props.Add(new SerializablePropertyValue
                                    {ID = srcProp.AttributeID, Value = (baseWarpSpeed*warpSpeedMultiplier).ToString()});

                // Other props
                props.Add(new SerializablePropertyValue
                                {ID = srcProp.AttributeID, Value = srcProp.FormatPropertyValue()});

                // Is metalevel property ?
                if (srcProp.AttributeID == DBConstants.MetaLevelPropertyID)
                    item.MetaLevel = propIntValue;

                // Is techlevel property ?
                if (srcProp.AttributeID == DBConstants.TechLevelPropertyID)
                {
                    switch (propIntValue)
                    {
                        default:
                        case 1:
                            item.MetaGroup = ItemMetaGroup.T1;
                            break;
                        case 2:
                            item.MetaGroup = ItemMetaGroup.T2;
                            break;
                        case 3:
                            item.MetaGroup = ItemMetaGroup.T3;
                            break;
                    }
                }

                // Is metagroup property ?
                if (srcProp.AttributeID == DBConstants.MetaGroupPropertyID)
                {
                    switch (propIntValue)
                    {
                        case 3:
                            item.MetaGroup = ItemMetaGroup.Storyline;
                            break;
                        case 4:
                            item.MetaGroup = ItemMetaGroup.Faction;
                            break;
                        case 5:
                            item.MetaGroup = ItemMetaGroup.Officer;
                            break;
                        case 6:
                            item.MetaGroup = ItemMetaGroup.Deadspace;
                            break;
                        default:
                            item.MetaGroup = ItemMetaGroup.None;
                            break;
                    }
                }
            }

            // Ensures there is a mass and add it to prop
            if (srcItem.Mass != 0)
                props.Add(new SerializablePropertyValue
                              {ID = DBConstants.MassPropertyID, Value = srcItem.Mass.ToString()});

            // Ensures there is a cargo capacity and add it to prop
            if (srcItem.Capacity != 0)
                props.Add(new SerializablePropertyValue
                              {ID = DBConstants.CargoCapacityPropertyID, Value = srcItem.Capacity.ToString()});

            // Ensures there is a volume and add it to prop
            if (srcItem.Volume != 0)
                props.Add(new SerializablePropertyValue
                              {ID = DBConstants.VolumePropertyID, Value = srcItem.Volume.ToString()});

            // Add base price as a prop
            props.Add(new SerializablePropertyValue {ID = s_propBasePriceID, Value = srcItem.BasePrice.FormatDecimal()});

            // Add properties info to item
            item.Properties = props.ToArray();

            // Prerequisites completion
            var prereqs = new List<SerializablePrerequisiteSkill>();
            for (int i = 0; i < prereqSkills.Length; i++)
            {
                if (prereqSkills[i] != 0)
                    prereqs.Add(new SerializablePrerequisiteSkill {ID = prereqSkills[i], Level = prereqLevels[i]});
            }

            // Add prerequisite skills info to item
            item.Prereqs = prereqs.ToArray();

            // Metagroup
            foreach (InvMetaType relation in s_metaTypes
                .Where(x => x.ItemID == srcItem.ID && item.MetaGroup == ItemMetaGroup.Empty))
            {
                switch (relation.MetaGroupID)
                {
                    case 1:
                        item.MetaGroup = ItemMetaGroup.T1;
                        break;
                    case 2:
                        item.MetaGroup = ItemMetaGroup.T2;
                        break;
                    case 3:
                        item.MetaGroup = ItemMetaGroup.Storyline;
                        break;
                    case 4:
                        item.MetaGroup = ItemMetaGroup.Faction;
                        break;
                    case 5:
                        item.MetaGroup = ItemMetaGroup.Officer;
                        break;
                    case 6:
                        item.MetaGroup = ItemMetaGroup.Deadspace;
                        break;
                    case 14:
                        item.MetaGroup = ItemMetaGroup.T3;
                        break;
                    default:
                        item.MetaGroup = ItemMetaGroup.None;
                        break;
                }
            }

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

            // Race ID
            item.Race = (Race) Enum.ToObject(typeof (Race), (srcItem.RaceID == null ? 0 : srcItem.RaceID));

            // Set race to Faction if item race is Jovian
            if (item.Race == Race.Jove)
                item.Race = Race.Faction;

            // Set race to ORE if it is in the ORE market groups
            // within mining barges, exhumers, industrial or capital industrial ships
            if (srcItem.MarketGroupID == DBConstants.MiningBargesGroupID
                || srcItem.MarketGroupID == DBConstants.ExhumersGroupID
                || srcItem.MarketGroupID == DBConstants.IndustrialsGroupID
                || srcItem.MarketGroupID == DBConstants.CapitalIndustrialsGroupID)
                item.Race = Race.Ore;

            // Set race to Faction if ship has Pirate Faction property
            foreach (SerializablePropertyValue prop in props)
            {
                if (prop.ID == DBConstants.ShipBonusPirateFactionPropertyID)
                    item.Race = Race.Faction;
            }

            // Look for slots
            if (s_typeEffects.Contains(srcItem.ID, DBConstants.LowSlotEffectID))
            {
                item.Slot = ItemSlot.Low;
            }
            else if (s_typeEffects.Contains(srcItem.ID, DBConstants.MedSlotEffectID))
            {
                item.Slot = ItemSlot.Medium;
            }
            else if (s_typeEffects.Contains(srcItem.ID, DBConstants.HiSlotEffectID))
            {
                item.Slot = ItemSlot.High;
            }
            else
            {
                item.Slot = ItemSlot.None;
            }

            // Add this item
            groupItems.Add(item);

            // If the current item isn't in a market group then we are done
            if (srcItem.MarketGroupID == null)
                return;

            // Look for variations which are not in any market group
            foreach (InvMetaType variation in s_metaTypes.Where(x => x.ParentItemID == srcItem.ID))
            {
                InvType srcVariationItem = s_types[variation.ItemID];
                if (srcVariationItem.Published && srcVariationItem.MarketGroupID == null)
                {
                    srcVariationItem.RaceID = (int)Race.Faction;
                    CreateItem(srcVariationItem, groupItems);
                }
            }
        }
示例#4
0
        /// <summary>
        /// Inventory Types
        /// </summary>
        /// <returns><c>Bag</c> of items from the Inventory</returns>
        internal static Bag<InvType> Types()
        {
            var list = new IndexedList<InvType>();

            foreach (invTypes type in Context.invTypes)
            {
                var item = new InvType
                               {
                                   ID = type.typeID,
                                   Description = type.description.Clean(),
                                   IconID = type.iconID,
                                   MarketGroupID = type.marketGroupID,
                                   Name = type.typeName,
                                   RaceID = type.raceID
                               };

                if (type.basePrice.HasValue)
                    item.BasePrice = type.basePrice.Value;

                if (type.capacity.HasValue)
                    item.Capacity = type.capacity.Value;

                if (type.groupID.HasValue)
                    item.GroupID = type.groupID.Value;

                if (type.mass.HasValue)
                    item.Mass = type.mass.Value;

                if (type.published.HasValue)
                    item.Published = type.published.Value;

                if (type.volume.HasValue)
                    item.Volume = type.volume.Value;

                list.Items.Add(item);
            }

            return new Bag<InvType>(list);
        }