(B, ValueSource) ConvertValue(IPropertyContainer container) { var propertyValueA = container.GetPropertyValue(property, searchOptions); var valueBResult = map(propertyValueA); return(valueBResult); }
/// <summary> /// Retrieve the value of a property given its name. /// </summary> /// <param name="propertyName">Name of property to retrieve</param> /// <returns>Value of the named property or null if it doesn't exist</returns> public override object GetPropertyValue(string propertyName) { if (propertyName == "Text") { return(this.text); } else if (propertyName == "ContainerName") { if (this.container != null) { IPropertyContainer propContainer = this.container.GetService(typeof(IPropertyContainer)) as IPropertyContainer; if (propContainer != null) { return((string)propContainer.GetPropertyValue("Name")); } } } if (this.propertyValues.Contains(propertyName)) { return(this.propertyValues[propertyName]); } if (this.Parent != null) { IPropertyContainer parentProps = this.Parent.GetPropertyContainer(this); if (parentProps != null) { return(parentProps.GetPropertyValue(propertyName)); } } return(null); }
/// <inheritdoc /> public IEnumerable <Message> Validate(IPropertyContainer propertyContainer) { IPropertyValue <T> propertyValue = propertyContainer.GetPropertyValue(Property, Search.ExistingOnly); if (propertyValue == null) { yield return(this.GetConfiguredMessage(new PropertyValue <T>(Property, default, ValueSource.NotDefined), propertyContainer, "{propertyName} is marked as required but is not exists."));
/// <summary> /// Retrieve the value of a property given its name. /// </summary> /// <param name="propertyName">Name of property to retrieve</param> /// <returns>Value of the named property or null if it doesn't exist</returns> public virtual object GetPropertyValue(string propertyName) { object value = null; IPortContainer portContainer = this.Container; IPropertyContainer parentProps = null; if (this.parent != null) { parentProps = this.parent.GetPropertyContainer(this); } if (this.propertyValues.Contains(propertyName)) { value = this.propertyValues[propertyName]; } if (value == null && parentProps != null) { value = parentProps.GetPropertyValue(propertyName); } if (propertyName == "Visible" && parentProps != null) { // Visibility may depend on whether the AutoHidePorts property // is set to true in the symbol symbol bool visible = true; if (value != null && value.GetType() == typeof(bool)) { visible = (bool)value; } if (visible && portContainer != null && portContainer.AutoHidePorts) { object revealPorts = parentProps.GetPropertyValue("RevealPorts"); if (revealPorts != null && revealPorts.GetType() == typeof(bool)) { value = (bool)revealPorts; } } } return(value); }
(TResult, ValueSource) ConvertValue(IPropertyContainer container, SearchOptions search) { search = configureSearch?.Invoke(search) ?? search; var sourcePropertyValue = container.GetPropertyValue(property, search); var resultValue = map(sourcePropertyValue); return(resultValue); }
/// <inheritdoc /> public IEnumerable <Message> Validate(IPropertyValue <T>?propertyValue, IPropertyContainer propertyContainer) { propertyValue ??= propertyContainer.GetPropertyValue(Property, SearchOptions) !; if (propertyValue.IsNullOrNotDefined()) { yield return(this.GetConfiguredMessage(propertyValue, propertyContainer)); } }
/// <inheritdoc /> public IEnumerable <Message> Validate(IPropertyContainer propertyContainer) { IPropertyValue <T> propertyValue = propertyContainer.GetPropertyValue(Property, Search.ExistingOnly.ReturnNotDefined()); if (propertyValue.IsNullOrNotDefined()) { yield return(this.GetConfiguredMessage(propertyValue, propertyContainer)); } }
/// <inheritdoc/> public IEnumerable <Message> Validate(IPropertyContainer propertyContainer) { IPropertyValue <T> propertyValue = propertyContainer.GetPropertyValue(Property, Search.Default); if (!IsValid(propertyValue.Value, propertyContainer)) { yield return(this.GetConfiguredMessage(propertyValue, propertyContainer)); } }
/// <inheritdoc /> public IEnumerable <Message> Validate(IPropertyValue <T>?propertyValue, IPropertyContainer propertyContainer) { // Search is from container. NotDefined uses to assure that propertyValue is always not null. // Also default value can be property defined (not always default(T)). propertyValue ??= propertyContainer.GetPropertyValue(Property, propertyContainer.SearchOptions.ReturnNotDefined()) !; if (!IsValid(propertyValue.Value)) { yield return(this.GetConfiguredMessage(propertyValue, propertyContainer)); } }
/// <summary> /// /// </summary> /// <param name="node"></param> /// <returns></returns> protected bool IsNodeAllowed(INode node) { bool allowed = true; IPropertyContainer curProps = node as IPropertyContainer; if (curProps != null) { allowed = (bool)curProps.GetPropertyValue("AllowRotate"); } return(allowed); }
public static U GetPropertyValue <T, U>(this IPropertyContainer propertyContainer, string name, int index = 0, U defaultValue = default(U), Func <T, U> map = null) { T value = propertyContainer.GetPropertyValue <T>(name, index); if (value == null || value.Equals(default(T))) { return(defaultValue); } if (map != null) { return(map(value)); } return((U)(object)value); }
/// <summary> /// Retrieve the value of a property given its name. /// </summary> /// <param name="propertyName">Name of property to retrieve</param> /// <returns>Value of the named property or null if it doesn't exist</returns> public virtual object GetPropertyValue(string propertyName) { if (this.propertyValues.Contains(propertyName)) { return(this.propertyValues[propertyName]); } IPropertyContainer parentProps = this.line as IPropertyContainer; if (parentProps != null) { return(parentProps.GetPropertyValue(propertyName)); } return(null); }
/// <inheritdoc /> public string?Render(IPropertyContainer source) { if (CustomRender != null) { return(CustomRender(Property, source) ?? NullValue); } IPropertyValue <T>?propertyValue = source.GetPropertyValue(Property, SearchOptions); if (propertyValue.HasValue()) { return(propertyValue.Value?.FormatValue() ?? NullValue); } return(NullValue); }
/// <summary> /// Gets property value from the first source where value is defined. /// </summary> /// <typeparam name="T">Property type.</typeparam> /// <param name="property">Property to search.</param> /// <param name="source1">Source 1.</param> /// <param name="source2">Source 2.</param> /// <param name="source3">Source 3.</param> /// <param name="source4">Source 4.</param> /// <returns>Property value or default value.</returns> public static T GetFirstDefinedValue <T>( IProperty <T> property, IPropertyContainer source1 = null, IPropertyContainer source2 = null, IPropertyContainer source3 = null, IPropertyContainer source4 = null) { IPropertyValue <T> propertyValue; if (source1 != null) { propertyValue = source1.GetPropertyValue(property, SearchOptions.ExistingOnly); if (propertyValue.HasValue()) { return(propertyValue.Value); } } if (source2 != null) { propertyValue = source2.GetPropertyValue(property, SearchOptions.ExistingOnly); if (propertyValue.HasValue()) { return(propertyValue.Value); } } if (source3 != null) { propertyValue = source3.GetPropertyValue(property, SearchOptions.ExistingOnly); if (propertyValue.HasValue()) { return(propertyValue.Value); } } if (source4 != null) { propertyValue = source4.GetPropertyValue(property, SearchOptions.ExistingOnly); if (propertyValue.HasValue()) { return(propertyValue.Value); } } return((source1 ?? source2 ?? source3 ?? source4).GetPropertyValue(property, SearchOptions.Default).Value); }
/// <summary> /// Retrieve the value of a property given its name. /// </summary> /// <param name="propertyName">Name of property to retrieve</param> /// <returns>Value of the named property or null if it doesn't exist</returns> public virtual object GetPropertyValue(string propertyName) { if (this.propertyValues.Contains(propertyName)) { return(this.propertyValues[propertyName]); } if (this.container != null) { IPropertyContainer containerProps = this.container.PropertyContainer; if (containerProps != null) { return(containerProps.GetPropertyValue(propertyName)); } } return(null); }
public ArkCloudInventoryCharacter(IPropertyContainer character) : this() { _character = character; //todo: add more properties for cloud characters //todo: read the player data from byte array var playerName = _character.GetPropertyValue <string>(_playerName); if (playerName != null) { var m = _r_nameLevel.Match(playerName); if (m.Success) { Name = m.Groups["name"].Value; Level = int.Parse(m.Groups["level"].Value); } } }
/// <inheritdoc /> public string Render(IPropertyContainer source) { if (CustomRender != null) { return(CustomRender(Property, source)); } string textValue = NullValue; IPropertyValue <T> propertyValue = source.GetPropertyValue(Property, SearchOptions ?? Metadata.SearchOptions.ExistingOnlyWithParent); if (propertyValue.HasValue()) { T value = propertyValue.Value; textValue = FormatValue?.Invoke(value, source) ?? DoDefaultFormatting(value); } return(textValue); }
/// <summary> /// /// </summary> /// <param name="nodesIn"></param> /// <returns></returns> protected NodeCollection GetAllowedNodes(NodeCollection nodesIn) { NodeCollection nodesOut = new NodeCollection(); IEnumerator enumNodesIn = nodesIn.GetEnumerator(); while (enumNodesIn.MoveNext()) { bool allowed = true; IPropertyContainer curProps = enumNodesIn.Current as IPropertyContainer; if (curProps != null) { allowed = (bool)curProps.GetPropertyValue("AllowMove"); } if (allowed) { nodesOut.Add(enumNodesIn.Current as INode); } } return(nodesOut); }
/** * 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"); }
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); }
static IPropertyValue?GetPropertyValueAdapter <T>(IPropertyContainer pc, IProperty p, SearchOptions?s) => pc.GetPropertyValue((IProperty <T>)p, s);
public ArkCloudInventoryItem(IPropertyContainer item) : this() { _item = item; var tribute = item.GetPropertyValue <StructPropertyList>(_arkTributeItem); var itemid = tribute.GetPropertyValue <StructPropertyList>(_itemId); Id1 = itemid.GetPropertyValue <uint>(_itemId1); Id2 = itemid.GetPropertyValue <uint>(_itemId2); ClassName = tribute.GetPropertyValue <ObjectReference>(_itemArchetype)?.ObjectString?.Name; IsBlueprint = tribute.GetPropertyValue <bool?>(_bIsBlueprint) ?? false; CustomDescription = tribute.GetPropertyValue <string>(_customItemDescription); CustomName = tribute.GetPropertyValue <string>(_customItemName); Quantity = tribute.GetPropertyValue <uint?>(_itemQuantity) ?? 1; Rating = tribute.GetPropertyValue <float?>(_itemRating); Durability = tribute.GetPropertyValue <float?>(_itemDurability); QualityIndex = tribute.GetPropertyValue <sbyte?>(_itemQualityIndex); { var statValues = new short?[_itemStatValues.Length]; var found = 0; for (var i = 0; i < statValues.Length; i++) { var statValue = tribute.GetPropertyValue <short?>(_itemStatValues[i]); if (statValue == null) { continue; } found++; statValues[i] = statValue.Value; } if (found > 0) { StatValues = statValues; } } EggDinoAncestors = ArkTamedCreatureAncestor.FromPropertyValue(tribute.GetPropertyValue <ArkArrayStruct>(_eggDinoAncestors)); EggDinoAncestorsMale = ArkTamedCreatureAncestor.FromPropertyValue(tribute.GetPropertyValue <ArkArrayStruct>(_eggDinoAncestorsMale)); { var colors = new sbyte[_eggColorSetIndices.Length]; var found = 0; for (var i = 0; i < colors.Length; i++) { var color = tribute.GetPropertyValue <sbyte?>(_eggColorSetIndices[i]); if (color == null) { continue; } found++; colors[i] = color.Value; } if (found > 0) { EggColors = colors; } } { var basestats = new sbyte[_eggNumberOfLevelUpPointsApplied.Length]; var found = 0; for (var i = 0; i < basestats.Length; i++) { var basestat = tribute.GetPropertyValue <sbyte?>(_eggNumberOfLevelUpPointsApplied[i]); if (basestat == null) { continue; } found++; basestats[i] = basestat.Value; } if (found > 0) { EggBaseStats = basestats; } } EggRandomMutationsMale = tribute.GetPropertyValue <int?>(_eggRandomMutationsMale); EggRandomMutationsFemale = tribute.GetPropertyValue <int?>(_eggRandomMutationsFemale); }
public TribeRankGroup(IPropertyContainer tribeRankGroup) { rankGroupName = tribeRankGroup.GetPropertyValue <string>("RankGroupName", defaultValue: string.Empty); rankGroupRank = tribeRankGroup.GetPropertyValue <ArkByteValue>("RankGroupRank")?.ByteValue ?? 0; inventoryRank = tribeRankGroup.GetPropertyValue <ArkByteValue>("InventoryRank")?.ByteValue ?? 0; structureActivationRank = tribeRankGroup.GetPropertyValue <ArkByteValue>("StructureActivationRank")?.ByteValue ?? 0; newStructureActivationRank = tribeRankGroup.GetPropertyValue <ArkByteValue>("NewStructureActivationRank")?.ByteValue ?? 0; newStructureInventoryRank = tribeRankGroup.GetPropertyValue <ArkByteValue>("NewStructureInventoryRank")?.ByteValue ?? 0; petOrderRank = tribeRankGroup.GetPropertyValue <ArkByteValue>("PetOrderRank")?.ByteValue ?? 0; petRidingRank = tribeRankGroup.GetPropertyValue <ArkByteValue>("PetRidingRank")?.ByteValue ?? 0; inviteToGroupRank = tribeRankGroup.GetPropertyValue <ArkByteValue>("InviteToGroupRank")?.ByteValue ?? 0; maxPromotionGroupRank = tribeRankGroup.GetPropertyValue <ArkByteValue>("MaxPromotionGroupRank")?.ByteValue ?? 0; maxDemotionGroupRank = tribeRankGroup.GetPropertyValue <ArkByteValue>("MaxDemotionGroupRank")?.ByteValue ?? 0; maxBanishmentGroupRank = tribeRankGroup.GetPropertyValue <ArkByteValue>("MaxBanishmentGroupRank")?.ByteValue ?? 0; numInvitesRemaining = tribeRankGroup.GetPropertyValue <ArkByteValue>("NumInvitesRemaining")?.ByteValue ?? 0; preventStructureDemolish = tribeRankGroup.GetPropertyValue <bool>("bPreventStructureDemolish"); preventStructureAttachment = tribeRankGroup.GetPropertyValue <bool>("bPreventStructureAttachment"); preventStructureBuildInRange = tribeRankGroup.GetPropertyValue <bool>("bPreventStructureBuildInRange"); preventUnclaiming = tribeRankGroup.GetPropertyValue <bool>("bPreventUnclaiming"); allowInvites = tribeRankGroup.GetPropertyValue <bool>("bAllowInvites"); limitInvites = tribeRankGroup.GetPropertyValue <bool>("bLimitInvites"); allowDemotions = tribeRankGroup.GetPropertyValue <bool>("bAllowDemotions"); allowPromotions = tribeRankGroup.GetPropertyValue <bool>("bAllowPromotions"); allowBanishments = tribeRankGroup.GetPropertyValue <bool>("bAllowBanishments"); defaultRank = tribeRankGroup.GetPropertyValue <bool>("bDefaultRank"); }
public Tribe(string path, ReadingOptions ro) { ArkTribe tribe = new ArkTribe().ReadBinary <ArkTribe>(path, ro); StructPropertyList tribeData = tribe.GetPropertyValue <IStruct, StructPropertyList>("TribeData"); tribeName = tribeData.GetPropertyValue <string>("TribeName", defaultValue: string.Empty); ownerPlayerDataId = tribeData.GetPropertyValue <int>("OwnerPlayerDataID"); tribeId = tribeData.GetPropertyValue <int>("TribeID"); ArkArrayString membersNames = tribeData.GetPropertyValue <IArkArray, ArkArrayString>("MembersPlayerName"); if (membersNames != null) { membersPlayerName.AddRange(membersNames); foreach (string memberName in membersNames) { membersPlayerName.Add(memberName); } } ArkArrayUInt32 membersData = tribeData.GetPropertyValue <IArkArray, ArkArrayUInt32>("MembersPlayerDataID"); if (membersData != null) { foreach (int memberDataId in membersData) { membersPlayerDataId.Add(memberDataId); } } ArkArrayUInt32 tribeAdminIds = tribeData.GetPropertyValue <IArkArray, ArkArrayUInt32>("TribeAdmins"); if (tribeAdminIds != null) { foreach (int tribeAdmin in tribeAdminIds) { tribeAdmins.Add(tribeAdmin); } } ArkArrayInt8 memberRankGroups = tribeData.GetPropertyValue <IArkArray, ArkArrayInt8>("MembersRankGroups"); if (memberRankGroups != null) { foreach (byte memberRankGroup in memberRankGroups) { membersRankGroups.Add(memberRankGroup); } } setGovernment = tribeData.GetPropertyValue <bool>("SetGovernment"); IPropertyContainer tribeGovernment = tribeData.GetPropertyValue <IStruct, IPropertyContainer>("TribeGovernment"); if (tribeGovernment != null) { tribeGovernPINCode = tribeGovernment.GetPropertyValue <int>("TribeGovern_PINCode"); tribeGovernDinoOwnership = tribeGovernment.GetPropertyValue <int>("TribeGovern_DinoOwnership"); tribeGovernStructureOwnership = tribeGovernment.GetPropertyValue <int>("TribeGovern_StructureOwnership"); tribeGovernDinoTaming = tribeGovernment.GetPropertyValue <int>("TribeGovern_DinoTaming"); tribeGovernDinoUnclaimAdminOnly = tribeGovernment.GetPropertyValue <int>("TribeGovern_DinoUnclaimAdminOnly"); } else { tribeGovernDinoOwnership = 1; tribeGovernStructureOwnership = 1; } ArkArrayString logEntrys = tribeData.GetPropertyValue <IArkArray, ArkArrayString>("TribeLog"); if (logEntrys != null) { foreach (string log in logEntrys) { tribeLog.Add(log); } } logIndex = tribeData.GetPropertyValue <int>("LogIndex"); ArkArrayStruct tribeRankStructs = tribeData.GetPropertyValue <IStruct, ArkArrayStruct>("TribeRankGroups"); if (tribeRankStructs != null) { foreach (IStruct tribeRankStruct in tribeRankStructs) { tribeRankGroups.Add(new TribeRankGroup((IPropertyContainer)tribeRankStruct)); } } }
public Player(string path, IDataContext context, ReadingOptions ro) { ArkProfile profile = new ArkProfile().ReadBinary <ArkProfile>(path, ro); savedPlayerDataVersion = profile.GetPropertyValue <int>("SavedPlayerDataVersion"); StructPropertyList myData = profile.GetPropertyValue <IStruct, StructPropertyList>("MyData"); playerDataId = myData.GetPropertyValue <long>("PlayerDataID"); uniqueId = myData.GetPropertyValue <IStruct, StructUniqueNetIdRepl>("UniqueID"); savedNetworkAddress = myData.GetPropertyValue <string>("SavedNetworkAddress"); playerName = myData.GetPropertyValue <string>("PlayerName"); tribeId = myData.GetPropertyValue <int>("TribeID"); playerDataVersion = myData.GetPropertyValue <int>("PlayerDataVersion"); spawnDayNumber = myData.GetPropertyValue <int>("SpawnDayNumber"); spawnDayTime = myData.GetPropertyValue <float>("SpawnDayTime"); IPropertyContainer characterConfig = myData.GetPropertyValue <IStruct, IPropertyContainer>("MyPlayerCharacterConfig"); // Character data isFemale = characterConfig.GetPropertyValue <bool>("bIsFemale"); bodyColors = Enumerable.Range(0, PlayerBodyColorRegions.Instance.Count).Select(i => characterConfig.GetPropertyValue <IStruct, StructLinearColor>("BodyColors", i)).ToArray(); //for (int i = 0; i < PlayerBodyColorRegions.Instance.Count; i++) { // bodyColors[i] = characterConfig.getPropertyValue<IStruct, StructLinearColor>("BodyColors", i); //} overrideHeadHairColor = characterConfig.GetPropertyValue <IStruct, StructLinearColor>("OverrideHeadHairColor"); overrideFacialHairColor = characterConfig.GetPropertyValue <IStruct, StructLinearColor>("OverrideFacialHairColor"); facialHairIndex = characterConfig.GetPropertyValue <ArkByteValue>("FacialHairIndex")?.ByteValue ?? 0; headHairIndex = characterConfig.GetPropertyValue <ArkByteValue>("HeadHairIndex")?.ByteValue ?? 0; playerCharacterName = characterConfig.GetPropertyValue <string>("PlayerCharacterName", defaultValue: string.Empty); rawBoneModifiers = Enumerable.Range(0, PlayerBoneModifierNames.Instance.Count).Select(i => characterConfig.GetPropertyValue <float>("RawBoneModifiers", i)).ToArray(); //for (int i = 0; i < PlayerBoneModifierNames.Instance.Count; i++) { // rawBoneModifiers[i] = characterConfig.findPropertyValue<float>("RawBoneModifiers", i); //} IPropertyContainer characterStats = myData.GetPropertyValue <IStruct, IPropertyContainer>("MyPersistentCharacterStats"); characterLevel = characterStats.GetPropertyValue <short>("CharacterStatusComponent_ExtraCharacterLevel") + 1; experiencePoints = characterStats.GetPropertyValue <float>("CharacterStatusComponent_ExperiencePoints"); totalEngramPoints = characterStats.GetPropertyValue <int>("PlayerState_TotalEngramPoints"); List <ObjectReference> learnedEngrams = characterStats.GetPropertyValue <IArkArray, ArkArrayObjectReference>("PlayerState_EngramBlueprints"); if (learnedEngrams != null) { foreach (ObjectReference reference in learnedEngrams) { engramBlueprints.Add(reference.ObjectString.ToString()); } } numberOfLevelUpPointsApplied = Enumerable.Range(0, AttributeNames.Instance.Count) .Select(i => characterStats.GetPropertyValue <ArkByteValue>("CharacterStatusComponent_NumberOfLevelUpPointsApplied", i)?.ByteValue ?? 0) .ToArray(); //for (int i = 0; i < AttributeNames.Instance.Count; i++) { // numberOfLevelUpPointsApplied[i] = characterStats.findPropertyValue<ArkByteValue>("CharacterStatusComponent_NumberOfLevelUpPointsApplied", i) // ?.ByteValue ?? 0; //} percentageOfHeadHairGrowth = characterStats.GetPropertyValue <float>("PercentageOfHeadHairGrowth"); percentageOfFacialHairGrowth = characterStats.GetPropertyValue <float>("PercentageOfFacialHairGrowth"); if (context.ObjectContainer == null) { return; } GameObject player = null; foreach (GameObject gameObject in context.ObjectContainer) { long?linkedPlayerDataId = gameObject.GetPropertyValue <long?>("LinkedPlayerDataID"); if (linkedPlayerDataId == null || linkedPlayerDataId != playerDataId) { continue; } player = gameObject; break; } if (player == null) { return; } GameObject playerCharacterStatus = null; foreach (GameObject gameObject in context.ObjectContainer) { if (gameObject.Names.Count != 2 || gameObject.Names[0].ToString() != "PlayerCharacterStatus" || gameObject.Names[1] != player.Names[0]) { continue; } playerCharacterStatus = gameObject; break; } inventory = player.GetPropertyValue <ObjectReference, GameObject>("MyInventoryComponent", map: reference => context.ObjectContainer[reference]); location = player.Location; if (playerCharacterStatus == null) { return; } lastHypothermalCharacterInsulationValue = playerCharacterStatus.GetPropertyValue <float>("LastHypothermalCharacterInsulationValue"); lastHyperthermalCharacterInsulationValue = playerCharacterStatus.GetPropertyValue <float>("LastHyperthermalCharacterInsulationValue"); for (int index = 0; index < AttributeNames.Instance.Count; index++) { currentStatusValues[index] = playerCharacterStatus.GetPropertyValue <float>("CurrentStatusValues", index); } }
protected override void RunCommand(IEnumerable <string> args) { List <string> argsList = args.ToList(); if (showCommandHelp(argsList)) { return; } string clusterDirectory = argsList[0]; string outputDirectory = argsList[1]; ArkDataManager.LoadData(GlobalOptions.Language); List <Action> tasks = GlobalOptions.Parallel ? new List <Action>() : null; Stopwatch stopwatch = new Stopwatch(GlobalOptions.UseStopWatch); foreach (string path in Directory.EnumerateFiles(clusterDirectory)) { Action task = () => { try { ArkCloudInventory cloudInventory = new ArkCloudInventory().ReadBinary <ArkCloudInventory>(path, ReadingOptions.Create()); CustomDataContext context = new CustomDataContext { ObjectContainer = cloudInventory }; IPropertyContainer arkData = cloudInventory.InventoryData.GetPropertyValue <IPropertyContainer>("MyArkData"); CommonFunctions.WriteJson(Path.Combine(outputDirectory, path + ".json"), (generator, writingOptions) => { generator.WriteStartObject(); ArkArrayStruct tamedDinosData = arkData.GetPropertyValue <ArkArrayStruct>("ArkTamedDinosData"); if (tamedDinosData != null && tamedDinosData.Any()) { generator.WriteArrayFieldStart("creatures"); foreach (IStruct dinoStruct in tamedDinosData) { IPropertyContainer dino = (IPropertyContainer)dinoStruct; ArkContainer container = null; if (cloudInventory.InventoryVersion == 1) { ArkArrayUInt8 byteData = dino.GetPropertyValue <ArkArrayUInt8>("DinoData"); container = new ArkContainer(byteData); } else if (cloudInventory.InventoryVersion == 3) { ArkArrayInt8 byteData = dino.GetPropertyValue <ArkArrayInt8>("DinoData"); container = new ArkContainer(byteData); } ObjectReference dinoClass = dino.GetPropertyValue <ObjectReference>("DinoClass"); // Skip "BlueprintGeneratedClass " = 24 chars string dinoClassName = dinoClass.ObjectString.ToString().Substring(24); generator.WriteStartObject(); generator.WriteField("type", ArkDataManager.HasCreatureByPath(dinoClassName) ? ArkDataManager.GetCreatureByPath(dinoClassName).Name : dinoClassName); // NPE for unknown versions Creature creature = new Creature(container.Objects[0], container); generator.WriteObjectFieldStart("data"); creature.writeAllProperties(generator, context, writeAllFields); generator.WriteEndObject(); generator.WriteEndObject(); } generator.WriteEndArray(); } ArkArrayStruct arkItems = arkData.GetPropertyValue <ArkArrayStruct>("ArkItems"); if (arkItems != null) { List <Item> items = new List <Item>(); foreach (IStruct itemStruct in arkItems) { IPropertyContainer item = (IPropertyContainer)itemStruct; IPropertyContainer netItem = item.GetPropertyValue <IPropertyContainer>("ArkTributeItem"); items.Add(new Item(netItem)); } if (items.Any()) { generator.WritePropertyName("items"); Inventory.writeInventoryLong(generator, context, items, writeAllFields); } } generator.WriteEndObject(); }, writingOptions); } catch (Exception ex) { Console.Error.WriteLine("Found potentially corrupt cluster data: " + path); if (GlobalOptions.Verbose) { Console.Error.WriteLine(ex.Message); Console.Error.WriteLine(ex.StackTrace); } } }; if (tasks != null) { tasks.Add(task); } else { task(); } } if (tasks != null) { Parallel.ForEach(tasks, task => task()); } stopwatch.Stop("Loading cluster data and writing info"); stopwatch.Print(); }