quantum-space-buddies/QSB/AuthoritySync/IAuthWorldObject_Extensions.cs

37 lines
820 B
C#
Raw Normal View History

2022-08-16 06:17:50 +00:00
using QSB.Messaging;
using QSB.Player;
namespace QSB.AuthoritySync;
2022-08-16 06:34:12 +00:00
public static class IAuthWorldObject_Extensions
2022-08-16 06:17:50 +00:00
{
/// <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;
}
2022-08-16 06:38:51 +00:00
authWorldObject.SendMessage(new AuthWorldObjectMessage(QSBPlayerManager.LocalPlayerId));
2022-08-16 06:17:50 +00:00
}
/// <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;
}
2022-08-16 06:38:51 +00:00
authWorldObject.SendMessage(new AuthWorldObjectMessage(QSBPlayerManager.LocalPlayerId));
2022-08-16 06:17:50 +00:00
}
}