public GrenadeState UpdateState(float progression, GrenadeState target) { return(new GrenadeState( Vector3.Lerp(Position, target.Position, progression), Quaternion.SlerpUnclamped(Rotation, target.Rotation, progression), target.IsExploding )); }
protected override GrenadesState DeserializeData(byte[] bytes) { lock (this) { Dictionary <int, GrenadeState> actions; float timeStamp; try { buffer.LoadBytes(bytes); buffer.ToRead(); timeStamp = buffer.ReadFloat(_timeStampMin, _timeStampMax, _timeStampPrecision); var amount = buffer.ReadInt(_mingranades, _maxGranades); actions = new Dictionary <int, GrenadeState>(amount); for (int i = 0; i < amount; i++) { var grenade = buffer.ReadInt(_mingranades, _maxGranades); var posX = buffer.ReadFloat(_positionMin, _positionMax, _positionPrecision); var posY = buffer.ReadFloat(_positionMin, _positionMax, _positionPrecision); var posZ = buffer.ReadFloat(_positionMin, _positionMax, _positionPrecision); var rotX = buffer.ReadFloat(_minRot, _maxRot, _stepRot); var rotY = buffer.ReadFloat(_minRot, _maxRot, _stepRot); var rotZ = buffer.ReadFloat(_minRot, _maxRot, _stepRot); var rotW = buffer.ReadFloat(_minRot, _maxRot, _stepRot); var isExploding = buffer.ReadBit(); actions[grenade] = new GrenadeState( new Vector3(posX, posY, posZ), new Quaternion(rotX, rotY, rotZ, rotW), isExploding ); } } catch (Exception e) { Debug.LogError(e); throw; } return(new GrenadesState(timeStamp, actions)); } }