private void OnTransformChanged(object sender, TransformChangedEventArgs e)
{
if (sender == this) return;
if (this.body == null) return;
Transform t = e.Component as Transform;
if ((e.Changes & Transform.DirtyFlags.Pos) != Transform.DirtyFlags.None)
this.body.Position = PhysicsConvert.ToPhysicalUnit(t.Pos.Xy);
if ((e.Changes & Transform.DirtyFlags.Angle) != Transform.DirtyFlags.None)
this.body.Rotation = t.Angle;
if ((e.Changes & Transform.DirtyFlags.Scale) != Transform.DirtyFlags.None)
{
float scale = t.Scale;
if (scale == 0.0f || this.lastScale == 0.0f)
{
this.FlagBodyShape();
}
else
{
const float pixelLimit = 2;
float boundRadius = this.BoundRadius;
float upper = (boundRadius + pixelLimit) / boundRadius;
float lower = (boundRadius - pixelLimit) / boundRadius;
if (scale / this.lastScale >= upper || scale / this.lastScale <= lower)
{
this.FlagBodyShape();
}
}
}
if (e.Changes != Transform.DirtyFlags.None)
this.body.Awake = true;
}