Exemplo n.º 1
0
        private void RemovePlayerByUserId(uint userId)
        {
            int i = GetPlayerIndexByUserId(userId);

            if (i >= 0)
            {
                m_data.players.RemoveAt(i);
            }

            if (m_mapUserId2Address.ContainsKey(userId))
            {
                m_mapUserId2Address.Remove(userId);
            }
        }
Exemplo n.º 2
0
        static void JournalHandler_JournalEntryAdded(object sender, JournalEntryAddedEventArgs e)
        {
            UpdateInstance(defaultInstance, e);

            List <int> removeList = new List <int>();

            lock (instanceList.SyncRoot) {
                foreach (KeyValuePair <int, Instance> pair in instanceList)
                {
                    if (pair.Value.Thread.IsAlive)
                    {
                        UpdateInstance(pair.Value, e);
                    }
                    else
                    {
                        removeList.Add(pair.Key);
                    }
                }
            }

            for (int i = 0; i < removeList.Count; i++)
            {
                instanceList.Remove(removeList[i]);
            }

            try {
                entryAddedEvent.Invoke(null, e);
            }
            catch (Exception ex) {
                System.Diagnostics.Trace.WriteLine("Unhandled exception in Journal.LineAdded event. Details:\n" + ex.ToString(), "Error");
            }
        }
Exemplo n.º 3
0
        public static void ReleaseView(EntityObject entity)
        {
            if (entity == null)
            {
                return;
            }

            ViewObject viewObj;

            if ((viewObj = m_objMap[entity]) == null)
            {
                return;
            }

            if (EnableLog && Debugger.EnableLog)
            {
                Debugger.Log(LOG_TAG, "ReleaseView() {0}:{1} -> {2}:{3}",
                             entity.GetType().Name, entity.GetHashCode(),
                             viewObj.GetRecycleType(), viewObj.GetInstanceID());
            }

            m_objMap.Remove(entity);
            viewObj.ReleaseInFactory();
            viewObj.gameObject.SetActive(false);

            // 将对象存入到对象池中
            m_recycler.Push(viewObj);
        }
Exemplo n.º 4
0
        public void DisposeConnection(uint connId)
        {
            IConnection conn = m_mapConnection[connId];

            if (conn != null)
            {
                m_mapConnection.Remove(connId);
                conn.Dispose();
            }
        }
Exemplo n.º 5
0
        public static void ReleaseView(EntityObject entity)
        {
            if (entity != null)
            {
                ViewObject obj = m_mapObject[entity];
                if (obj != null)
                {
                    if (EnableLog && Debuger.EnableLog)
                    {
                        Debuger.Log(LOG_TAG, "ReleaseView() {0}:{1} -> {2}:{3}",
                                    entity.GetType().Name, entity.GetHashCode(),
                                    obj.GetRecycleType(), obj.GetInstanceID());
                    }

                    m_mapObject.Remove(entity);
                    obj.ReleaseInFactory();
                    obj.gameObject.SetActive(false);

                    //将对象加入对象池
                    m_recycler.Push(obj);
                }
            }
        }