WVec BarrelOffset() { var localOffset = info.LocalOffset + new WVec(-armament.Recoil, WDist.Zero, WDist.Zero); var turretOffset = turreted != null?turreted.Position(self) : WVec.Zero; var turretOrientation = turreted != null?turreted.LocalOrientation(self) : WRot.Zero; var quantizedBody = body.QuantizeOrientation(self, self.Orientation); var quantizedTurret = body.QuantizeOrientation(self, turretOrientation); return(turretOffset + body.LocalToWorld(localOffset.Rotate(quantizedTurret).Rotate(quantizedBody))); }
public WVec MuzzleOffset(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) { var turretOrientation = coords.QuantizeOrientation(self, turret.LocalOrientation(self)); localOffset = localOffset.Rotate(turretOrientation); localOffset += turret.Offset; } return(coords.LocalToWorld(localOffset.Rotate(bodyOrientation))); }
IEnumerable <WRot> TurretRotation() { var b = self.Orientation; var qb = body.QuantizeOrientation(self, b); yield return(turreted.LocalOrientation(self) + 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 bodyOrientation = body.QuantizeOrientation(self, self.Orientation); var turretOrientation = body.QuantizeOrientation(self, t.LocalOrientation(self)); return t.Position(self) + body.LocalToWorld(localOffset.Rotate(turretOrientation).Rotate(bodyOrientation)); }