mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-01 03:32:38 +00:00
helpers helpers helpers
This commit is contained in:
parent
3c9c024fcd
commit
635eeca04c
@ -1,5 +1,4 @@
|
|||||||
using QSB.Messaging;
|
using QSB.Messaging;
|
||||||
using QSB.Player;
|
|
||||||
using QSB.WorldSync;
|
using QSB.WorldSync;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
@ -18,26 +17,4 @@ public abstract class AuthWorldObject<T> : WorldObject<T>, IAuthWorldObject
|
|||||||
{
|
{
|
||||||
((IAuthWorldObject)this).SendMessage(new WorldObjectAuthMessage(Owner) { To = to });
|
((IAuthWorldObject)this).SendMessage(new WorldObjectAuthMessage(Owner) { To = to });
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RequestOwnership()
|
|
||||||
{
|
|
||||||
if (!CanOwn)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (Owner != 0)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
((IAuthWorldObject)this).SendMessage(new WorldObjectAuthMessage(QSBPlayerManager.LocalPlayerId));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ReleaseOwnership()
|
|
||||||
{
|
|
||||||
if (Owner == 0)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
((IAuthWorldObject)this).SendMessage(new WorldObjectAuthMessage(QSBPlayerManager.LocalPlayerId));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
36
QSB/AuthoritySync/Extensions.cs
Normal file
36
QSB/AuthoritySync/Extensions.cs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
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));
|
||||||
|
}
|
||||||
|
}
|
@ -25,19 +25,18 @@ namespace QSB.EchoesOfTheEye.LightSensorSync.WorldObjects;
|
|||||||
/// the sector it's enabled in is bigger than the sector the zone2 walls are enabled in :(
|
/// the sector it's enabled in is bigger than the sector the zone2 walls are enabled in :(
|
||||||
/// maybe this can be fixed by making the collision group use the same sector.
|
/// maybe this can be fixed by making the collision group use the same sector.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal class QSBLightSensor : WorldObject<SingleLightSensor>, IAuthWorldObject
|
internal class QSBLightSensor : AuthWorldObject<SingleLightSensor>
|
||||||
{
|
{
|
||||||
internal bool _locallyIlluminated;
|
internal bool _locallyIlluminated;
|
||||||
public Action OnDetectLocalLight;
|
public Action OnDetectLocalLight;
|
||||||
public Action OnDetectLocalDarkness;
|
public Action OnDetectLocalDarkness;
|
||||||
|
|
||||||
|
|
||||||
public uint Owner { get; set; }
|
public override bool CanOwn => AttachedObject.enabled;
|
||||||
public bool CanOwn => AttachedObject.enabled;
|
|
||||||
|
|
||||||
|
|
||||||
public override void SendInitialState(uint to)
|
public override void SendInitialState(uint to)
|
||||||
{
|
{
|
||||||
|
base.SendInitialState(to);
|
||||||
// todo initial state
|
// todo initial state
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user