WVec BarrelOffset() { var b = self.Orientation; var qb = body.QuantizeOrientation(self, b); var localOffset = Info.LocalOffset + new WVec(-armament.Recoil, WDist.Zero, WDist.Zero); var turretLocalOffset = turreted != null ? turreted.Offset : WVec.Zero; var turretOrientation = turreted != null?turreted.WorldOrientation(self) - b + WRot.FromYaw(b.Yaw - qb.Yaw) : WRot.Zero; return(body.LocalToWorld((turretLocalOffset + localOffset.Rotate(turretOrientation)).Rotate(qb))); }
WVec BarrelOffset() { var localOffset = Info.LocalOffset + new WVec(-armament.Recoil, WDist.Zero, WDist.Zero); var turretOffset = turreted != null?turreted.Position(self) : WVec.Zero; var quantizedBody = body.QuantizeOrientation(self, self.Orientation); var turretOrientation = turreted != null?turreted.WorldOrientation(self) - quantizedBody : WRot.Zero; var quantizedTurret = body.QuantizeOrientation(self, turretOrientation); return(turretOffset + body.LocalToWorld(localOffset.Rotate(quantizedTurret).Rotate(quantizedBody))); }
protected virtual WVec CalculateMuzzleOffset(Actor self, Barrel b) { var bodyOrientation = coords.QuantizeOrientation(self, self.Orientation); var localOffset = b.Offset + new WVec(-Recoil, WDist.Zero, WDist.Zero); if (turret != null) { // WorldOrientation is quantized to satisfy the *Fudges. // Need to then convert back to a pseudo-local coordinate space, apply offsets, // then rotate back at the end var turretOrientation = turret.WorldOrientation(self) - bodyOrientation; localOffset = localOffset.Rotate(turretOrientation); localOffset += turret.Offset; } return(coords.LocalToWorld(localOffset.Rotate(bodyOrientation))); }
WVec CalculateTargetableOffset(Actor self, WVec offset) { var localOffset = offset; var quantizedBodyOrientation = orientation.QuantizeOrientation(self, self.Orientation); if (turret != null) { // WorldOrientation is quantized to satisfy the *Fudges. // Need to then convert back to a pseudo-local coordinate space, apply offsets, // then rotate back at the end var turretOrientation = turret.WorldOrientation(self) - quantizedBodyOrientation; localOffset = localOffset.Rotate(turretOrientation); localOffset += turret.Offset; } return(orientation.LocalToWorld(localOffset.Rotate(quantizedBodyOrientation))); }
IEnumerable <WRot> TurretRotation() { var b = self.Orientation; var qb = body.QuantizeOrientation(self, b); yield return(turreted.WorldOrientation(self) - b + WRot.FromYaw(b.Yaw - qb.Yaw)); yield return(qb); }
WVec TurretOffset(Actor self) { if (!Info.Recoils) { return(t.Position(self)); } var recoil = arms.Aggregate(WDist.Zero, (a, b) => a + b.Recoil); var localOffset = new WVec(-recoil, WDist.Zero, WDist.Zero); var quantizedWorldTurret = t.WorldOrientation(self); return(t.Position(self) + body.LocalToWorld(localOffset.Rotate(quantizedWorldTurret))); }