Exemplo n.º 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;
		}
Exemplo n.º 2
0
		public static VoxelProperties Load( ushort type )
		{
			VoxelProperties props = new VoxelProperties( type );
			props.LoadVoxelProperties();
			return props;
		}
Exemplo n.º 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;
		}
Exemplo n.º 4
0
		public void SetProperties( VoxelProperties props ) { properties = props; if( PropertiesSet != null ) PropertiesSet(); }