using NativeEngine; namespace Sandbox; // // garry: // // I decided to keep this seperate from SceneLayerType because that was implemented // when I had no idea what was going on.. SceneLayerType kind of serves to tell a manual // rendering sceneobject that we're rendering a shadow layer etc.. // /// /// SceneObjects can be rendered on layers other than the main game layer. /// This is useful if, for example, you want to render on top of everything without /// applying post processing. /// public enum SceneRenderLayer { /// /// Draw wherever makes sense based on the flags, default behaviour /// Default, /// /// Layer drawn on top of everything else - with altered depth /// ViewModel = 10, /// /// Overlay - after post processing - but still with the scene's depth /// OverlayWithDepth = 20, /// /// Overlay - after post processing - without depth (draw over) /// OverlayWithoutDepth = 30 } internal static class SceneRenderLayerHelper { /// /// Internally we don't pass these enums, they're just string tokens. /// No need to expose the actual string tokens to people unless we expose the render pipeline fully to them. /// public static Dictionary Names = new Dictionary() { { SceneRenderLayer.ViewModel, "viewmodel" }, { SceneRenderLayer.OverlayWithDepth, "OverlayWithDepth" }, { SceneRenderLayer.OverlayWithoutDepth, "OverlayWithoutDepth" } }; } public partial class SceneObject { SceneRenderLayer _renderLayer; /// /// For a layer to draw this object, the target layer must match (or be unset) /// and the flags must match /// public SceneRenderLayer RenderLayer { get => _renderLayer; set { if ( value == _renderLayer ) return; // if not found or default we'll set it to default if ( !SceneRenderLayerHelper.Names.TryGetValue( value, out var layer ) ) { native.SetLayerMatchID( null ); return; } _renderLayer = value; native.SetLayerMatchID( layer ); } } }