Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public ushort NetworkID
public bool IsOwnedLocallyOnClient = false;
public ushort CurrentOwnerId;
public BasisNetworkPlayer currentOwnedPlayer;

/// <summary>
/// the reason its start instead of awake is to make sure progation occurs to everything no matter the net connect
/// </summary>
Expand Down Expand Up @@ -122,6 +121,8 @@ private void LowLevelOwnershipReleased(string uniqueEntityID)
{
if (uniqueEntityID == clientIdentifier)
{
IsOwnedLocallyOnServer = false;
IsOwnedLocallyOnClient = false;
OnServerOwnershipDestroyed();
}
}
Expand All @@ -142,6 +143,7 @@ private void LowLevelOwnershipTransfer(string uniqueEntityID, ushort NetIdNewOwn
BasisUnInitalizedPlayer UnInitalizedPlayer = new BasisUnInitalizedPlayer(CurrentOwnerId);
BasisDebug.LogError($"No Owner for Id {CurrentOwnerId} Creating Fake {nameof(BasisUnInitalizedPlayer)} this should only occur rarely");
UnInitalizedPlayer.Initialize();
currentOwnedPlayer = UnInitalizedPlayer;
OnOwnershipTransfer(UnInitalizedPlayer);
}
}
Expand Down Expand Up @@ -302,6 +304,18 @@ public async Task<BasisOwnershipResult> RequestWhoIsOwnershipAsync(int Timout =
BasisOwnershipResult Result = await BasisNetworkOwnership.RequestCurrentOwnershipAsync(clientIdentifier, Timout);
return Result;
}

public bool TryGetOwnerId(out ushort OwnerId)
{
if (currentOwnedPlayer != null && currentOwnedPlayer.IsOwnerCached(clientIdentifier))
{
OwnerId = currentOwnedPlayer.playerId;
return true;
}
OwnerId = 0;
return false;
}

public virtual void OnNetworkReady()
{

Expand Down
2 changes: 2 additions & 0 deletions Basis/Packages/com.basis.shim/Shims/BasisNetworkShim.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ namespace Basis.Shims
{
public class BasisNetworkShim : BasisNetworkBehaviour
{
public DateTime NetworkTime => BasisNetworkManagement.RemoteUtcTime();
public long NetworkDeltaTime => BasisNetworkManagement.RemoteTimeDelta();
public delegate void NetworkReadyEvent();
public delegate void ServerOwnershipDestroyedEvent();
public delegate void OwnershipTransferEvent(BasisNetworkPlayer NewOwner);
Expand Down
5 changes: 4 additions & 1 deletion Basis/Packages/com.basis.shim/Shims/CilboxPropBasis.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public class CilboxPropBasis : Cilbox
"UnityEngine.Collision",
"UnityEngine.Events.UnityAction",
"UnityEngine.Events.UnityEvent",
"UnityEngine.EventSystems.*",
"UnityEngine.GameObject", // Hyper restrictive.
"UnityEngine.Material",
"UnityEngine.MaterialPropertyBlock",
Expand All @@ -86,6 +87,7 @@ public class CilboxPropBasis : Cilbox
"UnityEngine.Transform",
"UnityEngine.Quaternion",
"UnityEngine.Rigidbody",
"UnityEngine.RectTransform",
"UnityEngine.RenderTexture",
"UnityEngine.RenderTextureFormat",
"UnityEngine.UI.*",
Expand All @@ -107,6 +109,7 @@ public class CilboxPropBasis : Cilbox
"UnityEngine.Vector*.y",
"UnityEngine.Vector*.z",
"UnityEngine.Vector*.w",
"UnityEngine.EventSystems.EventTrigger+Entry.*",

// System fields
"System.Array.*",
Expand All @@ -118,7 +121,7 @@ public class CilboxPropBasis : Cilbox
"Basis.Scripts.BasisSdk.Interactions.BasisInteractableObject.OnInteractStartEvent",
"Basis.Scripts.BasisSdk.Interactions.BasisInteractableObject.OnInteractEndEvent",
"Basis.BasisNetworkBehaviour.CurrentOwnerId",
"Basis.BasisNetworkBehaviour.IsOwnedLocallyOnServer",
"Basis.BasisNetworkBehaviour.IsOwnedLocally*",
};

static public HashSet<String> GetWhiteListTypes() { return whiteListType; }
Expand Down
10 changes: 4 additions & 6 deletions Basis/Packages/com.basis.shim/Shims/CilboxSceneBasis.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,7 @@ public class CilboxSceneBasis : Cilbox
"UnityEngine.DynamicGI",
"UnityEngine.Events.UnityAction",
"UnityEngine.Events.UnityEvent",
"UnityEngine.EventSystems.BaseEventData",
"UnityEngine.EventSystems.EventTrigger",
"UnityEngine.EventSystems.EventTrigger+Entry",
"UnityEngine.EventSystems.EventTrigger+TriggerEvent",
"UnityEngine.EventSystems.EventTriggerType",
"UnityEngine.EventSystems.*",
"UnityEngine.GameObject", // Hyper restrictive.
"UnityEngine.Gradient",
"UnityEngine.LayerMask",
Expand All @@ -107,6 +103,7 @@ public class CilboxSceneBasis : Cilbox
"UnityEngine.ParticleSystem",
"UnityEngine.Quaternion",
"UnityEngine.Random",
"UnityEngine.RectTransform",
"UnityEngine.Renderer",
"UnityEngine.RenderTextureFormat",
"UnityEngine.Rendering.AmbientMode",
Expand All @@ -125,14 +122,15 @@ public class CilboxSceneBasis : Cilbox
static HashSet<String> whiteListFields = new HashSet<String>(){
// Basis fields
"Basis.BasisNetworkBehaviour.CurrentOwnerId",
"Basis.BasisNetworkBehaviour.IsOwnedLocallyOnServer",
"Basis.BasisNetworkBehaviour.IsOwnedLocally*",
"Basis.Scripts.Networking.NetworkedAvatar.BasisNetworkPlayer.playerId",

// Unity fields
"UnityEngine.Vector*.x",
"UnityEngine.Vector*.y",
"UnityEngine.Vector*.z",
"UnityEngine.Vector*.w",
"UnityEngine.EventSystems.EventTrigger+Entry.*",

// System fields
"System.Array.*",
Expand Down
Loading