Exemplo n.º 1
0
        private void UpdateNewlySpawnedCreaturesTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            updateNewlySpawnedCreaturesTimer.Stop();

            if (MiniGrouperScript == null)
            {
                return;
            }

            List <string>             foundCreatureIds         = new List <string>();
            List <CreatureBoardAsset> foundCreatureBoardAssets = new List <CreatureBoardAsset>();

            bool readyToInitializePlayers = false;

            lock (newlySpawnedCreatureLock)
            {
                foreach (string newlySpawnedCreatureId in newlySpawnedCreatureIds)
                {
                    CreatureBoardAsset creatureBoardAsset = Talespire.Minis.GetCreatureBoardAsset(newlySpawnedCreatureId);
                    if (creatureBoardAsset != null)
                    {
                        foundCreatureIds.Add(newlySpawnedCreatureId);
                        foundCreatureBoardAssets.Add(creatureBoardAsset);
                    }
                }

                foreach (string foundCreatureId in foundCreatureIds)
                {
                    newlySpawnedCreatureIds.Remove(foundCreatureId);
                }

                readyToInitializePlayers = newlySpawnedCreatureIds.Count == 0;
            }

            foreach (CreatureBoardAsset creatureBoardAsset in foundCreatureBoardAssets)
            {
                MiniGrouperScript.AddMemberToGroup(creatureBoardAsset);
            }

            if (readyToInitializePlayers)
            {
                InitializeNewlySpawnedCreatures();
            }
            else
            {
                updateNewlySpawnedCreaturesTimer.Start();                  // Try again in a moment.
            }
        }