mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-01-08 22:38:28 -05:00
This commit imports the C# engine code and game files, excluding C++ source code. [Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
52 lines
1.3 KiB
C#
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 );
|
|
}
|
|
}
|