Exemplo n.º 1
0
        // Token: 0x06003448 RID: 13384 RVA: 0x00155AC4 File Offset: 0x00153EC4
        public static void readRewards(Data data, Local localization, string prefix, INPCReward[] rewards, string errorMessageSource)
        {
            for (int i = 0; i < rewards.Length; i++)
            {
                if (!data.has(prefix + i + "_Type"))
                {
                    Assets.errors.Add(string.Concat(new object[]
                    {
                        "Missing ",
                        prefix,
                        i,
                        " reward type"
                    }));
                    throw new NotSupportedException(string.Concat(new object[]
                    {
                        "Missing ",
                        prefix,
                        i,
                        " reward type"
                    }));
                }
                ENPCRewardType enpcrewardType = (ENPCRewardType)Enum.Parse(typeof(ENPCRewardType), data.readString(prefix + i + "_Type"), true);
                string         text           = localization.read(prefix + i);
                text = ItemTool.filterRarityRichText(text);
                switch (enpcrewardType)
                {
                case ENPCRewardType.EXPERIENCE:
                    if (!data.has(prefix + i + "_Value"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Experience reward ",
                            prefix,
                            i,
                            " missing _Value in: ",
                            errorMessageSource
                        }));
                    }
                    rewards[i] = new NPCExperienceReward(data.readUInt32(prefix + i + "_Value"), text);
                    break;

                case ENPCRewardType.REPUTATION:
                    if (!data.has(prefix + i + "_Value"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Reputation reward ",
                            prefix,
                            i,
                            " missing _Value in: ",
                            errorMessageSource
                        }));
                    }
                    rewards[i] = new NPCReputationReward(data.readInt32(prefix + i + "_Value"), text);
                    break;

                case ENPCRewardType.FLAG_BOOL:
                    if (!data.has(prefix + i + "_ID"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Bool flag reward ",
                            prefix,
                            i,
                            " missing _ID in: ",
                            errorMessageSource
                        }));
                    }
                    if (!data.has(prefix + i + "_Value"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Bool flag reward ",
                            prefix,
                            i,
                            " missing _Value in: ",
                            errorMessageSource
                        }));
                    }
                    rewards[i] = new NPCBoolFlagReward(data.readUInt16(prefix + i + "_ID"), data.readBoolean(prefix + i + "_Value"), text);
                    break;

                case ENPCRewardType.FLAG_SHORT:
                    if (!data.has(prefix + i + "_ID"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Short flag reward ",
                            prefix,
                            i,
                            " missing _ID in: ",
                            errorMessageSource
                        }));
                    }
                    if (!data.has(prefix + i + "_Value"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Short flag reward ",
                            prefix,
                            i,
                            " missing _Value in: ",
                            errorMessageSource
                        }));
                    }
                    rewards[i] = new NPCShortFlagReward(data.readUInt16(prefix + i + "_ID"), data.readInt16(prefix + i + "_Value"), (ENPCModificationType)Enum.Parse(typeof(ENPCModificationType), data.readString(prefix + i + "_Modification"), true), text);
                    break;

                case ENPCRewardType.FLAG_SHORT_RANDOM:
                    if (!data.has(prefix + i + "_ID"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Random short flag reward ",
                            prefix,
                            i,
                            " missing _ID in: ",
                            errorMessageSource
                        }));
                    }
                    if (!data.has(prefix + i + "_Min_Value"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Random short flag reward ",
                            prefix,
                            i,
                            " missing _Min_Value in: ",
                            errorMessageSource
                        }));
                    }
                    if (!data.has(prefix + i + "_Max_Value"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Random short flag reward ",
                            prefix,
                            i,
                            " missing _Max_Value in: ",
                            errorMessageSource
                        }));
                    }
                    rewards[i] = new NPCRandomShortFlagReward(data.readUInt16(prefix + i + "_ID"), data.readInt16(prefix + i + "_Min_Value"), data.readInt16(prefix + i + "_Max_Value"), (ENPCModificationType)Enum.Parse(typeof(ENPCModificationType), data.readString(prefix + i + "_Modification"), true), text);
                    break;

                case ENPCRewardType.QUEST:
                    if (!data.has(prefix + i + "_ID"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Quest reward ",
                            prefix,
                            i,
                            " missing _ID in: ",
                            errorMessageSource
                        }));
                    }
                    rewards[i] = new NPCQuestReward(data.readUInt16(prefix + i + "_ID"), text);
                    break;

                case ENPCRewardType.ITEM:
                    if (!data.has(prefix + i + "_ID"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Item reward ",
                            prefix,
                            i,
                            " missing _ID in: ",
                            errorMessageSource
                        }));
                    }
                    if (!data.has(prefix + i + "_Amount"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Item reward ",
                            prefix,
                            i,
                            " missing _Amount in: ",
                            errorMessageSource
                        }));
                    }
                    rewards[i] = new NPCItemReward(data.readUInt16(prefix + i + "_ID"), data.readByte(prefix + i + "_Amount"), data.readUInt16(prefix + i + "_Sight"), data.readUInt16(prefix + i + "_Tactical"), data.readUInt16(prefix + i + "_Grip"), data.readUInt16(prefix + i + "_Barrel"), data.readUInt16(prefix + i + "_Magazine"), data.readByte(prefix + i + "_Ammo"), text);
                    break;

                case ENPCRewardType.ITEM_RANDOM:
                    if (!data.has(prefix + i + "_ID"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Random item reward ",
                            prefix,
                            i,
                            " missing _ID in: ",
                            errorMessageSource
                        }));
                    }
                    if (!data.has(prefix + i + "_Amount"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Random item reward ",
                            prefix,
                            i,
                            " missing _Amount in: ",
                            errorMessageSource
                        }));
                    }
                    rewards[i] = new NPCRandomItemReward(data.readUInt16(prefix + i + "_ID"), data.readByte(prefix + i + "_Amount"), text);
                    break;

                case ENPCRewardType.ACHIEVEMENT:
                    if (!data.has(prefix + i + "_ID"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Achievement reward ",
                            prefix,
                            i,
                            " missing _ID in: ",
                            errorMessageSource
                        }));
                    }
                    rewards[i] = new NPCAchievementReward(data.readString(prefix + i + "_ID"), text);
                    break;

                case ENPCRewardType.VEHICLE:
                    if (!data.has(prefix + i + "_ID"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Vehicle reward ",
                            prefix,
                            i,
                            " missing _ID in: ",
                            errorMessageSource
                        }));
                    }
                    if (!data.has(prefix + i + "_Spawnpoint"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Vehicle reward ",
                            prefix,
                            i,
                            " missing _Spawnpoint in: ",
                            errorMessageSource
                        }));
                    }
                    rewards[i] = new NPCVehicleReward(data.readUInt16(prefix + i + "_ID"), data.readString(prefix + i + "_Spawnpoint"), text);
                    break;

                case ENPCRewardType.TELEPORT:
                    if (!data.has(prefix + i + "_Spawnpoint"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Teleport reward ",
                            prefix,
                            i,
                            " missing _Spawnpoint in: ",
                            errorMessageSource
                        }));
                    }
                    rewards[i] = new NPCTeleportReward(data.readString(prefix + i + "_Spawnpoint"), text);
                    break;

                case ENPCRewardType.EVENT:
                    if (!data.has(prefix + i + "_ID"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Event reward ",
                            prefix,
                            i,
                            " missing _ID in: ",
                            errorMessageSource
                        }));
                    }
                    rewards[i] = new NPCEventReward(data.readString(prefix + i + "_ID"), text);
                    break;

                case ENPCRewardType.FLAG_MATH:
                    if (!data.has(prefix + i + "_A_ID"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Math reward ",
                            prefix,
                            i,
                            " missing _A_ID in: ",
                            errorMessageSource
                        }));
                    }
                    if (!data.has(prefix + i + "_B_ID"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Math reward ",
                            prefix,
                            i,
                            " missing _B_ID in: ",
                            errorMessageSource
                        }));
                    }
                    rewards[i] = new NPCFlagMathReward(data.readUInt16(prefix + i + "_A_ID"), data.readUInt16(prefix + i + "_B_ID"), (ENPCOperationType)Enum.Parse(typeof(ENPCOperationType), data.readString(prefix + i + "_Operation"), true), text);
                    break;
                }
            }
        }
Exemplo n.º 2
0
        public static void readRewards(Data data, Local localization, string prefix, INPCReward[] rewards)
        {
            for (int i = 0; i < rewards.Length; i++)
            {
                if (!data.has(prefix + i + "_Type"))
                {
                    throw new NotSupportedException("Missing reward type");
                }
                ENPCRewardType enpcrewardType = (ENPCRewardType)Enum.Parse(typeof(ENPCRewardType), data.readString(prefix + i + "_Type"), true);
                string         text           = localization.read(prefix + i);
                text = ItemTool.filterRarityRichText(text);
                switch (enpcrewardType)
                {
                case ENPCRewardType.EXPERIENCE:
                    rewards[i] = new NPCExperienceReward(data.readUInt32(prefix + i + "_Value"), text);
                    break;

                case ENPCRewardType.REPUTATION:
                    rewards[i] = new NPCReputationReward(data.readInt32(prefix + i + "_Value"), text);
                    break;

                case ENPCRewardType.FLAG_BOOL:
                    rewards[i] = new NPCBoolFlagReward(data.readUInt16(prefix + i + "_ID"), data.readBoolean(prefix + i + "_Value"), text);
                    break;

                case ENPCRewardType.FLAG_SHORT:
                    rewards[i] = new NPCShortFlagReward(data.readUInt16(prefix + i + "_ID"), data.readInt16(prefix + i + "_Value"), (ENPCModificationType)Enum.Parse(typeof(ENPCModificationType), data.readString(prefix + i + "_Modification"), true), text);
                    break;

                case ENPCRewardType.FLAG_SHORT_RANDOM:
                    rewards[i] = new NPCRandomShortFlagReward(data.readUInt16(prefix + i + "_ID"), data.readInt16(prefix + i + "_Min_Value"), data.readInt16(prefix + i + "_Max_Value"), (ENPCModificationType)Enum.Parse(typeof(ENPCModificationType), data.readString(prefix + i + "_Modification"), true), text);
                    break;

                case ENPCRewardType.QUEST:
                    rewards[i] = new NPCQuestReward(data.readUInt16(prefix + i + "_ID"), text);
                    break;

                case ENPCRewardType.ITEM:
                    rewards[i] = new NPCItemReward(data.readUInt16(prefix + i + "_ID"), data.readByte(prefix + i + "_Amount"), data.readUInt16(prefix + i + "_Sight"), data.readUInt16(prefix + i + "_Tactical"), data.readUInt16(prefix + i + "_Grip"), data.readUInt16(prefix + i + "_Barrel"), data.readUInt16(prefix + i + "_Magazine"), data.readByte(prefix + i + "_Ammo"), text);
                    break;

                case ENPCRewardType.ITEM_RANDOM:
                    rewards[i] = new NPCRandomItemReward(data.readUInt16(prefix + i + "_ID"), data.readByte(prefix + i + "_Amount"), text);
                    break;

                case ENPCRewardType.ACHIEVEMENT:
                    rewards[i] = new NPCAchievementReward(data.readString(prefix + i + "_ID"), text);
                    break;

                case ENPCRewardType.VEHICLE:
                    rewards[i] = new NPCVehicleReward(data.readUInt16(prefix + i + "_ID"), data.readString(prefix + i + "_Spawnpoint"), text);
                    break;

                case ENPCRewardType.TELEPORT:
                    rewards[i] = new NPCTeleportReward(data.readString(prefix + i + "_Spawnpoint"), text);
                    break;

                case ENPCRewardType.EVENT:
                    rewards[i] = new NPCEventReward(data.readString(prefix + i + "_ID"), text);
                    break;
                }
            }
        }