mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-01 03:32:38 +00:00
37 lines
803 B
C#
37 lines
803 B
C#
|
using QSB.Messaging;
|
|||
|
using QSB.Player;
|
|||
|
|
|||
|
namespace QSB.AuthoritySync;
|
|||
|
|
|||
|
public static class 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 WorldObjectAuthMessage(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 WorldObjectAuthMessage(QSBPlayerManager.LocalPlayerId));
|
|||
|
}
|
|||
|
}
|