public void UpdatePart(CompositePart hull) { Matrix rot = Matrix.CreateRotationZ(hull.Angle); Part.Position = hull.Position + Vector2.Transform(RelativePos + posChange * linkToCenter, rot); Part.Angle = hull.angle; if (!(Part is RectangularHull)) { Part.Angle += RelativeAngle; } }
public void SetPart(Part p, CompositePart hull) { Part = p; p.Sprite.Team = hull.Team; hull.Sprite.Team = hull.Team; if (RelativeAngle == (float)Math.PI / 2 || RelativeAngle == 0) //! only works for recthull { linkToCenter = Vector2.Transform((new Vector2(p.BoundBox.Width, p.BoundBox.Height) / 2), Matrix.CreateRotationZ(RelativeAngle)); } else { linkToCenter = Vector2.Transform((new Vector2(p.BoundBox.Width, p.BoundBox.Height) / 2), Matrix.CreateRotationZ(RelativeAngle + (float)Math.PI)); } posChange = new Vector2(RelativePos.X, RelativePos.Y); posChange.Normalize(); UpdatePart(hull); }