mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-01-25 14:49:28 -05:00
This commit imports the C# engine code and game files, excluding C++ source code. [Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
38 lines
1.0 KiB
C#
38 lines
1.0 KiB
C#
namespace Sandbox;
|
|
|
|
public partial class Material
|
|
{
|
|
/// <summary>
|
|
/// Access flags on this material, which usually hint about the contents. These are generally added by
|
|
/// the shader procedurally - but developers can add these in material editor too.
|
|
/// </summary>
|
|
public FlagsAccessor Flags => new FlagsAccessor( this );
|
|
|
|
public readonly ref struct FlagsAccessor
|
|
{
|
|
private readonly Material material;
|
|
|
|
public FlagsAccessor( Material material )
|
|
{
|
|
this.material = material;
|
|
}
|
|
|
|
public int GetInt( string name, int defaultValue = 0 )
|
|
{
|
|
return this.material.native.GetIntAttributeOrDefault( name, defaultValue );
|
|
}
|
|
|
|
public float GetFloat( string name, float defaultValue = 0 )
|
|
{
|
|
return this.material.native.GetFloatAttributeOrDefault( name, defaultValue );
|
|
}
|
|
|
|
public bool IsSky => GetInt( "sky" ) != 0;
|
|
public bool IsTranslucent => GetInt( "translucent" ) != 0;
|
|
public bool IsAlphaTest => GetInt( "alphatest" ) != 0;
|
|
|
|
[Obsolete( "Decal materials are obsolete" )]
|
|
public bool IsDecal => GetInt( "decal" ) != 0;
|
|
}
|
|
}
|