示例#1
0
        public T AddCop <T>(ICop cop, Entity entity) where T : ICop
        {
            Type type = cop.GetType();

            if (!m_Cops.ContainsKey(type))
            {
                m_Cops.Add(type, cop);
                cop.Entity = entity;
                cop.World  = entity.World;
                cop.OnInit();
            }

            return((T)cop);
        }
示例#2
0
        public void AddEntity(Entity entity)
        {
            uint entityId = entity.EntityId;

            if (!m_Entities.ContainsKey(entityId))
            {
                m_Entities.Add(entityId, entity);
                entity.World = m_World;
                entity.OnInit();
            }
        }
示例#3
0
        public T RegisterProtocol <T>() where T : AbsProtocolHandler, new()
        {
            Type t = typeof(T);

            if (!m_Protocols.ContainsKey(t))
            {
                T handler = new T();
                handler.Connection = this;
                handler.Register();
                m_Protocols.Add(t, handler);
                return(handler);
            }
            return(default);