Beispiel #1
0
		internal static VoxelType LoadExtendedVoxelType( VoxelProperties props, int type )
		{
			Assembly a = loaded_objects[type];
			if( a == null )
				if( LoadVoxelCode( props, type ) )
					a = loaded_objects[type];

			if( a != null )
			{
				Type[] types = a.GetTypes();
				foreach( Type t in types )
				{
					if( t.BaseType.Name == "VoxelType" )
					{
						object o = Activator.CreateInstance( t );
						return o as VoxelType;
					}
				}
			}
			return null;
		}
Beispiel #2
0
		public static VoxelProperties Load( ushort type )
		{
			VoxelProperties props = new VoxelProperties( type );
			props.LoadVoxelProperties();
			return props;
		}
Beispiel #3
0
		internal static bool LoadVoxelCode( VoxelProperties props, int type )
		{
			string FileName;
			if( loaded_objects.ContainsKey( type ) )
				return true;
			if( type < 32768 )
			{
				FileName = VoxelGlobalSettings.COMPILEOPTION_DATAFILESPATH + "VoxelTypes/voxelinfo/" + String.Format( "voxelcode_" + type + ".cs" );
			}
			else
			{
				FileName = VoxelGlobalSettings.USERDATA_DIRECTORY
					+ "/" + VoxelGlobalSettings.COMPILEOPTION_SAVEFOLDERNAME
					+ "/VoxelTypes/voxelinfo/" + String.Format( "voxelcode_" + type + ".cs" );
			}
			if( File.Exists( FileName ) )
			{
				string code = File.ReadAllText( FileName );
				Assembly a = CompileCode( props.VoxelClassName, code, FileName, null );
				if( a != null && AllowAssembly( a ) )
				{
					loaded_objects.Add( type, a );
					return true;
				}
			}
			return false;
		}
Beispiel #4
0
		public void SetProperties( VoxelProperties props ) { properties = props; if( PropertiesSet != null ) PropertiesSet(); }