// --------------------------------------------------------------------------------------------------------------------
//
// Copyright (c) VRMADA, All rights reserved.
//
// --------------------------------------------------------------------------------------------------------------------
using System.Collections.Generic;
using UltimateXR.Avatar;
using UltimateXR.Core.Components;
using UnityEngine;
namespace UltimateXR.Networking
{
///
/// Base class required to add support for a network SDK.
///
public abstract class UxrNetworkImplementation : UxrComponent, IUxrNetworkImplementation
{
#region Implicit IUxrNetworkImplementation
///
public abstract bool IsServer { get; }
///
public abstract bool IsClient { get; }
///
public abstract UxrNetworkCapabilities Capabilities { get; }
///
public virtual string NetworkRigidbodyWarning => null;
///
public abstract void SetupGlobal(UxrNetworkManager networkManager, out List newGameObjects, out List newComponents);
///
public abstract void SetupAvatar(UxrAvatar avatar, out List newGameObjects, out List newComponents);
///
public abstract void SetupPostProcess(IEnumerable avatarPrefabs);
///
public abstract IEnumerable AddNetworkTransform(GameObject gameObject, bool worldSpace, UxrNetworkTransformFlags networkTransformFlags);
///
public abstract IEnumerable AddNetworkRigidbody(GameObject gameObject, bool worldSpace, UxrNetworkRigidbodyFlags networkRigidbodyFlags);
///
public abstract void EnableNetworkTransform(GameObject gameObject, bool enable);
///
public abstract void EnableNetworkRigidbody(GameObject gameObject, bool enable);
///
public abstract bool HasAuthority(GameObject gameObject);
///
public abstract void RequestAuthority(GameObject gameObject);
///
public abstract void CheckReassignGrabAuthority(GameObject gameObject);
///
public abstract bool HasNetworkTransformSyncComponents(GameObject gameObject);
#endregion
#region Implicit IUxrNetworkSdk
///
public abstract string SdkName { get; }
#endregion
#region Protected Methods
///
/// Helper method to set up NetworkTransform components for a given object.
///
/// The GameObject to set up
/// Whether to use world-space coordinates or local-space coordinates
/// Option flags
/// List of components that were added, usually a NetworkTransform and NetworkObject or similar
protected IEnumerable SetupNetworkTransform(GameObject go, bool worldSpace, UxrNetworkTransformFlags flags)
{
if (go != null)
{
IEnumerable newComponents = ((IUxrNetworkImplementation)this).AddNetworkTransform(go, worldSpace, flags);
foreach (Behaviour newBehaviour in newComponents)
{
yield return newBehaviour;
}
}
}
#endregion
}
}