示例#1
0
        private EntityComponent[] GetComponents(Type type)
        {
            var componentTypeGUID = EntityComponent.GetComponentTypeGUID(type);

            NativeInternals.Entity.GetComponents(NativeEntityPointer, componentTypeGUID.hipart, componentTypeGUID.lopart, out EntityComponent[] baseComponents);

            return(baseComponents);
        }
示例#2
0
        /// <summary>
        /// Returns the first EntityComponent that matches the specified type, if it exists. Otherwise, adds a new instance of the component.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public T GetOrCreateComponent <T>() where T : EntityComponent, new()
        {
            var componentTypeGUID = EntityComponent.GetComponentTypeGUID <T>();

            return(NativeInternals.Entity.GetOrCreateComponent(NativeEntityPointer, componentTypeGUID.hipart, componentTypeGUID.lopart) as T);
        }