Esempio n. 1
0
        public DialogueAsset(Bundle bundle, Data data, Local localization, ushort id) : base(bundle, data, localization, id)
        {
            if (id < 2000 && !bundle.hasResource && !data.has("Bypass_ID_Limit"))
            {
                throw new NotSupportedException("ID < 2000");
            }
            this.messages = new DialogueMessage[(int)data.readByte("Messages")];
            byte b = 0;

            while ((int)b < this.messages.Length)
            {
                DialoguePage[] array = new DialoguePage[(int)data.readByte("Message_" + b + "_Pages")];
                byte           b2    = 0;
                while ((int)b2 < array.Length)
                {
                    string text = localization.format(string.Concat(new object[]
                    {
                        "Message_",
                        b,
                        "_Page_",
                        b2
                    }));
                    text           = ItemTool.filterRarityRichText(text);
                    array[(int)b2] = new DialoguePage(text);
                    b2            += 1;
                }
                byte[] array2 = new byte[(int)data.readByte("Message_" + b + "_Responses")];
                byte   b3     = 0;
                while ((int)b3 < array2.Length)
                {
                    array2[(int)b3] = data.readByte(string.Concat(new object[]
                    {
                        "Message_",
                        b,
                        "_Response_",
                        b3
                    }));
                    b3 += 1;
                }
                ushort          newPrev = data.readUInt16("Message_" + b + "_Prev");
                INPCCondition[] array3  = new INPCCondition[(int)data.readByte("Message_" + b + "_Conditions")];
                NPCTool.readConditions(data, localization, "Message_" + b + "_Condition_", array3);
                INPCReward[] array4 = new INPCReward[(int)data.readByte("Message_" + b + "_Rewards")];
                NPCTool.readRewards(data, localization, "Message_" + b + "_Reward_", array4);
                this.messages[(int)b] = new DialogueMessage(b, array, array2, newPrev, array3, array4);
                b += 1;
            }
            this.responses = new DialogueResponse[(int)data.readByte("Responses")];
            byte b4 = 0;

            while ((int)b4 < this.responses.Length)
            {
                byte[] array5 = new byte[(int)data.readByte("Response_" + b4 + "_Messages")];
                byte   b5     = 0;
                while ((int)b5 < array5.Length)
                {
                    array5[(int)b5] = data.readByte(string.Concat(new object[]
                    {
                        "Response_",
                        b4,
                        "_Message_",
                        b5
                    }));
                    b5 += 1;
                }
                ushort newDialogue = data.readUInt16("Response_" + b4 + "_Dialogue");
                ushort newQuest    = data.readUInt16("Response_" + b4 + "_Quest");
                ushort newVendor   = data.readUInt16("Response_" + b4 + "_Vendor");
                string text2       = localization.format("Response_" + b4);
                text2 = ItemTool.filterRarityRichText(text2);
                INPCCondition[] array6 = new INPCCondition[(int)data.readByte("Response_" + b4 + "_Conditions")];
                NPCTool.readConditions(data, localization, "Response_" + b4 + "_Condition_", array6);
                INPCReward[] array7 = new INPCReward[(int)data.readByte("Response_" + b4 + "_Rewards")];
                NPCTool.readRewards(data, localization, "Response_" + b4 + "_Reward_", array7);
                this.responses[(int)b4] = new DialogueResponse(b4, array5, newDialogue, newQuest, newVendor, text2, array6, array7);
                b4 += 1;
            }
            bundle.unload();
        }
Esempio n. 2
0
        // Token: 0x06001A26 RID: 6694 RVA: 0x00092038 File Offset: 0x00090438
        public ItemAsset(Bundle bundle, Data data, Local localization, ushort id) : base(bundle, data, localization, id)
        {
            this.isPro = data.has("Pro");
            if (id < 2000 && !bundle.hasResource && !this.isPro && !data.has("Bypass_ID_Limit"))
            {
                throw new NotSupportedException("ID < 2000");
            }
            if (!this.isPro)
            {
                this._itemName        = localization.format("Name");
                this._itemDescription = localization.format("Description");
                this._itemDescription = ItemTool.filterRarityRichText(this.itemDescription);
            }
            this.type = (EItemType)Enum.Parse(typeof(EItemType), data.readString("Type"), true);
            if (data.has("Rarity"))
            {
                this.rarity = (EItemRarity)Enum.Parse(typeof(EItemRarity), data.readString("Rarity"), true);
            }
            else
            {
                this.rarity = EItemRarity.COMMON;
            }
            if (this.isPro)
            {
                if (this.type == EItemType.SHIRT)
                {
                    this._proPath = "/Shirts";
                }
                else if (this.type == EItemType.PANTS)
                {
                    this._proPath = "/Pants";
                }
                else if (this.type == EItemType.HAT)
                {
                    this._proPath = "/Hats";
                }
                else if (this.type == EItemType.BACKPACK)
                {
                    this._proPath = "/Backpacks";
                }
                else if (this.type == EItemType.VEST)
                {
                    this._proPath = "/Vests";
                }
                else if (this.type == EItemType.MASK)
                {
                    this._proPath = "/Masks";
                }
                else if (this.type == EItemType.GLASSES)
                {
                    this._proPath = "/Glasses";
                }
                else if (this.type == EItemType.KEY)
                {
                    this._proPath = "/Keys";
                }
                else if (this.type == EItemType.BOX)
                {
                    this._proPath = "/Boxes";
                }
                this._proPath = this._proPath + "/" + this.name;
            }
            this.size_x = data.readByte("Size_X");
            if (this.size_x < 1)
            {
                this.size_x = 1;
            }
            this.size_y = data.readByte("Size_Y");
            if (this.size_y < 1)
            {
                this.size_y = 1;
            }
            this.size_z  = data.readSingle("Size_Z");
            this.size2_z = data.readSingle("Size2_Z");
            this.amount  = data.readByte("Amount");
            if (this.amount < 1)
            {
                this.amount = 1;
            }
            this.countMin = data.readByte("Count_Min");
            if (this.countMin < 1)
            {
                this.countMin = 1;
            }
            this.countMax = data.readByte("Count_Max");
            if (this.countMax < 1)
            {
                this.countMax = 1;
            }
            if (data.has("Quality_Min"))
            {
                this.qualityMin = data.readByte("Quality_Min");
            }
            else
            {
                this.qualityMin = 10;
            }
            if (data.has("Quality_Max"))
            {
                this.qualityMax = data.readByte("Quality_Max");
            }
            else
            {
                this.qualityMax = 90;
            }
            this.isBackward = data.has("Backward");
            this.useable    = data.readString("Useable");
            this.isUseable  = !string.IsNullOrEmpty(this.useable);
            if (this.isUseable)
            {
                this._equip = (AudioClip)bundle.load("Equip");
                if (!this.isPro)
                {
                    GameObject gameObject = (GameObject)bundle.load("Animations");
                    if (gameObject != null)
                    {
                        Animation component = gameObject.GetComponent <Animation>();
                        this._animations = new AnimationClip[component.GetClipCount()];
                        int         num        = 0;
                        IEnumerator enumerator = component.GetEnumerator();
                        try
                        {
                            while (enumerator.MoveNext())
                            {
                                object         obj            = enumerator.Current;
                                AnimationState animationState = (AnimationState)obj;
                                this.animations[num] = animationState.clip;
                                num++;
                            }
                        }
                        finally
                        {
                            IDisposable disposable;
                            if ((disposable = (enumerator as IDisposable)) != null)
                            {
                                disposable.Dispose();
                            }
                        }
                    }
                    else
                    {
                        this._animations = new AnimationClip[0];
                    }
                }
            }
            string text = data.readString("Slot");

            if (text == null)
            {
                this.slot = ESlotType.NONE;
            }
            else
            {
                this.slot = (ESlotType)Enum.Parse(typeof(ESlotType), text, true);
            }
            if (!Dedicator.isDedicated || this.type == EItemType.GUN || this.type == EItemType.MELEE)
            {
                this._item = (GameObject)bundle.load("Item");
                if (this.item == null)
                {
                    throw new NotSupportedException("Missing item gameobject");
                }
                if (this.item.transform.FindChild("Icon") != null && this.item.transform.FindChild("Icon").GetComponent <Camera>() != null)
                {
                    Assets.errors.Add(this.itemName + " icon has a camera attached!");
                }
                if (id < 2000 && (this.type == EItemType.GUN || this.type == EItemType.MELEE) && this.item.transform.FindChild("Stat_Tracker") == null)
                {
                    Assets.errors.Add(this.itemName + " missing stat tracker hook!");
                }
            }
            byte b  = data.readByte("Blueprints");
            byte b2 = data.readByte("Actions");

            this._blueprints = new List <Blueprint>((int)b);
            this._actions    = new List <Action>((int)b2);
            for (byte b3 = 0; b3 < b; b3 += 1)
            {
                if (!data.has("Blueprint_" + b3 + "_Type"))
                {
                    throw new NotSupportedException("Missing blueprint type");
                }
                EBlueprintType newType = (EBlueprintType)Enum.Parse(typeof(EBlueprintType), data.readString("Blueprint_" + b3 + "_Type"), true);
                byte           b4      = data.readByte("Blueprint_" + b3 + "_Supplies");
                if (b4 < 1)
                {
                    b4 = 1;
                }
                BlueprintSupply[] array = new BlueprintSupply[(int)b4];
                byte b5 = 0;
                while ((int)b5 < array.Length)
                {
                    ushort newID = data.readUInt16(string.Concat(new object[]
                    {
                        "Blueprint_",
                        b3,
                        "_Supply_",
                        b5,
                        "_ID"
                    }));
                    bool newCritical = data.has(string.Concat(new object[]
                    {
                        "Blueprint_",
                        b3,
                        "_Supply_",
                        b5,
                        "_Critical"
                    }));
                    byte b6 = data.readByte(string.Concat(new object[]
                    {
                        "Blueprint_",
                        b3,
                        "_Supply_",
                        b5,
                        "_Amount"
                    }));
                    if (b6 < 1)
                    {
                        b6 = 1;
                    }
                    array[(int)b5] = new BlueprintSupply(newID, newCritical, b6);
                    b5            += 1;
                }
                byte b7 = data.readByte("Blueprint_" + b3 + "_Outputs");
                BlueprintOutput[] array2;
                if (b7 > 0)
                {
                    array2 = new BlueprintOutput[(int)b7];
                    byte b8 = 0;
                    while ((int)b8 < array2.Length)
                    {
                        ushort newID2 = data.readUInt16(string.Concat(new object[]
                        {
                            "Blueprint_",
                            b3,
                            "_Output_",
                            b8,
                            "_ID"
                        }));
                        byte b9 = data.readByte(string.Concat(new object[]
                        {
                            "Blueprint_",
                            b3,
                            "_Output_",
                            b8,
                            "_Amount"
                        }));
                        if (b9 < 1)
                        {
                            b9 = 1;
                        }
                        array2[(int)b8] = new BlueprintOutput(newID2, b9);
                        b8 += 1;
                    }
                }
                else
                {
                    array2 = new BlueprintOutput[1];
                    ushort num2 = data.readUInt16("Blueprint_" + b3 + "_Product");
                    if (num2 == 0)
                    {
                        num2 = id;
                    }
                    byte b10 = data.readByte("Blueprint_" + b3 + "_Products");
                    if (b10 < 1)
                    {
                        b10 = 1;
                    }
                    array2[0] = new BlueprintOutput(num2, b10);
                }
                ushort          newTool         = data.readUInt16("Blueprint_" + b3 + "_Tool");
                bool            newToolCritical = data.has("Blueprint_" + b3 + "_Tool_Critical");
                ushort          newBuild        = data.readUInt16("Blueprint_" + b3 + "_Build");
                byte            b11             = data.readByte("Blueprint_" + b3 + "_Level");
                EBlueprintSkill newSkill        = EBlueprintSkill.NONE;
                if (b11 > 0)
                {
                    newSkill = (EBlueprintSkill)Enum.Parse(typeof(EBlueprintSkill), data.readString("Blueprint_" + b3 + "_Skill"), true);
                }
                bool            newTransferState = data.has("Blueprint_" + b3 + "_State_Transfer");
                string          newMap           = data.readString("Blueprint_" + b3 + "_Map");
                INPCCondition[] array3           = new INPCCondition[(int)data.readByte("Blueprint_" + b3 + "_Conditions")];
                NPCTool.readConditions(data, localization, "Blueprint_" + b3 + "_Condition_", array3, string.Concat(new object[]
                {
                    "item ",
                    id,
                    " blueprint ",
                    b3
                }));
                INPCReward[] array4 = new INPCReward[(int)data.readByte("Blueprint_" + b3 + "_Rewards")];
                NPCTool.readRewards(data, localization, "Blueprint_" + b3 + "_Reward_", array4, string.Concat(new object[]
                {
                    "item ",
                    id,
                    " blueprint ",
                    b3
                }));
                this.blueprints.Add(new Blueprint(id, b3, newType, array, array2, newTool, newToolCritical, newBuild, b11, newSkill, newTransferState, newMap, array3, array4));
            }
            for (byte b12 = 0; b12 < b2; b12 += 1)
            {
                if (!data.has("Action_" + b12 + "_Type"))
                {
                    throw new NotSupportedException("Missing action type");
                }
                EActionType newType2 = (EActionType)Enum.Parse(typeof(EActionType), data.readString("Action_" + b12 + "_Type"), true);
                byte        b13      = data.readByte("Action_" + b12 + "_Blueprints");
                if (b13 < 1)
                {
                    b13 = 1;
                }
                ActionBlueprint[] array5 = new ActionBlueprint[(int)b13];
                byte b14 = 0;
                while ((int)b14 < array5.Length)
                {
                    byte newID3 = data.readByte(string.Concat(new object[]
                    {
                        "Action_",
                        b12,
                        "_Blueprint_",
                        b14,
                        "_Index"
                    }));
                    bool newLink = data.has(string.Concat(new object[]
                    {
                        "Action_",
                        b12,
                        "_Blueprint_",
                        b14,
                        "_Link"
                    }));
                    array5[(int)b14] = new ActionBlueprint(newID3, newLink);
                    b14 += 1;
                }
                string newText    = data.readString("Action_" + b12 + "_Text");
                string newTooltip = data.readString("Action_" + b12 + "_Tooltip");
                string newKey     = data.readString("Action_" + b12 + "_Key");
                ushort num3       = data.readUInt16("Action_" + b12 + "_Source");
                if (num3 == 0)
                {
                    num3 = id;
                }
                this.actions.Add(new Action(num3, newType2, array5, newText, newTooltip, newKey));
            }
            if (b2 == 0)
            {
                bool flag = false;
                byte b15  = 0;
                while ((int)b15 < this.blueprints.Count)
                {
                    Blueprint blueprint = this.blueprints[(int)b15];
                    if (blueprint.type == EBlueprintType.REPAIR)
                    {
                        Action item = new Action(id, EActionType.BLUEPRINT, new ActionBlueprint[]
                        {
                            new ActionBlueprint(b15, true)
                        }, null, null, "Repair");
                        this.actions.Insert(0, item);
                    }
                    else if (blueprint.type == EBlueprintType.AMMO)
                    {
                        flag = true;
                    }
                    else if (blueprint.supplies.Length == 1 && blueprint.supplies[0].id == id)
                    {
                        Action item2 = new Action(id, EActionType.BLUEPRINT, new ActionBlueprint[]
                        {
                            new ActionBlueprint(b15, this.type == EItemType.GUN || this.type == EItemType.MELEE)
                        }, null, null, "Salvage");
                        this.actions.Add(item2);
                    }
                    b15 += 1;
                }
                if (flag)
                {
                    List <ActionBlueprint> list = new List <ActionBlueprint>();
                    byte b16 = 0;
                    while ((int)b16 < this.blueprints.Count)
                    {
                        Blueprint blueprint2 = this.blueprints[(int)b16];
                        if (blueprint2.type == EBlueprintType.AMMO)
                        {
                            ActionBlueprint item3 = new ActionBlueprint(b16, true);
                            list.Add(item3);
                        }
                        b16 += 1;
                    }
                    Action item4 = new Action(id, EActionType.BLUEPRINT, list.ToArray(), null, null, "Refill");
                    this.actions.Add(item4);
                }
            }
            this._shouldVerifyHash   = !data.has("Bypass_Hash_Verification");
            this.overrideShowQuality = data.has("Override_Show_Quality");
            if (!Dedicator.isDedicated)
            {
                this._albedoBase   = (Texture2D)bundle.load("Albedo_Base");
                this._metallicBase = (Texture2D)bundle.load("Metallic_Base");
                this._emissionBase = (Texture2D)bundle.load("Emission_Base");
            }
        }
        // Token: 0x060038D8 RID: 14552 RVA: 0x001A088C File Offset: 0x0019EC8C
        private static void updateQuest(QuestAsset newQuest, DialogueResponse newResponse, DialogueAsset newAcceptDialogue, DialogueAsset newDeclineDialogue, EQuestViewMode newMode)
        {
            PlayerNPCQuestUI.quest           = newQuest;
            PlayerNPCQuestUI.response        = newResponse;
            PlayerNPCQuestUI.acceptDialogue  = newAcceptDialogue;
            PlayerNPCQuestUI.declineDialogue = newDeclineDialogue;
            PlayerNPCQuestUI.mode            = newMode;
            if (PlayerNPCQuestUI.quest == null)
            {
                return;
            }
            PlayerNPCQuestUI.beginContainer.isVisible   = (PlayerNPCQuestUI.mode == EQuestViewMode.BEGIN);
            PlayerNPCQuestUI.endContainer.isVisible     = (PlayerNPCQuestUI.mode == EQuestViewMode.END);
            PlayerNPCQuestUI.detailsContainer.isVisible = (PlayerNPCQuestUI.mode == EQuestViewMode.DETAILS);
            if (PlayerNPCQuestUI.mode == EQuestViewMode.DETAILS)
            {
                if (Player.player.quests.TrackedQuestID == PlayerNPCQuestUI.quest.id)
                {
                    PlayerNPCQuestUI.trackButton.text = PlayerNPCQuestUI.localization.format("Track_Off");
                }
                else
                {
                    PlayerNPCQuestUI.trackButton.text = PlayerNPCQuestUI.localization.format("Track_On");
                }
            }
            PlayerNPCQuestUI.nameLabel.text = PlayerNPCQuestUI.quest.questName;
            string text = PlayerNPCQuestUI.quest.questDescription;

            text = text.Replace("<br>", "\n");
            PlayerNPCQuestUI.descriptionLabel.text = text;
            int num  = Screen.height - 80;
            int num2 = 0;

            if (PlayerNPCQuestUI.quest.conditions != null && PlayerNPCQuestUI.quest.conditions.Length > 0)
            {
                PlayerNPCQuestUI.conditionsLabel.isVisible     = true;
                PlayerNPCQuestUI.conditionsContainer.isVisible = true;
                PlayerNPCQuestUI.conditionsContainer.remove();
                int num3 = 0;
                for (int i = 0; i < PlayerNPCQuestUI.quest.conditions.Length; i++)
                {
                    INPCCondition inpccondition = PlayerNPCQuestUI.quest.conditions[i];
                    bool          flag          = inpccondition.isConditionMet(Player.player);
                    Texture2D     icon          = null;
                    if (PlayerNPCQuestUI.mode != EQuestViewMode.BEGIN)
                    {
                        if (flag)
                        {
                            icon = (Texture2D)PlayerNPCQuestUI.icons.load("Complete");
                        }
                        else
                        {
                            icon = (Texture2D)PlayerNPCQuestUI.icons.load("Incomplete");
                        }
                    }
                    Sleek sleek = inpccondition.createUI(Player.player, icon);
                    if (sleek != null)
                    {
                        sleek.positionOffset_Y = num3;
                        PlayerNPCQuestUI.conditionsContainer.add(sleek);
                        num3 += sleek.sizeOffset_Y;
                    }
                }
                PlayerNPCQuestUI.conditionsContainer.sizeOffset_Y = num3;
                num2 += 30;
                num2 += num3;
            }
            else
            {
                PlayerNPCQuestUI.conditionsLabel.isVisible     = false;
                PlayerNPCQuestUI.conditionsContainer.isVisible = false;
            }
            if (PlayerNPCQuestUI.quest.rewards != null && PlayerNPCQuestUI.quest.rewards.Length > 0)
            {
                PlayerNPCQuestUI.rewardsLabel.isVisible     = true;
                PlayerNPCQuestUI.rewardsContainer.isVisible = true;
                PlayerNPCQuestUI.rewardsContainer.remove();
                int num4 = 0;
                for (int j = 0; j < PlayerNPCQuestUI.quest.rewards.Length; j++)
                {
                    INPCReward inpcreward = PlayerNPCQuestUI.quest.rewards[j];
                    Sleek      sleek2     = inpcreward.createUI(Player.player);
                    if (sleek2 != null)
                    {
                        sleek2.positionOffset_Y = num4;
                        PlayerNPCQuestUI.rewardsContainer.add(sleek2);
                        num4 += sleek2.sizeOffset_Y;
                    }
                }
                PlayerNPCQuestUI.rewardsLabel.positionOffset_Y     = num2;
                PlayerNPCQuestUI.rewardsContainer.positionOffset_Y = num2 + 30;
                PlayerNPCQuestUI.rewardsContainer.sizeOffset_Y     = num4;
                num2 += 30;
                num2 += num4;
            }
            else
            {
                PlayerNPCQuestUI.rewardsLabel.isVisible     = false;
                PlayerNPCQuestUI.rewardsContainer.isVisible = false;
            }
            PlayerNPCQuestUI.detailsBox.area = new Rect(0f, 0f, 5f, (float)num2);
            if (num2 + 105 > num)
            {
                PlayerNPCQuestUI.questBox.positionOffset_Y   = 0;
                PlayerNPCQuestUI.questBox.positionScale_Y    = 0f;
                PlayerNPCQuestUI.questBox.sizeOffset_Y       = num;
                PlayerNPCQuestUI.detailsBox.positionOffset_Y = -num + 100;
                PlayerNPCQuestUI.detailsBox.sizeOffset_Y     = num - 105;
                PlayerNPCQuestUI.detailsBox.sizeOffset_X     = -10;
            }
            else
            {
                PlayerNPCQuestUI.questBox.positionOffset_Y   = -num2 / 2 - 80;
                PlayerNPCQuestUI.questBox.positionScale_Y    = 0.5f;
                PlayerNPCQuestUI.questBox.sizeOffset_Y       = num2 + 100;
                PlayerNPCQuestUI.detailsBox.positionOffset_Y = -5 - num2;
                PlayerNPCQuestUI.detailsBox.sizeOffset_Y     = num2;
                PlayerNPCQuestUI.detailsBox.sizeOffset_X     = 20;
            }
        }