Ejemplo n.º 1
0
        public override void Init(JObject node)
        {
            base.Init(node);
            structType = ArkName.From(node.Value <string>("structType"));

            Value = node["unknown"] != null && node["unknown"].Type != JTokenType.Null ? new StructUnknown(node["unknown"]) : StructRegistry.ReadJson(node["value"], structType);
        }
        private void readJson(JToken node, ReadingOptions options)
        {
            X        = node.Value <float>("x");
            Y        = node.Value <float>("y");
            Z        = node.Value <float>("z");
            UnkByte  = node.Value <byte>("unkByte");
            UnkFloat = node.Value <float>("unkFloat");

            ZoneVolumes.Clear();
            JArray zones = node.Value <JArray>("zones");

            if (zones != null && zones.Type != JTokenType.Null)
            {
                foreach (JToken zone in zones)
                {
                    ZoneVolumes.Add(ArkName.From(zone.Value <string>()));
                }
            }

            Objects.Clear();
            ObjectMap.Clear();
            JArray objectsNode = node.Value <JArray>("objects");

            if (objectsNode != null && objectsNode.Type != JTokenType.Null)
            {
                foreach (var jsonNode in objectsNode)
                {
                    addObject(new GameObject((JObject)jsonNode, options.HibernationObjectProperties), options.BuildComponentTree);
                }
            }

            UnkInt1    = node.Value <int>("unkInt1");
            ClassIndex = node.Value <int>("classIndex");
        }
Ejemplo n.º 3
0
        public static IProperty ReadJson(JObject node)
        {
            ArkName name = ArkName.From(node.Value <string>("type"));

            return(name != null && typeMap.TryGetValue(name, out PropertyConstructor constructor)
                    ? constructor.JsonConstructor(node)
                    : new PropertyUnknown(node));
        }
 public PropertyUnknown(JObject node) : base(null, 0, null)
 {
     base.Init(node);
     Type = ArkName.From(node.Value <string>("type"));
     try {
         Value = node["value"]?.ToObject <byte[]>();
     } catch (FormatException ex) {
         throw new UnreadablePropertyException(ex);
     }
 }
Ejemplo n.º 5
0
        public override void Init(JObject node)
        {
            base.Init(node);
            ArkName arrayType = ArkName.From(node.Value <string>("arrayType"));

            try {
                node["value"].ToObject <byte[]>();
                Value = new ArkArrayUnknown(node["value"], arrayType);
            } catch (Exception ex) when(ex is FormatException || ex is OverflowException || ex is JsonReaderException)
            {
                Value = ArkArrayRegistry.ReadJson(node.Value <JArray>("value"), arrayType, this);
            }
        }
Ejemplo n.º 6
0
 public override void Init(JObject node)
 {
     base.Init(node);
     EnumType = ArkName.From(node.Value <string>("enum") ?? ArkName.NameNone.ToString());
     Value    = new ArkByteValue(node.Value <byte>("value"));
 }
Ejemplo n.º 7
0
 public PropertyInt8(string name, int index, sbyte value) : base(ArkName.From(name), index, value)
 {
 }
Ejemplo n.º 8
0
 public PropertyString(string name, string value) : base(ArkName.From(name), 0, value)
 {
 }
Ejemplo n.º 9
0
 public PropertyFloat(string name, int index, float value) : base(ArkName.From(name), index, value)
 {
 }
Ejemplo n.º 10
0
        /**
         * From JSON / ModificationFile
         */
        public Item(JToken node)
        {
            className = ArkName.From(node.Value <string>("className"));
            ItemData itemData = ArkDataManager.GetItem(className.ToString());

            type = itemData != null ? itemData.Name : className.ToString();
            blueprintGeneratedClass = "BlueprintGeneratedClass " + node.Value <string>("blueprintGeneratedClass");

            canEquip             = node.Value <bool?>("canEquip") ?? true;
            canSlot              = node.Value <bool?>("canSlot") ?? true;
            isEngram             = node.Value <bool>("isEngram");
            isBlueprint          = node.Value <bool>("isBlueprint");
            canRemove            = node.Value <bool?>("canRemove") ?? true;
            canRemoveFromCluster = node.Value <bool?>("canRemoveFromCluster") ?? true;
            isHidden             = node.Value <bool>("isHidden");

            quantity = Math.Max(1, node.Value <int?>("quantity") ?? 1);

            customName = node.Value <string>("customName");

            customDescription = node.Value <string>("customDescription");

            durability = node.Value <float>("durability");
            rating     = node.Value <float>("rating");

            quality = node.Value <byte>("quality");

            nextSpoilingTime = node.Value <double>("nextSpoilingTime");
            lastSpoilingTime = node.Value <double>("lastSpoilingTime");

            for (int i = 0; i < itemStatValues.Length; i++)
            {
                itemStatValues[i] = node.Value <short>("itemStatsValue_" + i);
            }

            for (int i = 0; i < itemColors.Length; i++)
            {
                itemColors[i] = node.Value <short>("itemColor_" + i);
            }

            for (int i = 0; i < preSkinItemColors.Length; i++)
            {
                preSkinItemColors[i] = node.Value <short>("preSkinItemColor_" + i);
            }

            for (int i = 0; i < eggLevelups.Length; i++)
            {
                eggLevelups[i] = node.Value <byte>("eggLevelup_" + i);
            }

            for (int i = 0; i < eggColors.Length; i++)
            {
                eggColors[i] = node.Value <byte>("eggColor_" + i);
            }

            crafterCharacterName = node.Value <string>("crafterCharacterName");
            crafterTribeName     = node.Value <string>("crafterTribeName");
            craftedSkillBonus    = node.Value <float>("craftedSkillBonus");

            uploadOffset = node.Value <int>("uploadOffset");
        }
Ejemplo n.º 11
0
        /**
         * From cluster storage
         */
        public Item(IPropertyContainer item)
        {
            blueprintGeneratedClass = item.GetPropertyValue <ObjectReference>("ItemArchetype").ObjectString.ToString();
            className = ArkName.From(blueprintGeneratedClass.Substring(blueprintGeneratedClass.LastIndexOf('.') + 1));
            ItemData itemData = ArkDataManager.GetItem(className.ToString());

            type = itemData != null ? itemData.Name : className.ToString();

            canEquip             = true;
            canSlot              = item.GetPropertyValue <bool>("bIsSlot", defaultValue: true);
            isEngram             = item.GetPropertyValue <bool>("bIsEngram");
            isBlueprint          = item.GetPropertyValue <bool>("bIsBlueprint");
            canRemove            = item.GetPropertyValue <bool>("bAllowRemovalFromInventory", defaultValue: true);
            canRemoveFromCluster = item.GetPropertyValue <bool>("bAllowRemovalFromSteamInventory", defaultValue: true);
            isHidden             = item.GetPropertyValue <bool>("bHideFromInventoryDisplay");

            //quantity = Math.Max(1, item.findPropertyValue<Number>("ItemQuantity").map(Number::intValue).orElse(1));
            quantity = Math.Max(1, item.GetPropertyValue <int>("ItemQuantity", defaultValue: 1));

            customName = item.GetPropertyValue <string>("CustomItemName", defaultValue: string.Empty);

            customDescription = item.GetPropertyValue <string>("CustomItemDescription", defaultValue: string.Empty);

            durability = item.GetPropertyValue <float>("ItemDurability");

            rating = item.GetPropertyValue <float>("ItemRating");

            quality = item.GetPropertyValue <ArkByteValue>("ItemQualityIndex")?.ByteValue ?? 0;

            nextSpoilingTime = item.GetPropertyValue <double>("NextSpoilingTime");
            lastSpoilingTime = item.GetPropertyValue <double>("LastSpoilingTime");

            for (int i = 0; i < itemStatValues.Length; i++)
            {
                itemStatValues[i] = item.GetPropertyValue <short>("ItemStatValues", i);
            }

            for (int i = 0; i < itemColors.Length; i++)
            {
                itemColors[i] = item.GetPropertyValue <short>("ItemColorID", i);
            }

            for (int i = 0; i < preSkinItemColors.Length; i++)
            {
                preSkinItemColors[i] = item.GetPropertyValue <short>("PreSkinItemColorID", i);
            }

            for (int i = 0; i < eggLevelups.Length; i++)
            {
                eggLevelups[i] = item.GetPropertyValue <ArkByteValue>("EggNumberOfLevelUpPointsApplied", i)?.ByteValue ?? 0;
            }

            for (int i = 0; i < eggColors.Length; i++)
            {
                eggColors[i] = item.GetPropertyValue <ArkByteValue>("EggColorSetIndices", i)?.ByteValue ?? 0;
            }

            crafterCharacterName = item.GetPropertyValue <string>("CrafterCharacterName", defaultValue: string.Empty);
            crafterTribeName     = item.GetPropertyValue <string>("CrafterTribeName", defaultValue: string.Empty);
            craftedSkillBonus    = item.GetPropertyValue <float>("CraftedSkillBonus");
        }
Ejemplo n.º 12
0
 public override void Init(JArray node, PropertyArray property)
 {
     AddRange(node.Select(n => new ArkByteValue(ArkName.From(n.Value <string>()))));
 }
Ejemplo n.º 13
0
 public PropertyBool(string name, int index, bool value) : base(ArkName.From(name), index, value)
 {
 }
Ejemplo n.º 14
0
 public PropertyBool(string name, bool value) : base(ArkName.From(name), 0, value)
 {
 }
Ejemplo n.º 15
0
 public PropertyStruct(string name, int index, IStruct value, ArkName structType) : base(ArkName.From(name), index, value)
 {
     this.structType = structType;
 }
Ejemplo n.º 16
0
 public PropertyObject(string name, int index, ObjectReference value) : base(ArkName.From(name), index, value)
 {
 }
Ejemplo n.º 17
0
 public PropertyFloat(string name, float value) : base(ArkName.From(name), 0, value)
 {
 }
Ejemplo n.º 18
0
        public StructPropertyList toClusterData()
        {
            if (blueprintGeneratedClass == "BlueprintGeneratedClass ")
            {
                Console.Error.WriteLine("Item " + className + " is missing blueprintGeneratedClass.");
                return(null);
            }

            StructPropertyList result         = new StructPropertyList();
            StructPropertyList arkTributeItem = new StructPropertyList();

            result.Properties.Add(new PropertyStruct("ArkTributeItem", arkTributeItem, ArkName.From("ItemNetInfo")));

            ObjectReference itemArchetype = new ObjectReference();

            itemArchetype.ObjectType   = ObjectReference.TypePath;
            itemArchetype.ObjectString = ArkName.From(blueprintGeneratedClass);
            arkTributeItem.Properties.Add(new PropertyObject("ItemArchetype", itemArchetype));

            Random random   = new Random();
            long   randomId = random.NextLong();

            StructPropertyList structProperty = new StructPropertyList();

            structProperty.Properties.Add(new PropertyUInt32("ItemID1", (int)(randomId >> 32)));
            structProperty.Properties.Add(new PropertyUInt32("ItemID2", (int)randomId));

            arkTributeItem.Properties.Add(new PropertyStruct("ItemId", structProperty, ArkName.From("ItemNetID")));

            arkTributeItem.Properties.Add(new PropertyBool("bIsBlueprint", isBlueprint));
            arkTributeItem.Properties.Add(new PropertyBool("bIsEngram", isEngram));
            arkTributeItem.Properties.Add(new PropertyBool("bIsCustomRecipe", false));
            arkTributeItem.Properties.Add(new PropertyBool("bIsFoodRecipe", false));
            arkTributeItem.Properties.Add(new PropertyBool("bIsRepairing", false));
            arkTributeItem.Properties.Add(new PropertyBool("bAllowRemovalFromInventory", canRemove));
            arkTributeItem.Properties.Add(new PropertyBool("bAllowRemovalFromSteamInventory", canRemoveFromCluster));
            arkTributeItem.Properties.Add(new PropertyBool("bHideFromInventoryDisplay", isHidden));
            arkTributeItem.Properties.Add(new PropertyBool("bFromSteamInventory", false));
            arkTributeItem.Properties.Add(new PropertyBool("bIsFromAllClustersInventory", false));
            arkTributeItem.Properties.Add(new PropertyBool("bIsEquipped", false));
            arkTributeItem.Properties.Add(new PropertyBool("bIsSlot", canSlot));
            arkTributeItem.Properties.Add(new PropertyUInt32("ExpirationTimeUTC", 0));
            arkTributeItem.Properties.Add(new PropertyUInt32("ItemQuantity", quantity - 1));
            arkTributeItem.Properties.Add(new PropertyFloat("ItemDurability", durability));
            arkTributeItem.Properties.Add(new PropertyFloat("ItemRating", rating));

            arkTributeItem.Properties.Add(new PropertyByte("ItemQualityIndex", quality));

            for (int i = 0; i < itemStatValues.Length; i++)
            {
                arkTributeItem.Properties.Add(new PropertyUInt16("ItemStatValues", i, itemStatValues[i]));
            }

            for (int i = 0; i < itemColors.Length; i++)
            {
                arkTributeItem.Properties.Add(new PropertyInt16("ItemColorID", i, itemColors[i]));
            }

            ObjectReference itemCustomClass = new ObjectReference();

            itemCustomClass.Length     = 8;
            itemCustomClass.ObjectId   = -1;
            itemCustomClass.ObjectType = ObjectReference.TypeId;
            arkTributeItem.Properties.Add(new PropertyObject("ItemCustomClass", itemCustomClass));

            ObjectReference itemSkinTemplate = new ObjectReference();

            itemSkinTemplate.Length     = 8;
            itemSkinTemplate.ObjectId   = -1;
            itemSkinTemplate.ObjectType = ObjectReference.TypeId;
            arkTributeItem.Properties.Add(new PropertyObject("ItemSkinTemplate", itemSkinTemplate));

            arkTributeItem.Properties.Add(new PropertyFloat("CraftingSkill", 0.0f));

            arkTributeItem.Properties.Add(new PropertyString("CustomItemName", customName));
            arkTributeItem.Properties.Add(new PropertyString("CustomItemDescription", customDescription));

            // TODO: add other values

            arkTributeItem.Properties.Add(new PropertyDouble("NextSpoilingTime", nextSpoilingTime));
            arkTributeItem.Properties.Add(new PropertyDouble("LastSpoilingTime", lastSpoilingTime));

            ObjectReference lastOwnerPlayer = new ObjectReference();

            lastOwnerPlayer.Length     = 4;
            lastOwnerPlayer.ObjectId   = -1;
            lastOwnerPlayer.ObjectType = ObjectReference.TypeId;
            arkTributeItem.Properties.Add(new PropertyObject("LastOwnerPlayer", lastOwnerPlayer));

            arkTributeItem.Properties.Add(new PropertyDouble("LastAutoDurabilityDecreaseTime", 0.0));
            arkTributeItem.Properties.Add(new PropertyStruct("OriginalItemDropLocation", new StructVector(), ArkName.From("Vector")));

            for (int i = 0; i < preSkinItemColors.Length; i++)
            {
                arkTributeItem.Properties.Add(new PropertyInt16("PreSkinItemColorID", i, preSkinItemColors[i]));
            }

            for (int i = 0; i < eggLevelups.Length; i++)
            {
                arkTributeItem.Properties.Add(new PropertyByte("EggNumberOfLevelUpPointsApplied", i, eggLevelups[i]));
            }

            arkTributeItem.Properties.Add(new PropertyFloat("EggTamedIneffectivenessModifier", 0.0f));

            for (int i = 0; i < eggColors.Length; i++)
            {
                arkTributeItem.Properties.Add(new PropertyByte("EggColorSetIndices", i, eggColors[i]));
            }

            arkTributeItem.Properties.Add(new PropertyString("CrafterCharacterName", crafterCharacterName));
            arkTributeItem.Properties.Add(new PropertyString("CrafterTribeName", crafterTribeName));
            arkTributeItem.Properties.Add(new PropertyFloat("CraftedSkillBonus", craftedSkillBonus));

            arkTributeItem.Properties.Add(new PropertyByte("ItemVersion", (byte)0));
            arkTributeItem.Properties.Add(new PropertyInt("CustomItemID", 0));
            arkTributeItem.Properties.Add(new PropertyArray("SteamUserItemID", new ArkArrayUInt64()));

            arkTributeItem.Properties.Add(new PropertyBool("bIsInitialItem", false));

            arkTributeItem.Properties.Add(new PropertyDouble("ClusterSpoilingTimeUTC", DateTimeOffset.UtcNow.ToUnixTimeSeconds()));

            result.Properties.Add(new PropertyFloat("Version", 2.0f));
            result.Properties.Add(new PropertyInt("UploadTime", (int)DateTimeOffset.UtcNow.AddSeconds(uploadOffset).ToUnixTimeSeconds()));

            return(result);
        }
Ejemplo n.º 19
0
 public PropertyInt(string name, int value) : base(ArkName.From(name), 0, value)
 {
 }
Ejemplo n.º 20
0
        public GameObject toGameObject(ICollection <GameObject> existingObjects, int ownerInventory)
        {
            GameObject gameObject = new GameObject();

            gameObject.ClassName = className;

            if (!canEquip)
            {
                gameObject.Properties.Add(new PropertyBool("bAllowEquppingItem", canEquip));
            }

            if (!canSlot)
            {
                gameObject.Properties.Add(new PropertyBool("bCanSlot", canSlot));
            }

            if (isEngram)
            {
                gameObject.Properties.Add(new PropertyBool("bIsEngram", isEngram));
            }

            if (isBlueprint)
            {
                gameObject.Properties.Add(new PropertyBool("bIsBlueprint", isBlueprint));
            }

            if (!canRemove)
            {
                gameObject.Properties.Add(new PropertyBool("bAllowRemovalFromInventory", canRemove));
            }

            if (isHidden)
            {
                gameObject.Properties.Add(new PropertyBool("bHideFromInventoryDisplay", isHidden));
            }

            if (quantity != 1)
            {
                gameObject.Properties.Add(new PropertyInt("ItemQuantity", quantity));
            }

            if (!string.IsNullOrEmpty(customName))
            {
                gameObject.Properties.Add(new PropertyString("CustomItemName", customName));
            }

            if (!string.IsNullOrEmpty(customDescription))
            {
                gameObject.Properties.Add(new PropertyString("CustomItemDescription", customDescription));
            }

            if (durability > 0)
            {
                gameObject.Properties.Add(new PropertyFloat("SavedDurability", durability));
            }

            if (quality > 0)
            {
                gameObject.Properties.Add(new PropertyByte("ItemQualityIndex", quality));
            }

            if (nextSpoilingTime > 0)
            {
                gameObject.Properties.Add(new PropertyDouble("NextSpoilingTime", nextSpoilingTime));
            }

            if (lastSpoilingTime > 0)
            {
                gameObject.Properties.Add(new PropertyDouble("LastSpoilingTime", lastSpoilingTime));
            }

            for (int i = 0; i < itemStatValues.Length; i++)
            {
                if (itemStatValues[i] != 0)
                {
                    gameObject.Properties.Add(new PropertyUInt16("ItemStatValues", i, itemStatValues[i]));
                }
            }

            if (crafterCharacterName != null && !string.IsNullOrEmpty(crafterCharacterName))
            {
                gameObject.Properties.Add(new PropertyString("CrafterCharacterName", crafterCharacterName));
            }

            if (crafterTribeName != null && !string.IsNullOrEmpty(crafterTribeName))
            {
                gameObject.Properties.Add(new PropertyString("CrafterTribeName", crafterTribeName));
            }

            if (craftedSkillBonus != 0.0f)
            {
                gameObject.Properties.Add(new PropertyFloat("CraftedSkillBonus", craftedSkillBonus));
            }

            HashSet <long>    itemIDs = new HashSet <long>(); // Stored as StructPropertyList with 2 UInt32
            HashSet <ArkName> names   = new HashSet <ArkName>();

            foreach (GameObject existingObject in existingObjects)
            {
                existingObject.Names.ForEach(name => names.Add(name));

                IPropertyContainer itemID = existingObject.GetPropertyValue <IPropertyContainer>("ItemId");
                if (itemID != null)
                {
                    int?itemID1 = itemID.GetPropertyValue <int?>("ItemID1");
                    int?itemID2 = itemID.GetPropertyValue <int?>("ItemID2");
                    if (itemID1 != null && itemID2 != null)
                    {
                        long id = (long)itemID1.Value << 32 | (itemID2.Value & 0xFFFFFFFFL);
                        itemIDs.Add(id);
                        continue;
                    }
                }
            }

            Random random = new Random();

            Func <ArkName, ArkName> findFreeName = name => {
                for (int i = 1; i < int.MaxValue; i++)
                {
                    ArkName tempName = ArkName.From(name.Name, i);
                    if (!names.Contains(tempName))
                    {
                        return(tempName);
                    }
                }

                throw new Exception("This is insane.");
            };

            long randomId = random.NextLong();

            while (itemIDs.Contains(randomId))
            {
                randomId = random.NextLong();
            }

            StructPropertyList structProperty = new StructPropertyList();

            structProperty.Properties.Add(new PropertyUInt32("ItemID1", (int)(randomId >> 32)));
            structProperty.Properties.Add(new PropertyUInt32("ItemID2", (int)randomId));

            gameObject.Properties.Add(new PropertyStruct("ItemId", structProperty, ArkName.From("ItemNetID")));

            gameObject.Names.Clear();
            gameObject.Names.Add(findFreeName(className));

            gameObject.IsItem = true;

            ObjectReference ownerInventoryReference = new ObjectReference();

            ownerInventoryReference.Length     = 8;
            ownerInventoryReference.ObjectId   = ownerInventory;
            ownerInventoryReference.ObjectType = ObjectReference.TypeId;

            gameObject.Properties.Add(new PropertyObject("OwnerInventory", ownerInventoryReference));
            gameObject.ExtraData = new ExtraDataZero();

            return(gameObject);
        }
Ejemplo n.º 21
0
 public PropertyString(string name, int index, string value) : base(ArkName.From(name), index, value)
 {
 }
Ejemplo n.º 22
0
 public PropertyInt16(string name, int index, short value) : base(ArkName.From(name), index, value)
 {
 }
Ejemplo n.º 23
0
 public PropertyArray(string name, int index, IArkArray value) : base(ArkName.From(name), index, value)
 {
 }
Ejemplo n.º 24
0
 public PropertyDouble(string name, double value) : base(ArkName.From(name), 0, value)
 {
 }
Ejemplo n.º 25
0
 public virtual void Init(JObject node)
 {
     Name     = ArkName.From(node.Value <string>("name"));
     DataSize = node.Value <int>("size");
     Index    = node.Value <int>("index");
 }
Ejemplo n.º 26
0
 public PropertyDouble(string name, int index, double value) : base(ArkName.From(name), index, value)
 {
 }
Ejemplo n.º 27
0
 public PropertyInt8(string name, sbyte value) : base(ArkName.From(name), 0, value)
 {
 }
Ejemplo n.º 28
0
 public PropertyInt64(string name, long value) :
     base(ArkName.From(name), 0, value)
 {
 }
Ejemplo n.º 29
0
 public PropertyInt64(string name, int index, long value) :
     base(ArkName.From(name), index, value)
 {
 }
Ejemplo n.º 30
0
 public PropertyByte(string name, int index, byte value) : base(ArkName.From(name), index, new ArkByteValue(value))
 {
     EnumType = ArkName.NameNone;
 }