Example #1
0
        public void Add(TKey key, TValue value)
        {
            _localDictionary.Add(key, value);
            var overwrittenKey = _localKeyQueue.Enqueue(key);

            if (!Equals(overwrittenKey, default(TKey)))
            {
                MakePersistant(overwrittenKey);
            }
        }
    private void ClearBuffers()
    {
        for (int i = 0; i < _predictionBuffer.Length; i++)
        {
            _predictionBuffer[i] = new RigidbodyState();
        }

        _historyBuffer.Clear();
        _historyBuffer.Enqueue(RigidbodyState.ToImmutable(_body, Time.fixedTime));
    }
Example #3
0
        public void PushToEnd(ValueTransform ring, float distanceTraveled)
        {
            kernel.PushToEnd(ring);

            // Vertices and normals
            for (int i = 0; i < RealPointsPerRing; ++i)
            {
                float angle  = (2 * Mathf.PI) * i / visiblePointsPerRing;
                var   normal = new Vector3(Mathf.Cos(angle), Mathf.Sin(angle));
                normal = ring.rotation * normal;
                Vector3 vertex = normal * radius + ring.position;

                Vector2 uv = new Vector2();
                uv.x = 0.75f - (float)i / visiblePointsPerRing;
                uv.y = distanceTraveled / RingLength;

                vertices.Enqueue(vertex);
                normals.Enqueue(normal);
                uvs.Enqueue(uv);

    #if UNITY_EDITOR
                UpdateVertexDebugInfo(vertices.Count - 1);
    #endif
            }

            AddSegmentTriangles();

            meshIsDirty = true;
        }
Example #4
0
    private void OnReceiveState(PlayerMessage.StateUpdate message, MessageMetadata metadata)
    {
        _lastServerState            = message.State;
        _lastReceivedStateTimestamp = _fixedClock.CurrentTime;
        _lastReceivedStateRTT       = RamjetClient.RoundtripTime;

        _serverHistory.Enqueue(message.State);
    }
Example #5
0
    private void OnReceiveInput(PlayerMessage.InputUpdate message)
    {
        var input = message.Input;

        input.Timestamp = _fixedClock.CurrentTime;

        _simulation.SetInput(input);
        _inputHistory.Enqueue(input);
    }
Example #6
0
        public bool AddOrOverwrite(TKey key, TValue value, out KeyValuePair <TKey, TValue> overwritten)
        {
            var isFull = _localKeyQueue.Count == _localKeyQueue.Capacity;

            var overwrittenKey = _localKeyQueue.Enqueue(key);

            if (isFull)
            {
                var overwrittenValue = _localDictionary[overwrittenKey];
                _localDictionary.Remove(overwrittenKey);
                _localDictionary.Add(key, value);
                overwritten = KeyValuePair.Create(overwrittenKey, overwrittenValue);
                return(true);
            }

            _localDictionary.Add(key, value);
            overwritten = default(KeyValuePair <TKey, TValue>);
            return(false);
        }
Example #7
0
 /// <summary>
 ///     Method is called directly by the <see cref="ReactorBase" /> implementation to send data to this
 ///     <see cref="IConnection" />.
 ///     Can also be called by the socket itself if this reactor doesn't use <see cref="ReactorProxyResponseChannel" />.
 /// </summary>
 /// <param name="data">The data to pass directly to the recipient</param>
 internal virtual void OnReceive(NetworkData data)
 {
     if (NetworkEventLoop.Receive != null)
     {
         NetworkEventLoop.Receive(data, this);
     }
     else
     {
         UnreadMessages.Enqueue(data);
     }
 }
Example #8
0
        private void AddSegmentTriangles()
        {
            ICircularBuffer <ValueTransform> path = kernel.Path;

            if (path.Count >= 2)
            {
                int ring1Offset = path.RawPosition(path.Count - 2) * RealPointsPerRing;
                int ring2Offset = path.RawPosition(path.Count - 1) * RealPointsPerRing;

                int[] quadIndices     = new int[4];
                int[] triangleIndices = new int[6];
                for (int i = 0; i < visiblePointsPerRing; ++i)
                {
                    quadIndices[0] = ring1Offset + i;
                    quadIndices[1] = ring1Offset + i + 1;
                    quadIndices[2] = ring2Offset + i + 1;
                    quadIndices[3] = ring2Offset + i;

                    MeshUtils.ConvertQuadToTriangles(quadIndices, triangleIndices);
                    triangles.Enqueue(triangleIndices);
                }
            }
        }
Example #9
0
 public override IByteBuf WriteByte(int value)
 {
     EnsureWritable(1);
     InternalBuffer.Enqueue((byte)value);
     return(this);
 }
Example #10
0
 public override ICircularBuffer <T> RunActual(ICircularBuffer <T> obj0)
 {
     obj0.Enqueue(_data.Value);
     return(obj0);
 }
Example #11
0
 /// <inheritdoc />
 public void Enqueue(T item)
 {
     _buffer.Enqueue(item);
 }