//
// Generated by Brutal.Jolt.Generate; do not edit by hand.
#nullable enable
using System.Runtime.CompilerServices;
using Brutal.Interop;
using Brutal.Numerics;
namespace Brutal.JoltApi
{
///
///
/// Specialization that locks a body for writing to. @see BodyLockRead for usage patterns.
///
///
/// C++:
/// Jolt/Physics/Body/BodyLock.h:106
///
/// class BodyLockWrite : public BodyLockBase<true, Body>
///
///
[InteropHandle]
public readonly partial struct BodyLockWrite : IDisposable
{
///
///
/// Takes the write lock on one body, held until Dispose (or ReleaseLock). An ID that no longer names a body
/// still returns a lock, whose Succeeded() is false. Through PhysicsSystem.GetBodyLockInterface() this
/// really locks; through GetBodyLockInterfaceNoLock() it doesn't, for code that already runs where no other
/// thread can touch the body.
///
///
public static BodyLockWrite Create(BodyLockInterface lockInterface, uint bodyID) =>
Jolt.PInvoke.BodyLockWrite_Create(lockInterface, bodyID);
///
///
/// Whether the ID named a body, so GetBody() has one.
///
///
public bool Succeeded() => Jolt.PInvoke.BodyLockWrite_Succeeded(this);
///
///
/// Whether the ID named a body that is also in the broad phase (added to the physics system).
///
///
public bool SucceededAndIsInBroadPhase() => Jolt.PInvoke.BodyLockWrite_SucceededAndIsInBroadPhase(this);
///
///
/// The locked body, or a null handle when Succeeded() is false (where Jolt itself would assert). It is
/// borrowed and only safe to use while the lock is held.
///
///
public Body GetBody() => Jolt.PInvoke.BodyLockWrite_GetBody(this);
///
///
/// Releases the lock early; Dispose is still needed to free the lock object. GetBody() is null afterwards.
///
///
public void ReleaseLock() => Jolt.PInvoke.BodyLockWrite_ReleaseLock(this);
public void Dispose() => Jolt.PInvoke.BodyLockWrite_Destroy(this);
}
}