Example #1
0
        private void ApplyNewData(ArkSavegame save, ArkTamedCreature[] tamed, ArkWildCreature[] wild, ArkPlayer[] players, ArkTribe[] tribes, ArkItem[] items, ArkDroppedItem[] droppedItems, ArkStructure[] structures, bool decouple = true, ArkDeathCache[] deathCache = null, ArkAnonymizeData anonymize = null)
        {
            // Anonymize data if requested
            if (anonymize != null)
            {
                foreach (var i in players)
                {
                    anonymize.Do(i);
                }
                foreach (var i in tribes)
                {
                    anonymize.Do(i);
                }
                foreach (var i in tamed)
                {
                    anonymize.Do(i);
                }
                foreach (var i in structures)
                {
                    anonymize.Do(i);
                }
            }

            // Setup relations in the domain model between entities
            var newGameData = new ArkGameDataBase(save.SaveState, tamed, wild, players, tribes, items, droppedItems, structures, deathCache);

            newGameData.Initialize(_clusterData);
            foreach (var i in tamed)
            {
                i.Initialize(newGameData, _clusterData);
            }
            foreach (var i in wild)
            {
                i.Initialize(newGameData, _clusterData);
            }
            foreach (var i in players)
            {
                i.Initialize(newGameData, _clusterData);
            }
            foreach (var i in tribes)
            {
                i.Initialize(newGameData, _clusterData);
            }
            foreach (var i in items)
            {
                i.Initialize(newGameData, _clusterData);
            }
            foreach (var i in droppedItems)
            {
                i.Initialize(newGameData, _clusterData);
            }
            foreach (var i in structures)
            {
                i.Initialize(newGameData, _clusterData);
            }
            foreach (var i in deathCache)
            {
                i.Initialize(newGameData, _clusterData);
            }

            if (decouple) //should always be true except for debugging
            {
                // Unset all references to raw extracted game objects and properties to free memory
                foreach (var i in tamed)
                {
                    i.Decouple();
                }
                foreach (var i in wild)
                {
                    i.Decouple();
                }
                foreach (var i in players)
                {
                    i.Decouple();
                }
                foreach (var i in tribes)
                {
                    i.Decouple();
                }
                foreach (var i in items)
                {
                    i.Decouple();
                }
                foreach (var i in droppedItems)
                {
                    i.Decouple();
                }
                foreach (var i in structures)
                {
                    i.Decouple();
                }
                foreach (var i in deathCache)
                {
                    i.Decouple();
                }
            }

            // Assign updated data to public properties
            newGameData.CopyTo(this);

            // Force an immediate garbage collection because it seems more effective (extraction process requires a great deal of memory)
            //GC.Collect();
        }
        private void ApplyNewData(ArkSavegame save, ArkTamedCreature[] tamed, ArkWildCreature[] wild, ArkPlayer[] players, ArkTribe[] tribes, ArkItem[] items, ArkStructure[] structures, bool decouple = true)
        {
            // Setup relations in the domain model between entities
            var newGameData = new ArkGameDataBase(save.SaveState, tamed, wild, players, tribes, items, structures);

            newGameData.Initialize(_clusterData);
            foreach (var i in tamed)
            {
                i.Initialize(newGameData, _clusterData);
            }
            foreach (var i in wild)
            {
                i.Initialize(newGameData, _clusterData);
            }
            foreach (var i in players)
            {
                i.Initialize(newGameData, _clusterData);
            }
            foreach (var i in tribes)
            {
                i.Initialize(newGameData, _clusterData);
            }
            foreach (var i in items)
            {
                i.Initialize(newGameData, _clusterData);
            }
            foreach (var i in structures)
            {
                i.Initialize(newGameData, _clusterData);
            }

            if (decouple) //should always be true except for debugging
            {
                // Unset all references to raw extracted game objects and properties to free memory
                foreach (var i in tamed)
                {
                    i.Decouple();
                }
                foreach (var i in wild)
                {
                    i.Decouple();
                }
                foreach (var i in players)
                {
                    i.Decouple();
                }
                foreach (var i in tribes)
                {
                    i.Decouple();
                }
                foreach (var i in items)
                {
                    i.Decouple();
                }
                foreach (var i in structures)
                {
                    i.Decouple();
                }
            }

            // Assign updated data to public properties
            newGameData.CopyTo(this);
        }