mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-01-03 03:48:24 -05:00
This commit imports the C# engine code and game files, excluding C++ source code. [Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
56 lines
1.4 KiB
C#
56 lines
1.4 KiB
C#
using NativeMapDoc;
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
namespace Editor.MapDoc;
|
|
|
|
/// <summary>
|
|
/// A map node which allows a target group and its children to be placed with a new position
|
|
/// and orientation in the world without creating a new copy.
|
|
///
|
|
/// Multiple MapInstance classes may reference the same target allowing it to be placed in
|
|
/// multiple locations, but allowing any edits to be applied to all instances.
|
|
/// </summary>
|
|
[Display( Name = "Instance" ), Icon( "content_copy" )]
|
|
public sealed class MapInstance : MapNode
|
|
{
|
|
internal CMapInstance instanceNative;
|
|
|
|
internal MapInstance( HandleCreationData _ ) { }
|
|
|
|
public MapInstance( MapDocument mapDocument = null )
|
|
{
|
|
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.CreateMapInstance();
|
|
}
|
|
|
|
internal override void OnNativeInit( CMapNode ptr )
|
|
{
|
|
base.OnNativeInit( ptr );
|
|
|
|
instanceNative = (CMapInstance)ptr;
|
|
}
|
|
|
|
internal override void OnNativeDestroy()
|
|
{
|
|
base.OnNativeDestroy();
|
|
|
|
instanceNative = default;
|
|
}
|
|
|
|
/// <summary>
|
|
/// The target map node this MapInstance references to copy.
|
|
/// </summary>
|
|
public MapNode Target
|
|
{
|
|
get => instanceNative.GetTarget();
|
|
set => instanceNative.SetTarget( value );
|
|
}
|
|
}
|