/// <summary>
 /// Returns the serializer of the entity manager's <see cref="IConnection"/>.
 /// </summary>
 /// See also: <seealso cref="IConnection.Serializer"/>
 ///
 /// <param name="manager">The entity manager to get the serializer from</param>
 /// <returns>The serializer of the entity manager's <see cref="IConnection"/>.</returns>
 public static ISerializer GetSerializer([NotNull] this NetworkEntityManager manager)
 {
     return(manager.Connection?.Serializer);
 }
 /// <inheritdoc cref="ConnectionExtensions.SendEvent"/>
 public static void SendEvent([NotNull] this NetworkEntityManager manager, byte code, object data, bool reliable = true)
 {
     manager.Connection?.SendEvent(code, data, reliable);
 }
 /// <summary>
 /// Returns an observable that can be used to describe to network events of the given code
 /// </summary>
 /// <param name="manager">The manager with the connection to receive events from</param>
 /// <param name="code">The event code that identifies the event</param>
 /// <returns>An observable with network events</returns>
 public static IObservable <NetworkEvent> OnEvent([NotNull] this NetworkEntityManager manager, byte code)
 {
     return(manager.Connection?.OnEvent(code));
 }
 /// <summary>
 /// Returns if the manager is in offline mode (when the connection is a <see cref="MockConnection"/>)
 /// </summary>
 public static bool IsOffline(this NetworkEntityManager manager)
 {
     return(manager.Connection is MockConnection);
 }
 /// <summary>
 /// Creates a new <see cref="NetworkEntityManager"/> for the given connection.
 /// </summary>
 /// <param name="connection">The connection to create an entity manager for</param>
 /// <param name="serializationRate">The rate at which Entity and player Updates are sent per second</param>
 /// <returns></returns>
 public static NetworkEntityManager CreateEntityManager([NotNull] this IConnection connection,
                                                        int serializationRate = NetworkEntityManager.DefaultSerializationRate)
 {
     return(NetworkEntityManager.Create(connection, serializationRate));
 }
 public static IEnumerable <TPlayerEntity> GetPlayers <TPlayerEntity>([NotNull] this NetworkEntityManager manager) where TPlayerEntity : class, IPlayer
 {
     return(manager.Players.Cast <TPlayerEntity>());
 }
 public static TPlayerEntity GetServerPlayer <TPlayerEntity>([NotNull] this NetworkEntityManager manager) where TPlayerEntity : class, IPlayer
 {
     return(GetServerPlayer(manager) as TPlayerEntity);
 }
 public static TPlayer GetPlayer <TPlayer>([NotNull] this NetworkEntityManager manager, int clientId) where TPlayer : class, IPlayer
 {
     return(manager.GetPlayer(clientId) as TPlayer);
 }
 public static IPlayer GetServerPlayer([NotNull] this NetworkEntityManager manager)
 {
     return(manager.GetPlayer(manager.Connection.Server.ClientId));
 }
Esempio n. 10
0
 public static TPlayerEntity GetLocalPlayer <TPlayerEntity>([NotNull] this NetworkEntityManager manager) where TPlayerEntity : class, IPlayer
 {
     return(manager.LocalPlayer as TPlayerEntity);
 }