Skip to content
Open
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 @@ -30,6 +30,8 @@ public ushort NetworkID
public ushort CurrentOwnerId;
public BasisNetworkPlayer currentOwnedPlayer;

public DateTime RemoteUtcTime => BasisNetworkManagement.RemoteUtcTime();
public long RemoteDeltaTime => BasisNetworkManagement.RemoteTimeDelta();
/// <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 +124,8 @@ private void LowLevelOwnershipReleased(string uniqueEntityID)
{
if (uniqueEntityID == clientIdentifier)
{
IsOwnedLocallyOnServer = false;
IsOwnedLocallyOnClient = false;
OnServerOwnershipDestroyed();
}
}
Expand All @@ -142,6 +146,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 +307,20 @@ public async Task<BasisOwnershipResult> RequestWhoIsOwnershipAsync(int Timout =
BasisOwnershipResult Result = await BasisNetworkOwnership.RequestCurrentOwnershipAsync(clientIdentifier, Timout);
return Result;
}

public bool TryGetOwnerId(out ushort OwnerId)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i need convincing this is better then just making people async the server and store the result

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its just a wrapper for the normal check you may do in normal C#, and this allows direct access for Cilbox scripts to ask for the OwnerId directly, reducing the amount of instructions needing to call.

{
if (currentOwnedPlayer != null && currentOwnedPlayer.IsOwnerCached(clientIdentifier))
{
OwnerId = currentOwnedPlayer.playerId;
return true;
}
OwnerId = 0;
// if we dont have it cached locally we can ask the server to give it to us to cache and invoke any ownershipTransfer events.
RequestWhoIsOwnershipAsync();
return false;
}

public virtual void OnNetworkReady()
{

Expand Down
Loading