using System;
using MLAPI;
using MLAPI.Messaging;
using MLAPI.NetworkedVar;
using UnityEngine;
namespace BossRoom.Shared
{
///
/// Contains all NetworkedVars and RPCs of a character. This component is present on both client and server objects.
///
public class NetworkCharacterState : NetworkedBehaviour
{
///
/// The networked position of this Character. This reflects the authorative position on the server.
///
public NetworkedVarVector3 NetworkPosition { get;} = new NetworkedVarVector3();
///
/// The networked rotation of this Character. This reflects the authorative rotation on the server.
///
public NetworkedVarFloat NetworkRotationY { get; } = new NetworkedVarFloat();
public NetworkedVarFloat NetworkMovementSpeed;
///
/// Gets invoked when inputs are received from the client which own this networked character.
///
public event Action OnReceivedClientInput;
///
/// RPC to send inputs for this character from a client to a server.
///
/// The position which this character should move towards.
[ServerRPC]
public void SendCharacterInputServerRpc(Vector3 movementTarget)
{
OnReceivedClientInput?.Invoke(movementTarget);
}
}
}