<commit_before>﻿using System;
using System.Collections.Generic;
using System.Reflection;


namespace Nez
{
	public static class ComponentTypeManager
	{
		private static Dictionary<Type,int> _componentTypesMask = new Dictionary<Type, int>();


		public static void initialize()
		{
			var currentDomain = typeof( string ).Assembly.GetType( "System.AppDomain" ).GetProperty( "CurrentDomain" ).GetGetMethod().Invoke( null, new object[] { } );
			var getAssemblies = currentDomain.GetType().GetMethod( "GetAssemblies", new Type[]{ } );
			var assemblies = getAssemblies.Invoke( currentDomain, new object[]{ } ) as Assembly[];

			foreach( var assembly in assemblies )
			{
				foreach( var type in assembly.GetTypes() )
				{
					if( typeof( Component ).IsAssignableFrom( type ) )
					{
						add( type );
					}
				}
			}
		}


		public static void add( Type type )
		{
			int v;
			if( !_componentTypesMask.TryGetValue( type, out v ) )
				_componentTypesMask[type] = _componentTypesMask.Count;
		}


		public static int getIndexFor( Type type )
		{
			var v = -1;
			_componentTypesMask.TryGetValue( type, out v );
			return v;
		}
<commit_msg>add types after initialization if we come across one not already mapped fixes #31<commit_after>﻿using System;
using System.Collections.Generic;
using System.Reflection;


namespace Nez
{
	public static class ComponentTypeManager
	{
		private static Dictionary<Type,int> _componentTypesMask = new Dictionary<Type, int>();


		public static void initialize()
		{
			var currentDomain = typeof( string ).Assembly.GetType( "System.AppDomain" ).GetProperty( "CurrentDomain" ).GetGetMethod().Invoke( null, new object[] { } );
			var getAssemblies = currentDomain.GetType().GetMethod( "GetAssemblies", new Type[]{ } );
			var assemblies = getAssemblies.Invoke( currentDomain, new object[]{ } ) as Assembly[];

			foreach( var assembly in assemblies )
			{
				foreach( var type in assembly.GetTypes() )
				{
					if( typeof( Component ).IsAssignableFrom( type ) )
						add( type );
				}
			}
		}


		public static void add( Type type )
		{
			int v;
			if( !_componentTypesMask.TryGetValue( type, out v ) )
				_componentTypesMask[type] = _componentTypesMask.Count;
		}


		public static int getIndexFor( Type type )
		{
			var v = -1;
			if( !_componentTypesMask.TryGetValue( type, out v ) )
			{
				add( type );
				_componentTypesMask.TryGetValue( type, out v );
			}

			return v;
		}

{'fraction_non_alphanumeric': 0.11389802631578948, 'fraction_numerical': 0.001644736842105263, 'mean_word_length': 3.556179775280899, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7143478', 'n_tokens_mistral': 876, 'n_tokens_neox': 732, 'n_words': 212}