// Methods
        public override void PrepareForPlayback(Rigidbody2D component, ReplayState additionalData)
        {
            // Store the initial value
            additionalData.Write(component.isKinematic);
            additionalData.Write(component.simulated);

            // Make the body kinematic to avoid movement by the physics engine
            component.isKinematic = true;
            component.simulated   = false;
        }
Example #2
0
        // Methods
        /// <summary>
        /// Called by the replay system when all replay state information should be serialized.
        /// </summary>
        /// <param name="state">The <see cref="ReplayState"/> to write the data to</param>
        public void OnReplaySerialize(ReplayState state)
        {
            // Write the id
            state.Write(eventID);

            // Get the data size
            byte size = (byte)eventData.Size;

            // Write the size and data
            state.Write(size);
            state.Write(eventData);
        }
        // Methods
        public IEnumerator Start()
        {
            while (true)
            {
                // Wait until we are recording
                if (IsRecording == false)
                {
                    yield return(null);
                }

                // Record event type 1
                yield return(new WaitForSeconds(1f));

                RecordEvent((ushort)MyEventType.Event1);

                // Record event type 2
                yield return(new WaitForSeconds(1f));

                RecordEvent((ushort)MyEventType.Event2);

                // Record event type 3 with extra data
                ReplayState eventData = ReplayState.pool.GetReusable();
                eventData.Write("Hello World");

                yield return(new WaitForSeconds(1f));

                RecordEvent((ushort)MyEventType.Event3, eventData);
            }
        }
Example #4
0
        public void OnReplaySerialize(ReplayState state)
        {
            // Write the object identity
            state.Write(objectIdentity);
            state.Write(timestamp);

            // Calcualte the flags
            flags = ReplayInitialDataFlags.None;

            // Mkae sure initial state flags are updated
            UpdateDataFlags();

            // Write the data flags
            state.Write((short)flags);

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

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

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

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

            // Write the component identities
            int size = (observedComponentIdentities == null) ? 0 : observedComponentIdentities.Length;

            // Write the number of ids
            state.Write((short)size);

            // Write all ids
            for (int i = 0; i < size; i++)
            {
                // Write the identity
                state.Write(observedComponentIdentities[i]);
            }
        }
        // Methods
        public override void PrepareForPlayback(Animator component, ReplayState additionalData)
        {
            // Write the component state
            additionalData.Write(component.enabled);

            // Disable the animator - it could interfere with playback
            component.enabled = false;
        }
Example #6
0
        // Methods
        public override void PrepareForPlayback(Behaviour component, ReplayState additionalData)
        {
            // Store the initial value
            additionalData.Write(component.enabled);

            // Make the body kinematic to avoid movement by the physics engine
            component.enabled = false;
        }
Example #7
0
        // Methods
        public void OnReplaySerialize(ReplayState state)
        {
            state.Write(initialStates.Count);

            foreach (KeyValuePair <ReplayIdentity, List <ReplayInitialData> > initialState in initialStates)
            {
                // Write the identity key and state data size
                state.Write(initialState.Key);
                state.Write(initialState.Value.Count);

                // Write all states
                for (int i = 0; i < initialState.Value.Count; i++)
                {
                    initialState.Value[i].OnReplaySerialize(state);
                }
            }
        }
Example #8
0
        // Methods
        /// <summary>
        /// Called by the replay system when this <see cref="ReplaySnapshot"/> should be serialized.
        /// </summary>
        /// <param name="state">The <see cref="ReplayState"/> to write the data to</param>
        public void OnReplaySerialize(ReplayState state)
        {
            state.Write(timeStamp);

            // Write states size
            state.Write(states.Count);

            // Write all states
            foreach (KeyValuePair <ReplayIdentity, ReplayState> pair in states)
            {
                state.Write(pair.Key);

                // Write the size and bulk data
                state.Write((short)pair.Value.Size);
                state.Write(pair.Value);
            }
        }