private void SetNewState(TransformComponentState state) { lastState = state; states.Add(state); var interp = IoCManager.Resolve<IConfigurationManager>().GetInterpolation(); //Remove all states older than the one just before the interp time. lerpStateFrom = states.Where(s => s.ReceivedTime <= state.ReceivedTime - interp).OrderByDescending(s => s.ReceivedTime).FirstOrDefault(); if (lerpStateFrom != null) { lerpStateTo = states.Where(s => s.ReceivedTime > lerpStateFrom.ReceivedTime).OrderByDescending(s => s.ReceivedTime). LastOrDefault(); if (lerpStateTo == null) lerpStateTo = lerpStateFrom; states.RemoveAll(s => s.ReceivedTime < lerpStateFrom.ReceivedTime); } else { lerpStateFrom = state; lerpStateTo = state; } if(lastState.ForceUpdate) { TranslateTo(new Vector2(state.X, state.Y)); } }
public override ComponentState GetComponentState() { var state = new TransformComponentState(Position.X, Position.Y, firstState); firstState = false; return state; }