Files
sbox-public/engine/Sandbox.Engine/Scene/Components/Component.Id.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

37 lines
716 B
C#

namespace Sandbox;
public partial class Component
{
private Guid _id = Guid.NewGuid();
public Guid Id
{
get => _id;
private set
{
if ( _id == value ) return;
var oldId = _id;
_id = value;
Scene?.Directory?.Add( this, oldId );
}
}
/// <summary>
/// Should only be called by <see cref="GameObjectDirectory.Add( Component )"/>.
/// </summary>
internal void ForceChangeId( Guid guid )
{
_id = guid;
}
/// <summary>
/// Allows overriding the ID of this object. This should be used sparingly, and only when necessary.
/// This is generally used for network reasons, to make something deterministic.
/// </summary>
internal void SetDeterministicId( Guid id )
{
Id = id;
}
}