示例#1
0
        protected override void OnCreate()
        {
            var reliabilityParams = new ReliableUtility.Parameters {
                WindowSize = 32
            };

#if UNITY_EDITOR
            m_ClientPacketDelay = UnityEditor.EditorPrefs.GetInt("MultiplayerPlayMode_" + UnityEngine.Application.productName + "_ClientDelay");
            m_ClientPacketDrop  = UnityEditor.EditorPrefs.GetInt("MultiplayerPlayMode_" + UnityEngine.Application.productName + "_ClientDropRate");
            int networkRate = 60; // TODO: read from some better place
                                  // All 3 packet types every frame stored for maximum delay, doubled for safety margin
            int maxPackets      = 2 * (networkRate * 3 * m_ClientPacketDelay + 999) / 1000;
            var simulatorParams = new SimulatorUtility.Parameters
            {
                MaxPacketSize = NetworkParameterConstants.MTU, MaxPacketCount = maxPackets, PacketDelayMs = m_ClientPacketDelay, PacketDropPercentage = m_ClientPacketDrop
            };
            m_Driver = new UdpNetworkDriver(simulatorParams, reliabilityParams);
#else
            m_Driver = new UdpNetworkDriver(reliabilityParams);
#endif

            m_ConcurrentDriver   = m_Driver.ToConcurrent();
            m_UnreliablePipeline = NetworkPipeline.Null;
            m_ReliablePipeline   = NetworkPipeline.Null;
            m_DriverListening    = false;
            m_Barrier            = World.GetOrCreateSystem <BeginSimulationEntityCommandBufferSystem>();
            numNetworkIds        = new NativeArray <int>(1, Allocator.Persistent);
            freeNetworkIds       = new NativeQueue <int>(Allocator.Persistent);
            rpcQueue             = InternalRpcCollection.GetRpcQueue <RpcSetNetworkId>();
        }
示例#2
0
        protected override void OnCreate()
        {
            m_InternalRpcCollection       = default(InternalRpcCollection);
            m_InternalRpcCollectionLength = m_InternalRpcCollection.Length;
            m_RpcCollection = default(TRpcCollection);
#if ENABLE_UNITY_COLLECTIONS_CHECKS
            Debug.Assert(UnsafeUtility.SizeOf <OutgoingRpcDataStreamBufferComponent>() == 1);
            Debug.Assert(UnsafeUtility.SizeOf <IncomingRpcDataStreamBufferComponent>() == 1);
#endif
            m_RpcBufferQuery = GetEntityQuery(ComponentType.ReadWrite <IncomingRpcDataStreamBufferComponent>());
        }
示例#3
0
        protected override void OnCreate()
        {
            m_InternalRpcCollection       = default(InternalRpcCollection);
            m_InternalRpcCollectionLength = m_InternalRpcCollection.Length;
            m_RpcCollection = default(TRpcCollection);
#if ENABLE_UNITY_COLLECTIONS_CHECKS
            Debug.Assert(UnsafeUtility.SizeOf <OutgoingRpcDataStreamBufferComponent>() == 1);
            Debug.Assert(UnsafeUtility.SizeOf <IncomingRpcDataStreamBufferComponent>() == 1);
#endif
            m_Barrier        = World.GetOrCreateSystem <BeginSimulationEntityCommandBufferSystem>();
            m_RpcBufferGroup = GetEntityQuery(ComponentType.ReadWrite <IncomingRpcDataStreamBufferComponent>());
        }