コード例 #1
0
 /// <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);
 }
コード例 #2
0
 /// <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);
 }
コード例 #3
0
 /// <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));
 }
コード例 #4
0
 /// <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);
 }
コード例 #5
0
 /// <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));
 }
コード例 #6
0
 public static IEnumerable <TPlayerEntity> GetPlayers <TPlayerEntity>([NotNull] this NetworkEntityManager manager) where TPlayerEntity : class, IPlayer
 {
     return(manager.Players.Cast <TPlayerEntity>());
 }
コード例 #7
0
 public static TPlayerEntity GetServerPlayer <TPlayerEntity>([NotNull] this NetworkEntityManager manager) where TPlayerEntity : class, IPlayer
 {
     return(GetServerPlayer(manager) as TPlayerEntity);
 }
コード例 #8
0
 public static TPlayer GetPlayer <TPlayer>([NotNull] this NetworkEntityManager manager, int clientId) where TPlayer : class, IPlayer
 {
     return(manager.GetPlayer(clientId) as TPlayer);
 }
コード例 #9
0
 public static IPlayer GetServerPlayer([NotNull] this NetworkEntityManager manager)
 {
     return(manager.GetPlayer(manager.Connection.Server.ClientId));
 }
コード例 #10
0
 public static TPlayerEntity GetLocalPlayer <TPlayerEntity>([NotNull] this NetworkEntityManager manager) where TPlayerEntity : class, IPlayer
 {
     return(manager.LocalPlayer as TPlayerEntity);
 }