private static bool OverwriteSaveFile(MetaData metaData, string name)
        {
            bool flag;

            try
            {
                flag = MBSaveLoad.SaveGame(name, metaData);
            }
            catch
            {
                flag = false;
            }
            if (flag)
            {
                return(true);
            }
            if (!MBSaveLoad.DoNotShowSaveErrorAgain)
            {
                InformationManager.ShowInquiry(new InquiryData(GameTexts.FindText("str_save_unsuccessful_title").ToString(), GameTexts.FindText("str_save_unsuccessful_cannot_create_save_data").ToString(), true, false, GameTexts.FindText("str_ok").ToString(), GameTexts.FindText("str_dont_show_again").ToString(), (Action)null, (Action)(() => MBSaveLoad.DoNotShowSaveErrorAgain = true)));
            }
            return(false);
        }
Example #2
0
 public override TextObject GetName() => GameTexts.FindText("str_item_category", this.StringId);
Example #3
0
        public override void Deserialize(MBObjectManager objectManager, XmlNode node)
        {
            base.Deserialize(objectManager, node);
            this._hiddenPieceTypesOnHolsteredMesh = new bool[4];
            string objectName = node.Attributes["item_modifier_group"] != null ? node.Attributes["item_modifier_group"].Value : (string)null;

            if (objectName != null)
            {
                this.ItemModifierGroup = Game.Current.ObjectManager.GetObject <ItemModifierGroup>(objectName);
            }
            this.ItemHolsters                = node.Attributes["item_holsters"].Value.Split(':');
            this.ItemHolsterPositionShift    = Vec3.Parse(node.Attributes["default_item_holster_position_offset"].Value);
            this.UseWeaponAsHolsterMesh      = XmlHelper.ReadBool(node, "use_weapon_as_holster_mesh");
            this.AlwaysShowHolsterWithWeapon = XmlHelper.ReadBool(node, "always_show_holster_with_weapon");
            this.RotateWeaponInHolster       = XmlHelper.ReadBool(node, "rotate_weapon_in_holster");
            XmlAttribute attribute1 = node.Attributes["piece_type_to_scale_holster_with"];

            this.PieceTypeToScaleHolsterWith = attribute1 != null ? (CraftingPiece.PieceTypes)Enum.Parse(typeof(CraftingPiece.PieceTypes), attribute1.Value) : CraftingPiece.PieceTypes.Invalid;
            XmlAttribute attribute2 = node.Attributes["hidden_piece_types_on_holster"];

            if (attribute2 != null)
            {
                string str1    = attribute2.Value;
                char[] chArray = new char[1] {
                    ','
                };
                foreach (string str2 in str1.Split(chArray))
                {
                    this._hiddenPieceTypesOnHolsteredMesh[(int)Enum.Parse(typeof(CraftingPiece.PieceTypes), str2)] = true;
                }
            }
            foreach (XmlNode childNode1 in node.ChildNodes)
            {
                if (childNode1.Attributes != null)
                {
                    string name = childNode1.Name;
                    if (!(name == "PieceDatas"))
                    {
                        if (!(name == "WeaponUsageDatas"))
                        {
                            if (!(name == "UsablePieces"))
                            {
                                if (name == "StatsData")
                                {
                                    XmlAttribute attribute3 = childNode1.Attributes["usage_data"];
                                    float[]      numArray   = new float[10];
                                    for (int index = 0; index < numArray.Length; ++index)
                                    {
                                        numArray[index] = float.MinValue;
                                    }
                                    foreach (XmlNode childNode2 in childNode1.ChildNodes)
                                    {
                                        if (childNode2.NodeType == XmlNodeType.Element)
                                        {
                                            XmlAttribute attribute4 = childNode2.Attributes["stat_type"];
                                            XmlAttribute attribute5 = childNode2.Attributes["max_value"];
                                            CraftingTemplate.CraftingStatTypes craftingStatTypes = (CraftingTemplate.CraftingStatTypes)Enum.Parse(typeof(CraftingTemplate.CraftingStatTypes), attribute4.Value);
                                            float num = float.Parse(attribute5.Value);
                                            numArray[(int)craftingStatTypes] = num;
                                        }
                                    }
                                    if (attribute3 != null)
                                    {
                                        this._statDataValues[this.GetIndexOfUsageDataWithId(attribute3.Value)] = numArray;
                                    }
                                    else
                                    {
                                        for (int index = 0; index < this._statDataValues.Length; ++index)
                                        {
                                            this._statDataValues[index] = numArray;
                                        }
                                    }
                                }
                            }
                            else
                            {
                                this._craftingPieces = new List <CraftingPiece>();
                                foreach (XmlNode childNode2 in childNode1.ChildNodes)
                                {
                                    CraftingPiece craftingPiece = MBObjectManager.Instance.GetObject <CraftingPiece>(childNode2.Attributes["piece_id"].Value);
                                    if (craftingPiece != null)
                                    {
                                        this._craftingPieces.Add(craftingPiece);
                                    }
                                }
                            }
                        }
                        else
                        {
                            List <WeaponUsageData> weaponUsageDataList = new List <WeaponUsageData>();
                            foreach (XmlNode childNode2 in childNode1.ChildNodes)
                            {
                                string id = childNode2.Attributes["id"].Value;
                                weaponUsageDataList.Add(WeaponUsageDataManager.All.First <WeaponUsageData>((Func <WeaponUsageData, bool>)(wud => wud.WeaponUsageDataId == id)));
                            }
                            this._weaponUsageDatas = weaponUsageDataList.ToArray();
                            this._statDataValues   = new float[this._weaponUsageDatas.Length][];
                        }
                    }
                    else
                    {
                        List <PieceData> pieceDataList = new List <PieceData>();
                        foreach (XmlNode childNode2 in childNode1.ChildNodes)
                        {
                            XmlAttribute             attribute3 = childNode2.Attributes["piece_type"];
                            XmlAttribute             attribute4 = childNode2.Attributes["build_order"];
                            CraftingPiece.PieceTypes pieceType  = (CraftingPiece.PieceTypes)Enum.Parse(typeof(CraftingPiece.PieceTypes), attribute3.Value);
                            int order = int.Parse(attribute4.Value);
                            pieceDataList.Add(new PieceData(pieceType, order));
                        }
                        this._buildOrders = pieceDataList.ToArray();
                    }
                }
            }
            this.TemplateName = GameTexts.FindText("str_crafting_template", this.StringId);
        }