public ISyncAttribute GetSyncAttribute(uint syncId) { ISyncAttribute attribute = null; m_AttrIdDys.TryGetValue(syncId, out attribute); return(attribute); }
private void OnUpdate(float delta) { m_List.Clear(); if (m_World.CopyEntities(m_List)) { int length = m_List.Count; for (int i = 0; i < length; ++i) { Entity entity = m_List[i]; List <ISyncAttribute> attributes = entity.Sync.Attributes; if (attributes.Count > 0) { for (int j = 0; j < attributes.Count; ++j) { ISyncAttribute attribute = attributes[j]; if (attribute.IsDirty()) { ByteBuffer buffer = ByteBuffer.Allocate(512); buffer.Write(entity.EntityId); buffer.Write(attribute.GetSyncId()); attribute.Serialize(buffer); //NetworkServerManager.Broadcast(MsgID.Sync_Attribute, buffer, ChannelType.Reliable); } } } } } }
public T GetSyncAttribute <T>() where T : ISyncAttribute { ISyncAttribute attribute = default(T); m_AttrTypeDys.TryGetValue(typeof(T), out attribute); return((T)attribute); }
private void OnSyncAttribute(ChannelMessage msg) { ByteBuffer buffer = msg.Buffer; uint eid = buffer.ReadUInt(); uint syncId = buffer.ReadUInt(); Entity entity = m_World.GetEntity(eid); if (entity != null) { ISyncAttribute attribute = entity.GetSyncAttribute(syncId); if (attribute != null) { attribute.Deserialize(buffer); } } }