Example #1
0
        public void OnReplayDeserialize(ReplayState state)
        {
            int size = state.Read32();

            for (int i = 0; i < size; i++)
            {
                // Read the target identity
                ReplayIdentity identity  = state.ReadIdentity();
                int            localSize = state.Read32();

                // Read all states
                for (int j = 0; j < localSize; j++)
                {
                    // Create empty data container
                    ReplayInitialData data = new ReplayInitialData();

                    // Deserialize data
                    data.OnReplayDeserialize(state);

                    // Register state
                    if (initialStates.ContainsKey(identity) == false)
                    {
                        initialStates.Add(identity, new List <ReplayInitialData>());
                    }

                    initialStates[identity].Add(data);
                }
            }
        }
Example #2
0
        public void OnReplayDeserialize(ReplayState state)
        {
            // Read the object identity
            objectIdentity = state.ReadIdentity();
            timestamp      = state.ReadFloat();

            // Read the flags
            flags = (ReplayInitialDataFlags)state.Read16();

            // Read position
            if ((flags & ReplayInitialDataFlags.Position) != 0)
            {
                position = state.ReadVec3();
            }

            // Read rotation
            if ((flags & ReplayInitialDataFlags.Rotation) != 0)
            {
                rotation = state.ReadQuat();
            }

            // Read scale
            if ((flags & ReplayInitialDataFlags.Scale) != 0)
            {
                scale = state.ReadVec3();
            }

            // Read parent identity
            if ((flags & ReplayInitialDataFlags.Parent) != 0)
            {
                parentIdentity = state.ReadIdentity();
            }

            // Read the number of observed components
            int size = state.Read16();

            // Allocate the array
            observedComponentIdentities = new ReplayIdentity[size];

            // Read all ids
            for (int i = 0; i < size; i++)
            {
                // Read the identity
                observedComponentIdentities[i] = state.ReadIdentity();
            }
        }
Example #3
0
        /// <summary>
        /// Called by the replay system when this <see cref="ReplaySnapshot"/> should be deserialized.
        /// </summary>
        /// <param name="state">The <see cref="ReplayState"/> to read the data from</param>
        public void OnReplayDeserialize(ReplayState state)
        {
            timeStamp = state.ReadFloat();

            // Read states size
            int size = state.Read32();

            // Read all states
            for (int i = 0; i < size; i++)
            {
                // Read the identity
                ReplayIdentity identity = state.ReadIdentity();

                // Read size
                short stateSize = state.Read16();

                // Read the state data
                ReplayState stateData = state.ReadState(stateSize);

                // Add to states
                states.Add(identity, stateData);
            }
        }