示例#1
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);
            });
        }
        public void Do(ArkTribe i)
        {
            var anon = GetTribe(i.Id);

            i.Id   = anon.Id;
            i.Name = anon.Name;
            i.Logs = new string[] { };

            var owner = GetPlayer(i.OwnerPlayerId);

            i.OwnerPlayerId = (int)owner.Id;

            var members = i.MemberIds?.Select(x => GetPlayer(x)).Where(x => x != null).ToArray() ?? new dynamic[] { };

            i.MemberIds   = members?.Select(x => (int)x.Id).ToArray();
            i.MemberNames = members?.Select(x => (string)x.CharacterName).ToArray();

            var admins = i.AdminIds?.Select(x => GetPlayer(x)).Where(x => x != null).ToArray() ?? new dynamic[] { };

            i.AdminIds = admins?.Select(x => (int)x.Id).ToArray();
        }