A scene component that applies a night vision style postprocessing to the camera. OnStart caches the scene camera GameObject, OnUpdate removes postprocess components on proxies and otherwise ensures Tonemapping, ColorAdjustments and DepthOfField components exist and sets a few properties (exposure, brightness, saturation, focus range).
using Sandbox;
public class NightVision : Component
{
GameObject c;
protected override void OnStart()
{c = Scene.Camera.GameObject;}
protected override void OnUpdate()
{
if (IsProxy)
{
c.GetOrAddComponent<Tonemapping>().Destroy();
c.GetOrAddComponent<ColorAdjustments>().Destroy();
c.GetOrAddComponent<DepthOfField>().Destroy();
return; }
var tm = c.GetOrAddComponent<Tonemapping>();
var ca = c.GetOrAddComponent<ColorAdjustments>();
var dof = c.GetOrAddComponent<DepthOfField>();
tm.MaximumExposure = 5;
tm.Rate = 10;
ca.Brightness = 2;
ca.Saturation = 0;
dof.FocusRange = 1000;
}
}