mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-02-24 00:39:52 +00:00
37 lines
820 B
C#
37 lines
820 B
C#
using QSB.Messaging;
|
|
using QSB.Player;
|
|
|
|
namespace QSB.AuthoritySync;
|
|
|
|
public static class IAuthWorldObject_Extensions
|
|
{
|
|
/// <summary>
|
|
/// try and gain authority over the object
|
|
/// </summary>
|
|
public static void RequestOwnership(this IAuthWorldObject authWorldObject)
|
|
{
|
|
if (!authWorldObject.CanOwn)
|
|
{
|
|
return;
|
|
}
|
|
if (authWorldObject.Owner != 0)
|
|
{
|
|
return;
|
|
}
|
|
authWorldObject.SendMessage(new AuthWorldObjectMessage(QSBPlayerManager.LocalPlayerId));
|
|
}
|
|
|
|
/// <summary>
|
|
/// release authority over the object,
|
|
/// potentially to giving it to someone else
|
|
/// </summary>
|
|
public static void ReleaseOwnership(this IAuthWorldObject authWorldObject)
|
|
{
|
|
if (authWorldObject.Owner == 0)
|
|
{
|
|
return;
|
|
}
|
|
authWorldObject.SendMessage(new AuthWorldObjectMessage(QSBPlayerManager.LocalPlayerId));
|
|
}
|
|
}
|