Exemplo n.º 1
0
 public ObjectAsset(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._objectName = localization.format("Name");
     this.type        = (EObjectType)Enum.Parse(typeof(EObjectType), data.readString("Type"), true);
     if (this.type == EObjectType.NPC)
     {
         if (Dedicator.isDedicated)
         {
             this._modelGameObject = (GameObject)Resources.Load("Characters/NPC_Server");
         }
         else
         {
             this._modelGameObject = (GameObject)Resources.Load("Characters/NPC_Client");
         }
         this.useScale        = true;
         this.interactability = EObjectInteractability.NPC;
     }
     else if (this.type == EObjectType.DECAL)
     {
         float num  = data.readSingle("Decal_X");
         float num2 = data.readSingle("Decal_Y");
         float num3 = 1f;
         if (data.has("Decal_LOD_Bias"))
         {
             num3 = data.readSingle("Decal_LOD_Bias");
         }
         Texture2D texture2D = (Texture2D)bundle.load("Decal");
         this._modelGameObject           = Object.Instantiate <GameObject>(Resources.Load <GameObject>("Materials/Decal_Template"));
         this._modelGameObject.hideFlags = 61;
         Object.DontDestroyOnLoad(this._modelGameObject);
         BoxCollider component = this.modelGameObject.GetComponent <BoxCollider>();
         component.size = new Vector3(num2, num, 1f);
         Decal    component2 = this.modelGameObject.transform.FindChild("Decal").GetComponent <Decal>();
         Material material   = Object.Instantiate <Material>(component2.material);
         material.name      = "Decal_Deferred";
         material.hideFlags = 52;
         material.SetTexture("_MainTex", texture2D);
         component2.material             = material;
         component2.lodBias              = num3;
         component2.transform.localScale = new Vector3(num, num2, 1f);
         MeshRenderer component3 = this.modelGameObject.transform.FindChild("Mesh").GetComponent <MeshRenderer>();
         Material     material2  = Object.Instantiate <Material>(component3.sharedMaterial);
         material2.name      = "Decal_Forward";
         material2.hideFlags = 52;
         material2.SetTexture("_MainTex", texture2D);
         component3.sharedMaterial       = material2;
         component3.transform.localScale = new Vector3(num2, num, 1f);
         this.useScale = true;
     }
     else
     {
         if (Dedicator.isDedicated)
         {
             this._modelGameObject = (GameObject)bundle.load("Clip");
             if (this.modelGameObject == null && this.type != EObjectType.SMALL)
             {
                 Debug.LogError(this.objectName + " is missing collision data. Highly recommended to fix.");
             }
         }
         else
         {
             this._modelGameObject = (GameObject)bundle.load("Object");
             if (this.modelGameObject == null)
             {
                 throw new NotSupportedException("Missing object gameobject");
             }
             this._skyboxGameObject = (GameObject)bundle.load("Skybox");
         }
         if (this.modelGameObject != null)
         {
             if (Mathf.Abs(this.modelGameObject.transform.localScale.x - 1f) > 0.01f || Mathf.Abs(this.modelGameObject.transform.localScale.y - 1f) > 0.01f || Mathf.Abs(this.modelGameObject.transform.localScale.z - 1f) > 0.01f)
             {
                 this.useScale = false;
                 Assets.errors.Add(this.objectName + " should have a scale of one.");
             }
             else
             {
                 this.useScale = true;
             }
             Transform transform = this.modelGameObject.transform.FindChild("Block");
             if (transform != null && transform.GetComponent <Collider>() != null && transform.GetComponent <Collider>().sharedMaterial == null)
             {
                 Assets.errors.Add(this.objectName + " has a clip object but no physics material.");
             }
             Transform transform2 = this.modelGameObject.transform.FindChild("Model_0");
             if (this.type == EObjectType.SMALL)
             {
                 if (!this.modelGameObject.CompareTag("Small"))
                 {
                     Assets.errors.Add(this.objectName + " is set up as small, but is not tagged as small.");
                 }
                 if (this.modelGameObject.layer != LayerMasks.SMALL)
                 {
                     Assets.errors.Add(this.objectName + " is set up as small, but is not layered as small.");
                 }
                 if (transform2 != null)
                 {
                     if (!transform2.CompareTag("Small"))
                     {
                         Assets.errors.Add(this.objectName + " is set up as small, but is not tagged as small.");
                     }
                     if (transform2.gameObject.layer != LayerMasks.SMALL)
                     {
                         Assets.errors.Add(this.objectName + " is set up as small, but is not layered as small.");
                     }
                 }
             }
             else if (this.type == EObjectType.MEDIUM)
             {
                 if (!this.modelGameObject.CompareTag("Medium"))
                 {
                     Assets.errors.Add(this.objectName + " is set up as medium, but is not tagged as medium.");
                 }
                 if (this.modelGameObject.layer != LayerMasks.MEDIUM)
                 {
                     Assets.errors.Add(this.objectName + " is set up as medium, but is not layered as medium.");
                 }
                 if (transform2 != null)
                 {
                     if (!transform2.CompareTag("Medium"))
                     {
                         Assets.errors.Add(this.objectName + " is set up as medium, but is not tagged as medium.");
                     }
                     if (transform2.gameObject.layer != LayerMasks.MEDIUM)
                     {
                         Assets.errors.Add(this.objectName + " is set up as medium, but is not layered as medium.");
                     }
                 }
             }
             else if (this.type == EObjectType.LARGE)
             {
                 if (!this.modelGameObject.CompareTag("Large"))
                 {
                     Assets.errors.Add(this.objectName + " is set up as large, but is not tagged as large.");
                 }
                 if (this.modelGameObject.layer != LayerMasks.LARGE)
                 {
                     Assets.errors.Add(this.objectName + " is set up as large, but is not layered as large.");
                 }
                 if (transform2 != null)
                 {
                     if (!transform2.CompareTag("Large"))
                     {
                         Assets.errors.Add(this.objectName + " is set up as large, but is not tagged as large.");
                     }
                     if (transform2.gameObject.layer != LayerMasks.LARGE)
                     {
                         Assets.errors.Add(this.objectName + " is set up as large, but is not layered as large.");
                     }
                 }
             }
         }
         this._navGameObject = (GameObject)bundle.load("Nav");
         if (this.navGameObject == null && this.type == EObjectType.LARGE)
         {
             Assets.errors.Add(this.objectName + " is missing navigation data. Highly recommended to fix.");
         }
         if (this.navGameObject != null)
         {
             if (!this.navGameObject.CompareTag("Navmesh"))
             {
                 Assets.errors.Add(this.objectName + " is set up as navmesh, but is not tagged as navmesh.");
             }
             if (this.navGameObject.layer != LayerMasks.NAVMESH)
             {
                 Assets.errors.Add(this.objectName + " is set up as navmesh, but is not layered as navmesh.");
             }
         }
         this._slotsGameObject    = (GameObject)bundle.load("Slots");
         this._triggersGameObject = (GameObject)bundle.load("Triggers");
         this.isSnowshoe          = data.has("Snowshoe");
         if (data.has("Chart"))
         {
             this.chart = (EObjectChart)Enum.Parse(typeof(EObjectChart), data.readString("Chart"), true);
         }
         else
         {
             this.chart = EObjectChart.NONE;
         }
         this.isFuel               = data.has("Fuel");
         this.isRefill             = data.has("Refill");
         this.isSoft               = data.has("Soft");
         this.isCollisionImportant = data.has("Collision_Important");
         if (this.isFuel || this.isRefill)
         {
             Assets.errors.Add(this.objectName + " is using the legacy fuel/water system.");
         }
         if (data.has("LOD"))
         {
             this.lod     = (EObjectLOD)Enum.Parse(typeof(EObjectLOD), data.readString("LOD"), true);
             this.lodBias = data.readSingle("LOD_Bias");
             if (this.lodBias < 0.01f)
             {
                 this.lodBias = 1f;
             }
             this.lodCenter = data.readVector3("LOD_Center");
             this.lodSize   = data.readVector3("LOD_Size");
         }
         if (data.has("Interactability"))
         {
             this.interactability       = (EObjectInteractability)Enum.Parse(typeof(EObjectInteractability), data.readString("Interactability"), true);
             this.interactabilityRemote = data.has("Interactability_Remote");
             this.interactabilityDelay  = data.readSingle("Interactability_Delay");
             this.interactabilityReset  = data.readSingle("Interactability_Reset");
             if (data.has("Interactability_Hint"))
             {
                 this.interactabilityHint = (EObjectInteractabilityHint)Enum.Parse(typeof(EObjectInteractabilityHint), data.readString("Interactability_Hint"), true);
             }
             this.interactabilityEmission = data.has("Interactability_Emission");
             if (this.interactability == EObjectInteractability.NOTE)
             {
                 ushort        num4          = data.readUInt16("Interactability_Text_Lines");
                 StringBuilder stringBuilder = new StringBuilder();
                 for (ushort num5 = 0; num5 < num4; num5 += 1)
                 {
                     string value = localization.format("Interactability_Text_Line_" + num5);
                     stringBuilder.AppendLine(value);
                 }
                 this.interactabilityText = stringBuilder.ToString();
             }
             else
             {
                 this.interactabilityText = localization.read("Interact");
             }
             if (data.has("Interactability_Power"))
             {
                 this.interactabilityPower = (EObjectInteractabilityPower)Enum.Parse(typeof(EObjectInteractabilityPower), data.readString("Interactability_Power"), true);
             }
             else
             {
                 this.interactabilityPower = EObjectInteractabilityPower.NONE;
             }
             if (data.has("Interactability_Editor"))
             {
                 this.interactabilityEditor = (EObjectInteractabilityEditor)Enum.Parse(typeof(EObjectInteractabilityEditor), data.readString("Interactability_Editor"), true);
             }
             else
             {
                 this.interactabilityEditor = EObjectInteractabilityEditor.NONE;
             }
             if (data.has("Interactability_Nav"))
             {
                 this.interactabilityNav = (EObjectInteractabilityNav)Enum.Parse(typeof(EObjectInteractabilityNav), data.readString("Interactability_Nav"), true);
             }
             else
             {
                 this.interactabilityNav = EObjectInteractabilityNav.NONE;
             }
             this.interactabilityDrops = new ushort[(int)data.readByte("Interactability_Drops")];
             byte b = 0;
             while ((int)b < this.interactabilityDrops.Length)
             {
                 this.interactabilityDrops[(int)b] = data.readUInt16("Interactability_Drop_" + b);
                 b += 1;
             }
             this.interactabilityRewardID   = data.readUInt16("Interactability_Reward_ID");
             this.interactabilityEffect     = data.readUInt16("Interactability_Effect");
             this.interactabilityConditions = new INPCCondition[(int)data.readByte("Interactability_Conditions")];
             NPCTool.readConditions(data, localization, "Interactability_Condition_", this.interactabilityConditions);
             this.interactabilityRewards = new INPCReward[(int)data.readByte("Interactability_Rewards")];
             NPCTool.readRewards(data, localization, "Interactability_Reward_", this.interactabilityRewards);
             this.interactabilityResource      = data.readUInt16("Interactability_Resource");
             this.interactabilityResourceState = BitConverter.GetBytes(this.interactabilityResource);
         }
         else
         {
             this.interactability       = EObjectInteractability.NONE;
             this.interactabilityPower  = EObjectInteractabilityPower.NONE;
             this.interactabilityEditor = EObjectInteractabilityEditor.NONE;
         }
         if (this.interactability == EObjectInteractability.RUBBLE)
         {
             this.rubble               = EObjectRubble.DESTROY;
             this.rubbleReset          = data.readSingle("Interactability_Reset");
             this.rubbleHealth         = data.readUInt16("Interactability_Health");
             this.rubbleEffect         = data.readUInt16("Interactability_Effect");
             this.rubbleFinale         = data.readUInt16("Interactability_Finale");
             this.rubbleRewardID       = data.readUInt16("Interactability_Reward_ID");
             this.rubbleRewardXP       = data.readUInt32("Interactability_Reward_XP");
             this.rubbleIsVulnerable   = !data.has("Interactability_Invulnerable");
             this.rubbleProofExplosion = data.has("Interactability_Proof_Explosion");
         }
         else if (data.has("Rubble"))
         {
             this.rubble               = (EObjectRubble)Enum.Parse(typeof(EObjectRubble), data.readString("Rubble"), true);
             this.rubbleReset          = data.readSingle("Rubble_Reset");
             this.rubbleHealth         = data.readUInt16("Rubble_Health");
             this.rubbleEffect         = data.readUInt16("Rubble_Effect");
             this.rubbleFinale         = data.readUInt16("Rubble_Finale");
             this.rubbleRewardID       = data.readUInt16("Rubble_Reward_ID");
             this.rubbleRewardXP       = data.readUInt32("Rubble_Reward_XP");
             this.rubbleIsVulnerable   = !data.has("Rubble_Invulnerable");
             this.rubbleProofExplosion = data.has("Rubble_Proof_Explosion");
             if (data.has("Rubble_Editor"))
             {
                 this.rubbleEditor = (EObjectRubbleEditor)Enum.Parse(typeof(EObjectRubbleEditor), data.readString("Rubble_Editor"), true);
             }
             else
             {
                 this.rubbleEditor = EObjectRubbleEditor.ALIVE;
             }
         }
         if (data.has("Foliage"))
         {
             this.foliage = new AssetReference <FoliageInfoCollectionAsset>(new Guid(data.readString("Foliage")));
         }
         this.useWaterHeightTransparentSort = data.has("Use_Water_Height_Transparent_Sort");
         if (data.has("Material_Palette"))
         {
             this.materialPalette = new AssetReference <MaterialPaletteAsset>(data.readGUID("Material_Palette"));
         }
         if (data.has("Landmark_Quality"))
         {
             this.landmarkQuality = (EGraphicQuality)Enum.Parse(typeof(EGraphicQuality), data.readString("Landmark_Quality"), true);
         }
         else
         {
             this.landmarkQuality = EGraphicQuality.LOW;
         }
     }
     this.conditions = new INPCCondition[(int)data.readByte("Conditions")];
     NPCTool.readConditions(data, localization, "Condition_", this.conditions);
     bundle.unload();
 }
Exemplo n.º 2
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.º 3
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;
                }
            }
        }
Exemplo n.º 4
0
        // Token: 0x06003447 RID: 13383 RVA: 0x00154C10 File Offset: 0x00153010
        public static void readConditions(Data data, Local localization, string prefix, INPCCondition[] conditions, string errorMessageSource)
        {
            for (int i = 0; i < conditions.Length; i++)
            {
                if (!data.has(prefix + i + "_Type"))
                {
                    Assets.errors.Add(string.Concat(new object[]
                    {
                        "Missing condition ",
                        prefix,
                        i,
                        " type"
                    }));
                    throw new NotSupportedException(string.Concat(new object[]
                    {
                        "Missing condition ",
                        prefix,
                        i,
                        " type"
                    }));
                }
                ENPCConditionType enpcconditionType = (ENPCConditionType)Enum.Parse(typeof(ENPCConditionType), data.readString(prefix + i + "_Type"), true);
                string            text = localization.read(prefix + i);
                text = ItemTool.filterRarityRichText(text);
                bool          newShouldReset = data.has(prefix + i + "_Reset");
                ENPCLogicType newLogicType   = ENPCLogicType.NONE;
                if (data.has(prefix + i + "_Logic"))
                {
                    newLogicType = (ENPCLogicType)Enum.Parse(typeof(ENPCLogicType), data.readString(prefix + i + "_Logic"), true);
                }
                switch (enpcconditionType)
                {
                case ENPCConditionType.EXPERIENCE:
                    if (!data.has(prefix + i + "_Value"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Experience condition ",
                            prefix,
                            i,
                            " missing _Value in: ",
                            errorMessageSource
                        }));
                    }
                    conditions[i] = new NPCExperienceCondition(data.readUInt32(prefix + i + "_Value"), newLogicType, text, newShouldReset);
                    break;

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

                case ENPCConditionType.FLAG_BOOL:
                    if (!data.has(prefix + i + "_ID"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Bool flag condition ",
                            prefix,
                            i,
                            " missing _ID in: ",
                            errorMessageSource
                        }));
                    }
                    if (!data.has(prefix + i + "_Value"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Bool flag condition ",
                            prefix,
                            i,
                            " missing _Value in: ",
                            errorMessageSource
                        }));
                    }
                    conditions[i] = new NPCBoolFlagCondition(data.readUInt16(prefix + i + "_ID"), data.readBoolean(prefix + i + "_Value"), data.has(prefix + i + "_Allow_Unset"), newLogicType, text, newShouldReset);
                    break;

                case ENPCConditionType.FLAG_SHORT:
                    if (!data.has(prefix + i + "_ID"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Short flag condition ",
                            prefix,
                            i,
                            " missing _ID in: ",
                            errorMessageSource
                        }));
                    }
                    if (!data.has(prefix + i + "_Value"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Short flag condition ",
                            prefix,
                            i,
                            " missing _Value in: ",
                            errorMessageSource
                        }));
                    }
                    conditions[i] = new NPCShortFlagCondition(data.readUInt16(prefix + i + "_ID"), data.readInt16(prefix + i + "_Value"), data.has(prefix + i + "_Allow_Unset"), newLogicType, text, newShouldReset);
                    break;

                case ENPCConditionType.QUEST:
                    if (!data.has(prefix + i + "_ID"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Quest condition ",
                            prefix,
                            i,
                            " missing _ID in: ",
                            errorMessageSource
                        }));
                    }
                    if (!data.has(prefix + i + "_Status"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Quest condition ",
                            prefix,
                            i,
                            " missing _Status in: ",
                            errorMessageSource
                        }));
                    }
                    conditions[i] = new NPCQuestCondition(data.readUInt16(prefix + i + "_ID"), (ENPCQuestStatus)Enum.Parse(typeof(ENPCQuestStatus), data.readString(prefix + i + "_Status"), true), data.has(prefix + i + "_Ignore_NPC"), newLogicType, text, newShouldReset);
                    break;

                case ENPCConditionType.SKILLSET:
                    if (!data.has(prefix + i + "_Value"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Skillset condition ",
                            prefix,
                            i,
                            " missing _Value in: ",
                            errorMessageSource
                        }));
                    }
                    conditions[i] = new NPCSkillsetCondition((EPlayerSkillset)Enum.Parse(typeof(EPlayerSkillset), data.readString(prefix + i + "_Value"), true), newLogicType, text);
                    break;

                case ENPCConditionType.ITEM:
                    if (!data.has(prefix + i + "_ID"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Item condition ",
                            prefix,
                            i,
                            " missing _ID in: ",
                            errorMessageSource
                        }));
                    }
                    if (!data.has(prefix + i + "_Amount"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Item condition ",
                            prefix,
                            i,
                            " missing _Amount in: ",
                            errorMessageSource
                        }));
                    }
                    conditions[i] = new NPCItemCondition(data.readUInt16(prefix + i + "_ID"), data.readUInt16(prefix + i + "_Amount"), text, newShouldReset);
                    break;

                case ENPCConditionType.KILLS_ZOMBIE:
                {
                    if (!data.has(prefix + i + "_ID"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                            {
                                "Zombie kills condition ",
                                prefix,
                                i,
                                " missing _ID in: ",
                                errorMessageSource
                            }));
                    }
                    if (!data.has(prefix + i + "_Value"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                            {
                                "Zombie kills condition ",
                                prefix,
                                i,
                                " missing _Value in: ",
                                errorMessageSource
                            }));
                    }
                    EZombieSpeciality newZombie = EZombieSpeciality.NONE;
                    if (data.has(prefix + i + "_Zombie"))
                    {
                        newZombie = (EZombieSpeciality)Enum.Parse(typeof(EZombieSpeciality), data.readString(prefix + i + "_Zombie"), true);
                    }
                    else
                    {
                        Assets.errors.Add(string.Concat(new object[]
                            {
                                "Zombie kills condition ",
                                prefix,
                                i,
                                " missing _Zombie in: ",
                                errorMessageSource
                            }));
                    }
                    conditions[i] = new NPCZombieKillsCondition(data.readUInt16(prefix + i + "_ID"), data.readInt16(prefix + i + "_Value"), newZombie, data.has(prefix + i + "_Spawn"), data.readByte(prefix + i + "_Nav"), text, newShouldReset);
                    break;
                }

                case ENPCConditionType.KILLS_HORDE:
                    if (!data.has(prefix + i + "_ID"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Horde kills condition ",
                            prefix,
                            i,
                            " missing _ID in: ",
                            errorMessageSource
                        }));
                    }
                    if (!data.has(prefix + i + "_Value"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Horde kills condition ",
                            prefix,
                            i,
                            " missing _Value in: ",
                            errorMessageSource
                        }));
                    }
                    if (!data.has(prefix + i + "_Nav"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Horde kills condition ",
                            prefix,
                            i,
                            " missing _Nav in: ",
                            errorMessageSource
                        }));
                    }
                    conditions[i] = new NPCHordeKillsCondition(data.readUInt16(prefix + i + "_ID"), data.readInt16(prefix + i + "_Value"), data.readByte(prefix + i + "_Nav"), text, newShouldReset);
                    break;

                case ENPCConditionType.KILLS_ANIMAL:
                    if (!data.has(prefix + i + "_ID"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Animal kills condition ",
                            prefix,
                            i,
                            " missing _ID in: ",
                            errorMessageSource
                        }));
                    }
                    if (!data.has(prefix + i + "_Value"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Animal kills condition ",
                            prefix,
                            i,
                            " missing _Value in: ",
                            errorMessageSource
                        }));
                    }
                    if (!data.has(prefix + i + "_Animal"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Animal kills condition ",
                            prefix,
                            i,
                            " missing _Animal in: ",
                            errorMessageSource
                        }));
                    }
                    conditions[i] = new NPCAnimalKillsCondition(data.readUInt16(prefix + i + "_ID"), data.readInt16(prefix + i + "_Value"), data.readUInt16(prefix + i + "_Animal"), text, newShouldReset);
                    break;

                case ENPCConditionType.COMPARE_FLAGS:
                    if (!data.has(prefix + i + "_A_ID"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Compare flags condition ",
                            prefix,
                            i,
                            " missing _A_ID in: ",
                            errorMessageSource
                        }));
                    }
                    if (!data.has(prefix + i + "_B_ID"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Compare flags condition ",
                            prefix,
                            i,
                            " missing _B_ID in: ",
                            errorMessageSource
                        }));
                    }
                    conditions[i] = new NPCCompareFlagsCondition(data.readUInt16(prefix + i + "_A_ID"), data.readUInt16(prefix + i + "_B_ID"), data.has(prefix + i + "_Allow_A_Unset"), data.has(prefix + i + "_Allow_B_Unset"), newLogicType, text, newShouldReset);
                    break;

                case ENPCConditionType.TIME_OF_DAY:
                    if (!data.has(prefix + i + "_Second"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Time of day condition ",
                            prefix,
                            i,
                            " missing _Second in: ",
                            errorMessageSource
                        }));
                    }
                    conditions[i] = new NPCTimeOfDayCondition(data.readInt32(prefix + i + "_Second"), newLogicType, text, newShouldReset);
                    break;

                case ENPCConditionType.PLAYER_LIFE_HEALTH:
                    if (!data.has(prefix + i + "_Value"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Player life health condition ",
                            prefix,
                            i,
                            " missing _Value in: ",
                            errorMessageSource
                        }));
                    }
                    conditions[i] = new NPCPlayerLifeHealthCondition(data.readInt32(prefix + i + "_Value"), newLogicType, text);
                    break;

                case ENPCConditionType.PLAYER_LIFE_FOOD:
                    if (!data.has(prefix + i + "_Value"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Player life food condition ",
                            prefix,
                            i,
                            " missing _Value in: ",
                            errorMessageSource
                        }));
                    }
                    conditions[i] = new NPCPlayerLifeFoodCondition(data.readInt32(prefix + i + "_Value"), newLogicType, text);
                    break;

                case ENPCConditionType.PLAYER_LIFE_WATER:
                    if (!data.has(prefix + i + "_Value"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Player life water condition ",
                            prefix,
                            i,
                            " missing _Value in: ",
                            errorMessageSource
                        }));
                    }
                    conditions[i] = new NPCPlayerLifeWaterCondition(data.readInt32(prefix + i + "_Value"), newLogicType, text);
                    break;

                case ENPCConditionType.PLAYER_LIFE_VIRUS:
                    if (!data.has(prefix + i + "_Value"))
                    {
                        Assets.errors.Add(string.Concat(new object[]
                        {
                            "Player life virus condition ",
                            prefix,
                            i,
                            " missing _Value in: ",
                            errorMessageSource
                        }));
                    }
                    conditions[i] = new NPCPlayerLifeVirusCondition(data.readInt32(prefix + i + "_Value"), newLogicType, text);
                    break;
                }
            }
        }
Exemplo n.º 5
0
        public static void readConditions(Data data, Local localization, string prefix, INPCCondition[] conditions)
        {
            for (int i = 0; i < conditions.Length; i++)
            {
                if (!data.has(prefix + i + "_Type"))
                {
                    throw new NotSupportedException("Missing condition type");
                }
                ENPCConditionType enpcconditionType = (ENPCConditionType)Enum.Parse(typeof(ENPCConditionType), data.readString(prefix + i + "_Type"), true);
                string            text = localization.read(prefix + i);
                text = ItemTool.filterRarityRichText(text);
                bool          newShouldReset = data.has(prefix + i + "_Reset");
                ENPCLogicType newLogicType   = ENPCLogicType.NONE;
                if (data.has(prefix + i + "_Logic"))
                {
                    newLogicType = (ENPCLogicType)Enum.Parse(typeof(ENPCLogicType), data.readString(prefix + i + "_Logic"), true);
                }
                switch (enpcconditionType)
                {
                case ENPCConditionType.EXPERIENCE:
                    conditions[i] = new NPCExperienceCondition(data.readUInt32(prefix + i + "_Value"), newLogicType, text, newShouldReset);
                    break;

                case ENPCConditionType.REPUTATION:
                    conditions[i] = new NPCReputationCondition(data.readInt32(prefix + i + "_Value"), newLogicType, text);
                    break;

                case ENPCConditionType.FLAG_BOOL:
                    conditions[i] = new NPCBoolFlagCondition(data.readUInt16(prefix + i + "_ID"), data.readBoolean(prefix + i + "_Value"), data.has(prefix + i + "_Allow_Unset"), newLogicType, text, newShouldReset);
                    break;

                case ENPCConditionType.FLAG_SHORT:
                    conditions[i] = new NPCShortFlagCondition(data.readUInt16(prefix + i + "_ID"), data.readInt16(prefix + i + "_Value"), data.has(prefix + i + "_Allow_Unset"), newLogicType, text, newShouldReset);
                    break;

                case ENPCConditionType.QUEST:
                    conditions[i] = new NPCQuestCondition(data.readUInt16(prefix + i + "_ID"), (ENPCQuestStatus)Enum.Parse(typeof(ENPCQuestStatus), data.readString(prefix + i + "_Status"), true), data.has(prefix + i + "_Ignore_NPC"), newLogicType, text, newShouldReset);
                    break;

                case ENPCConditionType.SKILLSET:
                    conditions[i] = new NPCSkillsetCondition((EPlayerSkillset)Enum.Parse(typeof(EPlayerSkillset), data.readString(prefix + i + "_Value"), true), newLogicType, text);
                    break;

                case ENPCConditionType.ITEM:
                    conditions[i] = new NPCItemCondition(data.readUInt16(prefix + i + "_ID"), data.readUInt16(prefix + i + "_Amount"), text, newShouldReset);
                    break;

                case ENPCConditionType.KILLS_ZOMBIE:
                {
                    EZombieSpeciality newZombie = EZombieSpeciality.NONE;
                    if (data.has(prefix + i + "_Zombie"))
                    {
                        newZombie = (EZombieSpeciality)Enum.Parse(typeof(EZombieSpeciality), data.readString(prefix + i + "_Zombie"), true);
                    }
                    conditions[i] = new NPCZombieKillsCondition(data.readUInt16(prefix + i + "_ID"), data.readInt16(prefix + i + "_Value"), newZombie, data.has(prefix + i + "_Spawn"), data.readByte(prefix + i + "_Nav"), text, newShouldReset);
                    break;
                }

                case ENPCConditionType.KILLS_HORDE:
                    conditions[i] = new NPCHordeKillsCondition(data.readUInt16(prefix + i + "_ID"), data.readInt16(prefix + i + "_Value"), data.readByte(prefix + i + "_Nav"), text, newShouldReset);
                    break;
                }
            }
        }