using FishNet.Managing.Logging;
using FishNet.Transporting;
using System;
using UnityEngine;
namespace FishNet.Object
{
///
/// ServerRpc methods will send messages to the server.
///
[AttributeUsage(AttributeTargets.Method, Inherited = true, AllowMultiple = false)]
public class ServerRpcAttribute : Attribute
{
///
/// True to only allow the owning client to call this RPC.
///
public bool RequireOwnership = true;
///
/// True to also run the RPC logic locally.
///
public bool RunLocally = false;
///
/// Estimated length of data being sent.
/// When a value other than -1 the minimum length of the used serializer will be this value.
/// This is useful for writing large packets which otherwise resize the serializer.
///
public int DataLength = -1;
}
///
/// ObserversRpc methods will send messages to all observers.
///
[AttributeUsage(AttributeTargets.Method, Inherited = true, AllowMultiple = false)]
public class ObserversRpcAttribute : Attribute
{
///
/// True to exclude the owner from receiving this RPC.
///
public bool ExcludeOwner = false;
///
/// True to prevent the connection from receiving this Rpc if they are also server.
///
public bool ExcludeServer = false;
///
/// True to buffer the last value and send it to new players when the object is spawned for them.
/// RPC will be sent on the same channel as the original RPC, and immediately before the OnSpawnServer override.
///
public bool BufferLast = false;
///
/// True to also run the RPC logic locally.
///
public bool RunLocally = false;
///
/// Estimated length of data being sent.
/// When a value other than -1 the minimum length of the used serializer will be this value.
/// This is useful for writing large packets which otherwise resize the serializer.
///
public int DataLength = -1;
}
///
/// TargetRpc methods will send messages to a single client.
///
[AttributeUsage(AttributeTargets.Method, Inherited = true, AllowMultiple = false)]
public class TargetRpcAttribute : Attribute
{
///
/// True to prevent the connection from receiving this Rpc if they are also server.
///
public bool ExcludeServer = false;
///
/// True to also run the RPC logic locally.
///
public bool RunLocally = false;
///
/// True to validate the target is possible and output debug when not.
/// Use this field with caution as it may create undesired results when set to false.
///
public bool ValidateTarget = true;
///
/// Estimated length of data being sent.
/// When a value other than -1 the minimum length of the used serializer will be this value.
/// This is useful for writing large packets which otherwise resize the serializer.
///
public int DataLength = -1;
}
///
/// Prevents a method from running if server is not active.
/// Can only be used inside a NetworkBehaviour
///
[AttributeUsage(AttributeTargets.Method, Inherited = true, AllowMultiple = false)]
public class ServerAttribute : Attribute
{
///
/// Type of logging to use when the IsServer check fails.
///
public LoggingType Logging = LoggingType.Warning;
}
///
/// Prevents this method from running if client is not active.
///
[AttributeUsage(AttributeTargets.Method, Inherited = true, AllowMultiple = false)]
public class ClientAttribute : Attribute
{
///
/// Type of logging to use when the IsClient check fails.
///
public LoggingType Logging = LoggingType.Warning;
///
/// True to only allow a client to run the method if they are owner of the object.
///
public bool RequireOwnership = false;
}
}
namespace FishNet.Object.Synchronizing
{
///
/// Synchronizes collections or objects from the server to clients. Can be used with custom SyncObjects.
/// Value must be changed on server.
///
[AttributeUsage(AttributeTargets.Field, Inherited = true, AllowMultiple = false)]
public class SyncObjectAttribute : PropertyAttribute
{
///
/// How often values may update over the network.
///
public float SendRate = 0.1f;
///
/// Clients which may receive value updates.
///
public ReadPermission ReadPermissions = ReadPermission.Observers;
///
/// True if to require the readonly attribute.
/// Setting to false will allow inspector serialization of this object, but you must never manually initialize this object.
///
public bool RequireReadOnly = true;
}
///
/// Synchronizes a variable from server to clients automatically.
/// Value must be changed on server.
///
[AttributeUsage(AttributeTargets.Field, Inherited = true, AllowMultiple = false)]
public class SyncVarAttribute : PropertyAttribute
{
///
/// How often values may update over the network.
///
public float SendRate = 0.1f;
///
/// Clients which may receive value updates.
///
public ReadPermission ReadPermissions = ReadPermission.Observers;
///
/// Channel to use. Unreliable SyncVars will use eventual consistency.
///
public Channel Channel;
///
/// Method which will be called on the server and clients when the value changes.
///
public string OnChange;
}
}