public static ArkClusterDataResult <ArkCloudInventory> LoadSingle(string savePath, CancellationToken ct, bool loadOnlyPropertiesInDomain = false, bool decouple = true)
        {
            var success            = false;
            var cancelled          = false;
            var st                 = Stopwatch.StartNew();
            ArkCloudInventory data = null;

            try
            {
                var exclusivePropertyNameTree = loadOnlyPropertiesInDomain ? ArkClusterDataContainerBase._alldependencies : null;
                var arkcloudInventories       = new ArkSavegameToolkitNet.ArkCloudInventory(savePath, exclusivePropertyNameTree: exclusivePropertyNameTree);

                data = arkcloudInventories.InventoryData?.AsCloudInventory(arkcloudInventories.SteamId, SaveState.FromSaveTime(arkcloudInventories.SaveTime), arkcloudInventories.InventoryDinoData);
                if (decouple)
                {
                    data?.Decouple();
                }
                success = true;
            }
            catch (OperationCanceledException)
            {
                cancelled = true;
            }

            return(new ArkClusterDataResult <ArkCloudInventory>
            {
                Success = success,
                Cancelled = cancelled,
                Elapsed = st.Elapsed,
                FilePath = savePath,
                Data = data
            });
        }
Exemplo n.º 2
0
        public ArkPlayer()
        {
            Stats = new sbyte[_characterStatusComponent_NumberOfLevelUpPointsApplied.Length];

            // Relations
            _creatures = new Lazy <ArkTamedCreature[]>(() =>
            {
                ArkTamedCreature[] creatures = null;
                return(_gameData?._playerTamedCreatures.TryGetValue(Id, out creatures) == true ? creatures : new ArkTamedCreature[] { });
            });
            _structures = new Lazy <ArkStructure[]>(() =>
            {
                ArkStructure[] structures = null;
                return(_gameData?._playerStructures.TryGetValue(Id, out structures) == true ? structures : new ArkStructure[] { });
            });
            _items = new Lazy <ArkItem[]>(() => Structures.SelectMany(x => x.Inventory)
                                          .Concat(Creatures.SelectMany(x => x.Inventory))
                                          .Concat(Inventory).Where(ArkItem.Filter_RealItems).ToArray());
            _creatureTypes  = new Lazy <Dictionary <string, ArkTamedCreature[]> >(() => Creatures.GroupBy(x => x.ClassName).ToDictionary(x => x.Key, x => x.ToArray()));
            _structureTypes = new Lazy <Dictionary <string, ArkStructure[]> >(() => Structures.GroupBy(x => x.ClassName).ToDictionary(x => x.Key, x => x.ToArray()));
            _itemTypes      = new Lazy <Dictionary <string, ArkItemTypeGroup> >(() => Items.GroupBy(x => x.ClassName).ToDictionary(x => x.Key, x => new ArkItemTypeGroup(x.ToArray())));
            _tribe          = new Lazy <ArkTribe>(() =>
            {
                ArkTribe tribe = null;
                return(_gameData?._playerTribes.TryGetValue(Id, out tribe) == true ? tribe : null);
            });
            _inventory = new Lazy <ArkItem[]>(() => {
                if (!InventoryId.HasValue)
                {
                    return new ArkItem[] { }
                }
                ;

                ArkItem[] items = null;
                return(_gameData?._inventoryItems.TryGetValue(InventoryId.Value, out items) == true ? items.Where(ArkItem.Filter_RealItems).ToArray() : new ArkItem[] { });
            });
            _cloudCreatures = new Lazy <ArkCloudInventoryDino[]>(() =>
            {
                ArkCloudInventoryDino[] creatures = null;
                return(_clusterData?._playerCloudCreatures.TryGetValue(SteamId, out creatures) == true ? creatures : new ArkCloudInventoryDino[] { });
            });
            _cloudItems = new Lazy <ArkCloudInventoryItem[]>(() =>
            {
                ArkCloudInventoryItem[] items = null;
                return(_clusterData?._playerCloudItems.TryGetValue(SteamId, out items) == true ? items : new ArkCloudInventoryItem[] { });
            });
            _lastActiveTime = new Lazy <DateTime>(() =>
            {
                ArkCloudInventory inv = null;
                return(_clusterData?._playerCloudInventories.TryGetValue(SteamId, out inv) == true && inv.SavedAt > SavedAt ? inv.SavedAt : SavedAt);
            });
        }