Partial ViewModel class extension that adds throwable weapon support. It defines a Throwable enum, two properties (IsThrowable and ThrowableType) with feature attributes, and sets a renderer parameter when the view model is enabled.
public partial class ViewModel
{
/// <summary>
/// Throwable type
/// </summary>
public enum Throwable
{
HEGrenade,
SmokeGrenade,
StunGrenade,
Molotov,
Flashbang
}
/// <summary>
/// Is this a throwable?
/// </summary>
[Property, FeatureEnabled( "Throwables" )] public bool IsThrowable { get; set; }
/// <summary>
/// The throwable type
/// </summary>
[Property, Feature( "Throwables" )] public Throwable ThrowableType { get; set; }
protected override void OnEnabled()
{
if ( IsThrowable )
{
Renderer?.Set( "throwable_type", (int)ThrowableType );
}
}
}