Class GGEntityAccessManager extends Node

Manages player access to an entity by establishing a context.

Players (Clients) that want to interact with a scene make a request to the scene's access manager and specify the entity/actor they will act on behalf of.

The actor is represented by a [Node], such as the player character. The access manager grants access by returning a context ID (integer). The context ID is then used by the client to perform subsequent actions as that actor.

The access_policy encapsulates the logic that determines whether access should be granted.

Use case example: A character/actor requests access to a "storage box" entity so the player can interact with the storage box inventory on behalf of the character.

# Signals

## Emitted when a context was opened. The signal will be emitted on both the server and the client that made the [method open_context] request.
signal context_opened(context_id: intactor: Nodenonce: intremote_sender_id: int)
## Emitted when opening a context was denied. The signal will be emitted on both the server and the client that made the [method open_context] request.
signal context_denied(actor: Nodenonce: intremote_sender_id: int)
## Emitted when a context was closed. The signal will be emitted on both the server and the client that made the [method close_context] request. The signal may also be emitted when the server decides to close a context for any other reason, such as when [method close_all_contexts] is used.
signal context_closed(context_id: intactor: Nodenonce: intremote_sender_id: int)

# Members

## The access policy determines whether opening a context succeeds
var access_policy: GGEntityAccessPolicy = new()
## Limits the number of concurrent contexts a single client (i.e. [code]remote_sender_id[/code]) can have open.
var max_contexts_per_client: int = 5
## When enabled, [method get_subscribers] returns [code]0[/code] to broadcast an RPC to all clients. This bypasses the need for [method open_context], if the [member access_policy] supports it.
var sync_with_all_clients: bool = false
## How long the client should wait on the server for a reply when opening a context before considering it a failure. Only used client-side.
var await_rpc_timeout: float = 5.0

# Methods

## Attempts to open a context for an [param actor]. Returns a [code]context_id[/code] or [code]0[/code] indicating no context was opened. Providing a [param nonce] is optional, unless you intend to use [method cancel_context].
func open_context(actor: Nodenonce: int) -> int
## If world state changes that might affect open contexts, they must be revalidated, so that invalid contexts will be closed.
func revalidate() -> void
## Removes all contexts for a specific [param actor]. Can only be called on the server.
func close_all_contexts(actor: Node) -> void
## Used by clients to cancel a pending context. Will also close a context if it was already opened. In order for cancellation to work properly, the caller must have provided a [param nonce] to [method open_context].[br]
func cancel_context(nonce: int) -> void
## When invoked, will revoke access to the inventory for the [param actor]. If [param context_id] is not provided, it will removed all contexts for the client.
func close_context(context_id: int) -> void
## Returns true if a context for the [param actor] owned by the [param remote_sender_id] exists.
func has_context(actor: Noderemote_sender_id: int) -> bool
## Used by other components to determine the actor based on the [param context_id] and [param remote_sender_id].
func find_actor_for_context(context_id: intremote_sender_id: int) -> Node
## The number of contexts this access manager has. Clients are only aware of their own contexts.
func context_count() -> int
## Returns an array of [code]peer_id[/code]s that have at least one open context with this access manager.
func get_subscribers() -> Array[int]