public static IProperty ReadBinary(ArkArchive archive) { ArkName name = archive.ReadName(); if (name == null || string.IsNullOrEmpty(name.ToString())) { archive.HasUnknownData = true; throw new UnreadablePropertyException( $"Property name is {(name == null ? "null" : "empty")}, indicating a corrupt file. Ignoring remaining properties."); } if (name == ArkName.NameNone) { return(null); } ArkName type = archive.ReadName(); if (type != null && typeMap.TryGetValue(type, out PropertyConstructor constructor)) { return(constructor.BinaryConstructor(archive, name)); } archive.DebugMessage($"Unknown property type {name}"); archive.HasUnknownNames = true; return(new PropertyUnknown(archive, name)); }
public Structure(GameObject structure, GameObjectContainer saveFile) { id = structure.Names[0].ToString(); className = structure.ClassName; CreatureData structureData = ArkDataManager.GetStructure(className.ToString()); type = structureData != null ? structureData.Name : className.ToString(); location = structure.Location; inventory = structure.GetPropertyValue <ObjectReference, GameObject>("MyInventoryComponent", map: reference => saveFile[reference]); containerActivated = structure.GetPropertyValue <bool>("bContainerActivated"); owningPlayerId = structure.GetPropertyValue <int>("OwningPlayerID"); owningPlayerName = structure.GetPropertyValue <string>("OwningPlayerName", defaultValue: string.Empty); ArkArrayObjectReference linkedStructuresReferences = structure.GetPropertyValue <ArkArrayObjectReference>("LinkedStructures"); if (linkedStructuresReferences != null) { linkedStructures = new int[linkedStructuresReferences.Count]; int index = 0; foreach (ObjectReference objectReference in linkedStructuresReferences) { linkedStructures[index++] = objectReference.ObjectId; } } placedOnFloorStructure = structure.GetPropertyValue <ObjectReference>("PlacedOnFloorStructure")?.ObjectId ?? -1; ownerName = structure.GetPropertyValue <string>("OwnerName", defaultValue: string.Empty); boxName = structure.GetPropertyValue <string>("BoxName", defaultValue: string.Empty); bedName = structure.GetPropertyValue <string>("BedName", defaultValue: string.Empty); maxHealth = structure.GetPropertyValue <float>("MaxHealth"); health = structure.GetPropertyValue <float>("Health", defaultValue: maxHealth); targetingTeam = structure.GetPropertyValue <int>("TargetingTeam"); }
protected override void writeJsonValue(JsonTextWriter generator, WritingOptions writingOptions) { if (!writingOptions.Compact) { generator.WriteField("structType", structType.ToString()); generator.WritePropertyName(Value is StructUnknown ? "unknown" : "value"); } Value.WriteJson(generator, writingOptions); }
/** * From ArkSavegame */ public Item(GameObject item) { className = item.ClassName; ItemData itemData = ArkDataManager.GetItem(className.ToString()); type = itemData != null ? itemData.Name : className.ToString(); blueprintGeneratedClass = itemData != null ? itemData.BlueprintGeneratedClass : null; canEquip = item.GetPropertyValue <bool>("bAllowEquppingItem", defaultValue: true); canSlot = item.GetPropertyValue <bool>("bCanSlot", defaultValue: true); isEngram = item.GetPropertyValue <bool>("bIsEngram"); isBlueprint = item.GetPropertyValue <bool>("bIsBlueprint"); canRemove = item.GetPropertyValue <bool>("bAllowRemovalFromInventory", defaultValue: true); canRemoveFromCluster = 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>("SavedDurability"); 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 < ItemStatDefinitions.Instance.Count; 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"); }
/** * 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"); }
/** * 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"); }