OMRVisualFoundation.Scope.cs
using Sandbox;

/// <summary>
/// Independent scope-feed presentation profile.
///
/// The physical M700 scope always reads this profile from OMRVisualFoundation.
/// When ScopeInheritWorldLook is enabled the PiP mirrors the world treatment;
/// otherwise it uses the independent settings below. Scope glass, reticle and
/// the physical weapon remain outside this image treatment.
/// </summary>
public sealed partial class OMRVisualFoundation
{
    [Property, Group( "Scope Look" ), Title( "Inherit World Look" )]
    [Description( "When enabled, the scope PiP mirrors the effective World Look. Disable to author an independent scope-feed treatment." )]
    public bool ScopeInheritWorldLook { get; set; } = true;

    [Property, Group( "Scope Look" ), Title( "Enable Independent Scope Look" )]
    [Description( "Only used when Inherit World Look is disabled." )]
    public bool EnableScopeLook { get; set; } = false;

    [Property, Group( "Scope Look" ), Range( 0f, 1f ), Title( "Blend Weight" )]
    [Description( "Only used when Inherit World Look is disabled." )]
    public float ScopeBlendWeight { get; set; } = 1f;

    [Button, Group( "Scope Look" ), Title( "Reset Scope Look" )]
    public void ResetScopeLook()
    {
        ScopeInheritWorldLook = true;
        EnableScopeLook = false;
        ScopeBlendWeight = 1f;
        EnableScopePixelate = false;
        ScopePixelateScale = 0f;
        EnableScopeColorAdjustments = false;
        ScopeBrightness = 1f;
        ScopeContrast = 1f;
        ScopeSaturation = 1f;
        ScopeHueRotate = 0f;
        EnableScopeFilmGrain = false;
        ScopeFilmGrainIntensity = 0f;
        ScopeFilmGrainResponse = 0.5f;
    }

    [Property, Group( "Scope Look/Pixelate" ), Title( "Enable Pixelate" )]
    public bool EnableScopePixelate { get; set; } = false;

    [Property, Group( "Scope Look/Pixelate" ), Range( 0f, 1f ), Title( "Pixelate Scale" )]
    public float ScopePixelateScale { get; set; } = 0f;

    [Property, Group( "Scope Look/Color" ), Title( "Enable Color Adjustments" )]
    public bool EnableScopeColorAdjustments { get; set; } = false;

    [Property, Group( "Scope Look/Color" ), Range( 0f, 2f ), Title( "Brightness" )]
    public float ScopeBrightness { get; set; } = 1f;

    [Property, Group( "Scope Look/Color" ), Range( 0f, 2f ), Title( "Contrast" )]
    public float ScopeContrast { get; set; } = 1f;

    [Property, Group( "Scope Look/Color" ), Range( 0f, 2f ), Title( "Saturation" )]
    public float ScopeSaturation { get; set; } = 1f;

    [Property, Group( "Scope Look/Color" ), Range( -180f, 180f ), Title( "Hue Rotate" )]
    public float ScopeHueRotate { get; set; } = 0f;

    [Property, Group( "Scope Look/Film Grain" ), Title( "Enable Film Grain" )]
    public bool EnableScopeFilmGrain { get; set; } = false;

    [Property, Group( "Scope Look/Film Grain" ), Range( 0f, 1f ), Title( "Intensity" )]
    public float ScopeFilmGrainIntensity { get; set; } = 0f;

    [Property, Group( "Scope Look/Film Grain" ), Range( 0f, 1f ), Title( "Tonal Response" )]
    [Description( "0 = uniform grain strength. Higher values bias the legacy procedural grain toward darker image regions." )]
    public float ScopeFilmGrainResponse { get; set; } = 0.5f;

    public float EffectiveScopeLookBlend =>
        ScopeInheritWorldLook
            ? EffectiveWorldLookBlend
            : (EnableScopeLook ? MathX.Clamp( ScopeBlendWeight, 0f, 1f ) : 0f);

    public float EffectiveScopePixelateScale =>
        ScopeInheritWorldLook
            ? EffectivePixelateScale
            : (EnableScopeLook && EnableScopePixelate
                ? MathX.Clamp( ScopePixelateScale, 0f, 1f )
                : 0f);

    public bool EffectiveScopeColorAdjustmentsEnabled =>
        ScopeInheritWorldLook
            ? EffectiveColorAdjustmentsEnabled
            : EnableScopeLook && EnableScopeColorAdjustments;

    public float EffectiveScopeBrightness =>
        ScopeInheritWorldLook
            ? EffectiveBrightness
            : MathX.Clamp( ScopeBrightness, 0f, 2f );

    public float EffectiveScopeContrast =>
        ScopeInheritWorldLook
            ? EffectiveContrast
            : MathX.Clamp( ScopeContrast, 0f, 2f );

    public float EffectiveScopeSaturation =>
        ScopeInheritWorldLook
            ? EffectiveSaturation
            : MathX.Clamp( ScopeSaturation, 0f, 2f );

    public float EffectiveScopeHueRotate =>
        ScopeInheritWorldLook
            ? EffectiveHueRotate
            : MathX.Clamp( ScopeHueRotate, -180f, 180f );

    public float EffectiveScopeFilmGrainIntensity =>
        ScopeInheritWorldLook
            ? EffectiveFilmGrainIntensity
            : (EnableScopeLook && EnableScopeFilmGrain
                ? MathX.Clamp( ScopeFilmGrainIntensity, 0f, 1f )
                : 0f);

    public float EffectiveScopeFilmGrainResponse =>
        ScopeInheritWorldLook
            ? EffectiveFilmGrainResponse
            : MathX.Clamp( ScopeFilmGrainResponse, 0f, 1f );
}