Files
sbox-public/engine/Sandbox.Tools/MapEditor/MapDoc/Nodes/MapStaticOverlay.cs
s&box team 71f266059a Open source release
This commit imports the C# engine code and game files, excluding C++ source code.

[Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
2025-11-24 09:05:18 +00:00

52 lines
1.3 KiB
C#

using NativeMapDoc;
using System;
using System.ComponentModel.DataAnnotations;
namespace Editor.MapDoc;
/// <summary>
/// An overlay which is rendered using a mesh generated by projecting faces onto
/// surrounding geometry. Baked during map compile so that there is no runtime component.
/// Also supports being limited to specific targets.
/// </summary>
[Display( Name = "Static Overlay" ), Icon( "layers" )]
public sealed class MapStaticOverlay : MapMesh
{
internal CMapStaticOverlay overlayNative;
internal MapStaticOverlay( HandleCreationData _ ) : base( _ ) { }
public MapStaticOverlay( MapDocument mapDocument = null ) : base( new HandleCreationData() )
{
ThreadSafe.AssertIsMainThread();
// Default to the active map document if none specificed
mapDocument ??= MapEditor.Hammer.ActiveMap;
Assert.IsValid( mapDocument );
using var h = IHandle.MakeNextHandle( this );
mapDocument.native.CreateStaticOverlay();
}
internal override void OnNativeInit( CMapNode ptr )
{
base.OnNativeInit( ptr );
overlayNative = (CMapStaticOverlay)ptr;
}
internal override void OnNativeDestroy()
{
base.OnNativeDestroy();
overlayNative = default;
}
public void CreateCenteredQuad( Vector2 size, Material material )
{
ArgumentNullException.ThrowIfNull( material );
overlayNative.CreateCenteredQuad( size.x, size.y, material.Name );
}
}