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