public override void OnEvent(RigidbodyDataEvent evnt)
 {
     base.OnEvent(evnt);
     //everyone should get this
     if (evnt.entity != null)
     {
         evnt.entity.GetComponent <PhysicsRewindData>().ReceiveValidation(evnt);
     }
 }
 /// <summary>
 /// we send our current positions (as we just did a resim) along with the frame we resimed to, to everyone so they can
 /// use it in their local sims as a best guess starting point
 /// </summary>
 /// <param name="frame"></param>
 public void BroadcastValidation(int frame)
 {
     //could probably do entity events
     //lazy
     if (entity.isAttached)
     {
         RigidbodyDataEvent e = RigidbodyDataEvent.Create();
         e.entity          = entity;
         e.position        = this.transform.position;
         e.rotation        = this.transform.rotation;
         e.velocity        = GetRigidbody().velocity;
         e.angularVelocity = GetRigidbody().angularVelocity;
         e.frame           = frame;
         e.Send();
         DLog.Log("BroadcastValidation: " + this.gameObject.name);
     }
 }
    /// <summary>
    /// Server sends this once this frame has been simulated, along with inputs.  This is the truth at this frame with all inputs applied up to this point
    /// Use this as a base and simulate forward to current time to get local predictions
    /// </summary>
    /// <param name="e"></param>
    public void ReceiveValidation(RigidbodyDataEvent e)
    {
        PhysicsManager.instance.t1.text = "";
        DLog.Log("ReceivedValidationEvent for frame: " + e.frame + " current frame: " + BoltNetwork.serverFrame);
        PhysicsManager.instance.t1.text = "Validation for frame: " + e.frame + " - currentFrame: " + BoltNetwork.serverFrame;
        if (BoltNetwork.isServer)
        {
            return;                      //we don't need to validate server stuff, so we can skip all this jumk
        }
        if (e.frame > BoltNetwork.serverFrame)
        {
            //this can happen because BoltNetwork.serverFrame isn't exact on clients.
            //was happening with 1000ms pings
            DLog.Log("ReceivedValidationEvent for a frame that hasn't been simulated locally yet??");
        }

        //we can go through and discard any state date older than this validation


        validatedStateFrame = e.frame;
        validatedStateData  = new RigidbodyData()
        {
            frame           = e.frame,
            position        = e.position,
            rotation        = e.rotation,
            velocity        = e.velocity,
            angularVelocity = e.angularVelocity
        };
        //probably a better way to do this. Lazy
        SortedDictionary <int, RigidbodyData> temp = new SortedDictionary <int, RigidbodyData>();

        foreach (KeyValuePair <int, RigidbodyData> d in data)
        {
            if (d.Value.frame >= e.frame)
            {
                temp.Add(d.Key, d.Value);
            }
        }
        data = temp;

        NetworkedBubbleControllerBehaviour c = this.GetComponent <NetworkedBubbleControllerBehaviour>(); //this should be generalized ControllableRigidbody

        if (c != null)
        {
            c.CleanupOldInputs(e.frame);
        }

        ////when we receive a validation, check that against our local - stored values to see if our past frame was close enough to it.
        ////if we are not, we need to resync and resim.

        ////turning this on here just applies the states late as we get them, without any simulation
        //SetFromState(validatedStates[e.frame]);

        //do we even have a local frame data for this frame?
        bool hasLocalData = data.ContainsKey(e.frame);

        if (hasLocalData)
        {
            //is localData CLOSE to validatedData?
            if (StatesMatch(data[e.frame], validatedStateData))
            {
                //don't do anythign, we're mostly accurate ?
                //if we ARE close though, could we not just snap anyways because
                //1) We're close, so it won't be an abrupt snap
                //2) It will make the next step be more likely to be similar
                //like fixing the small drifts rather than fixing the big ones every once in a while?
                //DLog.Log("PRD::RecValidation - Close enough!");
                PhysicsManager.instance.NeedsLocalResim(e.frame);
            }
            else
            {
                //too far apart, fix this.
                DLog.Log("PRD::RecValidation - states too far apart, marking for resim");
                PhysicsManager.instance.NeedsLocalResim(e.frame);
            }
        }
        else
        {
            DLog.Log("PRD::RecValidation - don't have frame data, marking for resim");
            //don't even have data, so we need to resim anyways.
            PhysicsManager.instance.NeedsLocalResim(e.frame);
        }
    }