// --------------------------------------------------------------------------------------------------------------------
//
// Copyright (c) VRMADA, All rights reserved.
//
// --------------------------------------------------------------------------------------------------------------------
using System.Collections.Generic;
using UltimateXR.Avatar;
using UnityEngine;
namespace UltimateXR.Networking
{
///
/// Interface for classes that implement network functionality.
///
public interface IUxrNetworkImplementation : IUxrNetworkSdk
{
#region Public Types & Data
///
/// Gets whether there is a networking session currently active and the local user is the server.
///
bool IsServer { get; }
///
/// Gets whether there is a networking session currently active and the local user is a client.
///
bool IsClient { get; }
///
/// Gets the SDK capabilities.
///
UxrNetworkCapabilities Capabilities { get; }
///
/// Gets a warning string if the NetworkRigidbody support requires extra attention. This is used by the
/// UxrNetworkManagerEditor to show a warning text box in case this implementation is selected.
///
string NetworkRigidbodyWarning { get; }
#endregion
#region Public Methods
///
/// Adds global support for the SDK if necessary, by adding required GameObjects and/or components to the
/// or the scene where it is located.
///
/// The network manager
/// Returns a list of GameObjects that were created, if any
/// Returns a list of components that were created, if any
void SetupGlobal(UxrNetworkManager networkManager, out List newGameObjects, out List newComponents);
///
/// Adds network synchronization functionality to an . Each avatar passed as argument is an
/// instance of a prefab in the avatar list.
/// All changes will be applied to the prefab after the setup returns and the avatar instance will be destroyed. To get
/// references to the actual prefabs to, for example, fill a list of spawnable prefabs, use
/// .
///
/// The avatar to add functionality to
/// Returns a list of GameObjects that were created, if any
/// Returns a list of components that were created, if any
void SetupAvatar(UxrAvatar avatar, out List newGameObjects, out List newComponents);
///
/// Called after the setup finished. At this point the modifications on the avatar prefabs have been applied.
/// This can be used to fill a list of spawnable prefabs which is a common requirement in networking SDKs.
///
void SetupPostProcess(IEnumerable avatarPrefabs);
///
/// Adds network synchronization functionality to a .
///
/// The GameObject to add functionality to
/// Whether to synchronize world space coordinates (true) or local space (false)
/// Which elements to synchronize
/// List of components that were added
IEnumerable AddNetworkTransform(GameObject gameObject, bool worldSpace, UxrNetworkTransformFlags networkTransformFlags);
///
/// Adds network synchronization functionality to a .
///
/// The GameObject with the rigidbody to add functionality to
/// Whether to synchronize world space coordinates (true) or local space (false)
/// Options
/// List of components that were added
IEnumerable AddNetworkRigidbody(GameObject gameObject, bool worldSpace, UxrNetworkRigidbodyFlags networkRigidbodyFlags);
///
/// Enables or disables a network transform component.
///
/// GameObject where the network transform is located
/// Whether to enable or disable the component
void EnableNetworkTransform(GameObject gameObject, bool enable);
///
/// Enables or disables a network rigidbody component.
///
/// GameObject where the network rigidbody is located
/// Whether to enable or disable the component
void EnableNetworkRigidbody(GameObject gameObject, bool enable);
///
/// Gets whether the current client has the authority over a network GameObject.
///
/// The GameObject to check the authority of
bool HasAuthority(GameObject gameObject);
///
/// Requests authority of the local user over a network GameObject.
///
/// The GameObject to request authority over
void RequestAuthority(GameObject gameObject);
///
/// Checks if an object that is being grabbed is missing a client authority, and assigns a new avatar as authority.
///
/// The GameObject with a component
void CheckReassignGrabAuthority(GameObject gameObject);
///
/// Gets whether an object has networking components (NetworkTransform/NetworkRigidbody) to sync its transform.
///
/// GameObject to check
///
/// Boolean telling whether the object has any NetworkTransform/NetworkRigidbody components using the
/// implementation.
///
bool HasNetworkTransformSyncComponents(GameObject gameObject);
#endregion
}
}