using NativeMapDoc; using System; using System.ComponentModel.DataAnnotations; namespace Editor.MapDoc; /// /// 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. /// [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 ); } }