/// <summary> /// 从数据库中加载 /// </summary> /// <param name="playerId"></param> public void LoadFromDatabase(int playerId) { lock (m_lock) { using (PlayerBussiness db = new PlayerBussiness()) { BufferInfo[] infos = db.GetUserBuffer(playerId); BeginChanges(); foreach (BufferInfo info in infos) { AbstractBuffer buffer = CreateBuffer(info); if (buffer != null) { buffer.Start(m_player); } } CommitChanges(); } //更新状态 Update(); } }
public void LoadFromDatabase(int playerId) { object @lock; Monitor.Enter(@lock = this.m_lock); try { using (PlayerBussiness playerBussiness = new PlayerBussiness()) { BufferInfo[] userBuffer = playerBussiness.GetUserBuffer(playerId); this.BeginChanges(); BufferInfo[] array = userBuffer; for (int i = 0; i < array.Length; i++) { BufferInfo info = array[i]; AbstractBuffer abstractBuffer = BufferList.CreateBuffer(info); if (abstractBuffer != null) { abstractBuffer.Start(this.m_player); } } this.CommitChanges(); } this.Update(); } finally { Monitor.Exit(@lock); } }
protected void OnBuffersChanged(AbstractBuffer buffer) { if (!this.m_changedBuffers.Contains(buffer)) { this.m_changedBuffers.Add(buffer); } if (this.m_changeCount <= 0 && this.m_changedBuffers.Count > 0) { this.UpdateChangedBuffers(); } }
public bool AddBuffer(AbstractBuffer buffer) { lock (m_buffers) { m_buffers.Add(buffer); } OnBuffersChanged(buffer); return(true); }
protected void OnBuffersChanged(AbstractBuffer buffer) { if (m_changedBuffers.Contains(buffer) == false) { m_changedBuffers.Add(buffer); } if (m_changeCount <= 0 && m_changedBuffers.Count > 0) { UpdateChangedBuffers(); } }
public bool RemoveBuffer(AbstractBuffer buffer) { lock (m_buffers) { if (m_buffers.Remove(buffer)) { m_clearList.Add(buffer.Info); } } OnBuffersChanged(buffer); return(true); }
public bool AddBuffer(AbstractBuffer buffer) { List <AbstractBuffer> buffers; Monitor.Enter(buffers = this.m_buffers); try { this.m_buffers.Add(buffer); } finally { Monitor.Exit(buffers); } this.OnBuffersChanged(buffer); return(true); }
public bool RemoveBuffer(AbstractBuffer buffer) { List <AbstractBuffer> buffers; Monitor.Enter(buffers = this.m_buffers); try { if (this.m_buffers.Remove(buffer)) { this.m_clearList.Add(buffer.Info); } } finally { Monitor.Exit(buffers); } this.OnBuffersChanged(buffer); return(true); }
public static AbstractBuffer CreateBuffer(BufferInfo info) { AbstractBuffer result = null; switch (info.Type) { case 11: result = new KickProtectBuffer(info); break; case 12: result = new OfferMultipleBuffer(info); break; case 13: result = new GPMultipleBuffer(info); break; case 15: result = new PropsBuffer(info); break; } return(result); }
public void UpdateBuffer(AbstractBuffer buffer) { this.OnBuffersChanged(buffer); }
public bool AddBuffer(AbstractBuffer buffer) { lock (m_buffers) { m_buffers.Add(buffer); } OnBuffersChanged(buffer); return true; }
protected void OnBuffersChanged(AbstractBuffer buffer) { if (m_changedBuffers.Contains(buffer) == false) m_changedBuffers.Add(buffer); if (m_changeCount <= 0 && m_changedBuffers.Count > 0) { UpdateChangedBuffers(); } }
public void UpdateBuffer(AbstractBuffer buffer) { OnBuffersChanged(buffer); }
public bool RemoveBuffer(AbstractBuffer buffer) { lock (m_buffers) { if (m_buffers.Remove(buffer)) { m_clearList.Add(buffer.Info); } } OnBuffersChanged(buffer); return true; }