A partial ViewModel class extension that adds throwable support. It defines a Throwable enum, two properties (IsThrowable and ThrowableType) with attributes for serialization and feature gating, and sets a renderer parameter to the throwable type 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 );
}
}
}